本文整理汇总了Python中PyQt5.QtWidgets.QSystemTrayIcon.deleteLater方法的典型用法代码示例。如果您正苦于以下问题:Python QSystemTrayIcon.deleteLater方法的具体用法?Python QSystemTrayIcon.deleteLater怎么用?Python QSystemTrayIcon.deleteLater使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSystemTrayIcon
的用法示例。
在下文中一共展示了QSystemTrayIcon.deleteLater方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TriblerWindow
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import deleteLater [as 别名]
#.........这里部分代码省略.........
self.search_results_page.received_search_result)
# Install signal handler for ctrl+c events
def sigint_handler(*_):
self.close_tribler()
signal.signal(signal.SIGINT, sigint_handler)
self.installEventFilter(self.video_player_page)
# Resize the window according to the settings
center = QApplication.desktop().availableGeometry(self).center()
pos = self.gui_settings.value("pos", QPoint(center.x() - self.width() * 0.5, center.y() - self.height() * 0.5))
size = self.gui_settings.value("size", self.size())
self.move(pos)
self.resize(size)
self.show()
def update_tray_icon(self, use_monochrome_icon):
if not QSystemTrayIcon.isSystemTrayAvailable() or not self.tray_icon:
return
if use_monochrome_icon:
self.tray_icon.setIcon(QIcon(QPixmap(get_image_path('monochrome_tribler.png'))))
else:
self.tray_icon.setIcon(QIcon(QPixmap(get_image_path('tribler.png'))))
self.tray_icon.show()
def delete_tray_icon(self):
if self.tray_icon:
try:
self.tray_icon.deleteLater()
except RuntimeError:
# The tray icon might have already been removed when unloading Qt.
# This is due to the C code actually being asynchronous.
logging.debug("Tray icon already removed, no further deletion necessary.")
self.tray_icon = None
def on_low_storage(self):
"""
Dealing with low storage space available. First stop the downloads and the core manager and ask user to user to
make free space.
:return:
"""
self.downloads_page.stop_loading_downloads()
self.core_manager.stop(False)
close_dialog = ConfirmationDialog(self.window(), "<b>CRITICAL ERROR</b>",
"You are running low on disk space (<100MB). Please make sure to have "
"sufficient free space available and restart Tribler again.",
[("Close Tribler", BUTTON_TYPE_NORMAL)])
close_dialog.button_clicked.connect(lambda _: self.close_tribler())
close_dialog.show()
def on_torrent_finished(self, torrent_info):
self.tray_show_message("Download finished", "Download of %s has finished." % torrent_info["name"])
def show_loading_screen(self):
self.top_menu_button.setHidden(True)
self.left_menu.setHidden(True)
self.token_balance_widget.setHidden(True)
self.settings_button.setHidden(True)
self.add_torrent_button.setHidden(True)
self.top_search_bar.setHidden(True)
self.stackedWidget.setCurrentIndex(PAGE_LOADING)
示例2: QtApplication
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import deleteLater [as 别名]
#.........这里部分代码省略.........
# Handle Qt events
def event(self, event: QEvent) -> bool:
if event.type() == _QtFunctionEvent.QtFunctionEvent:
event._function_event.call()
return True
return super().event(event)
def windowClosed(self, save_data: bool = True) -> None:
Logger.log("d", "Shutting down %s", self.getApplicationName())
self._is_shutting_down = True
# garbage collect tray icon so it gets properly closed before the application is closed
self._tray_icon_widget = None
if save_data:
try:
self.savePreferences()
except Exception as e:
Logger.log("e", "Exception while saving preferences: %s", repr(e))
try:
self.applicationShuttingDown.emit()
except Exception as e:
Logger.log("e", "Exception while emitting shutdown signal: %s", repr(e))
try:
self.getBackend().close()
except Exception as e:
Logger.log("e", "Exception while closing backend: %s", repr(e))
if self._tray_icon_widget:
self._tray_icon_widget.deleteLater()
self.quit()
def checkWindowMinimizedState(self) -> bool:
if self._main_window is not None and self._main_window.windowState() == Qt.WindowMinimized:
return True
else:
return False
## Get the backend of the application (the program that does the heavy lifting).
# The backend is also a QObject, which can be used from qml.
@pyqtSlot(result = "QObject*")
def getBackend(self) -> Backend:
return self._backend
## Property used to expose the backend
# It is made static as the backend is not supposed to change during runtime.
# This makes the connection between backend and QML more reliable than the pyqtSlot above.
# \returns Backend \type{Backend}
@pyqtProperty("QVariant", constant = True)
def backend(self) -> Backend:
return self.getBackend()
## Create a class variable so we can manage the splash in the CrashHandler dialog when the Application instance
# is not yet created, e.g. when an error occurs during the initialization
splash = None # type: Optional[QSplashScreen]
def createSplash(self) -> None:
if not self.getIsHeadLess():
try:
QtApplication.splash = self._createSplashScreen()
except FileNotFoundError:
示例3: XNova_MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSystemTrayIcon [as 别名]
# 或者: from PyQt5.QtWidgets.QSystemTrayIcon import deleteLater [as 别名]
#.........这里部分代码省略.........
self._hidden_to_tray = False
def changeEvent(self, evt: QEvent):
super(XNova_MainWindow, self).changeEvent(evt)
if evt.type() == QEvent.WindowStateChange:
if not isinstance(evt, QWindowStateChangeEvent):
return
# make sure we only do this for minimize events
if (evt.oldState() != Qt.WindowMinimized) and self.isMinimized():
# we were minimized! explicitly hide settings widget
# if it is open, otherwise it will be lost forever :(
if self.settings_widget is not None:
if self.settings_widget.isVisible():
self.settings_widget.hide()
# should we minimize to tray?
if self.cfg['tray']['icon_usage'] == 'show_min':
if not self._hidden_to_tray:
self._hidden_to_tray = True
self.hide()
def create_tray_icon(self):
if QSystemTrayIcon.isSystemTrayAvailable():
logger.debug('System tray icon is available, showing')
self.tray_icon = QSystemTrayIcon(QIcon(':/i/xnova_logo_32.png'), self)
self.tray_icon.setToolTip(self.tr('XNova Commander'))
self.tray_icon.activated.connect(self.on_tray_icon_activated)
self.tray_icon.show()
else:
self.tray_icon = None
def hide_tray_icon(self):
if self.tray_icon is not None:
self.tray_icon.hide()
self.tray_icon.deleteLater()
self.tray_icon = None
def set_tray_tooltip(self, tip: str):
if self.tray_icon is not None:
self.tray_icon.setToolTip(tip)
def set_status_message(self, msg: str):
self._statusbar.set_status(msg)
def store_cfg_val(self, category: str, value):
pickle_filename = '{0}/{1}.dat'.format(self.config_store_dir, category)
try:
cache_dir = pathlib.Path(self.config_store_dir)
if not cache_dir.exists():
cache_dir.mkdir()
with open(pickle_filename, 'wb') as f:
pickle.dump(value, f)
except pickle.PickleError as pe:
pass
except IOError as ioe:
pass
def load_cfg_val(self, category: str, default_value=None):
value = None
pickle_filename = '{0}/{1}.dat'.format(self.config_store_dir, category)
try:
with open(pickle_filename, 'rb') as f:
value = pickle.load(f)
if value is None:
value = default_value
except pickle.PickleError as pe:
pass