Skip to content

Instantly share code, notes, and snippets.

@GravenilvecTV
Created February 18, 2019 20:12
Embed
What would you like to do?
from tkinter import *
import webbrowser
class MyApp:
def __init__(self):
self.window = Tk()
self.window.title("My Application")
self.window.geometry("720x480")
self.window.minsize(480, 360)
self.window.iconbitmap("logo.ico")
self.window.config(background='#41B77F')
# initialization des composants
self.frame = Frame(self.window, bg='#41B77F')
# creation des composants
self.create_widgets()
# empaquetage
self.frame.pack(expand=YES)
def create_widgets(self):
self.create_title()
self.create_subtitle()
self.create_youtube_button()
def create_title(self):
label_title = Label(self.frame, text="Bienvenue sur l'application", font=("Courrier", 40), bg='#41B77F',
fg='white')
label_title.pack()
def create_subtitle(self):
label_subtitle = Label(self.frame, text="Hey salut à tous c'est Graven", font=("Courrier", 25), bg='#41B77F',
fg='white')
label_subtitle.pack()
def create_youtube_button(self):
yt_button = Button(self.frame, text="Ouvrir Youtube", font=("Courrier", 25), bg='white', fg='#41B77F',
command=self.open_graven_channel)
yt_button.pack(pady=25, fill=X)
def open_graven_channel(self):
webbrowser.open_new("http://youtube.com/gravenilvectuto")
# afficher
app = MyApp()
app.window.mainloop()
@patrickjuniorsambantadi

merci bcp

@VinyPrestyNakavoua
Copy link

Merci beaucoup Graven

@antoinenowakowski
Copy link

thanks u a lot

@EudinoDev
Copy link

Merci Graven

@AbeileMiel
Copy link

comment on peut faire pour comme dans ta video avec une barre de menu au dessus avec des fonctions. J'ai essayé , sans réussite.

@elharrak58
Copy link

salut tous le monde j'ai un probleme avec la faction iconbitmap j'arrive pas a importer l'icone il me donne cette erreur
/usr/bin/python3.10 /home/el/PycharmProjects/TEST/ville.py
Traceback (most recent call last):
File "/home/el/PycharmProjects/TEST/ville.py", line 49, in
app = MyApp()
File "/home/el/PycharmProjects/TEST/ville.py", line 12, in init
self.window.iconbitmap("logo.ico")
File "/usr/lib/python3.10/tkinter/init.py", line 2109, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "logo.ico" not defined
pourtant j'ai mis l'icone dans le meme dossier

@DoctorDisco13
Copy link

Hello @elharrak58,
J'ai déjà eu cette erreur, je l'ai simplement corrigé en mettant le ''path = chemin" complet de l'objet "l'icone"

Exemple :
self.window.iconbitmap('c:/files/myfiles/icon.ico')

Au lieu de :
self.window.iconbitmap('icon.ico')

Assure toi aussi d'avoir bien convertie ton image en ICO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment