Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4950

Python • tkinter display issues switching between frames

$
0
0
Hello everyone,
I m experiencing a display issue on my rpi4 (debian 11), switching between frames.
Randomly buttons/labels are not displayed (see attached pics), but are visible after I move the mouse cursor above the hidden button
Note that it is working properly on my laptop with linux mint
If you have any idea to help...

Here is the python script :
import tkinter as tk

def raise_frame(sframe):
sframe.tkraise()

mainform = tk.Tk()
mainform.geometry("480x800")
mainform.columnconfigure(0, weight=1)
mainform.rowconfigure(0,weight=1 )

pg_noFS = tk.Frame(mainform)
pg_placeFS = tk.Frame(mainform)

for frame in (pg_noFS, pg_placeFS):

frame.columnconfigure(0, weight=1)
frame.columnconfigure(1,weight=1 )
frame.rowconfigure(0,weight=1 )
frame.rowconfigure(1,weight=2)
frame.rowconfigure(2,weight=1)
frame.rowconfigure(3,weight=1)
frame.grid(row=0,columnspan=2,rowspan=3, sticky = "nsew", padx=25, pady = 25)

# pg_noFS
#Mid label
tk.Label(pg_noFS, font = ('fixed', 15),
text = 'Machine opérationnelle' ).grid(row=1, columnspan=2, rowspan=2, sticky = "nsew")
#Center button
tk.Button(pg_noFS, font = ('fixed', 20), height = 2, width = 9,
text = 'Installer\nRecharge', command = lambda:raise_frame(pg_placeFS)).grid(row=3, columnspan = 2, sticky = 's')

# pg_placeFS
#Mid label
tk.Label(pg_placeFS, font = ('fixed', 15),
text = 'Ouvrir la porte du compartiment recharge \n\n Positionner le recharge dans le support \n\n Refermer la porte' ).grid(row=1, columnspan=2, rowspan=2, sticky = "nsew")
#Right button
tk.Button(pg_placeFS, font = ('fixed', 20), height = 2,width = 9,
text = 'Valider', command = lambda:raise_frame(pg_noFS)).grid(row=3, columnspan = 2, sticky = 'se')
#Left button
tk.Button(pg_placeFS, font = ('fixed', 20), height = 2, width = 9,
text = 'Annuler', command = lambda:raise_frame(pg_noFS)).grid(row=3, columnspan = 2, sticky = 'sw')

raise_frame(pg_noFS)
mainform.mainloop()
ok.jpg

ko.jpg

Statistics: Posted by bestof27 — Thu Jan 23, 2025 6:23 pm — Replies 0 — Views 3



Viewing all articles
Browse latest Browse all 4950

Trending Articles