(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.)
This commit is contained in:
Fred Drake 1996-07-23 17:47:21 +00:00
parent 99aa2a4132
commit 4dd0bf92e6
1 changed files with 21 additions and 21 deletions

View File

@ -12,37 +12,38 @@
# XXX This should be written in a more Python-like style!!! # XXX This should be written in a more Python-like style!!!
from Tkinter import * from Tkinter import *
import sys
# 1. Create basic application structure: menu bar on top of # 1. Create basic application structure: menu bar on top of
# text widget, scrollbar on right. # text widget, scrollbar on right.
root = Tk() root = Tk()
tk = root.tk tk = root.tk
mBar = Frame(root, {'relief': 'raised', 'bd': 2, mBar = Frame(root, relief=RAISED, borderwidth=2)
Pack: {'side': 'top', 'fill': 'x'}}) mBar.pack(fill=X)
f = Frame(root)
f.pack({'expand': 1, 'fill': 'both'}) f = Frame(root)
s = Scrollbar(f, {'relief': 'flat', f.pack(expand=1, fill=BOTH)
Pack: {'side': 'right', 'fill': 'y'}}) s = Scrollbar(f, relief=FLAT)
t = Text(f, {'relief': 'raised', 'bd': 2, 'yscrollcommand': (s, 'set'), s.pack(side=RIGHT, fill=Y)
'setgrid': 1, t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1)
Pack: {'side': 'left', 'fill': 'both', 'expand': 1}}) t.pack(side=LEFT, fill=BOTH, expand=1)
t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*')
s['command'] = t.yview
t.tag_config('bold', {'font': '-Adobe-Courier-Bold-R-Normal-*-120-*'})
s['command'] = (t, 'yview')
root.title('Tk Remote Controller') root.title('Tk Remote Controller')
root.iconname('Tk Remote') root.iconname('Tk Remote')
# 2. Create menu button and menus. # 2. Create menu button and menus.
file = Menubutton(mBar, {'text': 'File', 'underline': 0, file = Menubutton(mBar, text='File', underline=0)
Pack: {'side': 'left'}}) file.pack(side=LEFT)
file_m = Menu(file) file_m = Menu(file)
file['menu'] = file_m file['menu'] = file_m
file_m_apps = Menu(file_m) file_m_apps = Menu(file_m, tearoff=0)
file_m.add('cascade', {'label': 'Select Application', 'underline': 0, file_m.add_cascade(label='Select Application', underline=0,
'menu': file_m_apps}) menu=file_m_apps)
file_m.add('command', {'label': 'Quit', 'underline': 0, 'command': 'exit'}) file_m.add_command(label='Quit', underline=0, command=sys.exit)
# 3. Create bindings for text widget to allow commands to be # 3. Create bindings for text widget to allow commands to be
# entered and information to be selected. New characters # entered and information to be selected. New characters
@ -142,10 +143,9 @@ def fillAppsMenu():
# Inoperative window -- ignore it # Inoperative window -- ignore it
pass pass
else: else:
file_m_apps.add('command', {'label': name, file_m_apps.add_command(
'command': label=name,
lambda name=name: command=lambda name=name: newApp(name))
newApp(name)})
file_m_apps['postcommand'] = fillAppsMenu file_m_apps['postcommand'] = fillAppsMenu
mBar.tk_menuBar(file) mBar.tk_menuBar(file)