0

I'm using Tkinter for a gui experiment and I'm having some difficulties to pass my frame with some labels to full screen, do you have any ideas how can I do it?

#window 
root = Tk()
root.title("Sequencia")
#root.attributes('-fullscreen', True)
#root.bind('<Escape>',lambda e: root.destroy())
#root.state('zoomed')
#root.configure(background='black')
fm = Frame(root, width=500, height=350, bg="black")



# w = Canvas(fm, width=20, height=20, bg ="black", selectborderwidth=0)
#w.create_line(0, 200, 150, 150, width=10, fill="blue")

label_sim = Label(fm, width=10, height=1, bg="gray", text = "SIM")
label_nao = Label(fm, width=10, height=1, bg="gray", text = "NÃO")
label_fome = Label(fm, width=10, height=1, bg="gray", text = "FOME")
label_sede = Label(fm, width=10, height=1, bg="gray", text = "SEDE")
label_urinar = Label(fm, width=10, height=1, bg="gray", text = "URINAR")
label_ar = Label(fm, width=10, height=1, bg="gray", text = "AR")
label_posicao = Label(fm, width=10, height=1, bg="gray", text = "POSIÇÃO")



labels = [label_sim,label_nao,label_fome,label_sede,label_urinar,label_ar,label_posicao]

# ordem de sequencia (1 2 3 4 5 6 7): (SIM, NAO, FOME, SEDE, URINAR, AR, POSICAO)
fm.pack()
label_sim.place(relx=0.2, rely=0.5, anchor=CENTER)
label_nao.place(relx=0.8, rely=0.5, anchor=CENTER)
label_fome.place(relx=0.35, rely=0.8, anchor=CENTER)
label_sede.place(relx=0.65, rely=0.8, anchor=CENTER)
label_urinar.place(relx=0.25, rely=0.25, anchor=CENTER)
label_ar.place(relx=0.5, rely=0.1, anchor=CENTER)
label_posicao.place(relx=0.75, rely=0.25, anchor=CENTER)

root.update()

thank you very much EDIT: what I'm trying is make the frame that I have fullscreen automatically, or is it only possible with the window? do we have to choose the size of the frame manually?

EDIT2: I manage to do it by taking the size of the window and put in the arguments of the frame:

#window 
root = Tk()
root.title("Sequencia")
root.attributes('-fullscreen', True)
root.bind('<Escape>',lambda e: root.destroy())
#root.state('zoomed')
#root.configure(background='black')
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
fm = Frame(root, width=w, height=h, bg="black")
Ricky
  • 79
  • 1
  • 11

1 Answers1

0

This may not be the right answer, but I would do it this way!

Increase the frame height and width, always have the application zoomedand finally remove (disable) the resize option using resizable(0,0)

import tkinter as tk


#window
root = tk.Tk()
root.title("Sequencia")
#root.attributes('-fullscreen', True)
#root.bind('<Escape>',lambda e: root.destroy())
#root.state('zoomed')
#root.configure(background='black')
fm = tk.Frame(root, width=1400, height=720, bg="black")




# w = Canvas(fm, width=20, height=20, bg ="black", selectborderwidth=0)
#w.create_line(0, 200, 150, 150, width=10, fill="blue")

label_sim = tk.Label(fm, width=10, height=1, bg="gray", text = "SIM")
label_nao = tk.Label(fm, width=10, height=1, bg="gray", text = "NÃO")
label_fome = tk.Label(fm, width=10, height=1, bg="gray", text = "FOME")
label_sede = tk.Label(fm, width=10, height=1, bg="gray", text = "SEDE")
label_urinar = tk.Label(fm, width=10, height=1, bg="gray", text = "URINAR")
label_ar = tk.Label(fm, width=10, height=1, bg="gray", text = "AR")
label_posicao = tk.Label(fm, width=10, height=1, bg="gray", text = "POSIÇÃO")



labels = [label_sim,label_nao,label_fome,label_sede,label_urinar,label_ar,label_posicao]

# ordem de sequencia (1 2 3 4 5 6 7): (SIM, NAO, FOME, SEDE, URINAR, AR, POSICAO)
fm.pack()
label_sim.place(relx=0.2, rely=0.5, anchor=tk.CENTER)
label_nao.place(relx=0.8, rely=0.5, anchor=tk.CENTER)
label_fome.place(relx=0.35, rely=0.8, anchor=tk.CENTER)
label_sede.place(relx=0.65, rely=0.8, anchor=tk.CENTER)
label_urinar.place(relx=0.25, rely=0.25, anchor=tk.CENTER)
label_ar.place(relx=0.5, rely=0.1, anchor=tk.CENTER)
label_posicao.place(relx=0.75, rely=0.25, anchor=tk.CENTER)

root.update()
root.state('zoomed')
root.resizable(0,0)
root.mainloop()
user1404
  • 179
  • 1
  • 3
  • 10
  • Thank you for your answer, so there is no way to have the fullscreen automatically like we can do with the window? we have to choose the size of the frame manually? thank you – Ricky Mar 28 '19 at 14:12
  • Ok so I managed to do it like this: ``` root = Tk() root.title("Sequencia") root.attributes('-fullscreen', True) root.bind('',lambda e: root.destroy()) #root.state('zoomed') #root.configure(background='black') w, h = root.winfo_screenwidth(), root.winfo_screenheight() fm = Frame(root, width=w, height=h, bg="black") ``` – Ricky Mar 28 '19 at 14:38