ยปCore Development>Code coverage>Lib/idlelib/statusbar.py

Python code coverage for Lib/idlelib/statusbar.py

#countcontent
1n/afrom tkinter import Frame, Label
2n/a
3n/a
4n/aclass MultiStatusBar(Frame):
5n/a
6n/a def __init__(self, master, **kw):
7n/a Frame.__init__(self, master, **kw)
8n/a self.labels = {}
9n/a
10n/a def set_label(self, name, text='', side='left', width=0):
11n/a if name not in self.labels:
12n/a label = Label(self, borderwidth=0, anchor='w')
13n/a label.pack(side=side, pady=0, padx=4)
14n/a self.labels[name] = label
15n/a else:
16n/a label = self.labels[name]
17n/a if width != 0:
18n/a label.config(width=width)
19n/a label.config(text=text)
20n/a
21n/a
22n/adef _multistatus_bar(parent): # htest #
23n/a from tkinter import Toplevel, Frame, Text, Button
24n/a top = Toplevel(parent)
25n/a x, y = map(int, parent.geometry().split('+')[1:])
26n/a top.geometry("+%d+%d" %(x, y + 175))
27n/a top.title("Test multistatus bar")
28n/a frame = Frame(top)
29n/a text = Text(frame, height=5, width=40)
30n/a text.pack()
31n/a msb = MultiStatusBar(frame)
32n/a msb.set_label("one", "hello")
33n/a msb.set_label("two", "world")
34n/a msb.pack(side='bottom', fill='x')
35n/a
36n/a def change():
37n/a msb.set_label("one", "foo")
38n/a msb.set_label("two", "bar")
39n/a
40n/a button = Button(top, text="Update status", command=change)
41n/a button.pack(side='bottom')
42n/a frame.pack()
43n/a
44n/aif __name__ == '__main__':
45n/a from idlelib.idle_test.htest import run
46n/a run(_multistatus_bar)