|
12 | 12 | # XXX This should be written in a more Python-like style!!! |
13 | 13 |
|
14 | 14 | from Tkinter import * |
| 15 | +import sys |
15 | 16 |
|
16 | 17 | # 1. Create basic application structure: menu bar on top of |
17 | 18 | # text widget, scrollbar on right. |
18 | 19 |
|
19 | 20 | root = Tk() |
20 | 21 | tk = root.tk |
21 | | -mBar = Frame(root, {'relief': 'raised', 'bd': 2, |
22 | | - Pack: {'side': 'top', 'fill': 'x'}}) |
| 22 | +mBar = Frame(root, relief=RAISED, borderwidth=2) |
| 23 | +mBar.pack(fill=X) |
| 24 | + |
23 | 25 | f = Frame(root) |
24 | | -f.pack({'expand': 1, 'fill': 'both'}) |
25 | | -s = Scrollbar(f, {'relief': 'flat', |
26 | | - Pack: {'side': 'right', 'fill': 'y'}}) |
27 | | -t = Text(f, {'relief': 'raised', 'bd': 2, 'yscrollcommand': (s, 'set'), |
28 | | - 'setgrid': 1, |
29 | | - Pack: {'side': 'left', 'fill': 'both', 'expand': 1}}) |
30 | | - |
31 | | -t.tag_config('bold', {'font': '-Adobe-Courier-Bold-R-Normal-*-120-*'}) |
32 | | -s['command'] = (t, 'yview') |
| 26 | +f.pack(expand=1, fill=BOTH) |
| 27 | +s = Scrollbar(f, relief=FLAT) |
| 28 | +s.pack(side=RIGHT, fill=Y) |
| 29 | +t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1) |
| 30 | +t.pack(side=LEFT, fill=BOTH, expand=1) |
| 31 | +t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*') |
| 32 | +s['command'] = t.yview |
| 33 | + |
33 | 34 | root.title('Tk Remote Controller') |
34 | 35 | root.iconname('Tk Remote') |
35 | 36 |
|
36 | 37 | # 2. Create menu button and menus. |
37 | 38 |
|
38 | | -file = Menubutton(mBar, {'text': 'File', 'underline': 0, |
39 | | - Pack: {'side': 'left'}}) |
| 39 | +file = Menubutton(mBar, text='File', underline=0) |
| 40 | +file.pack(side=LEFT) |
40 | 41 | file_m = Menu(file) |
41 | 42 | file['menu'] = file_m |
42 | | -file_m_apps = Menu(file_m) |
43 | | -file_m.add('cascade', {'label': 'Select Application', 'underline': 0, |
44 | | - 'menu': file_m_apps}) |
45 | | -file_m.add('command', {'label': 'Quit', 'underline': 0, 'command': 'exit'}) |
| 43 | +file_m_apps = Menu(file_m, tearoff=0) |
| 44 | +file_m.add_cascade(label='Select Application', underline=0, |
| 45 | + menu=file_m_apps) |
| 46 | +file_m.add_command(label='Quit', underline=0, command=sys.exit) |
46 | 47 |
|
47 | 48 | # 3. Create bindings for text widget to allow commands to be |
48 | 49 | # entered and information to be selected. New characters |
@@ -142,10 +143,9 @@ def fillAppsMenu(): |
142 | 143 | # Inoperative window -- ignore it |
143 | 144 | pass |
144 | 145 | else: |
145 | | - file_m_apps.add('command', {'label': name, |
146 | | - 'command': |
147 | | - lambda name=name: |
148 | | - newApp(name)}) |
| 146 | + file_m_apps.add_command( |
| 147 | + label=name, |
| 148 | + command=lambda name=name: newApp(name)) |
149 | 149 |
|
150 | 150 | file_m_apps['postcommand'] = fillAppsMenu |
151 | 151 | mBar.tk_menuBar(file) |
|
0 commit comments