~ubuntu-branches/ubuntu/karmic/python3.0/karmic

« back to all changes in this revision

Viewing changes to Demo/tix/tixwidgets.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-16 17:18:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090216171823-1d5cm5qnnjvmnzzm
Tags: 3.0.1-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
2
2
#
3
 
# $Id: tixwidgets.py 56418 2007-07-17 20:59:35Z collin.winter $
 
3
# $Id: tixwidgets.py 68310 2009-01-04 19:01:19Z benjamin.peterson $
4
4
#
5
5
# tixwidgets.py --
6
6
#
12
12
#               % python tixwidgets.py
13
13
#
14
14
 
15
 
import os, os.path, sys, Tix
16
 
from Tkconstants import *
17
 
import traceback, tkMessageBox
 
15
import os, os.path, sys, tkinter.tix
 
16
from tkinter.constants import *
 
17
import traceback, tkinter.messagebox
18
18
 
19
19
TCL_DONT_WAIT           = 1<<1
20
20
TCL_WINDOW_EVENTS       = 1<<2
30
30
 
31
31
        self.dir = None                         # script directory
32
32
        self.balloon = None                     # balloon widget
33
 
        self.useBalloons = Tix.StringVar()
 
33
        self.useBalloons = tkinter.tix.StringVar()
34
34
        self.useBalloons.set('0')
35
35
        self.statusbar = None                   # status bar widget
36
36
        self.welmsg = None                      # Msg widget
56
56
 
57
57
    def MkMainMenu(self):
58
58
        top = self.root
59
 
        w = Tix.Frame(top, bd=2, relief=RAISED)
60
 
        file = Tix.Menubutton(w, text='File', underline=0, takefocus=0)
61
 
        help = Tix.Menubutton(w, text='Help', underline=0, takefocus=0)
 
59
        w = tkinter.tix.Frame(top, bd=2, relief=RAISED)
 
60
        file = tkinter.tix.Menubutton(w, text='File', underline=0, takefocus=0)
 
61
        help = tkinter.tix.Menubutton(w, text='Help', underline=0, takefocus=0)
62
62
        file.pack(side=LEFT)
63
63
        help.pack(side=RIGHT)
64
 
        fm = Tix.Menu(file, tearoff=0)
 
64
        fm = tkinter.tix.Menu(file, tearoff=0)
65
65
        file['menu'] = fm
66
 
        hm = Tix.Menu(help, tearoff=0)
 
66
        hm = tkinter.tix.Menu(help, tearoff=0)
67
67
        help['menu'] = hm
68
68
 
69
69
        fm.add_command(label='Exit', underline=1,
77
77
 
78
78
    def MkMainNotebook(self):
79
79
        top = self.root
80
 
        w = Tix.NoteBook(top, ipadx=5, ipady=5, options="""
 
80
        w = tkinter.tix.NoteBook(top, ipadx=5, ipady=5, options="""
81
81
        tagPadX 6
82
82
        tagPadY 4
83
83
        borderWidth 2
103
103
        global demo
104
104
        top = self.root
105
105
 
106
 
        w = Tix.Frame(top, relief=Tix.RAISED, bd=1)
107
 
        demo.statusbar = Tix.Label(w, relief=Tix.SUNKEN, bd=1)
 
106
        w = tkinter.tix.Frame(top, relief=tkinter.tix.RAISED, bd=1)
 
107
        demo.statusbar = tkinter.tix.Label(w, relief=tkinter.tix.SUNKEN, bd=1)
108
108
        demo.statusbar.form(padx=3, pady=3, left=0, right='%70')
109
109
        return w
110
110
 
116
116
            z.geometry('790x590+10+10')
117
117
        else:
118
118
            z.geometry('890x640+10+10')
119
 
        demo.balloon = Tix.Balloon(root)
 
119
        demo.balloon = tkinter.tix.Balloon(root)
120
120
        frame1 = self.MkMainMenu()
121
121
        frame2 = self.MkMainNotebook()
122
122
        frame3 = self.MkMainStatus()
152
152
                self.exit = 1
153
153
                return
154
154
            except KeyboardInterrupt:
155
 
                if tkMessageBox.askquestion ('Interrupt', 'Really Quit?') == 'yes':
 
155
                if tkinter.messagebox.askquestion ('Interrupt', 'Really Quit?') == 'yes':
156
156
                    # self.tk.eval('exit')
157
157
                    self.exit = 1
158
158
                    return
163
163
                text = ""
164
164
                for line in traceback.format_exception(t,v,tb):
165
165
                    text += line + '\n'
166
 
                try: tkMessageBox.showerror ('Error', text)
 
166
                try: tkinter.messagebox.showerror ('Error', text)
167
167
                except: pass
168
168
                self.exit = 1
169
169
                raise SystemExit(1)
191
191
def MkWelcomeBar(top):
192
192
    global demo
193
193
 
194
 
    w = Tix.Frame(top, bd=2, relief=Tix.GROOVE)
195
 
    b1 = Tix.ComboBox(w, command=lambda w=top: MainTextFont(w))
196
 
    b2 = Tix.ComboBox(w, command=lambda w=top: MainTextFont(w))
 
194
    w = tkinter.tix.Frame(top, bd=2, relief=tkinter.tix.GROOVE)
 
195
    b1 = tkinter.tix.ComboBox(w, command=lambda w=top: MainTextFont(w))
 
196
    b2 = tkinter.tix.ComboBox(w, command=lambda w=top: MainTextFont(w))
197
197
    b1.entry['width'] = 15
198
198
    b1.slistbox.listbox['height'] = 3
199
199
    b2.entry['width'] = 4
202
202
    demo.welfont = b1
203
203
    demo.welsize = b2
204
204
 
205
 
    b1.insert(Tix.END, 'Courier')
206
 
    b1.insert(Tix.END, 'Helvetica')
207
 
    b1.insert(Tix.END, 'Lucida')
208
 
    b1.insert(Tix.END, 'Times Roman')
 
205
    b1.insert(tkinter.tix.END, 'Courier')
 
206
    b1.insert(tkinter.tix.END, 'Helvetica')
 
207
    b1.insert(tkinter.tix.END, 'Lucida')
 
208
    b1.insert(tkinter.tix.END, 'Times Roman')
209
209
 
210
 
    b2.insert(Tix.END, '8')
211
 
    b2.insert(Tix.END, '10')
212
 
    b2.insert(Tix.END, '12')
213
 
    b2.insert(Tix.END, '14')
214
 
    b2.insert(Tix.END, '18')
 
210
    b2.insert(tkinter.tix.END, '8')
 
211
    b2.insert(tkinter.tix.END, '10')
 
212
    b2.insert(tkinter.tix.END, '12')
 
213
    b2.insert(tkinter.tix.END, '14')
 
214
    b2.insert(tkinter.tix.END, '18')
215
215
 
216
216
    b1.pick(1)
217
217
    b2.pick(3)
218
218
 
219
 
    b1.pack(side=Tix.LEFT, padx=4, pady=4)
220
 
    b2.pack(side=Tix.LEFT, padx=4, pady=4)
 
219
    b1.pack(side=tkinter.tix.LEFT, padx=4, pady=4)
 
220
    b2.pack(side=tkinter.tix.LEFT, padx=4, pady=4)
221
221
 
222
222
    demo.balloon.bind_widget(b1, msg='Choose\na font',
223
223
                             statusmsg='Choose a font for this page')
228
228
def MkWelcomeText(top):
229
229
    global demo
230
230
 
231
 
    w = Tix.ScrolledWindow(top, scrollbar='auto')
 
231
    w = tkinter.tix.ScrolledWindow(top, scrollbar='auto')
232
232
    win = w.window
233
233
    text = 'Welcome to TIX in Python'
234
 
    title = Tix.Label(win,
235
 
                      bd=0, width=30, anchor=Tix.N, text=text)
236
 
    msg = Tix.Message(win,
237
 
                      bd=0, width=400, anchor=Tix.N,
 
234
    title = tkinter.tix.Label(win,
 
235
                      bd=0, width=30, anchor=tkinter.tix.N, text=text)
 
236
    msg = tkinter.tix.Message(win,
 
237
                      bd=0, width=400, anchor=tkinter.tix.N,
238
238
                      text='Tix is a set of mega-widgets based on TK. This program \
239
239
demonstrates the widgets in the Tix widget set. You can choose the pages \
240
240
in this window to look at the corresponding widgets. \n\n\
241
241
To quit this program, choose the "File | Exit" command.\n\n\
242
242
For more information, see http://tix.sourceforge.net.')
243
 
    title.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10)
244
 
    msg.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10)
 
243
    title.pack(expand=1, fill=tkinter.tix.BOTH, padx=10, pady=10)
 
244
    msg.pack(expand=1, fill=tkinter.tix.BOTH, padx=10, pady=10)
245
245
    demo.welmsg = msg
246
246
    return w
247
247
 
267
267
    w = nb.page(name)
268
268
    options = "label.padX 4"
269
269
 
270
 
    til = Tix.LabelFrame(w, label='Chooser Widgets', options=options)
271
 
    cbx = Tix.LabelFrame(w, label='tixComboBox', options=options)
272
 
    ctl = Tix.LabelFrame(w, label='tixControl', options=options)
273
 
    sel = Tix.LabelFrame(w, label='tixSelect', options=options)
274
 
    opt = Tix.LabelFrame(w, label='tixOptionMenu', options=options)
275
 
    fil = Tix.LabelFrame(w, label='tixFileEntry', options=options)
276
 
    fbx = Tix.LabelFrame(w, label='tixFileSelectBox', options=options)
277
 
    tbr = Tix.LabelFrame(w, label='Tool Bar', options=options)
 
270
    til = tkinter.tix.LabelFrame(w, label='Chooser Widgets', options=options)
 
271
    cbx = tkinter.tix.LabelFrame(w, label='tixComboBox', options=options)
 
272
    ctl = tkinter.tix.LabelFrame(w, label='tixControl', options=options)
 
273
    sel = tkinter.tix.LabelFrame(w, label='tixSelect', options=options)
 
274
    opt = tkinter.tix.LabelFrame(w, label='tixOptionMenu', options=options)
 
275
    fil = tkinter.tix.LabelFrame(w, label='tixFileEntry', options=options)
 
276
    fbx = tkinter.tix.LabelFrame(w, label='tixFileSelectBox', options=options)
 
277
    tbr = tkinter.tix.LabelFrame(w, label='Tool Bar', options=options)
278
278
 
279
279
    MkTitle(til.frame)
280
280
    MkCombo(cbx.frame)
301
301
    fbx.form(right=-1, top=0, left='%66')
302
302
 
303
303
def MkCombo(w):
304
 
    options="label.width %d label.anchor %s entry.width %d" % (10, Tix.E, 14)
305
 
 
306
 
    static = Tix.ComboBox(w, label='Static', editable=0, options=options)
307
 
    editable = Tix.ComboBox(w, label='Editable', editable=1, options=options)
308
 
    history = Tix.ComboBox(w, label='History', editable=1, history=1,
309
 
                           anchor=Tix.E, options=options)
310
 
    static.insert(Tix.END, 'January')
311
 
    static.insert(Tix.END, 'February')
312
 
    static.insert(Tix.END, 'March')
313
 
    static.insert(Tix.END, 'April')
314
 
    static.insert(Tix.END, 'May')
315
 
    static.insert(Tix.END, 'June')
316
 
    static.insert(Tix.END, 'July')
317
 
    static.insert(Tix.END, 'August')
318
 
    static.insert(Tix.END, 'September')
319
 
    static.insert(Tix.END, 'October')
320
 
    static.insert(Tix.END, 'November')
321
 
    static.insert(Tix.END, 'December')
322
 
 
323
 
    editable.insert(Tix.END, 'Angola')
324
 
    editable.insert(Tix.END, 'Bangladesh')
325
 
    editable.insert(Tix.END, 'China')
326
 
    editable.insert(Tix.END, 'Denmark')
327
 
    editable.insert(Tix.END, 'Ecuador')
328
 
 
329
 
    history.insert(Tix.END, '/usr/bin/ksh')
330
 
    history.insert(Tix.END, '/usr/local/lib/python')
331
 
    history.insert(Tix.END, '/var/adm')
332
 
 
333
 
    static.pack(side=Tix.TOP, padx=5, pady=3)
334
 
    editable.pack(side=Tix.TOP, padx=5, pady=3)
335
 
    history.pack(side=Tix.TOP, padx=5, pady=3)
 
304
    options="label.width %d label.anchor %s entry.width %d" % (10, tkinter.tix.E, 14)
 
305
 
 
306
    static = tkinter.tix.ComboBox(w, label='Static', editable=0, options=options)
 
307
    editable = tkinter.tix.ComboBox(w, label='Editable', editable=1, options=options)
 
308
    history = tkinter.tix.ComboBox(w, label='History', editable=1, history=1,
 
309
                           anchor=tkinter.tix.E, options=options)
 
310
    static.insert(tkinter.tix.END, 'January')
 
311
    static.insert(tkinter.tix.END, 'February')
 
312
    static.insert(tkinter.tix.END, 'March')
 
313
    static.insert(tkinter.tix.END, 'April')
 
314
    static.insert(tkinter.tix.END, 'May')
 
315
    static.insert(tkinter.tix.END, 'June')
 
316
    static.insert(tkinter.tix.END, 'July')
 
317
    static.insert(tkinter.tix.END, 'August')
 
318
    static.insert(tkinter.tix.END, 'September')
 
319
    static.insert(tkinter.tix.END, 'October')
 
320
    static.insert(tkinter.tix.END, 'November')
 
321
    static.insert(tkinter.tix.END, 'December')
 
322
 
 
323
    editable.insert(tkinter.tix.END, 'Angola')
 
324
    editable.insert(tkinter.tix.END, 'Bangladesh')
 
325
    editable.insert(tkinter.tix.END, 'China')
 
326
    editable.insert(tkinter.tix.END, 'Denmark')
 
327
    editable.insert(tkinter.tix.END, 'Ecuador')
 
328
 
 
329
    history.insert(tkinter.tix.END, '/usr/bin/ksh')
 
330
    history.insert(tkinter.tix.END, '/usr/local/lib/python')
 
331
    history.insert(tkinter.tix.END, '/var/adm')
 
332
 
 
333
    static.pack(side=tkinter.tix.TOP, padx=5, pady=3)
 
334
    editable.pack(side=tkinter.tix.TOP, padx=5, pady=3)
 
335
    history.pack(side=tkinter.tix.TOP, padx=5, pady=3)
336
336
 
337
337
states = ['Bengal', 'Delhi', 'Karnataka', 'Tamil Nadu']
338
338
 
359
359
def MkControl(w):
360
360
    global demo_spintxt
361
361
 
362
 
    options="label.width %d label.anchor %s entry.width %d" % (10, Tix.E, 13)
 
362
    options="label.width %d label.anchor %s entry.width %d" % (10, tkinter.tix.E, 13)
363
363
 
364
 
    demo_spintxt = Tix.StringVar()
 
364
    demo_spintxt = tkinter.tix.StringVar()
365
365
    demo_spintxt.set(states[0])
366
 
    simple = Tix.Control(w, label='Numbers', options=options)
367
 
    spintxt = Tix.Control(w, label='States', variable=demo_spintxt,
 
366
    simple = tkinter.tix.Control(w, label='Numbers', options=options)
 
367
    spintxt = tkinter.tix.Control(w, label='States', variable=demo_spintxt,
368
368
                          options=options)
369
369
    spintxt['incrcmd'] = lambda w=spintxt: spin_cmd(w, 1)
370
370
    spintxt['decrcmd'] = lambda w=spintxt: spin_cmd(w, -1)
371
371
    spintxt['validatecmd'] = lambda w=spintxt: spin_validate(w)
372
372
 
373
 
    simple.pack(side=Tix.TOP, padx=5, pady=3)
374
 
    spintxt.pack(side=Tix.TOP, padx=5, pady=3)
 
373
    simple.pack(side=tkinter.tix.TOP, padx=5, pady=3)
 
374
    spintxt.pack(side=tkinter.tix.TOP, padx=5, pady=3)
375
375
 
376
376
def MkSelect(w):
377
 
    options = "label.anchor %s" % Tix.CENTER
 
377
    options = "label.anchor %s" % tkinter.tix.CENTER
378
378
 
379
 
    sel1 = Tix.Select(w, label='Mere Mortals', allowzero=1, radio=1,
380
 
                      orientation=Tix.VERTICAL,
381
 
                      labelside=Tix.TOP,
 
379
    sel1 = tkinter.tix.Select(w, label='Mere Mortals', allowzero=1, radio=1,
 
380
                      orientation=tkinter.tix.VERTICAL,
 
381
                      labelside=tkinter.tix.TOP,
382
382
                      options=options)
383
 
    sel2 = Tix.Select(w, label='Geeks', allowzero=1, radio=0,
384
 
                      orientation=Tix.VERTICAL,
385
 
                      labelside= Tix.TOP,
 
383
    sel2 = tkinter.tix.Select(w, label='Geeks', allowzero=1, radio=0,
 
384
                      orientation=tkinter.tix.VERTICAL,
 
385
                      labelside= tkinter.tix.TOP,
386
386
                      options=options)
387
387
 
388
388
    sel1.add('eat', text='Eat')
397
397
    sel2.add('prog3', text='Program')
398
398
    sel2.add('sleep', text='Sleep')
399
399
 
400
 
    sel1.pack(side=Tix.LEFT, padx=5, pady=3, fill=Tix.X)
401
 
    sel2.pack(side=Tix.LEFT, padx=5, pady=3, fill=Tix.X)
 
400
    sel1.pack(side=tkinter.tix.LEFT, padx=5, pady=3, fill=tkinter.tix.X)
 
401
    sel2.pack(side=tkinter.tix.LEFT, padx=5, pady=3, fill=tkinter.tix.X)
402
402
 
403
403
def MkOptMenu(w):
404
 
    options='menubutton.width 15 label.anchor %s' % Tix.E
 
404
    options='menubutton.width 15 label.anchor %s' % tkinter.tix.E
405
405
 
406
 
    m = Tix.OptionMenu(w, label='File Format : ', options=options)
 
406
    m = tkinter.tix.OptionMenu(w, label='File Format : ', options=options)
407
407
    m.add_command('text', label='Plain Text')
408
408
    m.add_command('post', label='PostScript')
409
409
    m.add_command('format', label='Formatted Text')
412
412
    m.add_command('tex', label='LaTeX')
413
413
    m.add_command('rtf', label='Rich Text Format')
414
414
 
415
 
    m.pack(fill=Tix.X, padx=5, pady=3)
 
415
    m.pack(fill=tkinter.tix.X, padx=5, pady=3)
416
416
 
417
417
def MkFileEnt(w):
418
 
    msg = Tix.Message(w,
419
 
                      relief=Tix.FLAT, width=240, anchor=Tix.N,
 
418
    msg = tkinter.tix.Message(w,
 
419
                      relief=tkinter.tix.FLAT, width=240, anchor=tkinter.tix.N,
420
420
                      text='Press the "open file" icon button and a TixFileSelectDialog will popup.')
421
 
    ent = Tix.FileEntry(w, label='Select a file : ')
422
 
    msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
423
 
    ent.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
 
421
    ent = tkinter.tix.FileEntry(w, label='Select a file : ')
 
422
    msg.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=3, pady=3)
 
423
    ent.pack(side=tkinter.tix.TOP, fill=tkinter.tix.X, padx=3, pady=3)
424
424
 
425
425
def MkFileBox(w):
426
426
    """The FileSelectBox is a Motif-style box with various enhancements.
427
427
    For example, you can adjust the size of the two listboxes
428
428
    and your past selections are recorded.
429
429
    """
430
 
    msg = Tix.Message(w,
431
 
                      relief=Tix.FLAT, width=240, anchor=Tix.N,
 
430
    msg = tkinter.tix.Message(w,
 
431
                      relief=tkinter.tix.FLAT, width=240, anchor=tkinter.tix.N,
432
432
                      text='The Tix FileSelectBox is a Motif-style box with various enhancements. For example, you can adjust the size of the two listboxes and your past selections are recorded.')
433
 
    box = Tix.FileSelectBox(w)
434
 
    msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
435
 
    box.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
 
433
    box = tkinter.tix.FileSelectBox(w)
 
434
    msg.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=3, pady=3)
 
435
    box.pack(side=tkinter.tix.TOP, fill=tkinter.tix.X, padx=3, pady=3)
436
436
 
437
437
def MkToolBar(w):
438
438
    """The Select widget is also good for arranging buttons in a tool bar.
441
441
 
442
442
    options='frame.borderWidth 1'
443
443
 
444
 
    msg = Tix.Message(w,
445
 
                      relief=Tix.FLAT, width=240, anchor=Tix.N,
 
444
    msg = tkinter.tix.Message(w,
 
445
                      relief=tkinter.tix.FLAT, width=240, anchor=tkinter.tix.N,
446
446
                      text='The Select widget is also good for arranging buttons in a tool bar.')
447
 
    bar = Tix.Frame(w, bd=2, relief=Tix.RAISED)
448
 
    font = Tix.Select(w, allowzero=1, radio=0, label='', options=options)
449
 
    para = Tix.Select(w, allowzero=0, radio=1, label='', options=options)
 
447
    bar = tkinter.tix.Frame(w, bd=2, relief=tkinter.tix.RAISED)
 
448
    font = tkinter.tix.Select(w, allowzero=1, radio=0, label='', options=options)
 
449
    para = tkinter.tix.Select(w, allowzero=0, radio=1, label='', options=options)
450
450
 
451
451
    font.add('bold', bitmap='@' + demo.dir + '/bitmaps/bold.xbm')
452
452
    font.add('italic', bitmap='@' + demo.dir + '/bitmaps/italic.xbm')
458
458
    para.add('center', bitmap='@' + demo.dir + '/bitmaps/centerj.xbm')
459
459
    para.add('justify', bitmap='@' + demo.dir + '/bitmaps/justify.xbm')
460
460
 
461
 
    msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
462
 
    bar.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
463
 
    font.pack({'in':bar}, side=Tix.LEFT, padx=3, pady=3)
464
 
    para.pack({'in':bar}, side=Tix.LEFT, padx=3, pady=3)
 
461
    msg.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=3, pady=3)
 
462
    bar.pack(side=tkinter.tix.TOP, fill=tkinter.tix.X, padx=3, pady=3)
 
463
    font.pack({'in':bar}, side=tkinter.tix.LEFT, padx=3, pady=3)
 
464
    para.pack({'in':bar}, side=tkinter.tix.LEFT, padx=3, pady=3)
465
465
 
466
466
def MkTitle(w):
467
 
    msg = Tix.Message(w,
468
 
                      relief=Tix.FLAT, width=240, anchor=Tix.N,
 
467
    msg = tkinter.tix.Message(w,
 
468
                      relief=tkinter.tix.FLAT, width=240, anchor=tkinter.tix.N,
469
469
                      text='There are many types of "chooser" widgets that allow the user to input different types of information')
470
 
    msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
 
470
    msg.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=3, pady=3)
471
471
 
472
472
def MkScroll(nb, name):
473
473
    w = nb.page(name)
474
474
    options='label.padX 4'
475
475
 
476
 
    sls = Tix.LabelFrame(w, label='Tix.ScrolledListBox', options=options)
477
 
    swn = Tix.LabelFrame(w, label='Tix.ScrolledWindow', options=options)
478
 
    stx = Tix.LabelFrame(w, label='Tix.ScrolledText', options=options)
 
476
    sls = tkinter.tix.LabelFrame(w, label='Tix.ScrolledListBox', options=options)
 
477
    swn = tkinter.tix.LabelFrame(w, label='Tix.ScrolledWindow', options=options)
 
478
    stx = tkinter.tix.LabelFrame(w, label='Tix.ScrolledText', options=options)
479
479
 
480
480
    MkSList(sls.frame)
481
481
    MkSWindow(swn.frame)
490
490
    """This TixScrolledListBox is configured so that it uses scrollbars
491
491
    only when it is necessary. Use the handles to resize the listbox and
492
492
    watch the scrollbars automatically appear and disappear.  """
493
 
    top = Tix.Frame(w, width=300, height=330)
494
 
    bot = Tix.Frame(w)
495
 
    msg = Tix.Message(top,
496
 
                      relief=Tix.FLAT, width=200, anchor=Tix.N,
 
493
    top = tkinter.tix.Frame(w, width=300, height=330)
 
494
    bot = tkinter.tix.Frame(w)
 
495
    msg = tkinter.tix.Message(top,
 
496
                      relief=tkinter.tix.FLAT, width=200, anchor=tkinter.tix.N,
497
497
                      text='This TixScrolledListBox is configured so that it uses scrollbars only when it is necessary. Use the handles to resize the listbox and watch the scrollbars automatically appear and disappear.')
498
498
 
499
 
    list = Tix.ScrolledListBox(top, scrollbar='auto')
 
499
    list = tkinter.tix.ScrolledListBox(top, scrollbar='auto')
500
500
    list.place(x=50, y=150, width=120, height=80)
501
 
    list.listbox.insert(Tix.END, 'Alabama')
502
 
    list.listbox.insert(Tix.END, 'California')
503
 
    list.listbox.insert(Tix.END, 'Montana')
504
 
    list.listbox.insert(Tix.END, 'New Jersey')
505
 
    list.listbox.insert(Tix.END, 'New York')
506
 
    list.listbox.insert(Tix.END, 'Pennsylvania')
507
 
    list.listbox.insert(Tix.END, 'Washington')
 
501
    list.listbox.insert(tkinter.tix.END, 'Alabama')
 
502
    list.listbox.insert(tkinter.tix.END, 'California')
 
503
    list.listbox.insert(tkinter.tix.END, 'Montana')
 
504
    list.listbox.insert(tkinter.tix.END, 'New Jersey')
 
505
    list.listbox.insert(tkinter.tix.END, 'New York')
 
506
    list.listbox.insert(tkinter.tix.END, 'Pennsylvania')
 
507
    list.listbox.insert(tkinter.tix.END, 'Washington')
508
508
 
509
 
    rh = Tix.ResizeHandle(top, bg='black',
510
 
                          relief=Tix.RAISED,
 
509
    rh = tkinter.tix.ResizeHandle(top, bg='black',
 
510
                          relief=tkinter.tix.RAISED,
511
511
                          handlesize=8, gridded=1, minwidth=50, minheight=30)
512
 
    btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=list: SList_reset(w,x))
 
512
    btn = tkinter.tix.Button(bot, text='Reset', command=lambda w=rh, x=list: SList_reset(w,x))
513
513
    top.propagate(0)
514
 
    msg.pack(fill=Tix.X)
515
 
    btn.pack(anchor=Tix.CENTER)
516
 
    top.pack(expand=1, fill=Tix.BOTH)
517
 
    bot.pack(fill=Tix.BOTH)
 
514
    msg.pack(fill=tkinter.tix.X)
 
515
    btn.pack(anchor=tkinter.tix.CENTER)
 
516
    top.pack(expand=1, fill=tkinter.tix.BOTH)
 
517
    bot.pack(fill=tkinter.tix.BOTH)
518
518
    list.bind('<Map>', func=lambda arg=0, rh=rh, list=list:
519
519
              list.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(list)))
520
520
 
535
535
    if not os.path.isfile(file):
536
536
        text += ' (Image missing)'
537
537
 
538
 
    top = Tix.Frame(w, width=330, height=330)
539
 
    bot = Tix.Frame(w)
540
 
    msg = Tix.Message(top,
541
 
                      relief=Tix.FLAT, width=200, anchor=Tix.N,
 
538
    top = tkinter.tix.Frame(w, width=330, height=330)
 
539
    bot = tkinter.tix.Frame(w)
 
540
    msg = tkinter.tix.Message(top,
 
541
                      relief=tkinter.tix.FLAT, width=200, anchor=tkinter.tix.N,
542
542
                      text=text)
543
543
 
544
 
    win = Tix.ScrolledWindow(top, scrollbar='auto')
 
544
    win = tkinter.tix.ScrolledWindow(top, scrollbar='auto')
545
545
 
546
546
    image1 = win.window.image_create('photo', file=file)
547
 
    lbl = Tix.Label(win.window, image=image1)
548
 
    lbl.pack(expand=1, fill=Tix.BOTH)
 
547
    lbl = tkinter.tix.Label(win.window, image=image1)
 
548
    lbl.pack(expand=1, fill=tkinter.tix.BOTH)
549
549
 
550
550
    win.place(x=30, y=150, width=190, height=120)
551
551
 
552
 
    rh = Tix.ResizeHandle(top, bg='black',
553
 
                          relief=Tix.RAISED,
 
552
    rh = tkinter.tix.ResizeHandle(top, bg='black',
 
553
                          relief=tkinter.tix.RAISED,
554
554
                          handlesize=8, gridded=1, minwidth=50, minheight=30)
555
 
    btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SWindow_reset(w,x))
 
555
    btn = tkinter.tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SWindow_reset(w,x))
556
556
    top.propagate(0)
557
 
    msg.pack(fill=Tix.X)
558
 
    btn.pack(anchor=Tix.CENTER)
559
 
    top.pack(expand=1, fill=Tix.BOTH)
560
 
    bot.pack(fill=Tix.BOTH)
 
557
    msg.pack(fill=tkinter.tix.X)
 
558
    btn.pack(anchor=tkinter.tix.CENTER)
 
559
    top.pack(expand=1, fill=tkinter.tix.BOTH)
 
560
    bot.pack(fill=tkinter.tix.BOTH)
561
561
 
562
562
    win.bind('<Map>', func=lambda arg=0, rh=rh, win=win:
563
563
             win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win)))
570
570
def MkSText(w):
571
571
    """The TixScrolledWindow widget allows you to scroll any kind of Tk
572
572
    widget. It is more versatile than a scrolled canvas widget."""
573
 
    top = Tix.Frame(w, width=330, height=330)
574
 
    bot = Tix.Frame(w)
575
 
    msg = Tix.Message(top,
576
 
                      relief=Tix.FLAT, width=200, anchor=Tix.N,
 
573
    top = tkinter.tix.Frame(w, width=330, height=330)
 
574
    bot = tkinter.tix.Frame(w)
 
575
    msg = tkinter.tix.Message(top,
 
576
                      relief=tkinter.tix.FLAT, width=200, anchor=tkinter.tix.N,
577
577
                      text='The Tix ScrolledWindow widget allows you to scroll any kind of Tk widget. It is more versatile than a scrolled canvas widget.')
578
578
 
579
 
    win = Tix.ScrolledText(top, scrollbar='auto')
 
579
    win = tkinter.tix.ScrolledText(top, scrollbar='auto')
580
580
    win.text['wrap'] = 'none'
581
 
    win.text.insert(Tix.END, '''When -scrollbar is set to "auto", the
 
581
    win.text.insert(tkinter.tix.END, '''When -scrollbar is set to "auto", the
582
582
scrollbars are shown only when needed.
583
583
Additional modifiers can be used to force a
584
584
scrollbar to be shown or hidden. For example,
591
591
)
592
592
    win.place(x=30, y=150, width=190, height=100)
593
593
 
594
 
    rh = Tix.ResizeHandle(top, bg='black',
595
 
                          relief=Tix.RAISED,
 
594
    rh = tkinter.tix.ResizeHandle(top, bg='black',
 
595
                          relief=tkinter.tix.RAISED,
596
596
                          handlesize=8, gridded=1, minwidth=50, minheight=30)
597
 
    btn = Tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SText_reset(w,x))
 
597
    btn = tkinter.tix.Button(bot, text='Reset', command=lambda w=rh, x=win: SText_reset(w,x))
598
598
    top.propagate(0)
599
 
    msg.pack(fill=Tix.X)
600
 
    btn.pack(anchor=Tix.CENTER)
601
 
    top.pack(expand=1, fill=Tix.BOTH)
602
 
    bot.pack(fill=Tix.BOTH)
 
599
    msg.pack(fill=tkinter.tix.X)
 
600
    btn.pack(anchor=tkinter.tix.CENTER)
 
601
    top.pack(expand=1, fill=tkinter.tix.BOTH)
 
602
    bot.pack(fill=tkinter.tix.BOTH)
603
603
    win.bind('<Map>', func=lambda arg=0, rh=rh, win=win:
604
604
             win.tk.call('tixDoWhenIdle', str(rh), 'attachwidget', str(win)))
605
605
 
612
612
    w = nb.page(name)
613
613
    options='label.padX 4'
614
614
 
615
 
    pane = Tix.LabelFrame(w, label='Tix.PanedWindow', options=options)
616
 
    note = Tix.LabelFrame(w, label='Tix.NoteBook', options=options)
 
615
    pane = tkinter.tix.LabelFrame(w, label='Tix.PanedWindow', options=options)
 
616
    note = tkinter.tix.LabelFrame(w, label='Tix.NoteBook', options=options)
617
617
 
618
618
    MkPanedWindow(pane.frame)
619
619
    MkNoteBook(note.frame)
626
626
    the sizes of several panes. The panes can be arranged either vertically
627
627
    or horizontally.
628
628
    """
629
 
    msg = Tix.Message(w,
630
 
                      relief=Tix.FLAT, width=240, anchor=Tix.N,
 
629
    msg = tkinter.tix.Message(w,
 
630
                      relief=tkinter.tix.FLAT, width=240, anchor=tkinter.tix.N,
631
631
                      text='The PanedWindow widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally.')
632
 
    group = Tix.LabelEntry(w, label='Newsgroup:', options='entry.width 25')
 
632
    group = tkinter.tix.LabelEntry(w, label='Newsgroup:', options='entry.width 25')
633
633
    group.entry.insert(0,'comp.lang.python')
634
 
    pane = Tix.PanedWindow(w, orientation='vertical')
 
634
    pane = tkinter.tix.PanedWindow(w, orientation='vertical')
635
635
 
636
636
    p1 = pane.add('list', min=70, size=100)
637
637
    p2 = pane.add('text', min=70)
638
 
    list = Tix.ScrolledListBox(p1)
639
 
    text = Tix.ScrolledText(p2)
 
638
    list = tkinter.tix.ScrolledListBox(p1)
 
639
    text = tkinter.tix.ScrolledText(p2)
640
640
 
641
 
    list.listbox.insert(Tix.END, "  12324 Re: Tkinter is good for your health")
642
 
    list.listbox.insert(Tix.END, "+ 12325 Re: Tkinter is good for your health")
643
 
    list.listbox.insert(Tix.END, "+ 12326 Re: Tix is even better for your health (Was: Tkinter is good...)")
644
 
    list.listbox.insert(Tix.END, "  12327 Re: Tix is even better for your health (Was: Tkinter is good...)")
645
 
    list.listbox.insert(Tix.END, "+ 12328 Re: Tix is even better for your health (Was: Tkinter is good...)")
646
 
    list.listbox.insert(Tix.END, "  12329 Re: Tix is even better for your health (Was: Tkinter is good...)")
647
 
    list.listbox.insert(Tix.END, "+ 12330 Re: Tix is even better for your health (Was: Tkinter is good...)")
 
641
    list.listbox.insert(tkinter.tix.END, "  12324 Re: Tkinter is good for your health")
 
642
    list.listbox.insert(tkinter.tix.END, "+ 12325 Re: Tkinter is good for your health")
 
643
    list.listbox.insert(tkinter.tix.END, "+ 12326 Re: Tix is even better for your health (Was: Tkinter is good...)")
 
644
    list.listbox.insert(tkinter.tix.END, "  12327 Re: Tix is even better for your health (Was: Tkinter is good...)")
 
645
    list.listbox.insert(tkinter.tix.END, "+ 12328 Re: Tix is even better for your health (Was: Tkinter is good...)")
 
646
    list.listbox.insert(tkinter.tix.END, "  12329 Re: Tix is even better for your health (Was: Tkinter is good...)")
 
647
    list.listbox.insert(tkinter.tix.END, "+ 12330 Re: Tix is even better for your health (Was: Tkinter is good...)")
648
648
 
649
649
    text.text['bg'] = list.listbox['bg']
650
650
    text.text['wrap'] = 'none'
651
 
    text.text.insert(Tix.END, """
 
651
    text.text.insert(tkinter.tix.END, """
652
652
Mon, 19 Jun 1995 11:39:52        comp.lang.python              Thread   34 of  220
653
653
Lines 353       A new way to put text and bitmaps together iNo responses
654
654
ioi@blue.seas.upenn.edu                Ioi K. Lam at University of Pennsylvania
661
661
support the -image option. For example, you can display a text string string
662
662
together with a bitmap, at the same time, inside a TK button widget.
663
663
""")
664
 
    list.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6)
665
 
    text.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6)
 
664
    list.pack(expand=1, fill=tkinter.tix.BOTH, padx=4, pady=6)
 
665
    text.pack(expand=1, fill=tkinter.tix.BOTH, padx=4, pady=6)
666
666
 
667
 
    msg.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH)
668
 
    group.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH)
669
 
    pane.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH, expand=1)
 
667
    msg.pack(side=tkinter.tix.TOP, padx=3, pady=3, fill=tkinter.tix.BOTH)
 
668
    group.pack(side=tkinter.tix.TOP, padx=3, pady=3, fill=tkinter.tix.BOTH)
 
669
    pane.pack(side=tkinter.tix.TOP, padx=3, pady=3, fill=tkinter.tix.BOTH, expand=1)
670
670
 
671
671
def MkNoteBook(w):
672
 
    msg = Tix.Message(w,
673
 
                      relief=Tix.FLAT, width=240, anchor=Tix.N,
 
672
    msg = tkinter.tix.Message(w,
 
673
                      relief=tkinter.tix.FLAT, width=240, anchor=tkinter.tix.N,
674
674
                      text='The NoteBook widget allows you to layout a complex interface into individual pages.')
675
675
    # prefix = Tix.OptionName(w)
676
676
    # if not prefix: prefix = ''
677
677
    # w.option_add('*' + prefix + '*TixNoteBook*tagPadX', 8)
678
 
    options = "entry.width %d label.width %d label.anchor %s" % (10, 18, Tix.E)
 
678
    options = "entry.width %d label.width %d label.anchor %s" % (10, 18, tkinter.tix.E)
679
679
 
680
 
    nb = Tix.NoteBook(w, ipadx=6, ipady=6, options=options)
 
680
    nb = tkinter.tix.NoteBook(w, ipadx=6, ipady=6, options=options)
681
681
    nb.add('hard_disk', label="Hard Disk", underline=0)
682
682
    nb.add('network', label="Network", underline=0)
683
683
 
684
684
    # Frame for the buttons that are present on all pages
685
 
    common = Tix.Frame(nb.hard_disk)
686
 
    common.pack(side=Tix.RIGHT, padx=2, pady=2, fill=Tix.Y)
 
685
    common = tkinter.tix.Frame(nb.hard_disk)
 
686
    common.pack(side=tkinter.tix.RIGHT, padx=2, pady=2, fill=tkinter.tix.Y)
687
687
    CreateCommonButtons(common)
688
688
 
689
689
    # Widgets belonging only to this page
690
 
    a = Tix.Control(nb.hard_disk, value=12, label='Access Time: ')
691
 
    w = Tix.Control(nb.hard_disk, value=400, label='Write Throughput: ')
692
 
    r = Tix.Control(nb.hard_disk, value=400, label='Read Throughput: ')
693
 
    c = Tix.Control(nb.hard_disk, value=1021, label='Capacity: ')
694
 
    a.pack(side=Tix.TOP, padx=20, pady=2)
695
 
    w.pack(side=Tix.TOP, padx=20, pady=2)
696
 
    r.pack(side=Tix.TOP, padx=20, pady=2)
697
 
    c.pack(side=Tix.TOP, padx=20, pady=2)
 
690
    a = tkinter.tix.Control(nb.hard_disk, value=12, label='Access Time: ')
 
691
    w = tkinter.tix.Control(nb.hard_disk, value=400, label='Write Throughput: ')
 
692
    r = tkinter.tix.Control(nb.hard_disk, value=400, label='Read Throughput: ')
 
693
    c = tkinter.tix.Control(nb.hard_disk, value=1021, label='Capacity: ')
 
694
    a.pack(side=tkinter.tix.TOP, padx=20, pady=2)
 
695
    w.pack(side=tkinter.tix.TOP, padx=20, pady=2)
 
696
    r.pack(side=tkinter.tix.TOP, padx=20, pady=2)
 
697
    c.pack(side=tkinter.tix.TOP, padx=20, pady=2)
698
698
 
699
 
    common = Tix.Frame(nb.network)
700
 
    common.pack(side=Tix.RIGHT, padx=2, pady=2, fill=Tix.Y)
 
699
    common = tkinter.tix.Frame(nb.network)
 
700
    common.pack(side=tkinter.tix.RIGHT, padx=2, pady=2, fill=tkinter.tix.Y)
701
701
    CreateCommonButtons(common)
702
702
 
703
 
    a = Tix.Control(nb.network, value=12, label='Access Time: ')
704
 
    w = Tix.Control(nb.network, value=400, label='Write Throughput: ')
705
 
    r = Tix.Control(nb.network, value=400, label='Read Throughput: ')
706
 
    c = Tix.Control(nb.network, value=1021, label='Capacity: ')
707
 
    u = Tix.Control(nb.network, value=10, label='Users: ')
708
 
    a.pack(side=Tix.TOP, padx=20, pady=2)
709
 
    w.pack(side=Tix.TOP, padx=20, pady=2)
710
 
    r.pack(side=Tix.TOP, padx=20, pady=2)
711
 
    c.pack(side=Tix.TOP, padx=20, pady=2)
712
 
    u.pack(side=Tix.TOP, padx=20, pady=2)
 
703
    a = tkinter.tix.Control(nb.network, value=12, label='Access Time: ')
 
704
    w = tkinter.tix.Control(nb.network, value=400, label='Write Throughput: ')
 
705
    r = tkinter.tix.Control(nb.network, value=400, label='Read Throughput: ')
 
706
    c = tkinter.tix.Control(nb.network, value=1021, label='Capacity: ')
 
707
    u = tkinter.tix.Control(nb.network, value=10, label='Users: ')
 
708
    a.pack(side=tkinter.tix.TOP, padx=20, pady=2)
 
709
    w.pack(side=tkinter.tix.TOP, padx=20, pady=2)
 
710
    r.pack(side=tkinter.tix.TOP, padx=20, pady=2)
 
711
    c.pack(side=tkinter.tix.TOP, padx=20, pady=2)
 
712
    u.pack(side=tkinter.tix.TOP, padx=20, pady=2)
713
713
 
714
 
    msg.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH)
715
 
    nb.pack(side=Tix.TOP, padx=5, pady=5, fill=Tix.BOTH, expand=1)
 
714
    msg.pack(side=tkinter.tix.TOP, padx=3, pady=3, fill=tkinter.tix.BOTH)
 
715
    nb.pack(side=tkinter.tix.TOP, padx=5, pady=5, fill=tkinter.tix.BOTH, expand=1)
716
716
 
717
717
def CreateCommonButtons(f):
718
 
    ok = Tix.Button(f, text='OK', width = 6)
719
 
    cancel = Tix.Button(f, text='Cancel', width = 6)
720
 
    ok.pack(side=Tix.TOP, padx=2, pady=2)
721
 
    cancel.pack(side=Tix.TOP, padx=2, pady=2)
 
718
    ok = tkinter.tix.Button(f, text='OK', width = 6)
 
719
    cancel = tkinter.tix.Button(f, text='Cancel', width = 6)
 
720
    ok.pack(side=tkinter.tix.TOP, padx=2, pady=2)
 
721
    cancel.pack(side=tkinter.tix.TOP, padx=2, pady=2)
722
722
 
723
723
def MkDirList(nb, name):
724
724
    w = nb.page(name)
725
725
    options = "label.padX 4"
726
726
 
727
 
    dir = Tix.LabelFrame(w, label='Tix.DirList', options=options)
728
 
    fsbox = Tix.LabelFrame(w, label='Tix.ExFileSelectBox', options=options)
 
727
    dir = tkinter.tix.LabelFrame(w, label='Tix.DirList', options=options)
 
728
    fsbox = tkinter.tix.LabelFrame(w, label='Tix.ExFileSelectBox', options=options)
729
729
    MkDirListWidget(dir.frame)
730
730
    MkExFileWidget(fsbox.frame)
731
731
    dir.form(top=0, left=0, right='%40', bottom=-1)
736
736
    system directory and makes it easy for the user to choose and access
737
737
    directories.
738
738
    """
739
 
    msg = Tix.Message(w,
740
 
                      relief=Tix.FLAT, width=240, anchor=Tix.N,
 
739
    msg = tkinter.tix.Message(w,
 
740
                      relief=tkinter.tix.FLAT, width=240, anchor=tkinter.tix.N,
741
741
                      text='The Tix DirList widget gives a graphical representation of the file system directory and makes it easy for the user to choose and access directories.')
742
 
    dirlist = Tix.DirList(w, options='hlist.padY 1 hlist.width 25 hlist.height 16')
743
 
    msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
744
 
    dirlist.pack(side=Tix.TOP, padx=3, pady=3)
 
742
    dirlist = tkinter.tix.DirList(w, options='hlist.padY 1 hlist.width 25 hlist.height 16')
 
743
    msg.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=3, pady=3)
 
744
    dirlist.pack(side=tkinter.tix.TOP, padx=3, pady=3)
745
745
 
746
746
def MkExFileWidget(w):
747
747
    """The TixExFileSelectBox widget is more user friendly than the Motif
748
748
    style FileSelectBox.  """
749
 
    msg = Tix.Message(w,
750
 
                      relief=Tix.FLAT, width=240, anchor=Tix.N,
 
749
    msg = tkinter.tix.Message(w,
 
750
                      relief=tkinter.tix.FLAT, width=240, anchor=tkinter.tix.N,
751
751
                      text='The Tix ExFileSelectBox widget is more user friendly than the Motif style FileSelectBox.')
752
752
    # There's a bug in the ComboBoxes - the scrolledlistbox is destroyed
753
 
    box = Tix.ExFileSelectBox(w, bd=2, relief=Tix.RAISED)
754
 
    msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
755
 
    box.pack(side=Tix.TOP, padx=3, pady=3)
 
753
    box = tkinter.tix.ExFileSelectBox(w, bd=2, relief=tkinter.tix.RAISED)
 
754
    msg.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=3, pady=3)
 
755
    box.pack(side=tkinter.tix.TOP, padx=3, pady=3)
756
756
 
757
757
###
758
758
### List of all the demos we want to show off
875
875
    w = nb.page(name)
876
876
    options = "label.padX 4"
877
877
 
878
 
    pane = Tix.PanedWindow(w, orientation='horizontal')
879
 
    pane.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH)
 
878
    pane = tkinter.tix.PanedWindow(w, orientation='horizontal')
 
879
    pane.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH)
880
880
    f1 = pane.add('list', expand='1')
881
881
    f2 = pane.add('text', expand='5')
882
882
    f1['relief'] = 'flat'
883
883
    f2['relief'] = 'flat'
884
884
 
885
 
    lab = Tix.LabelFrame(f1, label='Select a sample program:')
886
 
    lab.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=5, pady=5)
887
 
    lab1 = Tix.LabelFrame(f2, label='Source:')
888
 
    lab1.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=5, pady=5)
889
 
 
890
 
    slb = Tix.Tree(lab.frame, options='hlist.width 20')
891
 
    slb.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=5)
892
 
 
893
 
    stext = Tix.ScrolledText(lab1.frame, name='stext')
 
885
    lab = tkinter.tix.LabelFrame(f1, label='Select a sample program:')
 
886
    lab.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=5, pady=5)
 
887
    lab1 = tkinter.tix.LabelFrame(f2, label='Source:')
 
888
    lab1.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=5, pady=5)
 
889
 
 
890
    slb = tkinter.tix.Tree(lab.frame, options='hlist.width 20')
 
891
    slb.pack(side=tkinter.tix.TOP, expand=1, fill=tkinter.tix.BOTH, padx=5)
 
892
 
 
893
    stext = tkinter.tix.ScrolledText(lab1.frame, name='stext')
894
894
    font = root.tk.eval('tix option get fixed_font')
895
895
    stext.text.config(font=font)
896
896
 
897
 
    frame = Tix.Frame(lab1.frame, name='frame')
 
897
    frame = tkinter.tix.Frame(lab1.frame, name='frame')
898
898
 
899
 
    run = Tix.Button(frame, text='Run ...', name='run')
900
 
    view = Tix.Button(frame, text='View Source ...', name='view')
901
 
    run.pack(side=Tix.LEFT, expand=0, fill=Tix.NONE)
902
 
    view.pack(side=Tix.LEFT, expand=0, fill=Tix.NONE)
 
899
    run = tkinter.tix.Button(frame, text='Run ...', name='run')
 
900
    view = tkinter.tix.Button(frame, text='View Source ...', name='view')
 
901
    run.pack(side=tkinter.tix.LEFT, expand=0, fill=tkinter.tix.NONE)
 
902
    view.pack(side=tkinter.tix.LEFT, expand=0, fill=tkinter.tix.NONE)
903
903
 
904
904
    stext.text['bg'] = slb.hlist['bg']
905
905
    stext.text['state'] = 'disabled'
906
906
    stext.text['wrap'] = 'none'
907
907
    stext.text['width'] = 80
908
908
 
909
 
    frame.pack(side=Tix.BOTTOM, expand=0, fill=Tix.X, padx=7)
910
 
    stext.pack(side=Tix.TOP, expand=0, fill=Tix.BOTH, padx=7)
 
909
    frame.pack(side=tkinter.tix.BOTTOM, expand=0, fill=tkinter.tix.X, padx=7)
 
910
    stext.pack(side=tkinter.tix.TOP, expand=0, fill=tkinter.tix.BOTH, padx=7)
911
911
 
912
912
    slb.hlist['separator'] = '.'
913
913
    slb.hlist['width'] = 25
922
922
 
923
923
    for type in ['widget', 'image']:
924
924
        if type != 'widget':
925
 
            x = Tix.Frame(slb.hlist, bd=2, height=2, width=150,
926
 
                          relief=Tix.SUNKEN, bg=slb.hlist['bg'])
927
 
            slb.hlist.add_child(itemtype=Tix.WINDOW, window=x, state='disabled')
928
 
        x = slb.hlist.add_child(itemtype=Tix.TEXT, state='disabled',
 
925
            x = tkinter.tix.Frame(slb.hlist, bd=2, height=2, width=150,
 
926
                          relief=tkinter.tix.SUNKEN, bg=slb.hlist['bg'])
 
927
            slb.hlist.add_child(itemtype=tkinter.tix.WINDOW, window=x, state='disabled')
 
928
        x = slb.hlist.add_child(itemtype=tkinter.tix.TEXT, state='disabled',
929
929
                                text=comments[type])
930
930
        for key in stypes[type]:
931
 
            slb.hlist.add_child(x, itemtype=Tix.TEXT, data=key,
 
931
            slb.hlist.add_child(x, itemtype=tkinter.tix.TEXT, data=key,
932
932
                                text=key)
933
933
    slb.hlist.selection_clear()
934
934
 
955
955
 
956
956
    if action == 'run':
957
957
        exec('import ' + prog)
958
 
        w = Tix.Toplevel()
 
958
        w = tkinter.tix.Toplevel()
959
959
        w.title(title)
960
960
        rtn = eval(prog + '.RunSample')
961
961
        rtn(w)
962
962
    elif action == 'view':
963
 
        w = Tix.Toplevel()
 
963
        w = tkinter.tix.Toplevel()
964
964
        w.title('Source view: ' + title)
965
965
        LoadFile(w, demo.dir + '/samples/' + prog + '.py')
966
966
    elif action == 'browse':
968
968
 
969
969
def LoadFile(w, fname):
970
970
    global root
971
 
    b = Tix.Button(w, text='Close', command=w.destroy)
972
 
    t = Tix.ScrolledText(w)
 
971
    b = tkinter.tix.Button(w, text='Close', command=w.destroy)
 
972
    t = tkinter.tix.ScrolledText(w)
973
973
    #    b.form(left=0, bottom=0, padx=4, pady=4)
974
974
    #    t.form(left=0, bottom=b, right='-0', top=0)
975
975
    t.pack()
985
985
def ReadFile(w, fname):
986
986
    old_state = w['state']
987
987
    w['state'] = 'normal'
988
 
    w.delete('0.0', Tix.END)
 
988
    w.delete('0.0', tkinter.tix.END)
989
989
 
990
990
    try:
991
991
        f = open(fname)
992
992
        lines = f.readlines()
993
993
        for s in lines:
994
 
            w.insert(Tix.END, s)
 
994
            w.insert(tkinter.tix.END, s)
995
995
        f.close()
996
996
    finally:
997
997
#       w.see('1.0')
998
998
        w['state'] = old_state
999
999
 
1000
1000
if __name__ == '__main__':
1001
 
    root = Tix.Tk()
 
1001
    root = tkinter.tix.Tk()
1002
1002
    RunMain(root)