Swapping between Frames with Tkinter tkraise()
HTML-код
- Опубликовано: 3 окт 2024
- In this Tkinter Video Tutorial, we will explore how to "swap" between different Windows (or Frames) using the tkraise() method.
Instead of creating a new window every time you want to display something new, you can just "swap" the Frame instead with another. Once you are done, you can "swap" the original frame back in with tkraise!
I am very sure that even if you comment out tkraise(), the code will still work and achieve the same object. What exactly is the purpose of tkraise()?
so tkraise() is used to put the frames on top of each other and not to put them below each other
Can it be further enhanced with dictionaries aside instead of using indexes?
What is the value of the master?
Hi, thanks alot for this tutorial. It really helped me get through a solution I was trying to implement. So I'm done fixing up my code and I have a new problem at hand. The first window I created has entry widgets to which I assigned self.stringvar() variables. The second window contains radio buttons which were linked to a booleanvar. Now after subclassing the first and second windows as shown in your tutorial, how do I get the values from widgets in the first and second window in the main window. The form I designed has a submit button in the bottom frame. However when I click on that button; an error is thrown telling me the mainframe has no named entry and radiobutton attributes. Can you help me with this? Thanks
Successfully resolving this is key to the problem I'm working on.
The switch button works perfectly well as it enables me change views. However, I can't access the value of variables in each widget in the first and second windows.
Can't really tell what the problem is without seeing any code, but I actually made a whole video on a similar concept, because I know people have alot of trouble passing values back and forth between different windows/frames.
Here is a link: ruclips.net/video/wHeoWM4xv0U/видео.html
@@coderslegacy5661 I have seen this video tutorial and also read up on it from your blog which I bookmarked. But I'm still trying to figure out if it'll work in this case. I think the tk.raise() method used to switch frames doesn't support passing variables from child frames to parent. Or what do you think?
The situation did not address between 5 to 10 windows. In what way would we handle 5 windows?
A situation like that would be rather unusual, but the same concept can be applied to 5 frames as well. If you know how to swap two frames, then you can swap any number of frames.
@@coderslegacy5661 this time around instead of dealing with indexes you are dealing with the named of the classes.
hey thank you for ur lesson, can i ask? what if we have 3 frames? is it the same?
Same core logic, yes.
@@coderslegacy5661 thanks for your reply but the first frame on the framelist (0) wont show up, what happend??
@@hansedbertelian9520 Can't really tell without any code.
👍