PageRenderTime 354ms CodeModel.GetById 171ms app.highlight 5ms RepoModel.GetById 176ms app.codeStats 1ms

/Lib/idlelib/MultiStatusBar.py

http://unladen-swallow.googlecode.com/
Python | 32 lines | 29 code | 3 blank | 0 comment | 1 complexity | 81aec1be451fd3b0cea4165fa6aea390 MD5 | raw file
 1from Tkinter import *
 2
 3class MultiStatusBar(Frame):
 4
 5    def __init__(self, master=None, **kw):
 6        if master is None:
 7            master = Tk()
 8        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)
19
20def _test():
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()
30
31if __name__ == '__main__':
32    _test()