Monday, February 11, 2019

tkinter example - 15 (PanedWindow widget)

The PanedWindow widget is a geometry manager widget, which can contain one or more child widgets (“panes”). The child widgets can be resized by the user, by moving separator lines (“sashes”) using the mouse. They can be used to implement common 2-pane and 3-pane layouts.

Let's create a 2- pane PanedWindow:

from tkinter import *
from tkinter.filedialog import *

root = Tk()
root.title('Paned Window')

m = PanedWindow(orient=VERTICAL)
m.pack(fill=BOTH, expand=1)

top = Label(m, text="Top pane")
m.add(top)

bottom = Label(m, text="Bottom pane")
m.add(bottom)

mainloop()

The out put of the program is shown below:



A 3- pane window can be created in the following way:

from tkinter import *
from tkinter.filedialog import *

root = Tk()
root.title('3 -Pane Window')

m1 = PanedWindow()
m1.pack(fill=BOTH, expand=1)

left = Label(m1, text="Left pane")
m1.add(left)

m2 = PanedWindow(m1, orient=VERTICAL)
m1.add(m2)

top = Label(m2, text="Top pane")
m2.add(top)

bottom = Label(m2, text="Bottom pane")
m2.add(bottom)

mainloop()

The out put of the program is shown below:




PanedWindow objects have these methods and options −

Methods

1. add(child, options) - Adds a child window to the paned window.

2. get(startindex [,endindex]) - This method returns a specific character or a range of text.

3. config(options) - Modifies one or more widget options. If no options are given, the method returns a dictionary containing all current option values.

Options

1 . bg - The color of the slider and arrowheads when the mouse is not over them.

2. bd - The width of the 3-d borders around the entire perimeter of the trough, and also the width of the 3-d effects on the arrowheads and slider. Default is no border around the trough, and a 2-pixel border around the arrowheads and slider.

3. borderwidth - Default is 2.

4. cursor - The cursor that appears when the mouse is over the window.

5. handlepad - Default is 8.

6. handlesize - Default is 8.

9. height - No default value.

10. orient - Default is HORIZONTAL.

11. relief - Default is FLAT.

12. sashcursor - No default value.

13. sashrelief - Default is RAISED.

14. sashwidth - Default is 2.

15. showhandle - No default value

16. width - No default value.

Try to make programs using these methods and options to understand their utility. I'll end this post now and till we meet next, keep learning and practicing Python as Python is easy to learn!
Share:

0 comments:

Post a Comment