Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4dd0bf9

Browse files
committed
(rmt.py): Updated to "modern" python coding conventions, somewhat. Keyword
arguments and explicit calls to .pack() are used; no more dictionaries are being passed to Tkinter constructors. Otherwise, the example is unchanged. (The app isn't implemented as a Python object.)
1 parent 99aa2a4 commit 4dd0bf9

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

Demo/tkinter/guido/rmt.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,38 @@
1212
# XXX This should be written in a more Python-like style!!!
1313

1414
from Tkinter import *
15+
import sys
1516

1617
# 1. Create basic application structure: menu bar on top of
1718
# text widget, scrollbar on right.
1819

1920
root = Tk()
2021
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+
2325
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+
3334
root.title('Tk Remote Controller')
3435
root.iconname('Tk Remote')
3536

3637
# 2. Create menu button and menus.
3738

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)
4041
file_m = Menu(file)
4142
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)
4647

4748
# 3. Create bindings for text widget to allow commands to be
4849
# entered and information to be selected. New characters
@@ -142,10 +143,9 @@ def fillAppsMenu():
142143
# Inoperative window -- ignore it
143144
pass
144145
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))
149149

150150
file_m_apps['postcommand'] = fillAppsMenu
151151
mBar.tk_menuBar(file)

0 commit comments

Comments
 (0)