当前位置: 首页>>代码示例>>Python>>正文


Python ToolbarButton.show_all方法代码示例

本文整理汇总了Python中sugar3.graphics.toolbarbox.ToolbarButton.show_all方法的典型用法代码示例。如果您正苦于以下问题:Python ToolbarButton.show_all方法的具体用法?Python ToolbarButton.show_all怎么用?Python ToolbarButton.show_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sugar3.graphics.toolbarbox.ToolbarButton的用法示例。


在下文中一共展示了ToolbarButton.show_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PhysicsActivity

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import show_all [as 别名]
class PhysicsActivity(activity.Activity):
    def __init__(self, handle):
        super(PhysicsActivity, self).__init__(handle)
        self._collab = CollabWrapper(self)
        self._collab.message.connect(self.__message_cb)
        self.metadata["mime_type"] = "application/x-physics-activity"
        self.add_events(Gdk.EventMask.ALL_EVENTS_MASK | Gdk.EventMask.VISIBILITY_NOTIFY_MASK)

        self.connect("visibility-notify-event", self._focus_event)
        self.connect("window-state-event", self._window_event)

        self.game_canvas = sugargame.canvas.PygameCanvas(self)
        self.game = physics.main(self)

        self.preview = None
        self._sample_window = None

        self._fixed = Gtk.Fixed()
        self._fixed.put(self.game_canvas, 0, 0)

        w = Gdk.Screen.width()
        h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE

        self.game_canvas.set_size_request(w, h)

        self._constructors = {}
        self.build_toolbar()

        self.set_canvas(self._fixed)
        Gdk.Screen.get_default().connect("size-changed", self.__configure_cb)

        logging.debug(os.path.join(activity.get_activity_root(), "data", "data"))
        self.game_canvas.run_pygame(self.game.run)
        self.show_all()
        self._collab.setup()

    def __configure_cb(self, event):
        """ Screen size has changed """
        self.write_file(os.path.join(activity.get_activity_root(), "data", "data"))
        w = Gdk.Screen.width()
        h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE
        pygame.display.set_mode((w, h), pygame.RESIZABLE)
        self.read_file(os.path.join(activity.get_activity_root(), "data", "data"))
        self.game.run(True)

    def read_file(self, file_path):
        self.game.read_file(file_path)

    def write_file(self, file_path):
        self.game.write_file(file_path)

    def get_preview(self):
        """ Custom preview code to get image from pygame. """
        return self.game_canvas.get_preview()

    def build_toolbar(self):
        self.max_participants = 4

        toolbar_box = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        create_toolbar = ToolbarButton()
        create_toolbar.props.page = Gtk.Toolbar()
        create_toolbar.props.icon_name = "magicpen"
        create_toolbar.props.label = _("Create")
        toolbar_box.toolbar.insert(create_toolbar, -1)
        self._insert_create_tools(create_toolbar)

        color = ColorToolButton("Color Button")
        color.props.icon_name = "color"
        color.connect("notify::color", self.returnChosenColor)
        toolbar_box.toolbar.insert(color, -1)
        color.show()

        self.randomColor = ToggleToolButton("Random Color")
        self.randomColor.set_tooltip(_("Toggle random color"))
        self.randomColor.props.icon_name = "colorRandom"
        self.randomColor.connect("toggled", self.resetColors)
        toolbar_box.toolbar.insert(self.randomColor, -1)
        self.randomColor.set_active(True)
        self.randomColor.show()

        self._insert_stop_play_button(toolbar_box.toolbar)

        clear_trace = ToolButton("clear-trace")
        clear_trace.set_tooltip(_("Clear Trace Marks"))
        clear_trace.set_accelerator(_("<ctrl>x"))
        clear_trace.connect("clicked", self.clear_trace_cb)
        clear_trace.set_sensitive(False)
        toolbar_box.toolbar.insert(clear_trace, -1)
        clear_trace.show()
        self.clear_trace = clear_trace

        self._insert_clear_all_button(toolbar_box.toolbar)

        load_example = ToolButton("load-sample")
        load_example.set_tooltip(_("Show sample projects"))
        load_example.connect("clicked", self._create_store)
#.........这里部分代码省略.........
开发者ID:sugarlabs,项目名称:physics,代码行数:103,代码来源:activity.py

示例2: PhysicsActivity

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import show_all [as 别名]
class PhysicsActivity(activity.Activity):

    def __init__(self, handle):
        super(PhysicsActivity, self).__init__(handle)
        self.metadata['mime_type'] = 'application/x-physics-activity'
        self.add_events(Gdk.EventMask.ALL_EVENTS_MASK |
                        Gdk.EventMask.VISIBILITY_NOTIFY_MASK)

        self.connect('visibility-notify-event', self._focus_event)
        self.connect('window-state-event', self._window_event)

        self.game_canvas = sugargame.canvas.PygameCanvas(self)
        self.game = physics.main(self)

        self.preview = None
        self._sample_window = None

        self._fixed = Gtk.Fixed()
        self._fixed.put(self.game_canvas, 0, 0)

        w = Gdk.Screen.width()
        h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE

        self.game_canvas.set_size_request(w, h)

        self._constructors = {}
        self.build_toolbar()

        self.set_canvas(self._fixed)
        Gdk.Screen.get_default().connect('size-changed',
                                         self.__configure_cb)

        logging.debug(os.path.join(
                      activity.get_activity_root(), 'data', 'data'))
        self.game_canvas.run_pygame(self.game.run)
        GObject.idle_add(self._setup_sharing)
        self.show_all()

    def _setup_sharing(self):
        self.we_are_sharing = False

        if self.shared_activity:
            # We're joining
            if not self.get_shared():
                xocolors = XoColor(profile.get_color().to_string())
                share_icon = Icon(icon_name='zoom-neighborhood',
                                  xo_color=xocolors)
                self._joined_alert = Alert()
                self._joined_alert.props.icon = share_icon
                self._joined_alert.props.title = _('Please wait')
                self._joined_alert.props.msg = _('Starting connection...')
                self.add_alert(self._joined_alert)
                self._waiting_cursor()

        self._setup_presence_service()

    def __configure_cb(self, event):
        ''' Screen size has changed '''
        self.write_file(os.path.join(
                        activity.get_activity_root(), 'data', 'data'))
        w = Gdk.Screen.width()
        h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE
        pygame.display.set_mode((w, h),
                                pygame.RESIZABLE)
        self.read_file(os.path.join(
                       activity.get_activity_root(), 'data', 'data'))
        self.game.run(True)

    def read_file(self, file_path):
        self.game.read_file(file_path)

    def write_file(self, file_path):
        self.game.write_file(file_path)

    def get_preview(self):
        ''' Custom preview code to get image from pygame. '''
        return self.game_canvas.get_preview()

    def build_toolbar(self):
        self.max_participants = 4

        toolbar_box = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        create_toolbar = ToolbarButton()
        create_toolbar.props.page = Gtk.Toolbar()
        create_toolbar.props.icon_name = 'magicpen'
        create_toolbar.props.label = _('Create')
        toolbar_box.toolbar.insert(create_toolbar, -1)
        self._insert_create_tools(create_toolbar)

        self._insert_stop_play_button(toolbar_box.toolbar)

        clear_trace = ToolButton('clear-trace')
        clear_trace.set_tooltip(_('Clear Trace Marks'))
        clear_trace.set_accelerator(_('<ctrl>x'))
        clear_trace.connect('clicked', self.clear_trace_cb)
        clear_trace.set_sensitive(False)
#.........这里部分代码省略.........
开发者ID:godiard,项目名称:physics,代码行数:103,代码来源:activity.py


注:本文中的sugar3.graphics.toolbarbox.ToolbarButton.show_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。