5/19/2023 0 Comments Tkinter winfoNe jamais créer de canvas/widgets dans une boucle qui se répète sinon, bonne chance Jusqu’à l’infinie.Ĭe qui rend le programme lourd, si vous vous en rendez pas compte. Donc, si vous re-appuyez sur le bouton, vous enclenchez un autre callback, par dessus l’ancien. Puisque la fonction va continuer à l’infinie. # Aussitôt la fenêtre créé, on détruit fenêtre 10 secondes après. # Aussitôt appuyez sur le bouton, on change les choixīouton = tk.Button(fenetre, text=" Appuyez", command= commencez).pack() LabelA = tk.Label(fenetre, textvariable=varA) Il y a deux after() : une va détruire la fenêtre après 10s, à l’ouverture - l’autre va recommencer la fonction à chaque 1000 ms (1sec), une fois que vous aurez cliqué sur le bouton.ĬOULEURS = after() rappelle une fonction chaque X seconde. Is_ok = tkMB.showinfo(' Salut', ' Ceci est un Carton Rouge, Sortez!')īutton = tk.Button(root, text=' Appuyez', command= affichez_popup).pack() Question = tkMB.askquestion(' Bonjour', ' Ça va bien?') ssagebox # permet d'afficher des Popups, de type Warning,Stop,AskYesorNo. # Permet de réduire la fenêtre principaleīuttonA = tk.Button(secondaire, text=' Retourner', command= retourner).pack()īuttonB = tk.Button(secondaire, text=' Quitter', command=stroy).pack()īutton = tk.Button(w, text=' AutreFenetre', command= fenetre_secondaire).pack() # Remet la fenêtre principale en avant-plan Toplevel() est une fenêtre secondaire, identique au fenêtre normal, mais sans boucle (pas de mainloop) Takefocus= si true, la navigation par la touche TAB est possible (flase par défaut) NOTE: pour afficher la bordure, renseigner le bd=. Relief= Décoration de la bordure : flat (défaut), sunken, raised, groove et ridge. Padx= pady= padding horizontal, horizontal (0) Highlightthickness= Epaisseur de la bordure extérieure (0) Highlightbackground= couleur de la bordure extérieure Video.attach_window(frame.window_id()) optionsīackground= ou bg= Couleur de l’arrière-planīorderwidth= ou bd= Épaisseur de la bordure (0)Ĭursor= aspect du curseur de la souris (flèche par défaut) Window_id to get the window handle corresponding to the frame.įrame = Frame(width=768, height=576, bg="", colormap="new") Separator = tk.Frame(height=2, bd=1, relief=' SUNKEN') créer une séparation import Tkinter as tk get() pour récupérer la valeur de la variableītn_print = tk.Button( fenetre, text=" Printer", command= print_texte).pack()įrame est une région rectangulaire dans la fenêtre. set() pour modifier la valeur de la variableītn_modifier = tk.Button( fenetre, text=" Modifier", command= modifier_texte).pack() Label = tk.Label( fenetre, textvariable= variable_a_modifier).pack() #variable_a_modifier = tk.DoubleVar() # Float #variable_a_modifier = tk.IntVar() # Integer Variable_a_modifier = tk.StringVar() # String On peut affecter une variable tkinter à un widget, avec textvariable, comme argument kwargs. BACKGROUND w.configure(bg=' black') TEXTE Self.tk.config(menu=nu) # nu is your menu. Then switch it back to your menu when you want it to show up again. ![]() Self.tk.config(menu=self.blank_menu) # self.blank_menu is a Menu object The other is to make a blank menu to switch between. If you want to hide a menu, too, there are only two ways I’ve found to do that. Self.tk.attributes("-fullscreen", self.state) Self.state = not self.state # Just toggling the boolean Self.tk.attributes('-zoomed', True) # just maximizes it so we can see the window. Puis, on écoute la touche sur le widget :Įxemple avec to toggle fullscreen on and off and where escape will turn it off only : You should put it only if explicitly placing window somewhere on the screen Full screen tk.attributes("-fullscreen", True) # substitute `Tk` for whatever your `Tk()` object is called +0+0 part in self._geom and method `geometry’ is not obligatory. Without root.overrideredirect the title bar is shown. Note: avec root.overrideredirect(True) the doesn’t call anything on my machine (Ubuntu). W.geometry(" +0+0".format(master.winfo_screenwidth()-pad, master.winfo_screenheight()-pad)) winfo.screenheight() # hauteur de l'écran plein écran w_window = window. geometry(" 800 圆00") dimensions de l’écran w_window = w. geometry(' largeur x hauteur + posH + posV') W.mainloop() TITRE w.title('le titre') GÉOMÉTRIE DE LA FENÊTRE Position et dimensions w.
0 Comments
Leave a Reply. |