blob: 3b9ee4bc331323c3067b2290104dea39dcaff119 [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#
5# Tix Demostration Program
6#
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
Benjamin Petersond6d63f52009-01-04 18:53:28 +000018import tkinter.tix
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000019
20def RunSample(w):
21 # Create the label on the top of the dialog box
22 #
Benjamin Petersond6d63f52009-01-04 18:53:28 +000023 top = tkinter.tix.Label(w, padx=20, pady=10, bd=1, relief=tkinter.tix.RAISED,
24 anchor=tkinter.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 #
Benjamin Petersond6d63f52009-01-04 18:53:28 +000033 box = tkinter.tix.ButtonBox(w, orientation=tkinter.tix.HORIZONTAL)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000034 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())
Benjamin Petersond6d63f52009-01-04 18:53:28 +000038 box.pack(side=tkinter.tix.BOTTOM, fill=tkinter.tix.X)
39 top.pack(side=tkinter.tix.TOP, fill=tkinter.tix.BOTH, expand=1)
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000040
41if __name__ == '__main__':
Benjamin Petersond6d63f52009-01-04 18:53:28 +000042 root = tkinter.tix.Tk()
Martin v. Löwisb21cb5f2001-03-21 07:42:07 +000043 RunSample(root)
44 root.mainloop()