Switch Pages in Tkinter | Switch Frames in Tkinter | Switch Multiple Pages in Tkinter

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends in this video we will create a tkinter program which will be able to switch multi-pages notice here we will not use other module we will use only tkinter and also we will not use images to display these Pages switching indicates this program is able to switch multiple frames with Morton GUI and also we will use Easy and advanced technique to switch multiple frame let's code to create here is basic code of tkinter here we are creating a frame for Pages options like home menu contact about now we will resize this Frame basically we will make this Frame light container using pack underscore propagate method we can resize frame if you pass false argument to pack underscore propagate method frame will be allowed to you can set frame height and width let's set frame height and width and we need to change frame background color for see how it resized see their frame is resized but its appear in the center we need to set it in left side let's set we have resized this Frame because we will place Pages options buttons in this Frame but before we will create main frame and inside of this main frame we will switch all frames which we want to switch as a pages and also we will resize main frame as we have resized earlier and also we need main frame with a round border as a look like visible we will use two properties of fraying highlight background argument will define color of a round border highlight thickness argument will Define size of thickness around border now you can see around border appear and you can change border color or thickness now we will create Pages options buttons for Pages options we will simply create buttons see their button appear and also we will set button background color as his frame color same as we will create other buttons all buttons we have created now we will create indicators for switched page for create indicators we will use a technique with every button we will place a label when any page switched then we will change color of placed label let's see encode how we will do this here we are creating a indicator label for home page button every indicator text will be empty and we will place this label and we need to put this indicator with home button we will place this label with same y position here is most important thing here we will set width and height of this label then it will display little vertical shape if you don't understand how we do this you can see this again you can see this without text this label appear with this shape this is Possible only with Place method we have resize a empty label same as we will create for other buttons we have created indicators for all buttons now we will again use a technique when any button clicked for switch page we will show only clicked button indicator and other indicators will be hidden but before we need to hide all indicators for hide these indicators we will change all indicators background color in his frame background color see there are indicator hidden now we will hide all indicators now all indicators hidden now we will create a function which will show selected button indicator this function will take indicator label object argument using this label object argument we will show selected button indicator here we are just change selected button indicator color for show Let's test this function with home page button in the home page button we will pass home page indicator when home page button click then home page button indicator will show now let's test it let's if I click home page button you can see the indicator now showing let's add this function to other buttons for every button we will add his o and indicator label but there is a problem when any button-clicked indicator is showing but we want to show only current selected button indicator and other indicators should be hidden let's solve this problem here we are creating a function which will hide all indicators this function will change all indicators color into his frame background color before showing any indicator we will hide all indicators and then current selected button indicator will be shown now it's working cool now we will switch frames inside of Mainframe for every page we will create separate function and in the function should have actual page page means a frame and the frame can be contained widgets and what you want to display and the frame should pack in the main frame and in the home page we are just displaying only a label but you can display images and widgets now we will switch this home page in the indicate function we will take page argument page argument will be a function argument this argument will be a function of every page like this home page function using this page argument we will call Page function when given function will be executed then the page frame will be packed inside of Mainframe in the home page button we will add home page function now let's test it now you can see when I clicked home page button then home page function executed in home page packed in Mainframe let's create other pages every page should in a function when they execute they will be packed we have four pages home page menu page contact page about page just like a website View four pages created now we will add these Pages function in option Pages buttons now let's test it there is a problem two pages packed in Mainframe and we need every single page the solution is when we switch new page then we need to destroy current packed frame before packing new frame here we are creating a function which will be clean Mainframe means it will be destroyed packed frame from Mainframe frames winfo underscore children's method it will return all child widgets objects from Mainframe which means it will return all packed frames objects from Mainframe for Loop through we will access packed frame from Mainframe and then we will destroy packed frame here in the indicate function we will clean main frame before packing new frame now let's test it let's if I switch home page now let's switch menu page now you can see problem solved we have created multi-pages switchable tkinter program thanks for watching this video subscribe our channel for more videos see you in the next video
Info
Channel: Tkinter Hub
Views: 78,901
Rating: undefined out of 5
Keywords: switch frames in tkinter, switch pages in tkinter, switch tkinter frames, switch multiple pages in tkinter, switch multiple frames in tkinter, tkinter multiple pages, tkinter switch multiple frames, tkinter modern gui, switch pages in tkinter morden gui, tkinter tricks, tkinter modern window, tkinter frame, python tkinter, TkinterHub, tkinter
Id: 95tJO7XJlko
Channel Id: undefined
Length: 20min 0sec (1200 seconds)
Published: Sun Nov 13 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.