Tkinter - Switch Frames

preview_player
Показать описание
I'll show you how to switch frames in a Tkinter application.
The example will be a Settings window that shows content based on what the user selects in a treeview widget.

Switching frames is a useful technique that you can use in your Tkinter applications.

0:00 Intro
0:37 Demo application
1:15 Start code
1:48 Treeview class
3:42 Settings view class
4:25 Illustration of plan
5:39 Pages dictionary
6:20 Page class
10:35 Grid row/column configure
11:53 Create treeview frame
13:05 Treeview select binding
16:06 Create page frame
17:11 Show page method
19:51 Add page method
24:29 Add pages to dictionary
25:54 Debug code
27:08 First demo
27:22 Apply Ttk styles
28:35 Final demo
29:01 Why use Page class
30:28 Closure

#tkinter #pythongui #python3 #pythonguitutorial
Рекомендации по теме
Комментарии
Автор

Please continue making more videos. Tkinter is such a vague but incredibly powerful library. There need to be way more videos to help people learn it.
You explain things well and the video is clearly outlined.
Your channel is very underrated, keep it up and I bet more views will come.

lintycarcass
Автор

This is the 4th or 5th of your videos that I've watched about Treeview and they all have been SOOOO GOOD. The others were about a page of code, and I could easily understand the whole piece. This one tho... I think I understand each function, but I'm having a hard time understanding how the program works as a whole. I'm and *old* C coder (not C++) and the nuance of OO more than a little boggles my tiny mind. I'll study it more and figure it out more. Please keep up the great work!

larrymarek
Автор

YESSS... I have been waiting for this thanks bro

govinej
Автор

or if you created three different versions and working on a fourth of a program and want to combine them into one for an effective testing environment, i just thought that up, anyway, great video, i think i am going to use it to learn how to use classes more effectively in my code

sovereignlivingsoul
Автор

Bro. This video was SUPER helpful. Please don't stop making videos!

ghostslay
Автор

I was looking all over the web for something simular. I want to create an object oriebted menu page where the right frame should differ dependable on the setting.

I am sure youve covered my concern. Havent tried it yet but will watch your video again.

Good explanation with your drawings. Its a confusing subject.

However I wouldve understood it more from a onchange run explanantion. I am a visual learner.

However, I can still do this when i recreate the scenario and run the app as the changes are made.

Anyway, hopefully im a step closer to what i want to achieve.

Thanks man. Good video!

charlvantonder
Автор

I think the correct alignment would be 'wns' instead of 'ens'

For those who want to start with a visible page, they can start the program by selecting the first item in the treeview:
first_idd =


mrkalvinbs
Автор

Nice Work. Really Appreciate for sharing it with us all

Vandemataram-
Автор

wow... totally amazing !! amazing how you listening to your followers .. amazing how you explain so difficult issues so simply to understand.
and how can i switch frame1 from file1.py to frame2 in file2. py white both frame shown as one unit and not separatable? thanks you a lot..

bentsionben-david
Автор

hi please help me, im trying to copy your code one by one, and i found a problem in show_page method, the problem is, i cant do .pack on self.pages[setting_name]. how to fix it?? please help me

hansedbertelian
Автор

Would it be nice to show the pages in a separate tab? Are you able to give an example adding top menu and left the treeview and right are pages with different tab. Thanks for the sample.

tiejunzhu
Автор

to make it perfect, i think the majority of us ask:

1. how to imp[lement a menu/buttons in top of treeviewframe, while each button selected calss/binds differnt treeviewframe?
2. how do i implement a scrolleedframe class i have developed, into the audio page?

please, please help us, becuse unfortunately I'm stucked with it for 2 months already,

bentsionben-david
Автор

if I want use messagebox switch frame, how to do that? for example:if event happen, and then go to nextpage

kimwong
Автор

Would it be possible to pass parameter to the classes of the settings pages? I tried like this, but there was an error:


settings.add_page(image_path='language.png', setting_name='Language',

mrkalvinbs
Автор

in create_frame_treeview
self.treeview_settings.bind("<<TreeviewSelect>>",
AttributeError: 'SettingView' object has no attribute

Hi, how can I solve this error?

jzmn_c
Автор

Would it be possible to add Menubar on the top of the treeview frame?

virisha
Автор

Thank you for sharing the video. I was testing it and it seems to me that the title label in the AudioPage and LanguagePage is always in the center of the frame. i cannot use pack(side=tk.TOP) to put it to the top. It seems that pack() for the label here is not the same as what you have shown in Pack and Grid video. What have I done wrong? How to make title label at the top of the frame?

kcau
Автор

Fantastic, excellent tutorial!

Would it be possible for LanguagePage to interact with SettingsView ? example: If in the main frame (SettingsView) there was a status bar. And in LanguagePage there was a button. How to send text from lbl_title in LanguagePage to a label in SettingsView status bar? How to do this, interact between separate file classes?

because I can't import SettingsView in the LanguagePage class file. Something like:

from settings_view import SettingsView

mrkalvinbs
Автор

settings.pack(fill=tk.BOTH, expand=True)

say

cannot use geometry manager pack inside . which already has slaves managed by grid

CatariCesar
Автор

I waited long time for this kind of video.. can we download this code from your github ?

bentsionben-david