• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
2#
3# $Id$
4#
5# Tix Demonstration Program
6#
7# This sample program is structured in such a way so that it can be
8# executed from the Tix demo program "tixwidgets.py": it must have a
9# procedure called "RunSample". It should also have the "if" statment
10# at the end of this file so that it can be run as a standalone
11# program.
12
13# This file demonstrates the use of the tixButtonBox widget, which is a
14# group of TK buttons. You can use it to manage the buttons in a dialog box,
15# for example.
16#
17
18import Tix
19
20def RunSample(w):
21    # Create the label on the top of the dialog box
22    #
23    top = Tix.Label(w, padx=20, pady=10, bd=1, relief=Tix.RAISED,
24                    anchor=Tix.CENTER, text='This dialog box is\n a demonstration of the\n tixButtonBox widget')
25
26    # Create the button box and add a few buttons in it. Set the
27    # -width of all the buttons to the same value so that they
28    # appear in the same size.
29    #
30    # Note that the -text, -underline, -command and -width options are all
31    # standard options of the button widgets.
32    #
33    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
34    box.add('ok', text='OK', underline=0, width=5,
35            command=lambda w=w: w.destroy())
36    box.add('close', text='Cancel', underline=0, width=5,
37            command=lambda w=w: w.destroy())
38    box.pack(side=Tix.BOTTOM, fill=Tix.X)
39    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
40
41if __name__ == '__main__':
42    root = Tix.Tk()
43    RunSample(root)
44    root.mainloop()
45