Тёмный

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

Web Dev Tutorials
Подписаться 16 тыс.
Просмотров 69 тыс.
50% 1

Опубликовано:

 

16 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 127   
@leonlukosevicius1087
@leonlukosevicius1087 Год назад
Fantastic tutorial, no need to create classes! Thank you so much!
@djpolancotd
@djpolancotd 3 года назад
This is a really great tutorial, thank you so much you saved me from falling into a heavy frustration
@codefoxx
@codefoxx 3 года назад
No problem 👍
@mapleshots
@mapleshots 3 года назад
I am korean and this is sooooooooooooo great for me. This videos is more helpful than korean blog sites thank you
@raprocks9421
@raprocks9421 3 года назад
Great work man, this really helped me. 👍👍👍 Keep making such tutorials. ❤️❤️
@codefoxx
@codefoxx 3 года назад
Thanks, please like the video if it helped!
@raprocks9421
@raprocks9421 3 года назад
@@codefoxx already did sirrr.
@cillianck
@cillianck 4 года назад
Brilliant tutorial! very well explained
@codefoxx
@codefoxx 4 года назад
Glad you liked it!
@Akram_Wael
@Akram_Wael 2 года назад
thank you so much for this tutorial, you really helped me a lot
@tanktic1
@tanktic1 2 года назад
old video but just came across it and it helped me alot! This was just the thing i was looking for
@kfranaf
@kfranaf Год назад
Thank you!
@prernatopno6927
@prernatopno6927 3 года назад
Thank you so much this is exactly what I needed. You made my work easy. God bless you☺
@ayushseth1422
@ayushseth1422 2 года назад
You saved me man, ver very Thank you.. tomorrow is my hackathon project submission nd jst linking part was left
@JuanPortalG
@JuanPortalG 3 года назад
Thanks, man! Greetings from Perú 🇵🇪
@codefoxx
@codefoxx 3 года назад
No problem!
@Leimaister
@Leimaister 2 года назад
Really really Thanks!
@abdolabdollah1783
@abdolabdollah1783 2 года назад
Brilliant tutorial! very well explained. I just SUBSCRIBED
@joserubencordovarodriguez4440
@joserubencordovarodriguez4440 3 года назад
This is exactly what i was loking for! Thanks a lot.
@codefoxx
@codefoxx 3 года назад
No problem 👍
@rubebeyl3747
@rubebeyl3747 3 года назад
Why is this such a good video
@codefoxx
@codefoxx 3 года назад
Not sure, I feel like I could have done a better job! Thanks
@rubebeyl3747
@rubebeyl3747 3 года назад
@@codefoxx idk why this is sl good but i think it´s bcs you are going slow and expalining everyrhing
@jd-yo2is
@jd-yo2is 3 года назад
Thanks this is great basic tutorial for multiple pages gui
@dhruvsehwal3668
@dhruvsehwal3668 3 года назад
Thanks for the video. Really helpful
@suryakantamoharana4332
@suryakantamoharana4332 3 года назад
Finally I got this type of video. Thanks bro
@codefoxx
@codefoxx 3 года назад
No problem, thanks for watching 📺
@ayanokoji5594
@ayanokoji5594 3 года назад
Thank you very much. It was really useful
@seviecrawford
@seviecrawford 2 года назад
Thank you so much for this tutorial sir !!
@furz3y688
@furz3y688 3 года назад
Thank you ❤️, the other one is too hard for me.
@dieudonnetambah4559
@dieudonnetambah4559 3 года назад
Cool. Thanks man
@Prajwal_KV
@Prajwal_KV 3 года назад
Thanks a lot.
@jacery
@jacery 2 года назад
is there anyway to do this with canvas? my program I'm trying to create heavily relies on canvas'.
@Siva_Murugan
@Siva_Murugan 3 года назад
Excellent job dude
@codefoxx
@codefoxx 3 года назад
Thanks
@rosen.espinoza9477
@rosen.espinoza9477 4 года назад
Great content as always 👏
@codefoxx
@codefoxx 4 года назад
Glad you enjoyed it
@AbbyVbz
@AbbyVbz 3 года назад
Nice video thank for this
@codefoxx
@codefoxx 3 года назад
No problem 👍
3 года назад
THANKS!!!
@viji8126
@viji8126 2 года назад
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
@codefoxx
@codefoxx 2 года назад
You would have to create a menu bar and add the those two options to it. When a user clicks on the frame 2 option, for example, you would use the show_frame function to take them to that page. Doesn't seem too difficult
@viji8126
@viji8126 2 года назад
@@codefoxx thanks 🤗 . Love your videos . Really helpful . Keep rocking .
@armindazavala333
@armindazavala333 4 года назад
I needed this thanks
@codefoxx
@codefoxx 4 года назад
No problem
@kychemclass5850
@kychemclass5850 Год назад
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()
@Paul-ly1pw
@Paul-ly1pw 2 года назад
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?
@noiceselfc5199
@noiceselfc5199 2 года назад
i am having a problem that my frame3 is coming at 1st instead of frame1
@jayantbarthwal4470
@jayantbarthwal4470 3 года назад
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
@adityaprabhakar7368
@adityaprabhakar7368 2 года назад
this code is not working with pack method please help.
@AlexJaeger716
@AlexJaeger716 4 года назад
you got a new sub
@codefoxx
@codefoxx 4 года назад
Thanks
@wagnerengenhoca
@wagnerengenhoca 2 года назад
Massa o vídeo.
@vishwajeetbhagat9547
@vishwajeetbhagat9547 3 года назад
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
@lokmanturkmen8964
@lokmanturkmen8964 Год назад
what's IDE setting? espacialy what's font?
@danielcovaci6930
@danielcovaci6930 3 года назад
the sound volume from intro is too loud. great tutorial
@codefoxx
@codefoxx 3 года назад
I have made efforts to improve my sound quality since that video was recorded. Thanks for letting me know and for watching 📺
@davidkingsley8940
@davidkingsley8940 2 года назад
How did you make the color, fill the window?
@ChicaRara01
@ChicaRara01 3 года назад
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.
@codefoxx
@codefoxx 3 года назад
With Python you can use Kivy to make apps, although I don't know how to use it. I personally use Java with Android studio to make apps. Yes, Java can be more confusing than Python being that it's entirely based on object oriented programming. Hope this helps
@ChicaRara01
@ChicaRara01 3 года назад
@@codefoxx I know the basis of POO from c++ (I guess is kinda same) but Java seems more complex for me. Anyway thanks for the information, I'll keep it in mind.
@codefoxx
@codefoxx 3 года назад
@@ChicaRara01 nice, I recommend you use OOP because if you want to make something other than a beginner program, respectively, (something more complex with a lot of functionality) you will need OOP because it will give your code a better structure and it will help keep it organized when you get into the several hundred/ thousands lines of codes. It will also make it easier to add or delete things from your project!
@ChicaRara01
@ChicaRara01 3 года назад
@@codefoxx sure, thank u for the explanation.
@gabrielolvera8321
@gabrielolvera8321 3 года назад
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
@codefoxx
@codefoxx 3 года назад
Instead of (fill="x") use (fill="both" expand="true") when you pack the Label. You can add as many things as you want per frame, I just used the Label and button on each frame to demonstrate how it works
@gabrielolvera8321
@gabrielolvera8321 3 года назад
Thanks, got 10 on my project ;)
@codefoxx
@codefoxx 3 года назад
@@gabrielolvera8321 there u go!
@sairsc8043
@sairsc8043 4 года назад
Can u please say how to import photos in dis method that is using diff photos in diff window please make it sir
@codefoxx
@codefoxx 4 года назад
Email me, my email is in the description, I can send you an example of that
@sairsc8043
@sairsc8043 4 года назад
@@codefoxx ok sir thanku
@codefoxx
@codefoxx 4 года назад
@@sairsc8043 I do something similar to what you want in this video, if you still need help, email me ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-2V2QxFBMEyo.html
@jaco9263
@jaco9263 3 года назад
i am having issues with the button name not being defined, idk what I did wrong and i followed your steps.
@codefoxx
@codefoxx 3 года назад
That error is usually a typo. Please check the names of your buttons and make sure they match up
@furkancankaya4996
@furkancankaya4996 2 года назад
I can't add exit button :/ can anyone help me ?
@muhammadbangkit7528
@muhammadbangkit7528 2 года назад
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)?
@codefoxx
@codefoxx 2 года назад
I think I know what you mean. Not sure if you can do this with tkinter. That sounds more like something that is done with CSS in web development.
@muhammadbangkit7528
@muhammadbangkit7528 2 года назад
@@codefoxx yea true 🤣, how about I change the layer, but the data in main layer I set to global, is that doable?
@codefoxx
@codefoxx 2 года назад
@@muhammadbangkit7528 Not sure, try it! I have not worked with tkinter in over a year sorry I can't be of much help!
@muhammadbangkit7528
@muhammadbangkit7528 2 года назад
@@codefoxx okok thanku very much sir
@muhammadbangkit7528
@muhammadbangkit7528 2 года назад
I'll put ur channel on my paper as references, thanku very much 🙏
@atharvsinha8675
@atharvsinha8675 3 года назад
Bro is there any way that I can make dark to light theme switcher in tkinter?
@codefoxx
@codefoxx 3 года назад
Absolutely
@HenriqueCaldeiraPFraga-yt3wu
@HenriqueCaldeiraPFraga-yt3wu 3 года назад
Thanks for teach... Can change this game tic tac toe for Desktop Applicatio
@codefoxx
@codefoxx 3 года назад
No problem 👍
@ChicaRara01
@ChicaRara01 3 года назад
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()
@codefoxx
@codefoxx 3 года назад
Working out right now but I'll look at your code in 30min
@ChicaRara01
@ChicaRara01 3 года назад
@@codefoxx yay, thanks.
@codefoxx
@codefoxx 3 года назад
@@ChicaRara01 Ok, there was a lot of things missing from your code, for example, you didn't import the tkinter module nor did you call on the show_frame function. I fixed your code although I am not 100% sure what your aiming for in this project. I added a button to each of the frames. Below is the code import tkinter as tk def show_frame(frame): frame.tkraise() window=tk.Tk() window.title("PPA") window.config(bg="white") window.state("zoomed") window.rowconfigure(0, weight=1) window.columnconfigure(0, weight=1) frame1=tk.Frame(window) frame2=tk.Frame(window) frame3=tk.Frame(window) for frame in (frame1,frame2,frame3): frame.grid(row=0,column=0,sticky='nsew') frame1.config(bg="blue") boton1=tk.Button(frame1,width=10,height=2, relief="raised", text="SUBJECTS",fg="white",command=lambda:show_frame(frame2)) boton1.pack() frame2.config(bg="black") boton2=tk.Button(frame2,width=10,height=2, relief="raised", text="CALCULATOR",fg="white",command=lambda:show_frame(frame3)) boton2.pack() frame3.config(bg="red") boton3=tk.Button(frame3,width=10,height=2, relief="raised", text="MAIN MENU",fg="white",command=lambda:show_frame(frame1)) boton3.pack() show_frame(frame1) window.mainloop()
@ChicaRara01
@ChicaRara01 3 года назад
@@codefoxx not pretty sure why didn't work if before trying to switch between frames(I made a simple interface with just one frame and it worked perfectly) but thank u, I really appreciate. Anyway you got a new subscriber since a saw your video for the first time. Great job.
@Zhisaoka
@Zhisaoka 3 года назад
when I run the program both show up and frame 2 wont disappear I'm using only 2 frames
@codefoxx
@codefoxx 3 года назад
You must be doing something wrong, look at the tutorial again or send me your code and I can look at it
@Zhisaoka
@Zhisaoka 3 года назад
@@codefoxx oh okay sure, I tryed many different things so far. But nothing seems to work
@Zhisaoka
@Zhisaoka 3 года назад
@@codefoxx from tkinter import * wn = Tk() wn.geometry("400x300") Play = Frame(wn) TitleScreen = Frame(wn) def swap(frame): frame.tkraise() for frame in (Play, TitleScreen): frame.grid(row=0, column=0) #Title Screen# Button(TitleScreen, text="Play", command=lambda: swap(Play)).grid(row=0, column=0) Button(Play, text="TitleScreen", command=lambda: swap(TitleScreen)).grid(row=0, column=0) show_frame(Play) wn.mainloop()
@Zhisaoka
@Zhisaoka 3 года назад
@@codefoxx I tryed removing show_frame(0 before and it still doesn't work
@Zhisaoka
@Zhisaoka 3 года назад
@@codefoxx Never mind, I forgot labels
@tnnz9920
@tnnz9920 3 года назад
How to go back from page 2 to page1?
@codefoxx
@codefoxx 3 года назад
Use the show_frame(frame1) function
@bluezzyy5360
@bluezzyy5360 4 года назад
can ya help me i don't know why my frame starts from frame 3
@codefoxx
@codefoxx 4 года назад
Sure, did u make a function call to the show_frame function at the bottom of the program?
@codefoxx
@codefoxx 4 года назад
If you haven't, make a function call to show_frame(frame1), at the bottom of the program. That should make frame1, the one that shows up when you run the project
@bluezzyy5360
@bluezzyy5360 4 года назад
@@codefoxx i see.. thank you very much
@codefoxx
@codefoxx 4 года назад
@@bluezzyy5360 no problem
@bluezzyy5360
@bluezzyy5360 4 года назад
Uh.. looks like I have more problem. If I add sticky = 'nsew', there's nothing appear on the program. But if I get rid of it, the title, button and etc were appeared. So the difference between my code and your code on your tutorial video, I add entry in the frames. So, is that the one causing the problem?
@mr.bubble1657
@mr.bubble1657 3 года назад
Can you please share the code with me
@codefoxx
@codefoxx 3 года назад
Yea it's on GitHub. Link in the description
@mr.bubble1657
@mr.bubble1657 3 года назад
@@codefoxx oh Thanks bro ♥️♥️
@codefoxx
@codefoxx 3 года назад
@@mr.bubble1657 I got chu
@switchblade3868
@switchblade3868 3 года назад
how to solve it for a pin condition .
@codefoxx
@codefoxx 3 года назад
Not sure what you mean 🤔
@switchblade3868
@switchblade3868 3 года назад
@@codefoxx if atm pin is there so how to do if condition
@codefoxx
@codefoxx 3 года назад
@@switchblade3868 here is some pseudo code.......if(password == yourPassword){ showFrame(go to this frame)} else{ sorry wrong password}
@switchblade3868
@switchblade3868 3 года назад
@@codefoxx luv u babes made it
@HenriqueCaldeiraPFraga-yt3wu
@HenriqueCaldeiraPFraga-yt3wu 3 года назад
And please teach how to create tic tac toe game to desktop aplikatio
@codefoxx
@codefoxx 3 года назад
I already have a tutorial on a tic tac toe game. Here is the link ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-FrkofcY9whY.html
@hartech6162
@hartech6162 3 года назад
Broh can you share the code plz
@codefoxx
@codefoxx 3 года назад
No problem, I left a link in the description to the github repo
@hartech6162
@hartech6162 3 года назад
@@codefoxx Bro Can we do the same using "place" instead of "pack"
@codefoxx
@codefoxx 3 года назад
@@hartech6162 I have not coded with Python in months but when I did, I rarely used place. I either used grid or pack. I read that it was bad practice to use place once but not exactly sure why. Besides, nearly everything that you would want to do can be accomplished with grid and/or pack. So to answer your question, you would have to try to find out
@hartech6162
@hartech6162 3 года назад
@@codefoxx Oh ThankYou So much broh for ur help it helped me a lot in my project
@hartech6162
@hartech6162 3 года назад
Bro can i put scroll bar for labels
Далее
Using tkinter with classes
28:23
Просмотров 64 тыс.
Understanding parenting and frames in tkinter
11:42
Просмотров 14 тыс.
How to Pass Data between Multiple Windows in Tkinter
18:19
Modern Graphical User Interfaces in Python
11:12
Просмотров 1,5 млн
Object Oriented Tkinter
14:06
Просмотров 8 тыс.
Managing Multiple Windows Size and Position in OpenCV
41:38
The grid layout method in tkinter
22:44
Просмотров 30 тыс.