def __init__(self, args: list): super().__init__() self.load() # load preferences # initialize QtApplication self.application = QtGui.QApplication(args) self.parent = QtGui.QWidget() global_dict[application_key] = self # initialize thread pool executor self.executor = QtCore.QThreadPool() self.executor.setMaxThreadCount(self.GlobalInfos.pool_thread_size) # set some global stuff if self.description_icon: self.application.setWindowIcon(get_icon(self.description_icon)) if self.verbose_name: self.application.setApplicationName(str(self.verbose_name)) if self.application_version: self.application.setApplicationVersion(self.application_version) if self.systemtray_icon: self._parent_obj = QtGui.QWidget() self.systray = QtGui.QSystemTrayIcon(get_icon(self.systemtray_icon), self._parent_obj) self.systray.setVisible(True) self.systray.show() # retrieve menu and associated actions for the whole class hierarchy created_action_keys = set() menu = None for qualname in self.__class__.__mro__: cls_name = qualname.__name__.rpartition('.')[2] if cls_name not in registered_menus: continue for menu_action in registered_menu_actions[cls_name]: if menu is None: menu = QtGui.QMenu(self.verbose_name, self._parent_obj) if menu_action.uid in created_action_keys: # skip overriden actions (there are already created) continue created_action_keys.add(menu_action.uid) menu_action.create(self, menu) if menu is not None: self.systray.setContextMenu(menu) # noinspection PyUnresolvedReferences self.systray.activated.connect(self.systray_activated) # noinspection PyUnresolvedReferences self.systray.messageClicked.connect(self.systray_message_clicked) if self.splashscreen_icon: self.splashscreen = QtGui.QSplashScreen(self.parent, get_pixmap(self.splashscreen_icon), QtCore.Qt.WindowStaysOnTopHint) self.splashscreen.showMessage(_('Loading data…')) self.splashscreen.show() # noinspection PyUnresolvedReferences self.application.lastWindowClosed.connect(self.save) self.load_data() if self.splashscreen is not None: self.splashscreen.hide()
def __init__(self, message, parent=None): super().__init__(p(parent)) widgets = [] if application.splashscreen_icon: pixmap = get_pixmap(application.splashscreen_icon) label = QtGui.QLabel(p(self)) label.setPixmap(pixmap) widgets.append(label) edit = QtGui.QTextEdit(message, self) edit.setReadOnly(True) widgets.append(edit) widgets.append(create_button(_('Close'), min_size=True, parent=self, connect=self.close)) self.setLayout(v_layout(self, *widgets))
def base_set_sb_indicator(self, key, icon_name=None, message=None): if key not in self._indicators: label = QtGui.QLabel(p(self)) statusbar = self.statusBar() """:type: QtGui.QStatusBar""" statusbar.insertPermanentWidget(len(self._indicators), label, 0) self._indicators[key] = label else: label = self._indicators[key] """:type: QtGui.Label""" if icon_name is not None: label.setPixmap(get_pixmap(icon_name)) if message is not None: label.setText(message)