def main(): f = None args = sys.argv[1:] if args: fontsize = int(args[0]) sf = StdFonts.system_font f = Font(sf.family, fontsize, sf.style) #showfont("Using font", f) win = Window(title = "Heights") if f: kwds = {'font': f} else: kwds = {} controls = [ Label(text = "Label", **kwds), TextField(text = "Text", **kwds), CheckBox(title = "Check", **kwds), RadioButton(title = "Radio", **kwds), Slider(orient = 'h', width = 50), #Button(title = "Button", **kwds), ] #for ctl in controls: # say("Height of %r is %s" % (ctl, ctl.height)) win.place_row(controls, left = 10, top = 10) win.shrink_wrap(padding = (10, 10)) win.show() run()
def main(): f = None args = sys.argv[1:] if args: fontsize = int(args[0]) sf = StdFonts.system_font f = Font(sf.family, fontsize, sf.style) #showfont("Using font", f) win = Window(title="Heights") if f: kwds = {'font': f} else: kwds = {} controls = [ Label(text="Label", **kwds), TextField(text="Text", **kwds), CheckBox(title="Check", **kwds), RadioButton(title="Radio", **kwds), Slider(orient='h', width=50), #Button(title = "Button", **kwds), ] #for ctl in controls: # say("Height of %r is %s" % (ctl, ctl.height)) win.place_row(controls, left=10, top=10) win.shrink_wrap(padding=(10, 10)) win.show() run()
def main(): global cb1, cb2, rg win = Window(title="Place Me By Your Side", width=720, height=500) view1 = TestDrawing(width=320, height=200) cb1 = CheckBox(title="Check Me!", action=checked_it) cb2 = CheckBox(title="Check Me Too!", action=checked_it) rbs = [] for i in range(1, 4): rb = RadioButton(title="Hoopy Option %d" % i, value=i) rbs.append(rb) rg = RadioGroup(rbs, action=option_chosen) pb = Button(title="Push Me!", action=pushed_it) view2 = TestScrollableDrawing(width=300, height=300) label = Label(text="Flavour:") entry = TextField(width=200) win.place(view1, left=10, top=10, border=1) win.place_row([cb1, cb2], left=10, top=(view1, 20), spacing=20) win.place_column(rbs, left=view1 + 20, top=10) win.place(pb, right=-20, bottom=-10, anchor='rb') win.place(view2, left=rbs[0] + 20, top=10, right=-20, bottom=pb - 10, scrolling='hv', anchor='ltrb', border=1) win.place(label, left=10, top=(cb1, 20)) win.place( entry, left=10, top=(label, 10), #border = 1 ) entry.become_target() win.show() import GUI GUI.run()
def test(orient, pos, pad): win = Window(title = "%s Sliders" % orient.upper(), position = pos, auto_position = False) sliders = [] if 1: #say("Creating slider 1") sl1 = sl2 = sl3 = None sl1 = Slider(orient = orient, max_value = 100) sl1.action = slid(sl1, orient, 1) sliders.append(sl1) if 1: #say("Creating slider 2") sl2 = Slider(orient = orient, max_value = 100, ticks = 6, live = False) sl2.value = 50 sl2.action = slid(sl2, orient, 2) sliders.append(sl2) if 1: #say("Creating slider 3") sl3 = Slider(orient = orient, max_value = 100, ticks = 6, discrete = True) sl3.value = 100 sl3.action = slid(sl3, orient, 3) sliders.append(sl3) #say("Created sliders") if orient == 'h': win.place_column(sliders, left = 20, top = 20, spacing = 20, sticky = 'ew') if sl2: sl2.vstretch = True if sl3: sl3.vmove = True else: win.place_row(sliders, left = 20, top = 20, spacing = 20, sticky = 'ns') if sl2: sl2.hstretch = True if sl3: sl3.hmove = True #say("Placed sliders") win.shrink_wrap() win.show()
def __init__(self, name, **kwds): self.name = name TestScrollableDrawing.__init__(self, scrolling = 'hv', **kwds) def mouse_down(self, event): #self.become_target() TestMouseEvents.mouse_down(self, event) def report_mouse_event(self, mess): say("%s: %s" % (self.name, mess)) win = Window() view1 = TestView("View 1", width = 320, height = 200) view2 = TestScrollableView("View 2", width = 320, height = 200) win.place_row([view1, view2], left = 20, top = 20, spacing = 20) view2.hstretch = 1 view2.vstretch = 1 win.shrink_wrap(padding = (20, 20)) win.show() view1.become_target() say(""" There should be two views. The following events should be reported in either view: mouse_down, mouse_drag, mouse_up, mouse_move. The right-hand view should resize with the window. Check that mouse events are still reported correctly after resizing and after scrolling the view. """)