def run_setup(): global arm if arm is None: try: arm = roboarm.Arm() except Exception as e: print e gui.message_box(message="No arm found, please connect") else: make_buttons(arm) tingbot.screen.fill("black") gui.get_root_widget().update(downwards=True)
import time tingbot.screen.fill("black") current_button = gui.ToggleButton((10,0),NOTEBOOK_BUTTON_SIZE,align="topleft",label="Current") current_panel = current.CurrentPanel() current_panel.visible = False playlist_button = gui.ToggleButton((160,0),NOTEBOOK_BUTTON_SIZE,align="top",label="Playlist") playlist_panel = playlist.PlaylistPanel(current_panel) lib_button = gui.ToggleButton((310,0),NOTEBOOK_BUTTON_SIZE,align="topright",label="Library") lib_panel = library.LibraryPanel(playlist_panel) nb = gui.NoteBook([(lib_button,lib_panel),(playlist_button,playlist_panel),(current_button,current_panel)]) gui.get_root_widget().update(downwards=True) #set up twisted def setUp(): control_point = ControlPoint(Coherence({'logmode':'warning'}), auto_client=['MediaRenderer', 'MediaServer']) control_point.connect(lib_panel.add_library, 'Coherence.UPnP.ControlPoint.MediaServer.detected') control_point.connect(current_panel.add_renderer, 'Coherence.UPnP.ControlPoint.MediaRenderer.detected') from twisted.internet import reactor reactor.callWhenRunning(setUp) reactor.interleave(tingbot.main_run_loop.callAfter) try: tingbot.run() finally: print "closing server"
def remove_all(): cb("Remove dynamic items",'all') scroller.scrolled_area.remove_all() scroller.resize_canvas((135,10)) button_list[:] = [] scroller.update(downwards=True) gui.Button((0,0),(90,25),align="topleft",parent=dynamic_panel, label="Add item",callback=add_item) gui.Button((0,30),(90,25),align="topleft",parent=dynamic_panel, label="Del last",callback=remove_last_item) gui.Button((0,60),(90,25),align="topleft",parent=dynamic_panel, label="Del all",callback=remove_all) def nb_cb(button,panel): print "Notebook panel changed: " +button.label notebook_panels = [basic_panel,slider_panel,text_panel, button_panel,dialog_panel,dynamic_panel] nb = gui.NoteBook(zip(notebook_buttons,notebook_panels),callback = nb_cb) print "Current notebook tab: " + nb.selected.label gui.get_root_widget().fill(notebook_style.bg_color) gui.show_all() def loop(): pass run(loop)
def remove_all(): cb("Remove dynamic items", "all") scroller.scrolled_area.remove_all() scroller.resize_canvas((135, 10)) button_list[:] = [] scroller.update(downwards=True) gui.Button((0, 0), (90, 25), align="topleft", parent=dynamic_panel, label="Add item", callback=add_item) gui.Button((0, 30), (90, 25), align="topleft", parent=dynamic_panel, label="Del last", callback=remove_last_item) gui.Button((0, 60), (90, 25), align="topleft", parent=dynamic_panel, label="Del all", callback=remove_all) def nb_cb(button, panel): print "Notebook panel changed: " + button.label notebook_panels = [basic_panel, slider_panel, text_panel, button_panel, dialog_panel, dynamic_panel] nb = gui.NoteBook(zip(notebook_buttons, notebook_panels), callback=nb_cb) print "Current notebook tab: " + nb.selected.label gui.get_root_widget().fill(notebook_style.bg_color) gui.show_all() def loop(): pass run(loop)