~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Demo/tkinter/ttk/listbox_scrollcmd.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Sample taken from: http://www.tkdocs.com/tutorial/morewidgets.html and
 
2
converted to Python, mainly to demonstrate xscrollcommand option.
 
3
 
 
4
grid [tk::listbox .l -yscrollcommand ".s set" -height 5] -column 0 -row 0 -sticky nwes
 
5
grid [ttk::scrollbar .s -command ".l yview" -orient vertical] -column 1 -row 0 -sticky ns
 
6
grid [ttk::label .stat -text "Status message here" -anchor w] -column 0 -row 1 -sticky we
 
7
grid [ttk::sizegrip .sz] -column 1 -row 1 -sticky se
 
8
grid columnconfigure . 0 -weight 1; grid rowconfigure . 0 -weight 1
 
9
for {set i 0} {$i<100} {incr i} {
 
10
   .l insert end "Line $i of 100"
 
11
   }
 
12
"""
 
13
import tkinter
 
14
from tkinter import ttk
 
15
 
 
16
root = tkinter.Tk()
 
17
 
 
18
l = tkinter.Listbox(height=5)
 
19
l.grid(column=0, row=0, sticky='nwes')
 
20
 
 
21
s = ttk.Scrollbar(command=l.yview, orient='vertical')
 
22
l['yscrollcommand'] = s.set
 
23
s.grid(column=1, row=0, sticky="ns")
 
24
 
 
25
stat = ttk.Label(text="Status message here", anchor='w')
 
26
stat.grid(column=0, row=1, sticky='we')
 
27
 
 
28
sz = ttk.Sizegrip()
 
29
sz.grid(column=1, row=1, sticky='se')
 
30
 
 
31
root.grid_columnconfigure(0, weight=1)
 
32
root.grid_rowconfigure(0, weight=1)
 
33
 
 
34
for i in range(100):
 
35
    l.insert('end', "Line %d of 100" % i)
 
36
 
 
37
root.mainloop()