def __init__(self, handle): Activity.__init__(self, handle) self.add_events(Gdk.EventMask.POINTER_MOTION_MASK) self.connect("motion-notify-event", lambda w, e: self.look_at((e.x, e.y))) self._setup_toolbar() box = Gtk.HBox() self.set_canvas(box) screen = Gdk.Screen.get_default() rw = screen.get_width() / 2 rh = screen.get_height() / 2 self.eye1 = eyes.Eye(Gdk.Color.parse("#FFFFFF")[1]) self.eye1.set_size_request(rw, rh) self.eye1.set_hexpand(False) box.pack_start(self.eye1, True, True, 0) self.eye2 = eyes.Eye(Gdk.Color.parse("#FFFFFF")[1]) self.eye2.set_size_request(rw, rh) self.eye2.set_hexpand(False) box.pack_start(self.eye2, True, True, 0) self.show_all()
def __init__(self, handle): Activity.__init__(self, handle) logger.debug('Starting Jigsaw Puzzle activity... %s' % str(get_bundle_path())) os.chdir(get_bundle_path()) self.connect('destroy', self._destroy_cb) toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) activity_button.show() separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) toolbar_box.show() self.ui = JigsawPuzzleUI(self) self.set_canvas(self.ui) self.show_all() TubeHelper.__init__(self, tube_class=GameTube, service=SERVICE)
def __init__(self, handle): Activity.__init__(self, handle) # Self-Enforced max_participants self.max_participants = SUGAR_MAX_PARTICIPANTS # Prepare Storage Components self.network_stack = None self.gstreamer_stack = None # Set Owner self.owner = presenceservice.get_instance().get_owner() # Setup GUI logger.debug("Preparing GUI") self.set_canvas(Gui(self)) # Setup GStreamer Stack logger.debug("Setting up GSTStack") self.gststack = GSTStack() self.get_canvas().set_gstreamer_stack(self.gststack); # Setup Network Stack logger.debug("Connect Event to Setup Network Stack on Demand") self.establish_activity_sharing(handle)
def __init__(self, handle): Activity.__init__(self, handle) toolbarbox = toolbarbox.MBToolbarBox() self.set_toolbar_box(toolbarbox) self.show_all()
def __init__(self, handle): Activity.__init__(self, handle) # Self-Enforced max_participants self.max_participants = SUGAR_MAX_PARTICIPANTS # Prepare Storage Components self.network_stack = None self.gstreamer_stack = None # Set Owner self.owner = presenceservice.get_instance().get_owner() """ Setup GUI """ logger.debug("Preparing GUI") self.set_canvas(Gui(self)) """ Setup GSTStack """ logger.debug("Setting up GSTStack") self.gststack = GSTStack() self.get_canvas().set_gstreamer_stack(self.gststack); """ Setup Network Stack """ logger.debug("Connect Event to Setup Network Stack on Demand") self.establish_activity_sharing(handle)
def __init__(self, handle): Activity.__init__(self, handle) # Self-Enforced max_participants self.max_participants = 2 # Revise logical checks to shared_activity flags and remove these: if self.shared_activity: self.sent_ip = 1 else: self.sent_ip = 2 ########### # Setup Gui ########### self.set_canvas(Gui(self)) ##################### # Setup Network Stack ##################### # self.netstack = NetworkStack(self) # self._sh_hnd = self.connect('shared', self.netstack.shared_cb) # self._jo_hnd = self.connect('joined', self.netstack.joined_cb) ################# # Setup Pipeline ################# print "Setting up GStreamer" self.gststack = GSTStack(self.get_canvas().render_preview, self.get_canvas().render_incoming) self.gststack.build_preview() self.gststack.build_incoming_pipeline() GObject.idle_add(self.gststack.start_stop_incoming_pipeline, True)
def __init__(self, handle): Activity.__init__(self, handle) self.init_vars() self.build_toolbar() self.actividad = conozco.Conozco(self) self.build_canvas() self.run_canvas() self.show_all()
def __init__(self, handle): Activity.__init__(self, handle) self.socket = Gtk.Socket() self.set_canvas(self.socket) self.interfaz = Interfaz() self.socket.add_id(self.interfaz.get_id()) self.show_all() self.connect("key-press-event", self.interfaz.key_press_event) self.connect("key-release-event", self.interfaz.key_release_event)
def __init__(self, handle): Activity.__init__(self, handle) self.max_participants = 1 self.jamath_activity = Game(get_activity_root()) self.build_toolbar() self._pygamecanvas = sugargame.canvas.PygameCanvas( self, main=self.jamath_activity.run, modules=[pygame.display, pygame.font, pygame.mixer]) self.set_canvas(self._pygamecanvas)
def __init__(self, sugar_handle): Activity.__init__(self, sugar_handle) # Create a Toolbar toolbar = Gtk.Toolbar() # Add toolbar to Sugar Activity Toolbar Space self.set_toolbar_box(toolbar) # Add Activity Button toolbar.insert(ActivityButton(self), -1) # Create & Add Separator separator = Gtk.SeparatorToolItem(draw=False) separator.set_expand(True) toolbar.insert(separator, -1) # Add Stop Button toolbar.insert(StopButton(self), -1) # Create Container grid = Gtk.Grid() # Add grid to Sugar Activity GtkWindow self.set_canvas(grid) # Create & Add Label label = Gtk.Label(label=_("Name: ")) grid.attach(label, 0, 0, 1, 1) # Add Output Label output = Gtk.Label() grid.attach(output, 1, 1, 1, 1) # Create & Add Text Entry entry = Gtk.Entry() grid.attach(entry, 0, 1, 1, 1) # Empty output on keypress in entry entry.connect('key-release-event', self.emptyout, output) # Add a button button = Gtk.Button(label=_("Greet!")) grid.attach(button, 0, 2, 1, 1) # Tell the button to run a class method button.connect('clicked', self.greeter, entry, output) # Show all components (otherwise none will be displayed) self.show_all()
def __init__(self, handle): Activity.__init__(self, handle) self.game = PhysicsGame(activity=self) self.build_toolbar() self._pygamecanvas = sugargame.canvas.PygameCanvas(self, main=self.game.run, modules=[pygame.display]) w = Gdk.Screen.width() h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE self._pygamecanvas.set_size_request(w, h) self.set_canvas(self._pygamecanvas) self._pygamecanvas.grab_focus()
def __init__(self, handler): Activity.__init__(self, handler) # Setup Activity self.max_participants = 1 self.setup_toolbar() # Create Drawing Area self.draw = Gtk.DrawingArea() self.draw.show() # Apply Canvas self.set_canvas(self.draw) # Add signal for realized self.get_canvas().connect('realize', self.setup_gstreamer)
def __init__(self, handle): Activity.__init__(self, handle) self._joining_hide = False self._game = ImplodeGame() self._collab = CollabWrapper(self) self._collab.connect('message', self._message_cb) game_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) game_box.pack_start(self._game, True, True, 0) self._stuck_strip = _StuckStrip() self._configure_toolbars() self.set_canvas(game_box) # Show everything except the stuck strip. self.show_all() self._configure_cb() game_box.pack_end(self._stuck_strip, expand=False, fill=False, padding=0) self._game.connect('show-stuck', self._show_stuck_cb) self._game.connect('piece-selected', self._piece_selected_cb) self._game.connect('undo-key-pressed', self._undo_key_pressed_cb) self._game.connect('redo-key-pressed', self._redo_key_pressed_cb) self._game.connect('new-key-pressed', self._new_key_pressed_cb) self._stuck_strip.connect('undo-clicked', self._stuck_undo_cb) game_box.connect('key-press-event', self._key_press_event_cb) self._game.grab_focus() last_game_path = self._get_last_game_path() if os.path.exists(last_game_path): self.read_file(last_game_path) self._collab.setup() # Hide the canvas when joining a shared activity if self.shared_activity: if not self.get_shared(): self.get_canvas().hide() self.busy() self._joining_hide = True
def __init__(self, handle): # Initialize the parent Activity.__init__(self, handle) self.max_participants = 1 hbox = Gtk.HBox() self.set_canvas(hbox) self.show_all() options = ['gcompris', '--fullscreen'] proc = subprocess.Popen(options) # Stay alive with a blank window mapped for at least 60 seconds # so that the shell knows that we launched GLib.timeout_add_seconds(60, Gtk.main_quit) # but get rid of that window if the child exits beforehand GLib.child_watch_add(proc.pid, Gtk.main_quit)
def __init__(self, handle): Activity.__init__(self, handle) self.build_toolbar() self.game = main.Main() # Build the Pygame canvas and start the game running # (self.game.run is called when the activity constructor # returns). self._pygamecanvas = sugargame.canvas.PygameCanvas( self, main=self.game.run, modules=[pygame.display]) self.game.set_canvas(self._pygamecanvas) # Note that set_canvas implicitly calls read_file when # resuming from the Journal. self.set_canvas(self._pygamecanvas) self._pygamecanvas.grab_focus()
def __init__(self, handle): Activity.__init__(self, handle) toolbox = ActivityToolbar(self) stop_button = StopButton(self) stop_button.show() toolbox.insert(stop_button, -1) self.set_toolbar_box(toolbox) toolbox.show() self.scroller = Gtk.ScrolledWindow() self.scroller.set_vexpand(True) root = self.make_root() self.set_canvas(root) root.show_all() self.entry.grab_focus() self.pservice = PresenceService() self.owner = self.pservice.get_owner() # Track last message, to combine several messages: self._last_msg = None self._last_msg_sender = None self.text_channel = None if self.shared_activity: # we are joining the activity self.connect('joined', self._joined_cb) if self.get_shared(): # we have already joined self._joined_cb() else: # we are creating the activity if not self.metadata or self.metadata.get('share-scope', SCOPE_PRIVATE) == SCOPE_PRIVATE: # if we are in private session self._alert(_('Off-line'), _('Share, or invite someone.')) self.connect('shared', self._shared_cb)
def __init__(self, handle): Activity.__init__(self, handle) self.max_participants = 1 # Create the game instance. self.game = game.PyCutGame(poll_cb=self._poll_cb) # Build the activity toolbar. self.build_toolbar() # Build the Pygame canvas. # Start the game running (self.game.run is called when the # activity constructor returns). self.game.canvas = sugargame.canvas.PygameCanvas( self, main=self.game.run, modules=[pygame.display, pygame.font]) # Note that set_canvas implicitly calls read_file when # resuming from the Journal. self.set_canvas(self.game.canvas) self.game.canvas.grab_focus()
def __init__(self, handle): # Initialize the parent Activity.__init__(self, handle) self.max_participants = 1 hbox = Gtk.HBox() self.set_canvas(hbox) self.show_all() options = [ 'tuxpaint', '--nolockfile', '--fullscreen=native', '--noprint' ] doc_path = self.get_documents_path() if doc_path is not None: options.extend(('--savedir', doc_path)) proc = subprocess.Popen(options) # Stay alive with a blank window mapped for at least 60 seconds # so that the shell knows that we launched GLib.timeout_add_seconds(60, Gtk.main_quit) # but get rid of that window if the child exits beforehand GLib.child_watch_add(proc.pid, Gtk.main_quit)
def __init__(self, handle): # Initialize the parent Activity.__init__(self, handle) logger.debug('Initiating PlayGo') self.size = DEFAULT_SIZE self.komi = DEFAULT_KOMI # Set the activity toolbarbox toolbarbox = ToolbarBox() self.set_toolbar_box(toolbarbox) toolbarbox.toolbar.insert(ActivityToolbarButton(self), -1) toolbarbox.toolbar.insert(Gtk.SeparatorToolItem(), -1) self.gameToolbar = GameToolbar(self) self.gameToolbar.connect('game-restart', self.restart_game) self.gameToolbar.connect('game-board-size', self.board_size_change) self.gameToolbar.connect('ai-activated', self.ai_activated_cb) self.gameToolbar.connect('ai-deactivated', self.ai_deactivated_cb) toolbarbox.toolbar.insert(ToolbarButton(page=self.gameToolbar, icon_name='txt'), -1) separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbarbox.toolbar.insert(separator, -1) toolbarbox.toolbar.insert(StopButton(self), -1) toolbarbox.show_all() toolbarbox.toolbar.show_all() self.gameToolbar.show_all() # Initialize the game self.game = GoGame(self.size) self.CurrentColor = 'B' self.PlayerColor = 'B' self.pass_count = 0 self.ai_activated = False self.set_up_ui() if not handle.object_id: self.infopanel.show(_('Welcome to PlayGo!')) else: self.show_score() self.lastX = -1 self.lastY = -1 # Set keypad actions self._key_actions = { 'KP_Up' : 'move_up', 'KP_Right' : 'move_right', 'KP_Down' : 'move_down', 'KP_Left' : 'move_left', 'KP_Home' : 'place_stone', 'KP_Next' : 'undo', 'KP_End' : 'pass' } ##self._key_grabber = KeyGrabber() ##self._key_grabber.connect('key-pressed', ## self._key_pressed_cb) # New KeyGrabber API change (ticket #7999) ##try: ## self._key_grabber.grab_keys(self._key_actions.keys()) ##except: ## for key in self._key_actions.keys(): ## self._key_grabber.grab(key) #Set up collaboration self.collaboration = CollaborationWrapper(self, self.buddy_joined, self.buddy_left, self.Play, self.game.undostack, self.bootstrap) self.connect('shared', self.collaboration._shared_cb) if self.get_shared_activity(): # We are joining the activity self.connect('joined', self.collaboration._joined_cb) if self.get_shared(): # We've already joined self.collaboration._joined_cb()
def __init__(self, sugar_handle): Activity.__init__(self, sugar_handle) # Create a Toolbar toolbar = Gtk.Toolbar() # Add toolbar to Sugar Activity Toolbar Space self.set_toolbar_box(toolbar) # Add Activity Button toolbar.insert(ActivityButton(self), -1) # filepath to write to journal filepath = os.path.join(self.get_activity_root(), "data") # Load art assets? cloudimg = Gtk.Image() cloudimg.set_from_file("activity/art/Buttons/Cloudy.png") sunimg = Gtk.Image() sunimg.set_from_file("activity/art/Buttons/Sun.png") rainimg = Gtk.Image() rainimg.set_from_file("activity/art/Buttons/RainyCloud.png") snowimg = Gtk.Image() snowimg.set_from_file("activity/art/Buttons/SnowyCloud.png") stormimg = Gtk.Image() stormimg.set_from_file("activity/art/Buttons/ThunderCloud.png") windimg = Gtk.Image() windimg.set_from_file("activity/art/Buttons/WindyCloud.png") hotimg = Gtk.Image() hotimg.set_from_file("activity/art/Buttons/HotSun.png") thermoimg = Gtk.Image() thermoimg.set_from_file("activity/art/Buttons/Thermometer.png") humidimg = Gtk.Image() humidimg.set_from_file("activity/art/Buttons/Humidity.png") # Create & Add Separator separator = Gtk.SeparatorToolItem(draw=False) separator.set_expand(True) toolbar.insert(separator, -1) # Add Stop Button toolbar.insert(StopButton(self), -1) # Create Container grid = Gtk.Grid() # Add grid to Sugar Activity GtkWindow self.set_canvas(grid) # Create & Add Label label = Gtk.Label(label=_("Weather: ")) grid.attach(label, 0, 0, 1, 1) # Add Output Label output = Gtk.Label() grid.attach(output, 0, 6, 5, 1) # Create & Add Text Entry x2 entry = Gtk.Entry() grid.attach(entry, 1, 1, 2, 1) entry2 = Gtk.Entry() grid.attach(entry2, 1, 2, 2, 1) # Empty output on keypress in entry entry.connect("key-release-event", self.emptyout, output) entry2.connect("key-release-event", self.emptyout, output) # Add buttons sunnyButton = Gtk.Button(image=_(sunimg)) grid.attach(sunnyButton, 0, 3, 1, 1) cloudyButton = Gtk.Button(image=_(cloudimg)) grid.attach(cloudyButton, 1, 3, 1, 1) rainyButton = Gtk.Button(image=_(rainimg)) grid.attach(rainyButton, 2, 3, 1, 1) snowyButton = Gtk.Button(image=_(snowimg)) grid.attach(snowyButton, 3, 3, 1, 1) stormyButton = Gtk.Button(image=_(stormimg)) grid.attach(stormyButton, 4, 3, 1, 1) hotButton = Gtk.Button(image=_(hotimg)) grid.attach(hotButton, 5, 3, 1, 1) windyButton = Gtk.Button(image=_(windimg)) grid.attach(windyButton, 6, 3, 1, 1) tempButton = Gtk.Button(image=_(thermoimg)) grid.attach(tempButton, 0, 1, 1, 1) humidButton = Gtk.Button(image=_(humidimg)) grid.attach(humidButton, 0, 2, 1, 1) # Add Log Button, make it work logButton = Gtk.Button(label=_("Send to Journal")) grid.attach(logButton, 0, 7, 2, 1) # Tell the buttons to run a class method sunnyButton.connect("clicked", self.showWeather, "Sunny", entry, entry2, output) cloudyButton.connect("clicked", self.showWeather, "Cloudy", entry, entry2, output) rainyButton.connect("clicked", self.showWeather, "Rainy", entry, entry2, output) snowyButton.connect("clicked", self.showWeather, "Snowy", entry, entry2, output) stormyButton.connect("clicked", self.showWeather, "Stormy", entry, entry2, output) hotButton.connect("clicked", self.showWeather, "Hot", entry, entry2, output) windyButton.connect("clicked", self.showWeather, "Windy", entry, entry2, output) # Show all components (otherwise none will be displayed) self.show_all()
def __init__(self, sugar_handle): Activity.__init__(self, sugar_handle) # Create a Toolbar toolbar = Gtk.Toolbar() # Add toolbar to Sugar Activity Toolbar Space self.set_toolbar_box(toolbar) # Add Activity Button toolbar.insert(ActivityButton(self), -1) # Create & Add Separator separator = Gtk.SeparatorToolItem(draw=False) separator.set_expand(True) toolbar.insert(separator, -1) # Add Stop Button toolbar.insert(StopButton(self), -1) # Create Container grid = Gtk.Grid() # Add grid to Sugar Activity GtkWindow self.set_canvas(grid) # Create & Add Label label = Gtk.Label(label=_("Weather: ")) grid.attach(label, 0, 0, 1, 1) # Add Output Label output = Gtk.Label() grid.attach(output, 0, 6, 1, 1) # Create & Add Text Entry x2 entry = Gtk.Entry() grid.attach(entry, 0, 1, 1, 1) entry2 = Gtk.Entry() grid.attach(entry2, 0, 2, 1, 1) # Empty output on keypress in entry entry.connect('key-release-event', self.emptyout, output) entry2.connect('key-release-event', self.emptyout, output) # Add buttons sunnyButton = Gtk.Button(label=_("Sunny")) grid.attach(sunnyButton, 0, 3, 1, 1) cloudyButton = Gtk.Button(label=_("Cloudy")) grid.attach(cloudyButton, 1, 3, 1, 1) rainyButton = Gtk.Button(label=_("Rainy")) grid.attach(rainyButton, 2, 3, 1, 1) snowyButton = Gtk.Button(label=_("Snowy")) grid.attach(snowyButton, 3, 3, 1, 1) # Tell the buttons to run a class method sunnyButton.connect('clicked', self.showWeather, "Sunny", entry, entry2, output) cloudyButton.connect('clicked', self.showWeather, "Cloudy", entry, entry2, output) rainyButton.connect('clicked', self.showWeather, "Rainy", entry, entry2, output) snowyButton.connect('clicked', self.showWeather, "Snowy", entry, entry2, output) # Show all components (otherwise none will be displayed) self.show_all()
def __init__(self, handle): print "running activity init", handle Activity.__init__(self, handle) print "activity running" Sash()
def __init__(self, handle): Activity.__init__(self, handle) self.play_mode = None toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) self.activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(self.activity_button, -1) self._memorizeToolbarBuilder = \ memorizetoolbar.MemorizeToolbarBuilder(self) toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1) self._edit_button = ToggleToolButton('view-source') self._edit_button.set_tooltip(_('Edit game')) self._edit_button.set_active(False) toolbar_box.toolbar.insert(self._edit_button, -1) self._createToolbarBuilder = \ createtoolbar.CreateToolbarBuilder(self) separator = Gtk.SeparatorToolItem() separator.set_expand(True) separator.set_draw(False) separator.set_size_request(0, -1) toolbar_box.toolbar.insert(separator, -1) toolbar_box.toolbar.insert(StopButton(self), -1) self.game = game.MemorizeGame() # Play game mode self.table = cardtable.CardTable() self.scoreboard = scoreboard.Scoreboard() self.cardlist = cardlist.CardList() self.createcardpanel = createcardpanel.CreateCardPanel(self.game) self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected) self.cardlist.connect( 'update-create-toolbar', self._createToolbarBuilder.update_create_toolbar) self.createcardpanel.connect('add-pair', self.cardlist.add_pair) self.createcardpanel.connect('update-pair', self.cardlist.update_selected) self.createcardpanel.connect('change-font', self.cardlist.change_font) self.createcardpanel.connect('pair-closed', self.cardlist.rem_current_pair) self._createToolbarBuilder.connect('create_new_game', self.cardlist.clean_list) self._createToolbarBuilder.connect('create_new_game', self.createcardpanel.clean) self._createToolbarBuilder.connect( 'create_new_game', self._memorizeToolbarBuilder.reset) self._createToolbarBuilder.connect('create_equal_pairs', self.change_equal_pairs) self._edit_button.connect('toggled', self._change_mode_bt) self.connect('key-press-event', self.table.key_press_event) self.table.connect('card-flipped', self.game.card_flipped) self.table.connect('card-highlighted', self.game.card_highlighted) self.game.connect('set-border', self.table.set_border) self.game.connect('flop-card', self.table.flop_card) self.game.connect('flip-card', self.table.flip_card) self.game.connect('cement-card', self.table.cement_card) self.game.connect('highlight-card', self.table.highlight_card) self.game.connect('load_mode', self.table.load_msg) self.game.connect('msg_buddy', self.scoreboard.set_buddy_message) self.game.connect('add_buddy', self.scoreboard.add_buddy) self.game.connect('rem_buddy', self.scoreboard.rem_buddy) self.game.connect('increase-score', self.scoreboard.increase_score) self.game.connect('wait_mode_buddy', self.scoreboard.set_wait_mode) self.game.connect('change-turn', self.scoreboard.set_selected) self.game.connect('change_game', self.scoreboard.change_game) self.game.connect('reset_scoreboard', self.scoreboard.reset) self.game.connect('reset_table', self.table.reset) self.game.connect('load_game', self.table.load_game) self.game.connect('change_game', self.table.change_game) self.game.connect('load_game', self._memorizeToolbarBuilder.update_toolbar) self.game.connect('change_game', self._memorizeToolbarBuilder.update_toolbar) self.game.connect('change_game', self.createcardpanel.update_font_combos) self._memorizeToolbarBuilder.connect('game_changed', self.change_game) self.box = Gtk.HBox(orientation=Gtk.Orientation.VERTICAL, homogeneous=False) width = Gdk.Screen.width() height = Gdk.Screen.height() - style.GRID_CELL_SIZE self.table.resize(width, height - style.GRID_CELL_SIZE) self.scoreboard.set_size_request(-1, style.GRID_CELL_SIZE) self.box.pack_start(self.table, True, True, 0) self.box.pack_start(self.scoreboard, False, False, 0) self.set_canvas(self.box) # connect to the in/out events of the memorize activity self.connect('focus_in_event', self._focus_in) self.connect('focus_out_event', self._focus_out) self.connect('destroy', self._cleanup_cb) self.add_events(Gdk.EventMask.POINTER_MOTION_MASK) self.connect('motion_notify_event', lambda widget, event: face.look_at()) Gdk.Screen.get_default().connect('size-changed', self.__configure_cb) # start on the game toolbar, might change this # to the create toolbar later self._change_mode(_MODE_PLAY) # Get the Presence Service self.pservice = presenceservice.get_instance() self.initiating = None # Buddy object for you owner = self.pservice.get_owner() self.owner = owner self.current = 0 self.game.set_myself(self.owner) self.connect('shared', self._shared_cb) # Owner.props.key if self.get_shared_activity(): # We are joining the activity self.connect('joined', self._joined_cb) if self.get_shared(): # We've already joined self._joined_cb(self) elif not self._jobject.file_path: logging.debug('buddy joined - __init__: %s', self.owner.props.nick) game_file = os.path.join(os.path.dirname(__file__), 'demos', 'addition.zip') self.game.load_game(game_file, 4, 'demo') logging.debug('loading conventional') self.game.add_buddy(self.owner) else: self.game.add_buddy(self.owner) self.show_all()
def _complete_close(self): self._remove_temp_files() Activity._complete_close(self)
def __init__(self, handle): Activity.__init__(self, handle) logger.debug('Starting Slider Puzzle activity... %s' % str(get_bundle_path())) os.chdir(get_bundle_path()) self.connect('destroy', self._destroy_cb) self._sample_window = None self.fixed = Gtk.Fixed() self.ui = SliderPuzzleUI(self) toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) toolbar_box.show() activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, -1) activity_button.show() self.btn_9 = ToolButton('play-9') self.btn_9.set_tooltip(_('9 blocks')) toolbar_box.toolbar.insert(self.btn_9, -1) #btn_9.set_active(True) self.btn_9.connect('clicked', self.ui.set_nr_pieces, 9) self.btn_9.show() self.btn_12 = ToolButton('play-12') self.btn_12.set_tooltip(_('12 blocks')) toolbar_box.toolbar.insert(self.btn_12, -1) #btn_9.set_active(True) self.btn_12.connect('clicked', self.ui.set_nr_pieces, 12) self.btn_12.show() self.btn_16 = ToolButton('play-16') self.btn_16.set_tooltip(_('16 blocks')) toolbar_box.toolbar.insert(self.btn_16, -1) #btn_9.set_active(True) self.btn_16.connect('clicked', self.ui.set_nr_pieces, 16) self.btn_16.show() self.btn_solve = ToolButton('media-playback-start') self.btn_solve.set_tooltip(_('Solve')) toolbar_box.toolbar.insert(self.btn_solve, -1) #btn_9.set_active(True) self.btn_solve.connect('clicked', self.ui.do_solve) self.btn_solve.show() self.btn_shuffle = ToolButton('edit-redo') self.btn_shuffle.set_tooltip(_('Shuffle')) toolbar_box.toolbar.insert(self.btn_shuffle, -1) #btn_9.set_active(True) self.btn_shuffle.connect('clicked', self.ui.do_shuffle) self.btn_shuffle.show() self.btn_add = ToolButton('imageviewer') self.btn_add.set_tooltip(_('Add Picture')) toolbar_box.toolbar.insert(self.btn_add, -1) #btn_9.set_active(True) self.btn_add.connect('clicked', self.ui.do_add_image) self.btn_add.show() self.btn_select = ToolButton('image-load') self.btn_select.set_tooltip(_('Add Picture')) toolbar_box.toolbar.insert(self.btn_select, -1) #btn_9.set_active(True) self.btn_select.connect('clicked', self.do_samples_cb) self.btn_select.show() #self.set_canvas(self.ui) self.set_canvas(self.fixed) self.fixed.show() self.show_all() self.ui = SliderPuzzleUI(self) self.set_canvas(self.ui) self.show_all() self.frozen = FrozenState(self.ui) self.ui.game.connect('shuffled', self.frozen.sync) TubeHelper.__init__(self, tube_class=GameTube, service=SERVICE)
def __init__(self, handle): Activity.__init__(self, handle) self._setup_toolbarbox() eb = Gtk.EventBox() eb.modify_bg(Gtk.StateType.NORMAL, Gdk.Color.parse("white")[1]) self.set_canvas(eb) vbox = Gtk.VBox() eb.add(vbox) title = Gtk.Image.new_from_pixbuf(self._scale_pixbuf("images/logo.jpg", 400, 100)) vbox.pack_start(title, False, False, 0) self.entry = Gtk.Entry() self.entry.connect("activate", self.translate_cb) self.entry.connect("backspace", self.backspace_cb) vbox.pack_start(self.entry, False, False, 0) scroll = Gtk.ScrolledWindow() vbox.pack_start(scroll, True, True, 0) self.textview = Gtk.TextView() self.textview.set_wrap_mode(Gtk.WrapMode.WORD) scroll.add(self.textview) buttonbox = Gtk.HButtonBox() buttonbox.set_layout(Gtk.ButtonBoxStyle.CENTER) vbox.pack_start(buttonbox, False, False, 0) parser = SafeConfigParser() parser.read("config.ini") for data in [("dic", "A"), ("dic", "E"), ("dic", "I"), ("dic", "O"), ("dic", "U"), ("dic", "Y"), ("dic", "G")]: button = Gtk.Button(parser.get(*data)) button.modify_bg(Gtk.StateType.NORMAL, Gdk.Color.parse('#FCB947')[1]) button.connect("clicked", self.__add, data[1]) buttonbox.add(button) achegety = Gtk.Image.new_from_pixbuf(self._scale_pixbuf("images/achegety.jpg", 600, 200)) vbox.pack_start(achegety, False, False, 0) scroll = Gtk.ScrolledWindow() scroll.set_border_width(10) scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) vbox.pack_start(scroll, True, True, 0) textview = Gtk.TextView() textview.set_wrap_mode(Gtk.WrapMode.WORD) textview.set_editable(False) scroll.add(textview) self.buffer = textview.get_buffer() parser = SafeConfigParser() parser.read('config.ini') #Cargando archivo .txt path = "lang/guarani/dic.txt" if os.path.exists(path): infile = open("lang/guarani/dic.txt", "r") string = infile.read() infile.close() self.buffer.set_text(string) self.show_all()
def __init__(self, handle): """Set up the StopWatch activity.""" Activity.__init__(self, handle) self._logger = logging.getLogger('stopwatch-activity') GObject.threads_init() toolbar_box = ToolbarBox() self.activity_button = ActivityButton(self) toolbar_box.toolbar.insert(self.activity_button, 0) self.activity_button.show() title_entry = TitleEntry(self) toolbar_box.toolbar.insert(title_entry, -1) title_entry.show() try: from sugar3.activity.widgets import DescriptionItem description_item = DescriptionItem(self) toolbar_box.toolbar.insert(description_item, -1) description_item.show() except: pass share_button = ShareButton(self) toolbar_box.toolbar.insert(share_button, -1) share_button.show() separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbar_box) self.tubebox = dobject.TubeBox() self.timer = dobject.TimeHandler("main", self.tubebox) self.gui = stopwatch.GUIView(self.tubebox, self.timer, self) self.set_canvas(self.gui.display) self.show_all() self.initiating = False # get the Presence Service self.pservice = presenceservice.get_instance() # Buddy object for you owner = self.pservice.get_owner() self.owner = owner self.connect('shared', self._shared_cb) self.connect('joined', self._joined_cb) self.add_events(Gdk.EventMask.VISIBILITY_NOTIFY_MASK) self.connect("visibility-notify-event", self._visible_cb) self.connect("notify::active", self._active_cb) self.connect('key-press-event', self._keypress_cb)
def __init__(self, handle): #handle object contains command line inputs to this activity self.handle = handle _logger.debug('Activity id:%s.Object id: %s. uri:%s' % (handle.activity_id, handle.object_id, handle.uri)) self.passed_in_ds_object = None if handle.object_id and handle.object_id != '': self.passed_in_ds_object = datastore.get(handle.object_id) if self.passed_in_ds_object: d = self.passed_in_ds_object.metadata else: ds_object = self.get_new_dsobject() if hasattr(ds_object, 'get_object_id'): handle.object_id = ds_object.get_object_id() else: handle.object_id = ds_object.object_id _logger.debug( 'no initial datastore object id passed in via handle') #Save a global poiinter so remote procedure calls can communicate with pydebug global pydebug_instance pydebug_instance = self start_clock = time.clock() #init variables self.make_paths() self.save_icon_clicked = False self.source_directory = None self.data_file = None self.help = None self.help_x11 = None self.dirty = False self.sock = None #self.last_filename = None self.debug_dict = {} self.activity_dict = {} self.manifest_treeview = None #set up to recognize an re-display of playpen #self.set_title(_('PyDebug Activity')) self.ds = None #datastore pointer self._logger = _logger self.traceback = 'Context' self.abandon_changes = False self.delete_after_load = None self.find_window = None self.icon_outline = 'icon_square' self.icon_window = None self.last_icon_file = None self.activity_data_changed = False self.icon_basename = None #sugar 0.82 has a different way of getting colors and dies during init unless the following self.profile = profile.get_profile() self.profile.color = XoColor() #get the persistent data across all debug sessions and start using it self.get_config() #give the server a chance to get started so terminal can connect to it self.non_blocking_server() #glib.idle_add(self.non_blocking_server) # init the Classes we are subclassing _logger.debug('about to init superclass activity. Elapsed time: %f' % (time.clock() - start_clock)) Activity.__init__(self, handle, create_jobject=False) self.connect('realize', self.realize_cb) self.accelerator = Gtk.AccelGroup() self.add_accel_group(self.accelerator) #set up the PANES for the different functions of the debugger _logger.debug('about to set up Menu panes. Elapsed time: %f' % (time.clock() - start_clock)) self.panes = {} PANES = ['TERMINAL', 'EDITOR', 'PROJECT', 'HELP'] for i in range(len(PANES)): self.panes[PANES[i]] = i #toolbarbox needs to be available during init of modules self.toolbarbox = pytoolbar.ActivityToolbarBox(self) ######################################################################################### #init the sub functions TerminalGui.__init__(self, self, self.toolbarbox) EditorGui.__init__(self, self) ProjectGui.__init__(self, self) ##self.help = Help(self) self.util = Utilities(self) ######################################################################################### #if first time run on this machine, set up home directory if not os.path.isfile(os.path.join(self.debugger_home, '.bashrc')): self.setup_home_directory() # setup the search options self.s_opts = SearchOptions( where=S_WHERE.file, use_regex=False, ignore_caps=True, replace_all=False, #defaults to avoid creating #a new SearchOptions object for normal searches #should never be changed, just make a copy like: #SearchOptions(self.s_opts, forward=False) forward=True, stay=False) self.safe_to_replace = False ######################################################################################### _logger.debug( 'All app objects created. about to set up Display . Elapsed time: %f' % (time.clock() - start_clock)) self.canvas_list = [] self.canvas_list.append(self._get_terminal_canvas()) self.canvas_list.append(self._get_edit_canvas()) self.canvas_list.append(self._get_project_canvas()) self.canvas_list.append(self._get_help_canvas()) nb = Gtk.Notebook() nb.show() nb.set_show_tabs(False) for c in self.canvas_list: nb.append_page(c) self.pydebug_notebook = nb #the following call to the activity code puts our notebook under the stock toolbar self.set_canvas(nb) ##helpbar = self.help.get_help_toolbar() activity_button = ActivityToolbarButton(self) self.toolbarbox.toolbar.insert(activity_button, 0) # activity_button.show() self.toolbarbox.toolbar.insert( ToolbarButton(page=self.get_editbar(), icon_name='toolbar-edit'), -1) stop_button = StopButton(self) self.toolbarbox.toolbar.insert(stop_button, -1) ##self.toolbarbox.toolbar.insert(_('Help'), self.help.get_help_toolbar(), -1) self.set_toolbar_box(self.toolbarbox) self.toolbarbox.show_all() #set which PANE is visible initially self.set_visible_canvas(self.panes['PROJECT']) _logger.debug('about to setup_project_page. Elapsed time: %f' % (time.clock() - start_clock)) self.setup_project_page() _logger.debug( 'about Returned from setup_project_page. Elapsed time: %f' % (time.clock() - start_clock)) #get the journal datastore information and resume previous activity #self.metadata = self.ds if self.passed_in_ds_object and self.passed_in_ds_object.get_file_path( ): ds_file = self.passed_in_ds_object.get_file_path() else: ds_file = '' _logger.debug('about to call read routine Elapsed time: %f' % (time.clock() - start_clock)) self.read_file(ds_file) _logger.debug('about (end of init) Elapsed time: %f' % (time.clock() - start_clock))
def __init__(self, handle): Activity.__init__(self, handle) self._setup_toolbarbox() eb = Gtk.EventBox() eb.modify_bg(Gtk.StateType.NORMAL, Gdk.Color.parse("white")[1]) self.set_canvas(eb) vbox = Gtk.VBox() eb.add(vbox) title = Gtk.Image.new_from_pixbuf( self._scale_pixbuf("images/logo.jpg", 400, 100)) vbox.pack_start(title, False, False, 0) self.entry = Gtk.Entry() self.entry.connect("activate", self.translate_cb) self.entry.connect("backspace", self.backspace_cb) vbox.pack_start(self.entry, False, False, 0) scroll = Gtk.ScrolledWindow() vbox.pack_start(scroll, True, True, 0) self.textview = Gtk.TextView() self.textview.set_wrap_mode(Gtk.WrapMode.WORD) scroll.add(self.textview) buttonbox = Gtk.HButtonBox() buttonbox.set_layout(Gtk.ButtonBoxStyle.CENTER) vbox.pack_start(buttonbox, False, False, 0) parser = SafeConfigParser() parser.read("config.ini") for data in [("dic", "A"), ("dic", "E"), ("dic", "I"), ("dic", "O"), ("dic", "U"), ("dic", "Y"), ("dic", "G")]: button = Gtk.Button(parser.get(*data)) button.modify_bg(Gtk.StateType.NORMAL, Gdk.Color.parse('#FCB947')[1]) button.connect("clicked", self.__add, data[1]) buttonbox.add(button) achegety = Gtk.Image.new_from_pixbuf( self._scale_pixbuf("images/achegety.jpg", 600, 200)) vbox.pack_start(achegety, False, False, 0) scroll = Gtk.ScrolledWindow() scroll.set_border_width(10) scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) vbox.pack_start(scroll, True, True, 0) textview = Gtk.TextView() textview.set_wrap_mode(Gtk.WrapMode.WORD) textview.set_editable(False) scroll.add(textview) self.buffer = textview.get_buffer() parser = SafeConfigParser() parser.read('config.ini') #Cargando archivo .txt path = "lang/guarani/dic.txt" if os.path.exists(path): infile = open("lang/guarani/dic.txt", "r") string = infile.read() infile.close() self.buffer.set_text(string) self.show_all()
def __init__(self, handle): Activity.__init__(self, handle) self.set_title(_("Finance")) self.max_participants = 1 # Initialize database. # data # next_id # transactions # id, name, type, amount, date, category # budgets # category, period, amount, budget self.data = {'next_id': 0, 'transactions': [], 'budgets': {}} self.transaction_map = {} self.visible_transactions = [] self.transaction_names = {} self.category_names = {} #self.create_test_data() # Initialize view period to the first of the month. self.period = _('Month') self.period_start = self.get_this_period() # Create screens. self.register = registerscreen.RegisterScreen(self) self.chart = chartscreen.ChartScreen(self) self.budget = budgetscreen.BudgetScreen(self) self.build_toolbox() self.screens = [] self.screenbox = Gtk.VBox() # Add the context sensitive help. self.helplabel = Gtk.Label() self.helplabel.set_padding(10, 10) self.helpbox = Gtk.EventBox() parse, color = Gdk.Color.parse('#000000') self.helpbox.modify_bg(Gtk.StateType.NORMAL, color) self.helpbox.add(self.helplabel) # Add the header. self.periodlabel = Gtk.Label() self.periodlabel.set_padding(10, 0) headerbox = Gtk.HBox() headerbox.pack_end(self.periodlabel, False, False, 0) # Add the summary data. self.startlabel = Gtk.Label() self.creditslabel = Gtk.Label() self.debitslabel = Gtk.Label() self.balancelabel = Gtk.Label() summarybox = Gtk.HBox() summarybox.pack_start(self.startlabel, True, False, 0) summarybox.pack_start(self.creditslabel, True, False, 0) summarybox.pack_start(self.debitslabel, True, False, 0) summarybox.pack_start(self.balancelabel, True, False, 0) vbox = Gtk.VBox() vbox.pack_start(self.helpbox, False, False, 10) vbox.pack_start(headerbox, False, False, 10) vbox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, False, 0) vbox.pack_start(self.screenbox, True, True, 0) vbox.pack_start(summarybox, False, False, 10) # Start with the main screen. self.push_screen(self.register) # This has to happen last, because it calls the read_file # method when restoring from the Journal. self.set_canvas(vbox) self.show_all()
def __init__(self, handle): # Initialize the parent Activity.__init__(self, handle) logger.debug('Initiating PlayGo') self.size = DEFAULT_SIZE self.komi = DEFAULT_KOMI # Set the activity toolbarbox toolbarbox = ToolbarBox() self.set_toolbar_box(toolbarbox) toolbarbox.toolbar.insert(ActivityToolbarButton(self), -1) toolbarbox.toolbar.insert(Gtk.SeparatorToolItem(), -1) self.gameToolbar = GameToolbar(self) self.gameToolbar.connect('game-restart', self.restart_game) self.gameToolbar.connect('game-board-size', self.board_size_change) self.gameToolbar.connect('ai-activated', self.ai_activated_cb) self.gameToolbar.connect('ai-deactivated', self.ai_deactivated_cb) toolbarbox.toolbar.insert( ToolbarButton(page=self.gameToolbar, icon_name='txt'), -1) separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbarbox.toolbar.insert(separator, -1) toolbarbox.toolbar.insert(StopButton(self), -1) toolbarbox.show_all() toolbarbox.toolbar.show_all() self.gameToolbar.show_all() # Initialize the game self.game = GoGame(self.size) self.CurrentColor = 'B' self.PlayerColor = 'B' self.pass_count = 0 self.ai_activated = False self.set_up_ui() if not handle.object_id: self.infopanel.show(_('Welcome to PlayGo!')) else: self.show_score() self.lastX = -1 self.lastY = -1 # Set keypad actions self._key_actions = { 'KP_Up': 'move_up', 'KP_Right': 'move_right', 'KP_Down': 'move_down', 'KP_Left': 'move_left', 'KP_Home': 'place_stone', 'KP_Next': 'undo', 'KP_End': 'pass' } # Set up collaboration self.collaboration = CollaborationWrapper(self, self.buddy_joined, self.buddy_left, self.Play, self.game.undostack, self.bootstrap) self.connect('shared', self.collaboration._shared_cb) if self.get_shared_activity(): # We are joining the activity self.connect('joined', self.collaboration._joined_cb) if self.get_shared(): # We've already joined self.collaboration._joined_cb()
def __init__(self, handle): Activity.__init__(self, handle) self.play_mode = None toolbar_box = ToolbarBox() self.set_toolbar_box(toolbar_box) self.activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(self.activity_button, -1) self._memorizeToolbarBuilder = \ memorizetoolbar.MemorizeToolbarBuilder(self) toolbar_box.toolbar.insert(Gtk.SeparatorToolItem(), -1) self._edit_button = ToggleToolButton('view-source') self._edit_button.set_tooltip(_('Edit game')) self._edit_button.set_active(False) toolbar_box.toolbar.insert(self._edit_button, -1) self._createToolbarBuilder = \ createtoolbar.CreateToolbarBuilder(self) separator = Gtk.SeparatorToolItem() separator.set_expand(True) separator.set_draw(False) separator.set_size_request(0, -1) toolbar_box.toolbar.insert(separator, -1) toolbar_box.toolbar.insert(StopButton(self), -1) self.game = game.MemorizeGame() # Play game mode self.table = cardtable.CardTable() self.scoreboard = scoreboard.Scoreboard() self.cardlist = cardlist.CardList() self.createcardpanel = createcardpanel.CreateCardPanel(self.game) self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected) self.cardlist.connect('update-create-toolbar', self._createToolbarBuilder.update_create_toolbar) self.createcardpanel.connect('add-pair', self.cardlist.add_pair) self.createcardpanel.connect('update-pair', self.cardlist.update_selected) self.createcardpanel.connect('change-font', self.cardlist.change_font) self.createcardpanel.connect('pair-closed', self.cardlist.rem_current_pair) self._createToolbarBuilder.connect('create_new_game', self.cardlist.clean_list) self._createToolbarBuilder.connect('create_new_game', self.createcardpanel.clean) self._createToolbarBuilder.connect('create_new_game', self._memorizeToolbarBuilder.reset) self._createToolbarBuilder.connect('create_equal_pairs', self.change_equal_pairs) self._edit_button.connect('toggled', self._change_mode_bt) self.connect('key-press-event', self.table.key_press_event) self.table.connect('card-flipped', self.game.card_flipped) self.table.connect('card-highlighted', self.game.card_highlighted) self.game.connect('set-border', self.table.set_border) self.game.connect('flop-card', self.table.flop_card) self.game.connect('flip-card', self.table.flip_card) self.game.connect('cement-card', self.table.cement_card) self.game.connect('highlight-card', self.table.highlight_card) self.game.connect('load_mode', self.table.load_msg) self.game.connect('msg_buddy', self.scoreboard.set_buddy_message) self.game.connect('add_buddy', self.scoreboard.add_buddy) self.game.connect('rem_buddy', self.scoreboard.rem_buddy) self.game.connect('increase-score', self.scoreboard.increase_score) self.game.connect('wait_mode_buddy', self.scoreboard.set_wait_mode) self.game.connect('change-turn', self.scoreboard.set_selected) self.game.connect('change_game', self.scoreboard.change_game) self.game.connect('reset_scoreboard', self.scoreboard.reset) self.game.connect('reset_table', self.table.reset) self.game.connect('load_game', self.table.load_game) self.game.connect('change_game', self.table.change_game) self.game.connect('load_game', self._memorizeToolbarBuilder.update_toolbar) self.game.connect('change_game', self._memorizeToolbarBuilder.update_toolbar) self.game.connect('change_game', self.createcardpanel.update_font_combos) self._memorizeToolbarBuilder.connect('game_changed', self.change_game) self.box = Gtk.HBox(orientation=Gtk.Orientation.VERTICAL, homogeneous=False) width = Gdk.Screen.width() height = Gdk.Screen.height() - style.GRID_CELL_SIZE self.table.resize(width, height - style.GRID_CELL_SIZE) self.scoreboard.set_size_request(-1, style.GRID_CELL_SIZE) self.set_canvas(self.box) # connect to the in/out events of the memorize activity self.connect('focus_in_event', self._focus_in) self.connect('focus_out_event', self._focus_out) self.connect('destroy', self._cleanup_cb) self.add_events(Gdk.EventMask.POINTER_MOTION_MASK) self.connect('motion_notify_event', lambda widget, event: face.look_at()) Gdk.Screen.get_default().connect('size-changed', self.__configure_cb) # start on the game toolbar, might change this # to the create toolbar later self._change_mode(_MODE_PLAY) def on_activity_joined_cb(me): logging.debug('activity joined') self.game.add_buddy(self._collab.props.owner) self.connect('joined', on_activity_joined_cb) def on_activity_shared_cb(me): logging.debug('activity shared') self.connect('shared', on_activity_shared_cb) self._collab = CollabWrapper(self) self.game.set_myself(self._collab.props.owner) def on_message_cb(collab, buddy, msg): logging.debug('on_message_cb buddy %r msg %r' % (buddy, msg)) action = msg.get('action') if action == 'flip': n = msg.get('n') self.game.card_flipped(None, n, True) elif action == 'change': self.get_canvas().hide() def momentary_blank_timeout_cb(): self.set_data(msg) self.get_canvas().show() GLib.timeout_add(100, momentary_blank_timeout_cb) self._collab.connect('message', on_message_cb) def on_joined_cb(collab, msg): logging.debug('joined') self._collab.connect('joined', on_joined_cb, 'joined') def on_buddy_joined_cb(collab, buddy, msg): logging.debug('on_buddy_joined_cb buddy %r msg %r' % (buddy, msg)) self.game.add_buddy(buddy) self._collab.connect('buddy_joined', on_buddy_joined_cb, 'buddy_joined') def on_buddy_left_cb(collab, buddy, msg): logging.debug('on_buddy_left_cb buddy %r msg %r' % (buddy, msg)) self.game.rem_buddy(buddy) self._collab.connect('buddy_left', on_buddy_left_cb, 'buddy_left') self._files = {} # local temporary copies of shared games self._collab.setup() def on_flip_card_cb(game, n): logging.debug('on_flip_card_cb n %r' % (n)) self._collab.post({'action': 'flip', 'n': n}) self.game.connect('flip-card-signal', on_flip_card_cb) def on_change_game_cb(sender, mode, grid, data, waiting_list, zip): logging.debug('on_change_game_cb') blob = self.get_data() blob['action'] = 'change' self._collab.post(blob) self.game.connect('change_game_signal', on_change_game_cb) if self._collab.props.leader: logging.debug('is leader') game_file = os.path.join(os.path.dirname(__file__), 'demos', 'addition.zip') self.game.load_game(game_file, 4, 'demo') self.game.add_buddy(self._collab.props.owner) self.show_all()