Introduction
In this blog, I am going to create separate widgets in a Python GUI application. It will display the separate working frames on the application screen.
Software requirement
Python 3.5 and IDLE (Python 3.5)
Programming code
-
- from tkinter import *
- from tkinter import ttk
- root=Tk()
-
- root.title("Python GUI Application ")
- ttk.Label(root, text="Separating widget").pack()
-
- panedwindow=ttk.Panedwindow(root, orient=HORIZONTAL)
- panedwindow.pack(fill=BOTH, expand=True)
-
- fram1=ttk.Frame(panedwindow,width=100,height=300, relief=SUNKEN)
- fram2=ttk.Frame(panedwindow,width=400,height=400, relief=SUNKEN)
- panedwindow.add(fram1, weight=1)
- panedwindow.add(fram2, weight=4)
-
- root.mainloop()
About the code
First, I am importing the tkinter modules.
Next, I have assigned a class and variables and given the application title.
Next, I have created a paned window and added two frames in the code.
Finally, I have started the Windows event loop by calling the mainloop method, then executed the code.
Now, let’s execute the code.
Output