def test(): view = TestView(size=(300, 200)) win = Window(title="Coloured Text") win.add(view) win.shrink_wrap() win.show() run()
def main(): win = Window() view = PolyView(width=120, height=120) win.add(view) win.shrink_wrap() win.show() application().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 test(): view = TestView(size = (300, 200)) win = Window(title = "Coloured Text") win.add(view) win.shrink_wrap() 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 test(): win = Window(title = "Exceptions", size = (200, 100)) but1 = Button("ApplicationError", action = raise_application_error) but2 = Button("Exception", action = raise_exception) win.place_column([but1, but2], left = 20, top = 20) win.shrink_wrap(padding = (20, 20)) win.show() application().run()
def test(): view = GearsView(size = (300, 300)) win = Window(title = "Gears") win.place(view, sticky = "nsew") view.become_target() win.shrink_wrap() win.show() application().run()
def test(): win = Window(title="Exceptions", size=(200, 100)) but1 = Button("ApplicationError", action=raise_application_error) but2 = Button("Exception", action=raise_exception) win.place_column([but1, but2], left=20, top=20) win.shrink_wrap(padding=(20, 20)) win.show() application().run()
def test(): win = Window(title="Frame") frm = Frame() frm.place_column([Label("This is"), Label("A frame")], left=0, top=0) frm.shrink_wrap() win.place(frm, left=30, top=30) win.shrink_wrap(padding=(30, 30)) win.show()
def test(): starter = Button("Start", action = start_task) stopper = Button("Stop", action = stop_task) win = Window(title = "Tasks") win.place_column([starter, stopper], left = 20, top = 20, spacing = 20) win.shrink_wrap(padding = (20, 20)) win.show() application().run()
def test(): view = GearsView(size=(300, 300)) win = Window(title="Gears") win.place(view, sticky="nsew") view.become_target() win.shrink_wrap() win.show() application().run()
def test(): starter = Button("Start", action=start_task) stopper = Button("Stop", action=stop_task) win = Window(title="Tasks") win.place_column([starter, stopper], left=20, top=20, spacing=20) win.shrink_wrap(padding=(20, 20)) win.show() application().run()
def main(): view = CTV(size=(200, 300)) win = Window(title="Canvas") win.add(view) win.shrink_wrap() view.become_target() win.show() app = application() app.menus = basic_menus() + [test_menu] app.run()
def test(): win = Window(title = "Frame") frm = Frame() frm.place_column([ Label("This is"), Label("A frame")], left = 0, top = 0) frm.shrink_wrap() win.place(frm, left = 30, top = 30) win.shrink_wrap(padding = (30, 30)) win.show()
def test(): cursor = StdCursors.finger win = Window(title = "Cursor", width = 500, height = 400) view1 = TestDrawing(position = (20, 20), size = (100, 70), cursor = cursor) view2 = TestScrollableView(position = (140, 20), size = (200, 200), scrolling = 'hv') view2.cursor = cursor win.add(view1) win.place(view2, sticky = 'nsew') win.shrink_wrap((20, 20)) win.show()
def test(): app = application() pixmap = GLPixmap(50, 50, double_buffer=False, alpha=False) pixmap.with_context(draw_triangle, flush=True) #pixmap.with_canvas(draw_circle) view = PixmapTestView(pixmap, size=(180, 200)) win = Window(title="GLPixmap", resizable=False) win.add(view) win.shrink_wrap() win.show() app.run()
def test(): app = application() pixmap = GLPixmap(50, 50, double_buffer = False, alpha = False) pixmap.with_context(draw_triangle, flush = True) #pixmap.with_canvas(draw_circle) view = PixmapTestView(pixmap, size = (180, 200)) win = Window(title = "GLPixmap", resizable = False) win.add(view) win.shrink_wrap() win.show() app.run()
def test(): cursor = StdCursors.finger win = Window(title="Cursor", width=500, height=400) view1 = TestDrawing(position=(20, 20), size=(100, 70), cursor=cursor) view2 = TestScrollableView(position=(140, 20), size=(200, 200), scrolling='hv') view2.cursor = cursor win.add(view1) win.place(view2, sticky='nsew') win.shrink_wrap((20, 20)) win.show()
def test(): file = "grail_masked.tiff" # file = "spam_masked.tiff" image = Image(os.path.join(sys.path[0], file)) cursor = Cursor(image) win = Window(title="Image Cursor", width=500, height=400) view1 = TestDrawing(position=(20, 20), size=(100, 70), cursor=cursor) view2 = TestScrollableView(position=(140, 20), size=(200, 200), scrolling="hv") view2.cursor = cursor win.add(view1) win.place(view2, sticky="nsew") win.shrink_wrap((20, 20)) win.show()
def test(): def bing(): say("Bing!") #fld._win_dump_flags() win = Window(title = "Shrink Wrap", resizable = 0) but = Button("Bing!", action = bing) cbx = CheckBox("Spam") fld = TextField(width = 100) win.place(but, left = 20, top = 20) win.place(cbx, left = but + 20, top = 20) win.place(fld, left = 20, top = but + 20) win.shrink_wrap() win.show() application().run()
def test(): file = "grail_masked.tiff" #file = "spam_masked.tiff" image = Image(os.path.join(sys.path[0], file)) cursor = Cursor(image) win = Window(title = "Image Cursor", width = 500, height = 400) view1 = TestDrawing(position = (20, 20), size = (100, 70), cursor = cursor) view2 = TestScrollableView(position = (140, 20), size = (200, 200), scrolling = 'hv') view2.cursor = cursor win.add(view1) win.place(view2, sticky = 'nsew') win.shrink_wrap((20, 20)) win.show()
def test(): def select(): i = group.value name = cursor_names[i] say("Selecting cursor no. %d (%s)" % (i, name)) cursor = getattr(StdCursors, name) say("...", cursor) view.cursor = cursor win = Window(title = "Std Cursors") view = TestArea(size = (100, 100)) win.place(view, left = 20, top = 20) group = RadioGroup(action = select) for i, name in enumerate(cursor_names): group.add_item(RadioButton(title = name, value = i)) win.place_column(group, left = view + 20, top = 20, spacing = 0) win.shrink_wrap((20, 20)) win.show() application().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()
if button == Mouse.Right: self.xxmin, self.xxmax = self.gwidget.zoomout( self.xxmin, self.xxmax, self._xmin, self._xmax) self.yymin, self.yymax = self.gwidget.zoomout( self.yymin, self.yymax, self._ymin, self._ymax) else: self.xxmin, self.xxmax, self.yymin, self.yymax = self._xmin, self._xmax, self._ymin, self._ymax self.gwidget.zoom(self.xxmin, self.xxmax, self.yymin, self.yymax) self.gwidget.make_data_list() self.gwidget.updateGL() self.px, self.py = None, None ############################################################################## view = GLGraphWidget(size=(300, 300)) win = Window(title="Gears") win.place(view, sticky="nsew") view.become_target() win.shrink_wrap() win.show() application().run() # app=QApplication(sys.argv) # g = glGraph() # app.setMainWidget(g.win) # g.win.show() # app.exec_loop()
for align in ['t', 'c', 'b']: row = make_row(align) rows.append([row, "align = '%s'" % align]) row = Row([Button("Buckle"), Button("My"), Button("Shoe")], equalize = 'w') rows.append([row, "equalize = 'w'"]) y = 50 for row, title in rows: row.position = (10, 10) row.anchor = 'ltrb' win = Window(title = title, position = (10, y), auto_position = False) win.add(row) win.shrink_wrap() win.show() y = win.bottom + 50 instructions = """ Check that the text field in the first three rows expands horizontally when the window is resized. Check that the components in the third row are anchored to the bottom of the window. The buttons in the fourth row should all be the same width. """ say(instructions) app = application()
def make_window(self, document): win = Window(size=(700, 500), document=document) panel = Frame(width=170) def crop_action(): if view.selection is None: view.setselection(shrink_rect(view.viewrect, 0.8)) return croprect = view.pdfcoord(view.selection) #print 'view: %s, crop: %s' % (view.selection, croprect) view.model.crop(view.pagenum, croprect) view.selection = None view.set_status(selection=None) hide(view.crop_button) crop_button = Button(title='Crop', visible=True, action=crop_action) status = Label(text='\n\n\n\n') view = PDFView(pagenum=0, model=document, scrolling='hv', status=status, cursor=crosshair, crop_button=crop_button) #view = PDFView(... extent=(1000, 1000), cursor = self.blob_cursor) def page_changer(delta): def change(): np = win.document.numpages view.pagenum += delta if view.pagenum <= 0: view.pagenum = 0 prevpage.enabled = False else: prevpage.enabled = True if view.pagenum >= np - 1: view.pagenum = np - 1 nextpage.enabled = False else: nextpage.enabled = True page.text = '%s / %s' % (view.pagenum+1, np) view.invalidate() return change prevpage = Button(title='<', action=page_changer(-1)) nextpage = Button(title='>', action=page_changer(+1)) page = Label(just='center', anchor='b') page_changer(0)() panel.place(prevpage, top=5, left=5, sticky='w') panel.place(nextpage, top=5, right=-5, sticky='e') panel.place(page, bottom=prevpage.bottom, left=prevpage, right=nextpage, sticky='ew') panel.place(status, left=5, top=prevpage+5, right=0, sticky='ew') panel.place(crop_button, left=5, top=status, right=-5, sticky='ew') win.place(panel, left=0, top=0, bottom=0, sticky='nsw') win.place(view, left=panel, top=0, right=0, bottom=0, sticky='nsew') win.shrink_wrap() win.show()
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. """) application().run()