1
# This module is part of the Divmod project and is Copyright 2003 Amir Bakhtiar:
2
# amir@divmod.org. This is free software; you can redistribute it and/or
3
# modify it under the terms of version 2.1 of the GNU Lesser General Public
4
# License as published by the Free Software Foundation.
9
class StatusBar(Frame):
10
"""Courtesy of Fredrik Lundh.
13
def __init__(self, master):
14
Frame.__init__(self, master)
15
self.label = Label(self, bd=1, relief=SUNKEN, anchor=W)
16
self.label.pack(fill=X)
18
def set(self, format, *args):
19
self.label.config(text=format % args)
20
self.label.update_idletasks()
23
self.label.config(text="")
24
self.label.update_idletasks()
26
def log(self, text, clear=0):
27
# Clear after clear seconds
30
self.label.after(clear * 1000, self.clear)
34
"""Courtesy of Danny Yoo
35
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66521
37
def __init__(self, callback, *args, **kwargs):
38
self.callback = callback
43
return apply(self.callback, self.args, self.kwargs)
46
"""Courtesy of Iuri Wickert
47
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/188537
50
# initialization. receives the master widget
51
# reference and the notebook orientation
52
def __init__(self, master, side=LEFT):
55
self.choice = IntVar(0)
57
# allows the TOP and BOTTOM
58
# radiobuttons' positioning.
59
if side in (TOP, BOTTOM):
64
# creates notebook's frames structure
65
self.rb_fr = Frame(master, borderwidth=2, relief=RIDGE)
66
self.rb_fr.pack(side=side, fill=BOTH)
67
self.screen_fr = Frame(master, borderwidth=2, relief=RIDGE)
68
self.screen_fr.pack(fill=BOTH)
71
# return a master frame reference for the external frames (screens)
76
# add a new frame (screen) to the (bottom/left of the) notebook
77
def add_screen(self, fr, title):
78
b = Radiobutton(self.rb_fr, text=title, indicatoron=0, \
79
variable=self.choice, value=self.count, \
80
command=lambda: self.display(fr))
81
b.pack(fill=BOTH, side=self.side)
83
# ensures the first frame will be
84
# the first selected/enabled
85
if not self.active_fr:
86
fr.pack(fill=BOTH, expand=1)
92
# hides the former active frame and shows
93
# another one, keeping its reference
94
def display(self, fr):
95
self.active_fr.forget()
96
fr.pack(fill=BOTH, expand=1)