![]() ![]() # 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') Self.W.mainloop() TITRE w.title('le titre') GÉOMÉTRIE DE LA FENÊTRE Position et dimensions w. This technique is pretty standard now, we don’t expect any flicking in gui windows.Ī clock would simply add a timer function, like this: 1 You could make say a clock that updates every second, but won’t see any flickering. This technique prevents flicking of the screen when updating it. The tkinter label is using the techinque of double buffering. If you do not specify a size for the label widget, it will be made just large enough to fit the text. It is the famous “hello world” program for tkinter, but we decided to change the text. This example shows a label on the screen. Label1 = Label(master, text= "Helvetica", font=( "Helvetica", 18)) Label1 = Label(master, text= "Tkinter", fg= "red") You can change the font color or size of the label: 1 The second line sets the two dimensional position: 1 The first line defines the label and the text. Related course: Python Desktop Apps with Tkinter Example introductionĪ label can be addded with just two lines of code. You can put any text in a label and you can have multiple labels in a window (just like any widget can be placed multiple times in a window). A label can only display text in a single font. The tkinter label widgets can be used to show text or an image to the screen. ![]()
0 Comments
Leave a Reply. |