Python - How to Create Multiple Window Frames with TKinter ( The easiest way )

Python - How to Create Multiple Window Frames with TKinter ( The easiest way )

Web Dev Tutorials

3 года назад

68,302 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@kychemclass5850
@kychemclass5850 - 30.04.2023 19:12

Hi. I had multiple problems with the code as appearing in your video. I modified it a bit to work. I'm using python 3.10.6
import tkinter as tk

window = tk.Tk()
# Ori = window.state('zoomed')
window.geometry("800x700") # auto shows full size


def show_frame(frame_number):
frame_number.tkraise()


# window.rowconfigure(0,weight=1)
# window.columnconfigure(0,weight=1)

frame3 = tk.Frame(window, width=700, height=200, bg = 'black')
frame3.place(x=0,y=0)
frame2 = tk.Frame(window, width=700, height=200, bg = 'gray')
frame2.place(x=0,y=0)
frame1 = tk.Frame(window, width=700, height=200, bg = 'orange')
frame1.place(x=0,y=0)

# for frame in (frame1, frame2, frame3):
# frame.grid(row=0,column=10,sticky="nsew")
# ==========================
frame1_title = tk.Label(frame1, text="This is frame1", bg='skyblue')
frame1_title.place(x=30,y=50) # relative to 0,0 in the frame !!!!!!
frame1_btn = tk.Button(frame1, text='see Frame2', command=lambda:show_frame(frame2))
frame1_btn.place(x=30,y=100)

frame2_title = tk.Label(frame2, text="This is frame2", bg='yellow')
frame2_title.place(x=30,y=50) # relative to 0,0 in the frame !!!!!!
frame2_btn = tk.Button(frame2, text='see Frame3', command=lambda:show_frame(frame3))
frame2_btn.place(x=30,y=100)

frame3_title = tk.Label(frame3, text="This is frame3", bg='pink')
frame3_title.place(x=30,y=50)
frame3_btn = tk.Button(frame3, text='see Frame1', command=lambda:show_frame(frame1))
frame3_btn.place(x=30,y=100)


window.mainloop()

Ответить
@lokmanturkmen8964
@lokmanturkmen8964 - 17.03.2023 11:52

what's IDE setting? espacialy what's font?

Ответить
@leonlukosevicius1087
@leonlukosevicius1087 - 24.10.2022 18:35

Fantastic tutorial, no need to create classes! Thank you so much!

Ответить
@kfranaf
@kfranaf - 20.10.2022 16:13

Thank you!

Ответить
@noiceselfc5199
@noiceselfc5199 - 20.09.2022 20:44

i am having a problem that my frame3 is coming at 1st instead of frame1

Ответить
@tanktic1
@tanktic1 - 11.09.2022 12:09

old video but just came across it and it helped me alot! This was just the thing i was looking for

Ответить
@davidkingsley8940
@davidkingsley8940 - 10.09.2022 06:18

How did you make the color, fill the window?

Ответить
@akramwael1354
@akramwael1354 - 02.09.2022 05:01

thank you so much for this tutorial, you really helped me a lot

Ответить
@1_Satvik
@1_Satvik - 20.08.2022 12:54

Thanks!

Ответить
@Paul-ly1pw
@Paul-ly1pw - 24.07.2022 11:11

Brilliant video. If the user wants an image as the background, they will have to use a canvas. It is possible to do the same thing using canvases?

Ответить
@jacery
@jacery - 29.05.2022 02:34

is there anyway to do this with canvas? my program I'm trying to create heavily relies on canvas'.

Ответить
@seviecrawford
@seviecrawford - 06.04.2022 02:30

Thank you so much for this tutorial sir !!

Ответить
@furkancankaya4996
@furkancankaya4996 - 23.01.2022 06:32

I can't add exit button :/ can anyone help me ?

Ответить
@adityaprabhakar7368
@adityaprabhakar7368 - 28.12.2021 21:36

this code is not working with pack method please help.

Ответить
@abdolabdollah1783
@abdolabdollah1783 - 16.12.2021 04:51

Brilliant tutorial! very well explained. I just SUBSCRIBED

Ответить
@wagnerengenhoca
@wagnerengenhoca - 08.12.2021 08:34

Massa o vídeo.

Ответить
@viji8126
@viji8126 - 03.11.2021 11:31

what should we code if we want frame 1 as default and frame 2 , 3 should be under a menu button . when we click the menu button , i should get 2 options (frame 2 and frame 3) and when clicked the frame 2 or 3 , still the menu should be available and when we are in frame 2 or frame 3 , the menu button should show frame 1 so that i can go back to frame 1 .

please reply the code or make a video on it in short term . pls

Ответить
@muhammadbangkit7528
@muhammadbangkit7528 - 23.10.2021 22:43

can I ask u a question? can I double the layer without actually changing the back layer, for example, I have 2 layers, the first layer is the main layer, the second layer is like 'pop up' image with the blurry main layer behind it(without actually changing the data in the main layer)?

Ответить
@ayushseth1422
@ayushseth1422 - 22.10.2021 19:28

You saved me man, ver very Thank you.. tomorrow is my hackathon project submission nd jst linking part was left

Ответить
@Leimaister
@Leimaister - 16.10.2021 23:50

Really really Thanks!

Ответить
@jayantbarthwal4470
@jayantbarthwal4470 - 17.09.2021 08:01

Awesome video, python, java, flutter, which language I should choose to create a GUI app for rasbian (virtual environment), I want to create an app on my windows pc, and when it's done I just want to test how it is working in rasbian and than in real raspberry pi 4.

I don't want to install any additional module from the terminal, I want something that can directly run on rasbian

Ответить
@DronesMedellin
@DronesMedellin - 13.08.2021 19:54

THANKS!!!

Ответить
@mr.bubble1657
@mr.bubble1657 - 06.08.2021 11:35

Can you please share the code with me

Ответить
@ayanokoji5594
@ayanokoji5594 - 15.07.2021 21:47

Thank you very much. It was really useful

Ответить
@vishwajeetbhagat9547
@vishwajeetbhagat9547 - 05.07.2021 10:53

Hey, thanks for the idea. I am trying to use it where I have 3 frames at a time on a screen and I just want to update only one frame but it isn't working for me?
Can you please help

Ответить
@Prajwal_KV
@Prajwal_KV - 25.05.2021 11:24

Thanks a lot.

Ответить
@dieudonnetambah4559
@dieudonnetambah4559 - 19.05.2021 23:34

Cool. Thanks man

Ответить
@atharvsinha8675
@atharvsinha8675 - 18.05.2021 06:18

Bro is there any way that I can make dark to light theme switcher in tkinter?

Ответить
@jd-yo2is
@jd-yo2is - 13.05.2021 19:29

Thanks this is great basic tutorial for multiple pages gui

Ответить
@tnnz9920
@tnnz9920 - 11.05.2021 14:43

How to go back from page 2 to page1?

Ответить
@rohitpatil3534
@rohitpatil3534 - 19.04.2021 18:16

Great work man, this really helped me. 👍👍👍 Keep making such tutorials. ❤️❤️

Ответить
@prernatopno6927
@prernatopno6927 - 14.04.2021 07:49

Thank you so much this is exactly what I needed. You made my work easy.
God bless you☺

Ответить
@dxthduckkim8342
@dxthduckkim8342 - 13.04.2021 17:23

I am korean and this is sooooooooooooo great for me. This videos is more helpful than korean blog sites thank you

Ответить
@rubebeyl3747
@rubebeyl3747 - 16.03.2021 20:46

Why is this such a good video

Ответить
@gabrielolvera8321
@gabrielolvera8321 - 03.03.2021 03:06

Hi bro, loved the video. Just a question tho, how can i make it like full size? In the intro you've got like these big frames but in the video they are small. Thanks

Ответить
@JuanPortalG
@JuanPortalG - 08.02.2021 04:28

Thanks, man! Greetings from Perú 🇵🇪

Ответить
@ChicaRara01
@ChicaRara01 - 19.01.2021 20:50

Great video. Exactly what I was looking for. Btw, do you know how to create android apps using python? I just found Java but I don't want it.

Ответить
@ChicaRara01
@ChicaRara01 - 19.01.2021 20:49

I have a problem. It says, can't invoke pack command the application has been destroyed and I don't know why. ¿Cuold you help me to figure out what is wrong or what am I missing?

from tkinter import *
import time

#---------------------SHOW FRAMES------------------------
def show_frame(frame):
frame.tkraise()

window=Tk()
window.title("PPA")
window.config(bg="white")
window.state("zoomed")

frame1=Frame(window)
frame2=Frame(window)
frame3=Frame(window)


for frame in (frame1,frame2,frame3):
frame.pack()



frame1.config(bg="blue")
boton=Button(frame,width=10,height=2, relief="raised", text="SUBJECTS",fg="white",command=lambda:show_frame(frame2))
boton1.pack()

frame2.config(bg="black")
boton2=Button(frame,width=10,height=2, relief="raised", text="CALCULATOR",fg="white",command=lambda:show_frame(frame3))
boton2.pack()

frame3.config(bg="red")
boton3=Button(frame,width=10,height=2, relief="raised", text="MAIN MENU",fg="white",command=lambda:show_frame(frame1))
boton3.pack()


window.mainloop()

Ответить
@hartech6162
@hartech6162 - 11.01.2021 04:01

Broh can you share the code plz

Ответить
@dhruvsehwal3668
@dhruvsehwal3668 - 09.01.2021 18:04

Thanks for the video. Really helpful

Ответить
@Zhisaoka
@Zhisaoka - 04.01.2021 21:30

when I run the program both show up and frame 2 wont disappear I'm using only 2 frames

Ответить
@AbinayaAnand401
@AbinayaAnand401 - 27.12.2020 16:56

Nice video thank for this

Ответить
@djpolancotd
@djpolancotd - 24.12.2020 03:47

This is a really great tutorial, thank you so much you saved me from falling into a heavy frustration <3

Ответить
@switchblade3868
@switchblade3868 - 02.12.2020 06:15

how to solve it for a pin condition .

Ответить
@Siva_Murugan
@Siva_Murugan - 29.11.2020 17:04

Excellent job dude

Ответить
@jaco9263
@jaco9263 - 26.11.2020 21:39

i am having issues with the button name not being defined, idk what I did wrong and i followed your steps.

Ответить
@furz3y688
@furz3y688 - 23.11.2020 18:40

Thank you ❤️, the other one is too hard for me.

Ответить
@joserubencordovarodriguez4440
@joserubencordovarodriguez4440 - 22.11.2020 01:37

This is exactly what i was loking for! Thanks a lot.

Ответить
@danielcovaci6930
@danielcovaci6930 - 08.11.2020 00:33

the sound volume from intro is too loud. great tutorial

Ответить
@suryakantamoharana4332
@suryakantamoharana4332 - 07.11.2020 03:48

Finally I got this type of video. Thanks bro

Ответить