Coverage for statusbar.py: 16%
39 statements
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-11 13:22 -0700
« prev ^ index » next coverage.py v7.2.5, created at 2023-05-11 13:22 -0700
1from tkinter.ttk import Label, Frame
4class MultiStatusBar(Frame):
6 def __init__(self, master, **kw):
7 Frame.__init__(self, master, **kw)
8 self.labels = {}
10 def set_label(self, name, text='', side='left', width=0):
11 if name not in self.labels:
12 label = Label(self, borderwidth=0, anchor='w')
13 label.pack(side=side, pady=0, padx=4)
14 self.labels[name] = label
15 else:
16 label = self.labels[name]
17 if width != 0:
18 label.config(width=width)
19 label.config(text=text)
22def _multistatus_bar(parent): # htest #
23 from tkinter import Toplevel, Text
24 from tkinter.ttk import Frame, Button
25 top = Toplevel(parent)
26 x, y = map(int, parent.geometry().split('+')[1:])
27 top.geometry("+%d+%d" %(x, y + 175))
28 top.title("Test multistatus bar")
29 frame = Frame(top)
30 text = Text(frame, height=5, width=40)
31 text.pack()
32 msb = MultiStatusBar(frame)
33 msb.set_label("one", "hello")
34 msb.set_label("two", "world")
35 msb.pack(side='bottom', fill='x')
37 def change():
38 msb.set_label("one", "foo")
39 msb.set_label("two", "bar")
41 button = Button(top, text="Update status", command=change)
42 button.pack(side='bottom')
43 frame.pack()
45if __name__ == '__main__': 45 ↛ 46line 45 didn't jump to line 46, because the condition on line 45 was never true
46 from unittest import main
47 main('idlelib.idle_test.test_statusbar', verbosity=2, exit=False)
49 from idlelib.idle_test.htest import run
50 run(_multistatus_bar)