def make_window(self, document): window_width = 800 window_height = 600 #create a Window object and associate it with our document #so when the window is closed the doc can ask the user if #he wants to save app_window = Window(size=(window_width, window_height), document=document) #make a view for the window app_view = LineView(model=document, extent=(window_width, window_height), printable=False, cursor=self.line_cursor) #place the view in the window, make it resizeable app_window.place(app_view, left=0, top=0, right=0, bottom=0, sticky='nsew') #display the window when we are done initializing app_window.show()
def run(self): root1 = Toplevel(self.root) root1.wm_geometry("800x500") self.sender_window = Window(root1, "server") try: Thread(target=self.handle_udp_messages).start() except: print("UDP Thread did not start.") traceback.print_exc() while True: connection, client_address = self.tcp_soc.accept() self.client_list.append(client_address) self.connection_list[client_address] = connection self.sender_window.server_init_window(self.client_list) print("server: Connected with " + client_address[0] + ":" + str(client_address[1])) try: Thread(target=self.handle_tcp_messages, args=(connection, client_address)).start() except: self.sender_window.server_warning() print("TCP Thread did not start.") traceback.print_exc()
def test(): view = TestView(size=(300, 200)) win = Window(title="Coloured Text") win.add(view) win.shrink_wrap() win.show() run()
def make_window(): win = Window(size=(240, 100), title="Password") tf = TextField(position=(20, 20), width=200, password=True) ok = Button("OK", position=(20, 60), action=(show, tf)) win.add(tf) win.add(ok) win.show()
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(): win = Window() view = PolyView(width=120, height=120) win.add(view) win.shrink_wrap() win.show() application().run()
def test(): win = Window(title="Targeting", size=(180, 100)) patch1 = TestPatch("Red patch", red, position=(20, 20)) patch2 = TestPatch("Green patch", green, position=(100, 20)) win.add(patch1) win.add(patch2) win.show() application().run()
def make_window(self, document): win = Window(size=(400, 400), document=document) view = BlobView(model=document, extent=(1000, 1000), scrolling='hv', cursor=self.blob_cursor) win.place(view, left=0, top=0, right=0, bottom=0, sticky='nsew') win.show()
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 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(): 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 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(): doc = TestDoc(title="Document") view = TestDocView(model=doc, size=(200, 200)) win = Window(resizable=0, size=(200, 200)) win.add(view) win.document = doc #say(view.x, view.y, view.width, view.height) 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(): 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 make_view(db, options): pf = GLConfig(double_buffer=db) pf.alpha = "a" in options pf.depth_buffer = "d" in options pf.stencil_buffer = "s" in options pf.aux_buffers = "x" in options pf.accum_buffer = "A" in options view = TriangleView(pf, size=(200, 200)) win = Window(title="%s Buffered GLView" % ["Single", "Double"][db], size=(240, 240)) win.place(view, left=20, top=20, sticky="nsew") view.become_target() win.show()
def make_window(self, document): self.tabview = view = TabView() win = Window(size=(600, 400), document=document) self.view1 = Button(title='Item 1', action=self.item1Action) view.add_item(self.view1, title='asdfe') self.view2 = Button(title='Item 2', action=self.item2Action) view.add_item(self.view2, title="Two") win.place(view, left=0, top=0, right=0, bottom=0, sticky='nsew') 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 main(): # setup serial port port_name = '/dev/cu.usbmodem14401' # this is specific to os and which usb port it's plugged into # '/dev/cu.usbmodem14401' # '/dev/cu.usbserial-1440' baud_rate = 115200 # make sure this matches the rate specified in arduino code max_plot_length = 301 # number of points in x-axis data_num_bytes = 4 # number of bytes of 1 data point sm = SM.SerialManagement(port_name, baud_rate, max_plot_length, data_num_bytes) sm.initial_serial_read() # get temp history sm.start_serial_thread() # starts background thread # setup texting service phone_nums = ['+15156196749', '+15553710142'] # [Twilio's number, your number] Window.sending_number = phone_nums[0] Window.receiving_number = phone_nums[1] Window.max_temp = 30.0 Window.min_temp = 22.0 # setup plot plt_interval = 1000 # Period at which the plot animation update in ms xmin = 0 xmax = max_plot_length - 1 # The - 1 allows the line to touch the edge of the plot ymin = 10 ymax = 50 fig = plt.figure(figsize=(8, 6)) ax = plt.axes(xlim=(xmin, xmax), ylim=(float(ymin - (ymax - ymin) / 10), float(ymax + (ymax - ymin) / 10))) ax.invert_xaxis() ax.set_title('Temperature Sensor') ax.set_xlabel("Time (s)") ax.set_ylabel("Temperature (\u00b0C)") ax.yaxis.tick_right() ax.yaxis.set_label_position("right") line_label = "Temperature (\u00b0C)" lines = ax.plot([], [], label=line_label)[0] line_value_text = ax.text(0.50, 0.90, '', transform=ax.transAxes) plt.legend(loc="upper left") # Tkinter's GUI.py root = tkinter.Tk() Window(fig, root, sm) # Animates the plot anim = animation.FuncAnimation(fig, animate, fargs=(sm, lines, line_value_text, line_label), interval=plt_interval) root.mainloop() sm.close()
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()
def do_confirm(): say("Doing confirm") result = confirm("Attack Orpuddex?") say("Result =", result) def do_confirm_or_cancel(): say("Doing confirm_or_cancel") result = confirm_or_cancel( "Orpuddex is attacking.\nWhat is your response?", "Retaliate", "Surrender", "Run Away") say("Result =", result) win = Window(title="Alerts") rg = RadioGroup() rb = [] for kind in kinds: rb.append(RadioButton(kind.capitalize(), value=kind, group=rg)) rg.set_value('stop') pb = [ Button(title="Alert", action=do_alert), Button(title="Alert2", action=do_alert2), Button(title="Alert3", action=do_alert3), ] pb2 = [ Button("Note Alert", action=do_note_alert), Button("Stop Alert", action=do_stop_alert), Button("Ask", action=do_ask), Button("Confirm", action=do_confirm),
import sys from PyQt5.QtWidgets import QApplication from GUI import Window if __name__ == '__main__': app = QApplication(sys.argv) window = Window() window.show() #transfer the window in the GUI sys.exit(app.exec_())
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()
view = TestTableView(size=(300, 150), scrolling='hv', model=model) view.add_column(TextColumn('code', "Code", 60)) view.add_column(TextColumn('name', "Name", 100, editable=True)) #@editor = TextField())) view.add_column( TextColumn('price', "Price", 50, 'right', format="%.2f", parser=float, editable=True)) win = Window(title="Table") win.add(view) view.anchor = 'ltrb' win.shrink_wrap() view.become_target() view.selected_row_num = 0 win.show() instructions = """ There should be a window containing a table with the following columns: "Code", left justified, not editable "Name", left justified, editable "Price", right justified, format "%.2f", editable Mouse-down events should be reported together with the row number and
def setUp(self): self.main = Window() # self.main.auto_configure() self.gui = AppGUI(self.main, True)
c.forecolor = red c.fill_rect(r) r = (160, 90, 300, 180) c.forecolor = yellow c.fill_rect(r) r = (250, 200, 350, 275) c.forecolor = blue c.fill_oval(r) instructions = """ There should be a 400x300 image containing a filled red rectangle, yellow rectangle and blue oval on a cyan background, with a black frame around part of the image. The framed part should appear below in three different sizes, 150x150, 100x100 and 50x50. """ say(instructions) app = application() pixmap = Pixmap(400, 300) pixmap.with_canvas(do_test_drawing) win = Window(title="Pixmap", size=(500, 500)) view = PixmapTestView(size=win.size) win.add(view) win.show() app.run()