David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 1 | from Tkinter import * |
| 2 | |
| 3 | class MultiStatusBar(Frame): |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 4 | |
Kurt B. Kaiser | 8220fdd | 2001-07-13 17:52:08 +0000 | [diff] [blame] | 5 | def __init__(self, master=None, **kw): |
| 6 | if master is None: |
| 7 | master = Tk() |
| 8 | apply(Frame.__init__, (self, master), kw) |
| 9 | self.labels = {} |
| 10 | |
| 11 | def set_label(self, name, text='', side=LEFT): |
| 12 | if not self.labels.has_key(name): |
| 13 | label = Label(self, bd=1, relief=SUNKEN, anchor=W) |
| 14 | label.pack(side=side) |
| 15 | self.labels[name] = label |
| 16 | else: |
| 17 | label = self.labels[name] |
| 18 | label.config(text=text) |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 19 | |
| 20 | def _test(): |
Kurt B. Kaiser | 8220fdd | 2001-07-13 17:52:08 +0000 | [diff] [blame] | 21 | b = Frame() |
| 22 | c = Text(b) |
| 23 | c.pack(side=TOP) |
| 24 | a = MultiStatusBar(b) |
| 25 | a.set_label("one", "hello") |
| 26 | a.set_label("two", "world") |
| 27 | a.pack(side=BOTTOM, fill=X) |
| 28 | b.pack() |
| 29 | b.mainloop() |
David Scherer | 7aced17 | 2000-08-15 01:13:23 +0000 | [diff] [blame] | 30 | |
| 31 | if __name__ == '__main__': |
Kurt B. Kaiser | 8220fdd | 2001-07-13 17:52:08 +0000 | [diff] [blame] | 32 | _test() |