Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Geometry Method in Python Tkinter
Next article icon
Tkinter supports a variety of widgets to make GUI more and more attractive and functional. ThePanedWindow widget is a geometry manager widget, which can contain one or more child widgetspanes. The child widgets can be resized by the user, by moving separator linessashes using the mouse.
Syntax: PanedWindow(master, **options)Parameters:master: parent widget or main Tk() objectoptions: which are passed in config method or directly in the constructor
PanedWindow can be used to implement common 2-panes or 3-panes but multiple panes can be used.Code #1:PanedWindow with only two panesPython3 1==
# Importing everything from tkinter modulefromtkinterimport*fromtkinterimportttk# main tkinter windowroot=Tk()# panedwindow objectpw=PanedWindow(orient='vertical')# Button widgettop=ttk.Button(pw,text="Click Me !\nI'm a Button")top.pack(side=TOP)# This will add button widget to the panedwindowpw.add(top)# Checkbutton Widgetbot=Checkbutton(pw,text="Choose Me !")bot.pack(side=TOP)# This will add Checkbutton to panedwindowpw.add(bot)# expand is used so that widgets can expand# fill is used to let widgets adjust itself# according to the size of main windowpw.pack(fill=BOTH,expand=True)# This method is used to show sashpw.configure(sashrelief=RAISED)# Infinite loop can be destroyed by# keyboard or mouse interruptmainloop()
Output: Code #2: PanedWindow with multiple panesPython3 1==
# Importing everything from tkinter modulefromtkinterimport*fromtkinterimportttk# main tkinter windowroot=Tk()# panedwindow objectpw=PanedWindow(orient='vertical')# Button widgettop=ttk.Button(pw,text="Click Me !\nI'm a Button")top.pack(side=TOP)# This will add button widget to the panedwindowpw.add(top)# Checkbutton Widgetbot=Checkbutton(pw,text="Choose Me !")bot.pack(side=TOP)# This will add Checkbutton to panedwindowpw.add(bot)# adding Label widgetlabel=Label(pw,text="I'm a Label")label.pack(side=TOP)pw.add(label)# Tkinter string variablestring=StringVar()# Entry widget with some styling in fontsentry=Entry(pw,textvariable=string,font=('arial',15,'bold'))entry.pack()# Focus force is used to focus on particular# widget that means widget is already selected for operationsentry.focus_force()pw.add(entry)# expand is used so that widgets can expand# fill is used to let widgets adjust itself# according to the size of main windowpw.pack(fill=BOTH,expand=True)# This method is used to show sashpw.configure(sashrelief=RAISED)# Infinite loop can be destroyed by# keyboard or mouse interruptmainloop()
Output:

Improve
Practice Tags :

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp