blob: d5e2e29d91da5cc79d42a46934362d579e7f494a [file] [log] [blame]
Martin v. Löwis8ec03e02002-03-17 18:19:13 +00001# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
Tim Peters182b5ac2004-07-18 06:16:08 +00002#
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00003# $Id$
4#
Martin Pantera850ef62016-07-28 01:11:04 +00005# Tix Demonstration Program
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00006#
7# This sample program is structured in such a way so that it can be
Martin v. Löwis8ec03e02002-03-17 18:19:13 +00008# executed from the Tix demo program "tixwidgets.py": it must have a
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +00009# 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,
Tim Peters182b5ac2004-07-18 06:16:08 +000024 anchor=Tix.CENTER, text='This dialog box is\n a demonstration of the\n tixButtonBox widget')
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000025
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,
Tim Peters182b5ac2004-07-18 06:16:08 +000035 command=lambda w=w: w.destroy())
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000036 box.add('close', text='Cancel', underline=0, width=5,
Tim Peters182b5ac2004-07-18 06:16:08 +000037 command=lambda w=w: w.destroy())
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000038 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()