def init(app_name): """Initializes the DBus connection""" global APP_NAME, DBUS_IFACE APP_NAME = app_name name = "org.freedesktop.Notifications" path = "/org/freedesktop/Notifications" interface = "org.freedesktop.Notifications" mainloop = None try: if DBusQtMainLoop is not None: mainloop = DBusQtMainLoop(set_as_default=True) bus = dbus.SessionBus(mainloop) proxy = bus.get_object(name, path) DBUS_IFACE = dbus.Interface(proxy, interface) if mainloop is not None: # We have a mainloop, so connect callbacks DBUS_IFACE.connect_to_signal('ActionInvoked', _onActionInvoked) DBUS_IFACE.connect_to_signal('NotificationClosed', _onNotificationClosed) except Exception as e: LOG.warning('Descktop Notify not availale:: {}'.format(e))
print("repoUpdate clicked") def rebootBtn_clicked(self): print("rebootBtn clicked") def ownCmd1_clicked(self): print("ownCmd1 clicked") def ownCmd2_clicked(self): print("ownCmd2 clicked") if __name__ == "__main__": homePage = "" bugEmail = "" aboutData = "" if not dbus.get_default_main_loop(): from dbus.mainloop.pyqt5 import DBusQtMainLoop DBusQtMainLoop(set_as_default=True) app = QApplication(sys.argv) window = ParallX() window.show() rect = QDesktopWidget().screenGeometry() window.move((rect.width() - window.width()) // 2, (rect.height() - window.height()) // 2) sys.exit(app.exec_())
def main(): signal.signal(signal.SIGINT, signal.SIG_DFL) DBusQtMainLoop(set_as_default=True) app = QtCore.QCoreApplication([]) service = QomuiDbus() app.exec_()
def __init__(self, debug=False, minimized=None, urgent_hint=None, settings_path='', cache_path=''): super(ScudCloud, self).__init__(None) self.debug = debug self.minimized = minimized self.urgent_hint = urgent_hint self.setWindowTitle(self.title) self.settings_path = settings_path self.cache_path = cache_path self.notifier = Notifier(Resources.APP_NAME, Resources.get_path('scudcloud.png')) self.settings = QSettings(self.settings_path + '/scudcloud_qt5.cfg', QSettings.IniFormat) self.notifier.enabled = self.settings.value('Notifications', defaultValue=True, type=bool) self.identifier = self.settings.value("Domain") if Unity is not None: self.launcher = Unity.LauncherEntry.get_for_desktop_id( "scudcloud.desktop") else: self.launcher = DummyLauncher(self) self.webSettings() self.snippetsSettings() self.leftPane = LeftPane(self) self.stackedWidget = QtWidgets.QStackedWidget() centralWidget = QtWidgets.QWidget(self) layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.leftPane) layout.addWidget(self.stackedWidget) centralWidget.setLayout(layout) self.setCentralWidget(centralWidget) self.startURL = Resources.SIGNIN_URL if self.identifier is not None: if isinstance(self.identifier, str): self.domains = self.identifier.split(",") else: self.domains = self.identifier self.startURL = self.normalize(self.domains[0]) else: self.domains = [] self.addWrapper(self.startURL) self.addMenu() self.tray = Systray(self) self.systray(self.minimized) self.installEventFilter(self) self.statusBar().showMessage('Loading Slack...') self.tickler = QTimer(self) self.tickler.setInterval(1800000) # Watch for ScreenLock events if DBusQtMainLoop is not None: DBusQtMainLoop(set_as_default=True) sessionBus = dbus.SessionBus() # Ubuntu 12.04 and other distros sessionBus.add_match_string( "type='signal',interface='org.gnome.ScreenSaver'") # Ubuntu 14.04 sessionBus.add_match_string( "type='signal',interface='com.ubuntu.Upstart0_6'") # Ubuntu 16.04 and KDE sessionBus.add_match_string( "type='signal',interface='org.freedesktop.ScreenSaver'") # Cinnamon sessionBus.add_match_string( "type='signal',interface='org.cinnamon.ScreenSaver'") sessionBus.add_message_filter(self.screenListener) self.tickler.timeout.connect(self.sendTickle) # If dbus is not present, tickler timer will act like a blocker to not send tickle too often else: self.tickler.setSingleShot(True) self.tickler.start()
def main(argv): global server_thread print("Starting %s %s..." % (common.app_name, common.app_version)) print(""" __ / \_ __( )_ _( \_ _( )_ (__________________) """) app = QApplication(argv) network.setup() filtering.setup() # Create extension server. server_thread = extension_server.ExtensionServerThread( QCoreApplication.instance()) # Start DBus loop if has_dbus: print("DBus available. Creating main loop...", end=" ") mainloop = DBusQtMainLoop(set_as_default=True) dbus.set_default_main_loop(mainloop) print("done.") else: print("DBus unavailable.") # Create app. app.setApplicationName(common.app_name) app.setApplicationVersion(common.app_version) app.installTranslator(translate.translator) # We want Nimbus to stay open when the last window is closed, # so we set this. app.setQuitOnLastWindowClosed(False) # If D-Bus is present... if has_dbus: print("Creating DBus session bus...", end=" ") try: bus = dbus.SessionBus() except: print("failed.") else: print("done.") try: print("Checking for running instances of %s..." % (common.app_name, ), end=" ") proxy = bus.get_object( "org.nimbus.%s" % (common.app_name, ), "/%s" % common.app_name, ) except: dbus_present = False else: dbus_present = True print("done.") # If Nimbus detects the existence of another Nimbus process, it # will send all the requested URLs to the existing process and # exit. if dbus_present: print( "An instance of Nimbus is already running. Passing arguments via DBus." ) for arg in argv[1:]: proxy.addTab(arg) if len(argv) < 2: proxy.addWindow() return elif has_dbus: print("No prior instances found. Continuing on our merry way.") # Hack together the browser's icon. This needs to be improved. common.app_icon = common.complete_icon("nimbus") app.setWindowIcon(common.app_icon) common.searchEditor = search_manager.SearchEditor() common.downloadManager = DownloadManager(windowTitle=tr("Downloads")) common.downloadManager.resize(QSize(480, 320)) common.downloadManager.loadSession() # Create tray icon. common.trayIcon = SystemTrayIcon() common.trayIcon.newWindowRequested.connect(addWindow) #common.trayIcon.windowReopenRequested.connect(reopenWindow) common.trayIcon.show() # Creates a licensing information dialog. common.licenseDialog = custom_widgets.LicenseDialog() # Create instance of clear history dialog. common.chistorydialog = clear_history_dialog.ClearHistoryDialog() uc = QUrl.fromUserInput(settings.user_css) websettings = QWebSettings.globalSettings() websettings.setUserStyleSheetUrl(uc) websettings.enablePersistentStorage(settings.settings_folder) websettings.setAttribute(websettings.LocalContentCanAccessRemoteUrls, True) websettings.setAttribute(websettings.LocalContentCanAccessFileUrls, True) websettings.setAttribute(websettings.DeveloperExtrasEnabled, True) try: websettings.setAttribute(websettings.ScrollAnimatorEnabled, True) except: pass common.applyWebSettings() # Set up settings dialog. settings.settingsDialog = settings_dialog.SettingsDialog() settings.settingsDialog.setWindowFlags(Qt.Dialog) closeSettingsDialogAction = QAction(settings.settingsDialog) closeSettingsDialogAction.setShortcuts(["Esc", "Ctrl+W"]) closeSettingsDialogAction.triggered.connect(settings.settingsDialog.hide) settings.settingsDialog.addAction(closeSettingsDialogAction) # Set up clippings manager. settings.clippingsManager = settings_dialog.ClippingsPanel() settings.clippingsManager.setWindowFlags(Qt.Dialog) closeClippingsManagerAction = QAction(settings.clippingsManager) closeClippingsManagerAction.setShortcuts(["Esc", "Ctrl+W"]) closeClippingsManagerAction.triggered.connect( settings.clippingsManager.hide) settings.clippingsManager.addAction(closeClippingsManagerAction) # Create DBus server if has_dbus: print("Creating DBus server...", end=" ") server = DBusServer(bus) print("done.") # Load adblock rules. filtering.adblock_filter_loader.start() if not os.path.isdir(settings.extensions_folder): try: print("Copying extensions...", end=" ") shutil.copytree(common.extensions_folder,\ settings.extensions_folder) except: print("failed.") else: print("done.") if not os.path.isfile(settings.startpage): try: print("Copying start page...", end=" ") shutil.copy2(common.startpage, settings.startpage) except: print("failed.") else: print("done.") settings.reload_extensions() settings.reload_userscripts() server_thread.setDirectory(settings.extensions_folder) # Start extension server. server_thread.start() # On quit, save settings. app.aboutToQuit.connect(prepareQuit) # Load settings. data.loadData() # View source dialog. common.viewSourceDialog = ViewSourceDialogTabber() #common.viewSourceDialog.show() # This is a baaad name. common.sessionSaver = QTimer(QCoreApplication.instance()) common.sessionSaver.timeout.connect(saveSession) common.sessionSaver.timeout.connect(data.saveData) if common.portable: common.sessionSaver.start(50000) else: common.sessionSaver.start(30000) common.desktop = QDesktopWidget() changeSettings = False if os.path.isfile(settings.crash_file): print("Crash file detected.", end="") if not has_dbus: print( " With no DBus, %s may already be running." % common.app_name, ) multInstances = QMessageBox.question( None, tr("Hm."), tr("It's not good to run multiple instances of %(app_name)s. Is an instance of %(app_name)s already running?" ) % {"app_name": common.app_name}, QMessageBox.Yes | QMessageBox.No) if multInstances == QMessageBox.Yes: print("%s will now halt." % common.app_name, ) return else: print() clearCache = QMessageBox() clearCache.setWindowTitle(tr("Ow.")) clearCache.setText( tr("%(app_name)s seems to have crashed during your last session. Fortunately, your tabs were saved up to 30 seconds beforehand. Would you like to restore them?" ) % {"app_name": common.app_name}) clearCache.addButton(QPushButton(tr("Yes and change &settings")), QMessageBox.YesRole) clearCache.addButton(QMessageBox.Yes) clearCache.addButton(QMessageBox.No) returnValue = clearCache.exec_() if returnValue == QMessageBox.No: try: os.remove(settings.session_file) except: pass if returnValue == 0: changeSettings = True else: f = open(settings.crash_file, "w") f.write("") f.close() if not "--daemon" in argv and os.path.exists(settings.session_file): print("Loading previous session...", end=" ") if changeSettings: settings.settingsDialog.exec_() loadSession() print("done.") if not "--daemon" in argv and len(argv[1:]) > 0: # Create instance of MainWindow. print("Loading the URLs you requested...", end=" ") if len(browser.windows) > 0: win = browser.windows[-1] else: win = MainWindow(appMode=("--app" in argv)) # Open URLs from command line. if len(argv[1:]) > 0: for arg in argv[1:]: if "." in arg or ":" in arg: win.addTab(url=arg) if win.tabWidget().count() < 1: win.addTab(url=settings.settings.value("general/Homepage")) # Show window. win.show() print("done.") elif not "--daemon" in argv and len(argv[1:]) == 0 and len( browser.windows) == 0: win = MainWindow(appMode=("--app" in argv)) win.addTab(url=settings.settings.value("general/Homepage")) win.show() # Load filtering stuff. if not os.path.isdir(filtering.hosts_folder): common.trayIcon.showMessage(tr("Downloading content filters"), ( "Ad blocking and host filtering will not work until this completes." )) filtering.update_filters() else: filtering.load_host_rules() # Start app. print("Kon~!") sys.exit(app.exec_())
def main(): DBusQtMainLoop(set_as_default=True) app = QtCore.QCoreApplication([]) service = QomuiDbus() app.exec_()
def __init__(self): super(gpvdm_main_window, self).__init__() self.splash = splash_window() self.splash.inc_value() process_events() process_events() #from wiz import wiz #a=wiz() #a.exec_() #sys.exit() do_import() if os.path.isdir(os.path.dirname(sys.argv[0])) == False: error_dlg(self, _("I can't run from inside a zip file!")) sys.exit() self.splash.inc_value() self.splash.inc_value() server_init() self.splash.inc_value() self.check_sim_exists = check_sim_exists() self.splash.inc_value() self.check_sim_exists.start_thread() self.splash.inc_value() self.check_sim_exists.sim_gone.connect(self.sim_gone) self.splash.inc_value() self.my_server = server_get() self.my_server.init(get_sim_path()) self.splash.inc_value() self.undo_list = undo_list_class() wpos_load() self.splash.inc_value() self.ribbon = ribbon() self.splash.inc_value() self.notebook_active_page = None self.setAcceptDrops(True) #self.setGeometry(200, 100, 1300, 600) self.setWindowTitle( "General-purpose Photovoltaic Device Model (https://www.gpvdm.com)" ) #super(gpvdm_main_window, self).__init__(parent, QtCore.Qt.FramelessWindowHint) #gobject.GObject.__init__(self) self.my_server.setup_gui(self.gui_sim_start) self.splash.inc_value() self.my_server.sim_finished.connect(self.gui_sim_stop) self.splash.inc_value() help_init() self.splash.inc_value() #help_window().help_set_help(["star.png",_("<big><b>Update available!</b></big><br>")]) #self.show() if running_on_linux() == True: DBusQtMainLoop(set_as_default=True) self.bus = dbus.SessionBus() self.bus.add_match_string_non_blocking( "type='signal',interface='org.my.gpvdm'") self.bus.add_message_filter(self.adbus) else: self.win_pipe = win_pipe() self.win_pipe.new_data.connect(self.win_dbus) self.win_pipe.start() self.notebook = gpvdm_notebook() vbox = QVBoxLayout() self.splash.inc_value() vbox.addWidget(self.ribbon) vbox.addWidget(self.notebook) wvbox = QWidget() self.splash.inc_value() wvbox.setLayout(vbox) self.setCentralWidget(wvbox) self.splash.inc_value() self.statusBar() temp_error = ver_error() #print(temp_error) if len(temp_error) > 0: error_dlg(self, temp_error) return self.setWindowIcon( QIcon(os.path.join(get_image_file_path(), "image.jpg"))) self.splash.inc_value() self.show_tabs = True self.show_border = True self.ribbon.home_export.triggered.connect(self.callback_export) #if enable_webupdates()==False: # self.help_menu_update=help_menu.addAction("&"+_("Check for updates")) # self.help_menu_update.triggered.connect(self.callback_update) self.ribbon.home_new.triggered.connect(self.callback_new) self.ribbon.home_open.triggered.connect(self.callback_open) self.ribbon.home.undo.triggered.connect(self.callback_undo) self.ribbon.home.run.triggered.connect(self.callback_simulate) self.splash.inc_value() self.ribbon.home.stop.setEnabled(False) self.ribbon.home.scan.setEnabled(False) self.ribbon.home.help.triggered.connect(self.callback_on_line_help) resize_window_to_be_sane(self, 0.7, 0.75) self.change_dir_and_refresh_interface(get_sim_path()) self.splash.inc_value() self.ribbon.home.sun.changed.connect(self.notebook.update) self.ribbon.setAutoFillBackground(True) self.splash.inc_value() self.show() help_window().show() from update import update_window self.a = update_window() self.a.show()