Python Forum
[Tkinter] Multiple frames with tkinter - How to make them run on fullscreen mode
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Multiple frames with tkinter - How to make them run on fullscreen mode
#1
Hello guys!

I wrote a code using tkinter to switch between frames after a few seconds. The problem is: All the application must run in fullscreen.

Here is the code.

from tkinter import *


N_TRIALS = 3
COUNT=-2
N_INTERVALS = 2*N_TRIALS + 1
RELAXING_TIME = 2000
RESTING_TIME = 2000
TASKING_TIME = 2000
start_btn_state = False

def raise_frame(frame):
    frame.tkraise()
    global COUNT
    COUNT+=1
    print(COUNT)

    if (frame == f3 and COUNT==N_INTERVALS):
        frame.after(RESTING_TIME,lambda:raise_frame(f5)) 

    elif(frame == f5):

        frame.after(RELAXING_TIME,lambda:raise_frame(f6)) 

    elif frame == f2: 
                frame.after(RELAXING_TIME, lambda:raise_frame(f3)) 
    elif frame == f3: 
                frame.after(RESTING_TIME, lambda:raise_frame(f4))

    elif frame == f4: 
                 frame.after(TASKING_TIME, lambda:raise_frame(f3))

    elif frame==f6:
        root.destroy()           


def finish():
    root.destroy()

def start():
    start_btn_state=True
    raise_frame(f2)


root = Tk()

f1 = Frame(root)
f2 = Frame(root)
f3 = Frame(root)
f4 = Frame(root)
f5 = Frame(root)
f6 = Frame(root)



for frame in (f1, f2, f3, f4, f5,f6):
   frame.grid(row = 0, column = 0, sticky='nsew')




lb0=Label(f1, text="blablabla",font=("Arial Bold",10))
lb0.pack(padx = 10, pady=10)
lb1=Label(f1, text="blablabla",font = ("Arial Bold",10),fg = "black")
lb1.pack(padx = 10, pady=10)
lb2 = Label(f1, text="blablabla",font = ("Arial Bold",10),fg = "green")
lb2.pack(padx = 10, pady=10)
lb3 = Label(f1, text="blablabla",font = ("Arial Bold",10),fg = "blue") 
lb3.pack(padx = 10, pady=10)
lb4 = Label(f1, text="blablabla",font = ("Arial Bold",10),fg = "red")
lb4.pack(padx = 10, pady=10)
# =============================================================================
# Start Button
# =============================================================================
start_value=BooleanVar()
btn_start=Button(f1, text="Start",font = ("Arial Bold",20), command = start)
btn_start.pack(padx=10,pady=30)
###############################################################################
# =============================================================================
# Close Button
# =============================================================================
close_value=BooleanVar()
btn_close=Button(f1, text="CLOSE",font = ("Arial Bold",20), command=finish)
btn_close.pack(padx=10,pady=30)
###############################################################################


# =============================================================================
# Frame 2
# =============================================================================
Label(f2, text='ACTION 1').pack()
#Button(f2, text='Go to frame 3', command=lambda:raise_frame(f1)).pack()
f2.config(bg='red')

###############################################################################

# =============================================================================
# Frame 3
# =============================================================================
Label(f3, text='ACTION2').pack(side='left')
f3.config(bg='green')
###############################################################################

# =============================================================================
# Frame 4
# =============================================================================
Label(f4, text='ACTION3').pack()
f4.config(bg='blue')

###############################################################################

# =============================================================================
# Frame 5
# =============================================================================
Label(f5, text='RELAXING FINAL').pack()
f5.config(bg='black')
###############################################################################


raise_frame(f1)
root.mainloop()
I don't know how to expand the frames to fill all the window. I tried everything: geometry, width and height, etc. It seems probably (100% sure) that I am doing something wrong to put those frames on fullscreen.

could anyone help me?

Sorry about the code that is not in OOP. I am learning about it.

I appreciate the help!

Best Regards
Reply


Messages In This Thread
Multiple frames with tkinter - How to make them run on fullscreen mode - by eabs86 - Sep-18-2018, 04:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  make widgets disappear from tkinter jacksfrustration 12 1,123 Feb-06-2024, 03:58 PM
Last Post: deanhystad
  Tkinter multiple windows in the same window tomro91 1 845 Oct-30-2023, 02:59 PM
Last Post: Larz60+
  Why I am getting ModuleNotFoundError when I make an Exe file for tkinter GUI? pymn 0 1,648 Apr-01-2022, 05:36 PM
Last Post: pymn
  [Tkinter] It it possible to make a help file explorer with tkinter? Clunk_Head 0 1,981 Aug-07-2021, 06:02 PM
Last Post: Clunk_Head
  [Tkinter] tkinter.Menu – How to make text-variable? Sir 3 5,631 Mar-10-2021, 04:21 PM
Last Post: Sir
  Tkinter Python: How to make sure tkSimpleDialog takes in No value entered rcmanu95 3 2,339 Aug-05-2020, 05:32 AM
Last Post: Yoriz
  How to check if window is fullscreen or not delphinis 2 3,816 Aug-01-2020, 01:21 PM
Last Post: delphinis
  How to make button text bold in Tkinter? scratchmyhead 2 12,038 May-16-2020, 02:53 AM
Last Post: scratchmyhead
  [Tkinter] Change label for multiple frames Dandy_Don 3 2,979 Apr-30-2020, 02:22 PM
Last Post: Dandy_Don
  [Tkinter] How to add multiple frames to main window Dandy_Don 13 7,948 Apr-29-2020, 09:21 PM
Last Post: Dandy_Don

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020