variable non définie et affichage des dimensions d'une fenêtre en direct
Alors voilà mon problème:
J'aimerais que le label sur ma 'StartPage' affiche les dimensions en direct de la fenêtre (l x h + x + y) donc pour ça je sais qu'il faut utiliser .geometry() mais le problème que j'ai c'est que app (ma fenêtre) n'est définie que plus tard et je ne n'arrive pas à la définir avant sans que tout plante.
De plus si jamais qqn me trouve une solution a ce problème je ne suis pas sur que ça fonctionne correctement quand même, qu'il n'y ai pas un ou plusieurs problèmes en plus dans mon code… (Comme par exemple d'afficher la taille une seule fois et non pas en direct)
Merci d'avance,
Voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| from tkinter import *
class windows(Tk):
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
container = Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (StartPage):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class StartPage(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent, bg='black')
center = Frame(self, bg='black')
center.pack(expand=YES)
appsize = app.geometry()
titre = Label(center, text=str(appsize), font=(40), bg='#000000', fg='#FFFFFF')
titre.grid(row=0, column=1)
app = windows()
app.title("Don't press the button")
fullscreenstate = True
app.attributes('-fullscreen', fullscreenstate)
app.config(bg='black')
width_screen = app.winfo_screenwidth()
height_screen = app.winfo_screenheight()
app.minsize(width_screen//3, height_screen//3)
app.mainloop() |