from Tkinter import * def msg( ): print 'Bienvenu sur python graphique' top = Frame( ) # Création d'un conteneur top.pack( ) Label(top, text="Et le python..").pack(side=TOP) push = Button(top, text="Cliquez ici", command=msg) push.pack(side=BOTTOM) top.mainloop( )
Posts Related to GUI: Création d’un conteneur avec des widgets à l’aide de ‘Tkinter’
-
Tkinter: Lier un événement à un conteneur
{filelink=15689} from Tkinter import * from tkMessageBox import * #Package des boîtes de dialogue def showMessageBox(event): showinfo(‘Message’,”Merci d’avoir cliqué sur le Frame”) root= Tk() conteneur=Frame(root) …
-
GUI: Ajouter un widget dans un containeur
{filelink=15431} from Tkinter import * root = Tk() frame = Frame(root) #Création d’un conteneur frame.pack() btn = Button(frame, text=”Cliquez sur Moi”) btn[“background”] = “Cyan” btn.pack() …
-
Exemple de création d’une zone graphique ‘canvas’
{filelink=15408} from Tkinter import * win = Tk() # Le conteneur # Création d’un objet image img = PhotoImage(file=’C:/logo.gif’) # widget des zones graphiques can …
-
Création d’un ‘TitledBoder’(Bordure avec titre)
{filelink=15418} from Tkinter import * class TitledBorder(Frame): “”” GUI: Avec TKinter “”” def __init__(self): Frame.__init__(self) self.pack() self.master.title(“Bordure avec Titre”) f = Frame(self, width=300, height=110) xf …
-
Python: Modification automatique du texte d’un Label à l’aide de ‘textvariable’
{filelink=15678} import Tkinter root = Tkinter.Tk() root.title(‘Modification de label’) message = Tkinter.StringVar() Tkinter.Label(textvariable=message).pack() Tkinter.Entry(textvariable=message).pack() message.set(‘Bienvenu, Tapez un texte ici’) Tkinter.Button(text=”Quitter”, command=root.quit).pack() Tkinter.mainloop() print message.get()
-
Lier un ‘Callback’ à un événement
{filelink=15423} from Tkinter import * def hi(*ignore): “”” Ce message s’affiche à chaque fois que vous appuyez la touche entrer””” print ‘Bienvenu sur Python graphique’ …
-
Exemple d’une calculatrice graphique simple
{filelink=16850} from Tkinter import * def frame(root, side): w = Frame(root) w.pack(side=side, expand=YES, fill=BOTH) return w def button(root, side, text, command=None): w = Button(root, text=text, …
-
Générer un beep au lancement d’un fenêtre
{filelink=15417} from Tkinter import * class Beep(Frame): def __init__(self): Frame.__init__(self) self.bell() if __name__ == ‘__main__’: Beep().mainloop()
-
GUI: Création des Menus avec TKinter
{filelink=15430} import Tkinter root = Tkinter.Tk( ) bar = Tkinter.Menu( ) def msg(menu, entry): “”” Afficher le menu et l’option du menu sélectionné””” print menu, …
-
Exemple d’utilisation des boutons Radio et choix
{filelink=15420} from Tkinter import * class AllTkinterWidgets: def __init__(self, master): frame = Frame(master, width=500, height=400, bd=1) frame.pack() iframe1 = Frame(frame, bd=2, relief=SUNKEN) Checkbutton(iframe1, text=’Choix’).pack(side=LEFT, padx=5) …