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


Python KanoButton.disconnect方法代码示例

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


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

示例1: NetworkScreen

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import disconnect [as 别名]

#.........这里部分代码省略.........

        self._connect_btn = KanoButton(_("CONNECT"))
        self._connect_btn.pack_and_align()
        self.connect_handler = self._connect_btn.connect(
            'clicked', self._first_time_connect
        )
        self._connect_btn.set_sensitive(False)
        self._refresh_btn = self._create_refresh_button()

        # For now, show both connect and refresh buttons
        buttonbox = Gtk.ButtonBox()
        buttonbox.set_layout(Gtk.ButtonBoxStyle.CENTER)
        buttonbox.set_spacing(10)
        buttonbox.pack_start(self._refresh_btn, False, False, 0)
        buttonbox.pack_start(self._connect_btn.align, False, False, 0)

        if self._win.is_plug():
            self._skip_btn = WhiteButton(_("Skip"))
            buttonbox.pack_start(self._skip_btn, False, False, 0)
            self._skip_btn.connect('clicked', self.skip)
        else:
            blank_label = Gtk.Label("")
            buttonbox.pack_start(blank_label, False, False, 0)

        return buttonbox

    # Attached to a callback, hence the extra argument
    def skip(self, skip_btn=None):
        # Exit with an extreme exit code so the init-flow knows the user
        # pressed SKIP
        sys.exit(100)

    def _set_connect_btn_status(self, connect=True):
        self._connect_btn.disconnect(self.connect_handler)

        if connect:
            self.connect_handler = self._connect_btn.connect(
                'clicked', self._first_time_connect
            )
            self._connect_btn.set_color('green')
            self._connect_btn.set_label(_("CONNECT"))

        else:
            self.connect_handler = self._connect_btn.connect(
                'clicked', self._launch_disconnect_thread
            )
            self._connect_btn.set_color('red')
            self._connect_btn.set_label(_("DISCONNECT"))

    def _launch_disconnect_thread(self, widget=None):
        watch_cursor = Gdk.Cursor(Gdk.CursorType.WATCH)
        self._win.get_window().set_cursor(watch_cursor)
        self._connect_btn.start_spinner()
        self._connect_btn.set_sensitive(False)

        # Force the spinner to show on the window.
        while Gtk.events_pending():
            Gtk.main_iteration()

        t = threading.Thread(target=self._threaded_disconnect)
        t.start()

    def _disconnect_screen(self):
        self._win.remove_main_widget()
        title = _("Disconnect complete.")
        description = _("You're now offline")
开发者ID:KanoComputing,项目名称:kano-settings,代码行数:70,代码来源:NetworkScreen.py


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