本文整理汇总了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()
示例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())
#.........这里部分代码省略.........