Commit 8ec03e05 authored by Martin v. Löwis's avatar Martin v. Löwis

Patch #485959: Various changes to Tix demos.

parent 42ab61ee
#!/usr/local/bin/python
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program.
......@@ -17,13 +17,27 @@
import Tix
def RunSample(w):
TCL_ALL_EVENTS = 0
def RunSample (root):
balloon = DemoBalloon(root)
balloon.mainloop()
balloon.destroy()
class DemoBalloon:
def __init__(self, w):
self.root = w
self.exit = -1
z = w.winfo_toplevel()
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
status = Tix.Label(w, width=40, relief=Tix.SUNKEN, bd=1)
status.pack(side=Tix.BOTTOM, fill=Tix.Y, padx=2, pady=1)
# Create two mysterious widgets that need balloon help
button1 = Tix.Button(w, text='Something Unexpected',
command=lambda w=w: w.destroy())
command=self.quitcmd)
button2 = Tix.Button(w, text='Something Else Unexpected')
button2['command'] = lambda w=button2: w.destroy()
button1.pack(side=Tix.TOP, expand=1)
......@@ -38,8 +52,17 @@ def RunSample(w):
b.bind_widget(button2, balloonmsg='Self-destruct button',
statusmsg='Press this button and it will destroy itself')
def quitcmd (self):
self.exit = 0
def mainloop(self):
foundEvent = 1
while self.exit < 0 and foundEvent > 0:
foundEvent = self.root.tk.dooneevent(TCL_ALL_EVENTS)
def destroy (self):
self.root.destroy()
if __name__ == '__main__':
root = Tix.Tk()
RunSample(root)
root.mainloop()
#!/usr/local/bin/python
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program.
......
#!/usr/local/bin/python
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program.
......
#!/usr/local/bin/python
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program.
......@@ -85,13 +85,15 @@ def RunSample(w):
top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
def select_month(event=None):
print "Month =", demo_month.get()
# tixDemo:Status "Month = %s" % demo_month.get()
pass
def select_year(event=None):
print "Year =", demo_year.get()
# tixDemo:Status "Year = %s" % demo_year.get()
pass
def ok_command(w):
print "Month =", demo_month.get(), ", Year=", demo_year.get()
# tixDemo:Status "Month = %s, Year= %s" % (demo_month.get(), demo_year.get())
w.destroy()
if __name__ == '__main__':
......
#!/usr/local/bin/python
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program.
......@@ -17,10 +17,21 @@
# This example program uses three Control widgets. One lets you select
# integer values; one lets you select floating point values and the last
# one lets you select a few names.
#
import Tix
def RunSample(w):
TCL_ALL_EVENTS = 0
def RunSample (root):
control = DemoControl(root)
control.mainloop()
control.destroy()
class DemoControl:
def __init__(self, w):
self.root = w
self.exit = -1
global demo_maker, demo_thrust, demo_num_engines
demo_maker = Tix.StringVar()
......@@ -63,12 +74,26 @@ def RunSample(w):
box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
box.add('ok', text='Ok', underline=0, width=6,
command=lambda w=w: ok_command(w))
command=self.okcmd)
box.add('cancel', text='Cancel', underline=0, width=6,
command=lambda w=w: w.destroy())
command=self.quitcmd)
box.pack(side=Tix.BOTTOM, fill=Tix.X)
top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
def okcmd (self):
# tixDemo:Status "Selected %d of %s engines each of thrust %d", (demo_num_engines.get(), demo_maker.get(), demo_thrust.get())
self.quitcmd()
def quitcmd (self):
self.exit = 0
def mainloop(self):
while self.exit < 0:
self.root.tk.dooneevent(TCL_ALL_EVENTS)
def destroy (self):
self.root.destroy()
maker_list = ['P&W', 'GE', 'Rolls Royce']
def adjust_maker(w, inc):
......@@ -92,11 +117,6 @@ def validate_maker(w):
# Works here though. Why ? Beats me.
return maker_list[i]
def ok_command(w):
print "Selected", demo_num_engines.get(), "of", demo_maker.get(), " engines each of thrust", demo_thrust.get()
w.destroy()
if __name__ == '__main__':
root = Tix.Tk()
RunSample(root)
root.mainloop()
......@@ -5,7 +5,7 @@
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "widget": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program using tixwish.
......@@ -19,15 +19,9 @@
import Tix, os, copy
from Tkconstants import *
TCL_DONT_WAIT = 1<<1
TCL_WINDOW_EVENTS = 1<<2
TCL_FILE_EVENTS = 1<<3
TCL_TIMER_EVENTS = 1<<4
TCL_IDLE_EVENTS = 1<<5
TCL_ALL_EVENTS = 0
def RunSample (root):
global dirlist
dirlist = DemoDirList(root)
dirlist.mainloop()
dirlist.destroy()
......@@ -38,7 +32,7 @@ class DemoDirList:
self.exit = -1
z = w.winfo_toplevel()
z.wm_title('Tix.DirList Widget Demo')
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
# Create the tixDirList and the tixLabelEntry widgets on the on the top
# of the dialog box
......@@ -98,7 +92,6 @@ class DemoDirList:
command = lambda self=self: self.quitcmd () )
box.pack( anchor='s', fill='x', side=BOTTOM)
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
def copy_name (self, dir, ent):
# This should work as it is the entry's textvariable
......@@ -108,24 +101,21 @@ class DemoDirList:
ent.entry.insert(0, self.dlist_dir)
def okcmd (self):
# tixDemo:Status "You have selected the directory" + $self.dlist_dir
# tixDemo:Status "You have selected the directory" + self.dlist_dir
self.quitcmd()
def quitcmd (self):
# self.root.destroy()
self.exit = 0
def mainloop(self):
while self.exit < 0:
self.root.tk.dooneevent(TCL_ALL_EVENTS)
# self.root.tk.dooneevent(TCL_DONT_WAIT)
def destroy (self):
self.root.destroy()
# This "if" statement makes it possible to run this script file inside or
# outside of the main demo program "widget".
# outside of the main demo program "tixwidgets.py".
#
if __name__== '__main__' :
import tkMessageBox, traceback
......
......@@ -5,7 +5,7 @@
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "widget": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program using tixwish.
......@@ -19,15 +19,20 @@
import Tix, os, copy
from Tkconstants import *
def RunSample (w):
DemoDirTree(w)
TCL_ALL_EVENTS = 0
def RunSample (root):
dirtree = DemoDirTree(root)
dirtree.mainloop()
dirtree.destroy()
class DemoDirTree:
def __init__(self, w):
self.root = w
self.exit = -1
z = w.winfo_toplevel()
z.wm_title('Tix.DirTree Widget Demo')
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
# Create the tixDirTree and the tixLabelEntry widgets on the on the top
# of the dialog box
......@@ -90,19 +95,24 @@ class DemoDirTree:
ent.entry.insert(0, self.dlist_dir)
def okcmd (self):
# tixDemo:Status "You have selected the directory" + $self.dlist_dir
# tixDemo:Status "You have selected the directory" + self.dlist_dir
self.quitcmd()
def quitcmd (self):
# tixDemo:Status "You have selected the directory" + self.dlist_dir
self.exit = 0
def mainloop(self):
while self.exit < 0:
self.root.tk.dooneevent(TCL_ALL_EVENTS)
def destroy (self):
self.root.destroy()
# This "if" statement makes it possible to run this script file inside or
# outside of the main demo program "widget".
# outside of the main demo program "tixwidgets.py".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
root.mainloop()
root.destroy()
#!/usr/local/bin/python
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program.
......
#!/usr/local/bin/python
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program.
......@@ -59,7 +59,7 @@ def RunSample(w):
top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
def ok_command(w):
print "Convert file from", demo_opt_from.get(), " to", demo_opt_to.get()
# tixDemo:Status "Convert file from %s to %s" % ( demo_opt_from.get(), demo_opt_to.get())
w.destroy()
if __name__ == '__main__':
......
# Tix Demostration Program
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "widget": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program using tixwish.
......
......@@ -5,7 +5,7 @@
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program using tixwish.
......@@ -15,7 +15,20 @@
import Tix
def RunSample (w) :
TCL_ALL_EVENTS = 0
def RunSample (root):
shlist = DemoSHList(root)
shlist.mainloop()
shlist.destroy()
class DemoSHList:
def __init__(self, w):
self.root = w
self.exit = -1
z = w.winfo_toplevel()
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
# We create the frame and the ScrolledHList widget
# at the top of the dialog box
......@@ -28,7 +41,6 @@ def RunSample (w) :
top.a = Tix.ScrolledHList(top)
top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)
# This is our little relational database
#
bosses = [
......@@ -89,20 +101,32 @@ def RunSample (w) :
#
box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
box.add( 'ok', text='Ok', underline=0, width=6,
command = lambda w=w: w.quit() )
command = self.okcmd)
box.add( 'cancel', text='Cancel', underline=0, width=6,
command = lambda w=w: w.quit() )
command = self.quitcmd)
box.pack( side=Tix.BOTTOM, fill=Tix.X)
top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 )
def okcmd (self):
self.quitcmd()
def quitcmd (self):
self.exit = 0
def mainloop(self):
while self.exit < 0:
self.root.tk.dooneevent(TCL_ALL_EVENTS)
def destroy (self):
self.root.destroy()
# This "if" statement makes it possible to run this script file inside or
# outside of the main demo program "widget".
# outside of the main demo program "tixwidgets.py".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
root.mainloop()
root.destroy()
......@@ -5,7 +5,7 @@
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the PyTix demo program "tixwidget": it must have a
# executed from the Tix demo program "tixwidget": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program using tixwish.
......@@ -18,7 +18,20 @@
import Tix
def RunSample (w) :
TCL_ALL_EVENTS = 0
def RunSample (root):
shlist = DemoSHList(root)
shlist.mainloop()
shlist.destroy()
class DemoSHList:
def __init__(self, w):
self.root = w
self.exit = -1
z = w.winfo_toplevel()
z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())
# We create the frame and the ScrolledHList widget
# at the top of the dialog box
......@@ -29,7 +42,6 @@ def RunSample (w) :
# separator widgets (frames) to make the list look fancy
#
top.a = Tix.ScrolledHList(top, options='hlist.columns 3 hlist.header 1' )
top.a.pack( expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)
hlist=top.a.hlist
......@@ -43,7 +55,7 @@ def RunSample (w) :
# First some styles for the headers
style={}
style['header'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top,
style['header'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist,
anchor=Tix.CENTER, padx=8, pady=2, font = boldfont )
hlist.header_create(0, itemtype=Tix.TEXT, text='Name',
......@@ -78,13 +90,13 @@ def RunSample (w) :
('chuck', 'jeff', 'Chuck McLean', 'Cleaner')
]
style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top)
style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)
style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=top)
style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist)
style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=top)
style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)
style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=top)
style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist)
# Let configure the appearance of the HList subwidget
#
......@@ -126,20 +138,32 @@ def RunSample (w) :
#
box= Tix.ButtonBox(top, orientation=Tix.HORIZONTAL )
box.add( 'ok', text='Ok', underline=0, width=6,
command = lambda w=w: w.quit() )
command = self.okcmd )
box.add( 'cancel', text='Cancel', underline=0, width=6,
command = lambda w=w: w.quit() )
command = self.quitcmd )
box.pack( side=Tix.BOTTOM, fill=Tix.X)
top.pack( side=Tix.TOP, fill=Tix.BOTH, expand=1 )
def okcmd (self):
self.quitcmd()
def quitcmd (self):
self.exit = 0
def mainloop(self):
while self.exit < 0:
self.root.tk.dooneevent(TCL_ALL_EVENTS)
def destroy (self):
self.root.destroy()
# This "if" statement makes it possible to run this script file inside or
# outside of the main demo program "widget".
# outside of the main demo program "tixwidgets.py".
#
if __name__== '__main__' :
root=Tix.Tk()
RunSample(root)
root.mainloop()
root.destroy()
#!/usr/local/bin/python
# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id$
#
# Tix Demostration Program
#
# This sample program is structured in such a way so that it can be
# executed from the Tix demo program "tixwidgets": it must have a
# executed from the Tix demo program "tixwidgets.py": it must have a
# procedure called "RunSample". It should also have the "if" statment
# at the end of this file so that it can be run as a standalone
# program.
......
......@@ -154,7 +154,8 @@ class Demo:
text += line + '\n'
try: tkMessageBox.showerror ('Error', text)
except: pass
tkinspect_quit (1)
self.exit = 1
raise SystemExit, 1
def destroy (self):
self.root.destroy()
......@@ -420,9 +421,13 @@ def MkFileEnt(w):
ent.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
def MkFileBox(w):
"""The 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.
"""
msg = Tix.Message(w,
relief=Tix.FLAT, width=240, anchor=Tix.N,
text='The TixFileSelectBox 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.')
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.')
box = Tix.FileSelectBox(w)
msg.pack(side=Tix.TOP, expand=1, fill=Tix.BOTH, padx=3, pady=3)
box.pack(side=Tix.TOP, fill=Tix.X, padx=3, pady=3)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment