Color strings are also printed to the stdout stream (the console window); run this on
your computer to experiment with available color settings:
C:\...\PP4E\Gui\Tour> python setcolor.py
#0080c0
#408080
#77d5df
Other standard dialog calls
We’ve seen most of the standard dialogs and we’ll use these pop ups in examples
throughout the rest of this book. But for more details on other calls and options avail-
able, either consult other tkinter documentation or browse the source code of the
modules used at the top of the dialogTable module in Example 8-8; all are simple
Python files installed in the tkinter subdirectory of the Python source library on your
machine (e.g., in C:\Python31\Lib on Windows). And keep this demo bar example filed
away for future reference; we’ll reuse it later in the tour for callback actions when we
meet other button-like widgets.
The Old-Style Dialog Module
In older Python code, you may see dialogs occasionally coded with the standard tkinter
dialog module. This is a bit dated now, and it uses an X Windows look-and-feel; but
just in case you run across such code in your Python maintenance excursions, Exam-
ple 8-12 gives you a feel for the interface.
Example 8-12. PP4E\Gui\Tour\dlg-old.py
from tkinter import *
from tkinter.dialog import Dialog
class OldDialogDemo(Frame):
def init(self, master=None):
Frame.init(self, master)
Pack.config(self) # same as self.pack()
Button(self, text='Pop1', command=self.dialog1).pack()
Button(self, text='Pop2', command=self.dialog2).pack()
def dialog1(self):
ans = Dialog(self,
title = 'Popup Fun!',
text = 'An example of a popup-dialog '
'box, using older "Dialog.py".',
bitmap = 'questhead',
default = 0, strings = ('Yes', 'No', 'Cancel'))
if ans.num == 0: self.dialog2()
def dialog2(self):
Dialog(self, title = 'HAL-9000',
text = "I'm afraid I can't let you do that, Dave...",
bitmap = 'hourglass',
438 | Chapter 8: A tkinter Tour, Part 1