annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/idlelib/statusbar.py @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 from tkinter import Frame, Label
jpayne@68 2
jpayne@68 3
jpayne@68 4 class MultiStatusBar(Frame):
jpayne@68 5
jpayne@68 6 def __init__(self, master, **kw):
jpayne@68 7 Frame.__init__(self, master, **kw)
jpayne@68 8 self.labels = {}
jpayne@68 9
jpayne@68 10 def set_label(self, name, text='', side='left', width=0):
jpayne@68 11 if name not in self.labels:
jpayne@68 12 label = Label(self, borderwidth=0, anchor='w')
jpayne@68 13 label.pack(side=side, pady=0, padx=4)
jpayne@68 14 self.labels[name] = label
jpayne@68 15 else:
jpayne@68 16 label = self.labels[name]
jpayne@68 17 if width != 0:
jpayne@68 18 label.config(width=width)
jpayne@68 19 label.config(text=text)
jpayne@68 20
jpayne@68 21
jpayne@68 22 def _multistatus_bar(parent): # htest #
jpayne@68 23 from tkinter import Toplevel, Frame, Text, Button
jpayne@68 24 top = Toplevel(parent)
jpayne@68 25 x, y = map(int, parent.geometry().split('+')[1:])
jpayne@68 26 top.geometry("+%d+%d" %(x, y + 175))
jpayne@68 27 top.title("Test multistatus bar")
jpayne@68 28 frame = Frame(top)
jpayne@68 29 text = Text(frame, height=5, width=40)
jpayne@68 30 text.pack()
jpayne@68 31 msb = MultiStatusBar(frame)
jpayne@68 32 msb.set_label("one", "hello")
jpayne@68 33 msb.set_label("two", "world")
jpayne@68 34 msb.pack(side='bottom', fill='x')
jpayne@68 35
jpayne@68 36 def change():
jpayne@68 37 msb.set_label("one", "foo")
jpayne@68 38 msb.set_label("two", "bar")
jpayne@68 39
jpayne@68 40 button = Button(top, text="Update status", command=change)
jpayne@68 41 button.pack(side='bottom')
jpayne@68 42 frame.pack()
jpayne@68 43
jpayne@68 44 if __name__ == '__main__':
jpayne@68 45 from unittest import main
jpayne@68 46 main('idlelib.idle_test.test_statusbar', verbosity=2, exit=False)
jpayne@68 47
jpayne@68 48 from idlelib.idle_test.htest import run
jpayne@68 49 run(_multistatus_bar)