[Python-checkins] r63206 - in sandbox/trunk/ttk-gsoc: Doc/library/ttk.rst samples/listbox_scrollcmd.py

guilherme.polo python-checkins at python.org
Tue May 13 16:55:14 CEST 2008


Author: guilherme.polo
Date: Tue May 13 16:55:13 2008
New Revision: 63206

Log:
Docummented last two options missing in the Ttk documentation;
Added a sample demonstrating xscrollcommand.


Added:
   sandbox/trunk/ttk-gsoc/samples/listbox_scrollcmd.py
Modified:
   sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst

Modified: sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst
==============================================================================
--- sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst	(original)
+++ sandbox/trunk/ttk-gsoc/Doc/library/ttk.rst	Tue May 13 16:55:13 2008
@@ -129,13 +129,22 @@
 The following options are supported by widgets that are controlled by a
 scrollbar.
 
-   +----------------+-------------+
-   | option         | description |
-   +================+=============+
-   | xscrollcommand | XXX         |
-   +----------------+-------------+
-   | yscrollcommand | XXX         |
-   +----------------+-------------+
+   +----------------+---------------------------------------------------------+
+   | option         | description                                             |
+   +================+=========================================================+
+   | xscrollcommand | Used to comunicate with horizontal scrollbars.          |
+   |                |                                                         |
+   |                | When the view in the widget's window change, the widget |
+   |                | will generate a Tcl command based on the scrollcommand. |
+   |                |                                                         |
+   |                | Usually this option consists of the method              |
+   |                | :meth:`Scrollbar.set` of some scrollbar. This will cause|
+   |                | the scrollbar to be updated whenever the view in the    |
+   |                | window changes.                                         |
+   +----------------+---------------------------------------------------------+
+   | yscrollcommand | Used to comunicate with vertical scrollbars.            |
+   |                | For some more information, see above.                   |
+   +----------------+---------------------------------------------------------+
 
 
 Label Options

Added: sandbox/trunk/ttk-gsoc/samples/listbox_scrollcmd.py
==============================================================================
--- (empty file)
+++ sandbox/trunk/ttk-gsoc/samples/listbox_scrollcmd.py	Tue May 13 16:55:13 2008
@@ -0,0 +1,38 @@
+"""Sample taken from: http://www.tkdocs.com/tutorial/morewidgets.html and
+converted to Python, mainly to demonstrate xscrollcommand option.
+
+grid [tk::listbox .l -yscrollcommand ".s set" -height 5] -column 0 -row 0 -sticky nwes
+grid [ttk::scrollbar .s -command ".l yview" -orient vertical] -column 1 -row 0 -sticky ns
+grid [ttk::label .stat -text "Status message here" -anchor w] -column 0 -row 1 -sticky we
+grid [ttk::sizegrip .sz] -column 1 -row 1 -sticky se
+grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1
+for {set i 0} {$i<100} {incr i} {
+   .l insert end "Line $i of 100"
+   }
+"""
+
+import Tkinter
+import Ttk
+
+root = Tkinter.Tk()
+
+l = Tkinter.Listbox(height=5)
+l.grid(column=0, row=0, sticky='nwes')
+
+s = Ttk.Scrollbar(command=l.yview, orient='vertical')
+l['yscrollcommand'] = s.set
+s.grid(column=1, row=0, sticky="ns")
+
+stat = Ttk.Label(text="Status message here", anchor='w')
+stat.grid(column=0, row=1, sticky='we')
+
+sz = Ttk.Sizegrip()
+sz.grid(column=1, row=1, sticky='se')
+
+root.grid_columnconfigure(0, weight=1)
+root.grid_rowconfigure(0, weight=1)
+
+for i in range(100):
+    l.insert('end', "Line %d of 100" % i)
+
+root.mainloop()


More information about the Python-checkins mailing list