當前位置: 首頁>>代碼示例>>Python>>正文


Python MainWindow.connect方法代碼示例

本文整理匯總了Python中main_window.MainWindow.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python MainWindow.connect方法的具體用法?Python MainWindow.connect怎麽用?Python MainWindow.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在main_window.MainWindow的用法示例。


在下文中一共展示了MainWindow.connect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Application

# 需要導入模塊: from main_window import MainWindow [as 別名]
# 或者: from main_window.MainWindow import connect [as 別名]
class Application(Gtk.Application):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, application_id="easy-ebook-viewer",
                         flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE,
                         **kwargs)
        self.window = None
        self.file_path = None
        GLib.set_application_name('Easy eBook Viewer')
        GLib.set_prgname('easy-ebook-viewer')
        GLib.setenv('PULSE_PROP_application.icon_name', 'easy-ebook-viewer', True)

    def do_startup(self):
        Gtk.Application.do_startup(self)

        action = Gio.SimpleAction.new("about", None)
        action.connect("activate", self.on_about)
        self.add_action(action)

        action = Gio.SimpleAction.new("quit", None)
        action.connect("activate", self.on_quit)
        self.add_action(action)

    def do_activate(self):
        GObject.threads_init()
        gettext.install('easy-ebook-viewer', '/usr/share/easy-ebook-viewer/locale')
        # We only allow a single window and raise any existing ones
        if not self.window:
            # Windows are associated with the application
            # when the last one is closed the application shuts down
            self.window = MainWindow(file_path=self.file_path)
            self.window.connect("delete-event", self.on_quit)
            self.window.set_wmclass("easy-ebook-viewer", "easy-ebook-viewer")
        self.window.show_all()
        if not self.window.book_loaded:
            self.window.header_bar_component.hide_jumping_navigation()
        Gtk.main()

    def do_command_line(self, command_line):
        # If book came from arguments ie. was oppened using "Open with..." method etc.
        if len(sys.argv) > 1:
            # Check if that file really exists
            if os.path.exists(sys.argv[1]):
                self.file_path = sys.argv[1]
        self.activate()
        return 0

    def on_about(self, action, param):
        dialog = about_dialog.AboutDialog()
        dialog.show_all()

    def on_quit(self, action, param):
        Gdk.threads_leave()
        Gtk.main_quit()
        self.quit()
開發者ID:michaldaniel,項目名稱:Ebook-Viewer,代碼行數:56,代碼來源:main.py

示例2: PSSOptimisation

# 需要導入模塊: from main_window import MainWindow [as 別名]
# 或者: from main_window.MainWindow import connect [as 別名]
class PSSOptimisation(object):
    def __init__(self):
        QtCore.QCoreApplication.setApplicationName("PSSOptimisation")
        QtCore.QCoreApplication.setApplicationVersion(str(VERSION))
        QtCore.QCoreApplication.setOrganizationName("Hubert Grzeskowiak")

        self.settings = QtCore.QSettings()
        self.main_window = MainWindow(True)
        self.grades_model = GradesModel(self.main_window)
        self.proxy_model = GradesModelProxy()
        self.proxy_model.setSourceModel(self.grades_model)

        self.initUI()
        # tray = QtGui.QSystemTrayIcon(self.main_window)
        # tray.setIcon(QtGui.QIcon("icons/Accessories-calculator.svg"))
        # tray.connect(tray,
        #     SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),
        #     self.trayClicked)
        # tray.show()
        # self.tray = tray

    # def trayClicked(self, reason):
    #     print reason
    #     if reason == QtGui.QSystemTrayIcon.DoubleClick:
    #         self.main_window.setVisible(not self.main_window.isVisible())

    def initUI(self):
        self.connectUI()
        self.main_window.show()

    def __columnsChanged(self):
        """This should be called whenever the columns filter is changed.
        It's a workaround for a bug in the headerview not updating the columns
        properly on filter change.
        """
        header = self.main_window.grades_table.horizontalHeader()
        header.resizeSections(QtGui.QHeaderView.ResizeToContents)
        header.resizeSection(0, header.sectionSize(0)-1)
        header.resizeSection(0, header.sectionSize(0)+1)

    def connectUI(self):
        self.main_window.grades_table.setModel(self.proxy_model)
        delegate = CheckBoxDelegate()
        self.main_window.grades_table.setItemDelegate(delegate)

        self.main_window.connect(self.main_window.action_download,
            SIGNAL("triggered()"), self.openLoginDialog)
        self.main_window.connect(self.main_window.action_donate,
            SIGNAL("triggered()"), self.openDonationDialog)
        self.main_window.connect(self.main_window.action_open,
            SIGNAL("triggered()"), self.openFileDialog)
        self.main_window.connect(self.grades_model,
            SIGNAL("dataChanged()"), self.updateStats)
        self.main_window.connect(self.grades_model,
            SIGNAL("dataChanged()"),
            self.main_window.grades_table.resizeColumnsToContents)
        self.main_window.connect(self.grades_model,
            SIGNAL("modelReset()"), self.updateStats)
        self.main_window.connect(self.grades_model,
            SIGNAL("modelReset()"),
            self.main_window.grades_table.resizeColumnsToContents)
        
        # workaround for buggy headerview
        self.main_window.connect(self.proxy_model,
            SIGNAL("columnsVisibilityChanged()"),
            self.__columnsChanged)
        
        # create actions for toggling table columns
        header = self.main_window.grades_table.horizontalHeader()
        self.header_actions = QtGui.QActionGroup(header)
        self.header_actions.setExclusive(False)
        for nr, (name, visible) in enumerate(zip(
                self.grades_model.header_data,
                self.proxy_model.col_visibility)):
            action = self.header_actions.addAction(name)
            action.setCheckable(True)
            action.setChecked(visible)
            action.connect(action, SIGNAL("triggered()"),
                lambda nr=nr: self.proxy_model.toggleColumn(nr))

        # add that menu as context menu for the header
        header.addActions(self.header_actions.actions())
        header.setContextMenuPolicy(
            QtCore.Qt.ActionsContextMenu)

        # and put it into the main window's menus
        self.main_window.menu_table_columns.clear()
        for action in self.header_actions.actions():
            self.main_window.menu_table_columns.addAction(action)

        # automatically download new grades (depends on settings)
        if self.settings.value("updateOnStart", False).toBool():
            QtCore.QTimer.singleShot(200, self.tryAutoDownloadFromPSSO)
    
    def openLoginDialog(self):
        self.login_dialog = LoginDialog(self.main_window)
        self.login_dialog.exec_()
        if self.login_dialog.result():
            username = str(self.login_dialog.username_line.text())
            password = str(self.login_dialog.password_line.text())
#.........這裏部分代碼省略.........
開發者ID:amrni,項目名稱:PSSOptimisation2,代碼行數:103,代碼來源:main.py


注:本文中的main_window.MainWindow.connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。