def __init__(self, title=None, show_vars=False, menu_enabled=True, server=False, port=7777, fullscreen=False): Gtk.Window.__init__(self) DrawQueueSink.__init__(self) GtkInputDeviceMixin.__init__(self) if os.path.isfile(ICON_FILE): self.set_icon_from_file(ICON_FILE) self.menu_enabled = menu_enabled self.has_server = server self.serverport = port self.show_vars = show_vars self.var_window = None self.is_fullscreen = False sb_widget = ShoebotWidget(input_device=self) self.title = title if title: self.set_title(title) if fullscreen: self.is_fullscreen = True self.fullscreen() self.connect("delete-event", self.do_window_close) self.sb_widget = sb_widget self.attach_gtk(self) self.uimanager = Gtk.UIManager() accelgroup = self.uimanager.get_accel_group() self.add_accel_group(accelgroup) self.action_group = Gtk.ActionGroup('Canvas') self.action_group.add_actions([ ('Save as', None, _('_Save as')), ('svg', 'Save as SVG', _('Save as _SVG'), "<Control>1", None, self.snapshot_svg), ('pdf', 'Save as PDF', _('Save as _PDF'), "<Control>2", None, self.snapshot_pdf), ('ps', 'Save as PS', _('Save as P_S'), "<Control>3", None, self.snapshot_ps), ('png', 'Save as PNG', _('Save as P_NG'), "<Control>4", None, self.snapshot_png), ('close', 'Close window', _('_Close Window'), "<Control>w", None, self.do_window_close) ]) self.action_group.add_toggle_actions([ ('vars', 'Variables Window', _('Va_riables Window'), "<Control>r", None, self.do_toggle_variables, self.show_vars), ('fullscreen', 'Fullscreen', _('_Fullscreen'), "<Control>f", None, self.do_toggle_fullscreen, False), ('play', 'Play', _('_Play'), "<Alt>p", None, self.do_toggle_play, True), ]) menuxml = ''' <popup action="Save as"> <menuitem action="play"/> <menuitem action="vars"/> <menuitem action="fullscreen"/> <separator/> <menuitem action="svg"/> <menuitem action="ps"/> <menuitem action="pdf"/> <menuitem action="png"/> <separator/> <separator/> <menuitem action="close"/> </popup> ''' self.uimanager.insert_action_group(self.action_group, 0) self.uimanager.add_ui_from_string(menuxml) sb_widget.show() self.add(sb_widget) self.present() self.scheduled_snapshots = deque() while Gtk.events_pending(): Gtk.main_iteration() self.window_open = True self.pause_speed = None # TODO - factor out bot controller stuff self.last_draw_ctx = None # Need this to save snapshots after frame is drawn
def __init__( self, title=None, show_vars=False, menu_enabled=True, server=False, port=7777, fullscreen=False, outputfile=None, ): Gtk.Window.__init__(self) DrawQueueSink.__init__(self) GtkInputDeviceMixin.__init__(self) if os.path.isfile(ICON_FILE): self.set_icon_from_file(ICON_FILE) self.menu_enabled = menu_enabled self.has_server = server self.serverport = port self.show_vars = show_vars self.var_window = None self.is_fullscreen = False sb_widget = ShoebotWidget(input_device=self) self.title = title if title: self.set_title(title) if fullscreen: self.is_fullscreen = True self.fullscreen() self.connect("delete-event", self.do_window_close) self.sb_widget = sb_widget self.attach_gtk(self) self.uimanager = Gtk.UIManager() accelgroup = self.uimanager.get_accel_group() self.add_accel_group(accelgroup) self.action_group = Gtk.ActionGroup(name="Canvas") self.action_group.add_actions([ ("Save as", None, _("_Save as")), ( "svg", "Save as SVG", _("Save as _SVG"), "<Control>1", None, self.snapshot_svg, ), ( "pdf", "Save as PDF", _("Save as _PDF"), "<Control>2", None, self.snapshot_pdf, ), ( "ps", "Save as PS", _("Save as P_S"), "<Control>3", None, self.snapshot_ps, ), ( "png", "Save as PNG", _("Save as P_NG"), "<Control>4", None, self.snapshot_png, ), ( "close", "Close window", _("_Close Window"), "<Control>w", None, self.do_window_close, ), ]) self.action_group.add_toggle_actions([ ( "vars", "Variables Window", _("Va_riables Window"), "<Control>r", None, self.do_toggle_variables, self.show_vars, ), ( "fullscreen", "Fullscreen", _("_Fullscreen"), "<Control>f", None, self.do_toggle_fullscreen, False, ), ("play", "Play", _("_Play"), "<Alt>p", None, self.do_toggle_play, True), ]) menuxml = """ <popup action="Save as"> <menuitem action="play"/> <menuitem action="vars"/> <menuitem action="fullscreen"/> <separator/> <menuitem action="svg"/> <menuitem action="ps"/> <menuitem action="pdf"/> <menuitem action="png"/> <separator/> <separator/> <menuitem action="close"/> </popup> """ self.uimanager.insert_action_group(self.action_group, 0) self.uimanager.add_ui_from_string(menuxml) sb_widget.show() self.add(sb_widget) self.present() self.pending_snapshots = [ ] # list of filenames to save after rendering. if outputfile: # The test harness uses this to get the gui to output an image, otherwise it may not make much sense # to have an output file with a GUI window ? self.pending_snapshots.append(outputfile) while Gtk.events_pending(): Gtk.main_iteration() self.window_open = True self.pause_speed = None # TODO - factor out bot controller stuff
def __init__(self, title = None, show_vars = False, menu_enabled = True, server=False, port=7777, fullscreen=False): Gtk.Window.__init__(self) DrawQueueSink.__init__(self) GtkInputDeviceMixin.__init__(self) if os.path.isfile(ICON_FILE): self.set_icon_from_file( ICON_FILE ) self.menu_enabled = menu_enabled self.has_server = server self.serverport = port self.show_vars = show_vars self.var_window = None self.is_fullscreen = False sb_widget = ShoebotWidget(input_device=self) self.title = title if title: self.set_title(title) if fullscreen: self.is_fullscreen = True self.fullscreen() self.connect("delete-event", self.do_window_close) #self.connect("destroy", ) self.sb_widget = sb_widget self.attach_gtk(self) self.uimanager = Gtk.UIManager() accelgroup = self.uimanager.get_accel_group() self.add_accel_group(accelgroup) self.action_group = Gtk.ActionGroup('Canvas') self.action_group.add_actions([('Save as', None, _('_Save as')), ('svg', 'Save as SVG', _('Save as _SVG'), "<Control>1", None, self.snapshot_svg), ('pdf', 'Save as PDF', _('Save as _PDF'), "<Control>2", None, self.snapshot_pdf), ('ps', 'Save as PS', _('Save as P_S'), "<Control>3", None, self.snapshot_ps), ('png', 'Save as PNG', _('Save as P_NG'), "<Control>4", None, self.snapshot_png), ('close', 'Close window', _('_Close Window'), "<Control>w", None, self.do_window_close) ]) self.action_group.add_toggle_actions([ ('vars', 'Variables Window', _('Va_riables Window'), "<Control>r", None, self.do_toggle_variables, self.show_vars), ('fullscreen', 'Fullscreen', _('_Fullscreen'), "<Control>f", None, self.do_toggle_fullscreen, False), ('play', 'Play', _('_Play'), "<Alt>p", None, self.do_toggle_play, True), ]) menuxml = ''' <popup action="Save as"> <menuitem action="play"/> <menuitem action="vars"/> <menuitem action="fullscreen"/> <separator/> <menuitem action="svg"/> <menuitem action="ps"/> <menuitem action="pdf"/> <menuitem action="png"/> <separator/> <separator/> <menuitem action="close"/> </popup> ''' self.uimanager.insert_action_group(self.action_group, 0) self.uimanager.add_ui_from_string(menuxml) sb_widget.show() self.add(sb_widget) self.present() self.scheduled_snapshots = deque() while Gtk.events_pending(): Gtk.main_iteration() if server: self.server('', self.serverport) self.window_open = True self.pause_speed = None # TODO - factor out bot controller stuff
def __init__(self, title = None, show_vars = False, menu_enabled = True, server=False, port=7777, go_fullscreen=False): gtk.Window.__init__(self) DrawQueueSink.__init__(self) GtkInputDeviceMixin.__init__(self) self.menu_enabled = menu_enabled self.has_server = server self.serverport = port self.show_vars = show_vars self.var_window = None sb_widget = ShoebotWidget() if title: self.set_title(title) self.connect("delete-event", self.do_window_close) #self.connect("destroy", ) self.sb_widget = sb_widget self.attach_gtk(self) self.uimanager = gtk.UIManager() accelgroup = self.uimanager.get_accel_group() self.add_accel_group(accelgroup) actiongroup = gtk.ActionGroup('Canvas') actiongroup.add_actions([('Save as', None, _('_Save as')), ('svg', 'Save as SVG', _('Save as _SVG'), "<Control>1", None, self.snapshot_svg), ('pdf', 'Save as PDF', _('Save as _PDF'), "<Control>2", None, self.snapshot_pdf), ('ps', 'Save as PS', _('Save as P_S'), "<Control>3", None, self.snapshot_ps), ('png', 'Save as PNG', _('Save as P_NG'), "<Control>4", None, self.snapshot_png), ('fullscreen', 'Go fullscreen', _('_Go fullscreen'), "<Control>5", None, self.do_fullscreen), ('unfullscreen', 'Exit fullscreen', _('_Exit fullscreen'), "<Control>6", None, self.do_unfullscreen), ('close', 'Close window', _('_Close Window'), "<Control>w", None, self.do_window_close) ]) menuxml = ''' <popup action="Save as"> <menuitem action="svg"/> <menuitem action="ps"/> <menuitem action="pdf"/> <menuitem action="png"/> <separator/> <menuitem action="fullscreen"/> <menuitem action="unfullscreen"/> <separator/> <menuitem action="close"/> </popup> ''' self.uimanager.insert_action_group(actiongroup, 0) self.uimanager.add_ui_from_string(menuxml) sb_widget.show() self.add(sb_widget) self.present() self.scheduled_snapshots = deque() while gtk.events_pending(): gtk.main_iteration() if server: self.server('', self.serverport) self.window_open = True
def __init__(self, title=None, show_vars=False, menu_enabled=True, server=False, port=7777, go_fullscreen=False): gtk.Window.__init__(self) DrawQueueSink.__init__(self) GtkInputDeviceMixin.__init__(self) self.menu_enabled = menu_enabled self.has_server = server self.serverport = port self.show_vars = show_vars self.var_window = None sb_widget = ShoebotWidget() if title: self.set_title(title) self.connect("delete-event", self.do_window_close) #self.connect("destroy", ) self.sb_widget = sb_widget self.attach_gtk(self) self.uimanager = gtk.UIManager() accelgroup = self.uimanager.get_accel_group() self.add_accel_group(accelgroup) actiongroup = gtk.ActionGroup('Canvas') actiongroup.add_actions([ ('Save as', None, _('_Save as')), ('svg', 'Save as SVG', _('Save as _SVG'), "<Control>1", None, self.snapshot_svg), ('pdf', 'Save as PDF', _('Save as _PDF'), "<Control>2", None, self.snapshot_pdf), ('ps', 'Save as PS', _('Save as P_S'), "<Control>3", None, self.snapshot_ps), ('png', 'Save as PNG', _('Save as P_NG'), "<Control>4", None, self.snapshot_png), ('fullscreen', 'Go fullscreen', _('_Go fullscreen'), "<Control>5", None, self.do_fullscreen), ('unfullscreen', 'Exit fullscreen', _('_Exit fullscreen'), "<Control>6", None, self.do_unfullscreen), ('close', 'Close window', _('_Close Window'), "<Control>w", None, self.do_window_close) ]) menuxml = ''' <popup action="Save as"> <menuitem action="svg"/> <menuitem action="ps"/> <menuitem action="pdf"/> <menuitem action="png"/> <separator/> <menuitem action="fullscreen"/> <menuitem action="unfullscreen"/> <separator/> <menuitem action="close"/> </popup> ''' self.uimanager.insert_action_group(actiongroup, 0) self.uimanager.add_ui_from_string(menuxml) sb_widget.show() self.add(sb_widget) self.present() self.scheduled_snapshots = deque() while gtk.events_pending(): gtk.main_iteration() if server: self.server('', self.serverport) self.window_open = True