def openPopover(self, name="popover", html="UniqueBible.app", fullScreen=False, screenNo=-1): # image options if config.exportEmbeddedImages: html = self.parent.parent.exportAllImages(html) if config.clickToOpenImage: html = self.parent.parent.addOpenImageAction(html) # format html content html = self.parent.parent.wrapHtml(html) if not hasattr(self, "popoverView") or not self.popoverView.isVisible: self.popoverView = WebEngineViewPopover(self, name, self.name) self.popoverView.setHtml(html, config.baseUrl) if fullScreen: monitor = QDesktopWidget().screenGeometry(screenNo) self.popoverView.move(monitor.left(), monitor.top()) if platform.system() == "Linux": # Using self.popoverView.showFullScreen() directly does not work on Linux self.popoverView.showMaximized() self.popoverView.escKeyPressed() else: self.popoverView.showFullScreen() else: self.popoverView.setMinimumWidth(config.popoverWindowWidth) self.popoverView.setMinimumHeight(config.popoverWindowHeight) self.popoverView.show()
def setup_for_first_run(self): """Assume this is a first run of the application and set layouts accordingly""" self.setWindowState(Qt.WindowMaximized) desktop = QDesktopWidget() self.window_size = desktop.screenGeometry().size() self.setup_default_layouts()
def get_screen_size(): """Get **available** screen size/resolution.""" if mpl.get_backend().startswith('Qt'): # Inspired by spyder/widgets/shortcutssummary.py from qtpy.QtWidgets import QDesktopWidget # noqa widget = QDesktopWidget() sg = widget.availableGeometry(widget.primaryScreen()) x0 = sg.x() y0 = sg.y() w0 = sg.width() h0 = sg.height() elif mpl.get_backend() == "TkAgg": # https://stackoverflow.com/a/42951711/38281 window = plt.get_current_fig_manager().window x0, y0 = 0, 0 w0, h0 = window.wm_maxsize() # h = window.winfo_screenheight() # w = window.winfo_screenwidth() else: # Mac Retina Early 2013 x0 = 0 y0 = 23 w0 = 1280 h0 = 773 return x0, y0, w0, h0
def get_screen_resolution(self): """ """ widget = QDesktopWidget() geometry = widget.availableGeometry(widget.primaryScreen()) value = "{0}x{1}".format(geometry.width(), geometry.height()) return value
def _detrend_end(self, result): self.detrendButton.setEnabled(True) self.df_fit = result['fit'] self.df_residual = result['residual'] self.df_continuous = result['continuous'] if self.actionDetrendLog.isChecked(): pos = self.frameGeometry().topRight() x = pos.x() y = pos.y() rect = QDesktopWidget().screenGeometry() if x + 10 > rect.width(): x -= 320 y += 30 else: y += 20 x += 20 self.logDialog = TSLogDialog(parent=self, name=self.site, log=result['log']) self.logDialog.setGeometry(x, y, 300, self.frameGeometry().height() - 20) self.logDialog.show() else: log = result['log'] self.display_information(log) self.detrend_plot_check() self._update_data_combox()
def readSettings(self, settings): qapp = QApplication.instance() # get the saved window geometry window_size = settings.get('MainWindow/size') if not isinstance(window_size, QSize): window_size = QSize(*window_size) window_pos = settings.get('MainWindow/position') if not isinstance(window_pos, QPoint): window_pos = QPoint(*window_pos) if settings.has('MainWindow/font'): font_string = settings.get('MainWindow/font').split(',') font = QFontDatabase().font(font_string[0], font_string[-1], int(font_string[1])) qapp.setFont(font) # reset font for ipython console to ensure it stays monospace self.ipythonconsole.console.reset_font() # make sure main window is smaller than the desktop desktop = QDesktopWidget() # this gives the maximum screen number if the position is off screen screen = desktop.screenNumber(window_pos) # recalculate the window size desktop_geom = desktop.availableGeometry(screen) w = min(desktop_geom.size().width(), window_size.width()) h = min(desktop_geom.size().height(), window_size.height()) window_size = QSize(w, h) # and position it on the supplied desktop screen x = max(window_pos.x(), desktop_geom.left()) y = max(window_pos.y(), desktop_geom.top()) if x + w > desktop_geom.right(): x = desktop_geom.right() - w if y + h > desktop_geom.bottom(): y = desktop_geom.bottom() - h window_pos = QPoint(x, y) # set the geometry self.resize(window_size) self.move(window_pos) # restore window state if settings.has('MainWindow/state'): if not self.restoreState(settings.get('MainWindow/state'), SAVE_STATE_VERSION): logger.warning( "The previous layout of workbench is not compatible with this version, reverting to default layout." ) else: self.setWindowState(Qt.WindowMaximized) # read in settings for children AlgorithmInputHistory().readSettings(settings) for widget in self.widgets: if hasattr(widget, 'readSettingsIfNotDone'): widget.readSettingsIfNotDone(settings)
def get_screen_resolution(): """Return the screen resolution of the primary screen.""" try: widget = QDesktopWidget() geometry = widget.availableGeometry(widget.primaryScreen()) value = "{0}x{1}".format(geometry.width(), geometry.height()) except Exception: value = None return value
def readSettings(self, settings): qapp = QApplication.instance() qapp.setAttribute(Qt.AA_UseHighDpiPixmaps) if hasattr(Qt, 'AA_EnableHighDpiScaling'): qapp.setAttribute(Qt.AA_EnableHighDpiScaling, settings.get('high_dpi_scaling')) # get the saved window geometry window_size = settings.get('MainWindow/size') if not isinstance(window_size, QSize): window_size = QSize(*window_size) window_pos = settings.get('MainWindow/position') if not isinstance(window_pos, QPoint): window_pos = QPoint(*window_pos) if settings.has('MainWindow/font'): font_string = settings.get('MainWindow/font').split(',') font = QFontDatabase().font(font_string[0], font_string[-1], int(font_string[1])) qapp.setFont(font) # make sure main window is smaller than the desktop desktop = QDesktopWidget() # this gives the maximum screen number if the position is off screen screen = desktop.screenNumber(window_pos) # recalculate the window size desktop_geom = desktop.availableGeometry(screen) w = min(desktop_geom.size().width(), window_size.width()) h = min(desktop_geom.size().height(), window_size.height()) window_size = QSize(w, h) # and position it on the supplied desktop screen x = max(window_pos.x(), desktop_geom.left()) y = max(window_pos.y(), desktop_geom.top()) if x + w > desktop_geom.right(): x = desktop_geom.right() - w if y + h > desktop_geom.bottom(): y = desktop_geom.bottom() - h window_pos = QPoint(x, y) # set the geometry self.resize(window_size) self.move(window_pos) # restore window state if settings.has('MainWindow/state'): self.restoreState(settings.get('MainWindow/state')) else: self.setWindowState(Qt.WindowMaximized) # read in settings for children AlgorithmInputHistory().readSettings(settings) for widget in self.widgets: if hasattr(widget, 'readSettings'): widget.readSettings(settings)
def __honour_image_aspect_ratio(self): ''' resizes the window to fit the image aspect ratio based on the chart size ''' if len(self.image.text()) > 0: width, height = Image.open(self.image.text()).size width_delta = width - self.__x height_delta = height - self.__y if width_delta != 0 or height_delta != 0: win_size = self.size() target_size = QSize(win_size.width() + width_delta, win_size.height() + height_delta) available_size = QDesktopWidget().availableGeometry() if available_size.width() < target_size.width() or available_size.height() < target_size.height(): target_size.scale(available_size.width() - 48, available_size.height() - 48, Qt.KeepAspectRatio) self.resize(target_size)
def _center_main_window(self): self.logger.info("MainWindow._center_main_window") qr = self.frameGeometry() cp = QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft())
def __init__(self, parent=None): super(NativeNotification, self).__init__(parent=parent) time = datetime.now() current_time = "{}:{}".format(time.hour, time.minute) self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowSystemMenuHint) resolution = QDesktopWidget().screenGeometry(-1) screenWidth = resolution.width() screenHeight = resolution.height() self.nMessages = 0 self.mainLayout = QVBoxLayout(self) self.move(screenWidth, 0)
def readSettings(self, settings): qapp = QApplication.instance() qapp.setAttribute(Qt.AA_UseHighDpiPixmaps) if hasattr(Qt, 'AA_EnableHighDpiScaling'): qapp.setAttribute(Qt.AA_EnableHighDpiScaling, settings.get('high_dpi_scaling')) # get the saved window geometry window_size = settings.get('MainWindow/size') if not isinstance(window_size, QSize): window_size = QSize(*window_size) window_pos = settings.get('MainWindow/position') if not isinstance(window_pos, QPoint): window_pos = QPoint(*window_pos) # make sure main window is smaller than the desktop desktop = QDesktopWidget() # this gives the maximum screen number if the position is off screen screen = desktop.screenNumber(window_pos) # recalculate the window size desktop_geom = desktop.screenGeometry(screen) w = min(desktop_geom.size().width(), window_size.width()) h = min(desktop_geom.size().height(), window_size.height()) window_size = QSize(w, h) # and position it on the supplied desktop screen x = max(window_pos.x(), desktop_geom.left()) y = max(window_pos.y(), desktop_geom.top()) window_pos = QPoint(x, y) # set the geometry self.resize(window_size) self.move(window_pos) # restore window state if settings.has('MainWindow/state'): self.restoreState(settings.get('MainWindow/state')) else: self.setWindowState(Qt.WindowMaximized) # read in settings for children AlgorithmInputHistory().readSettings(settings) for widget in self.widgets: if hasattr(widget, 'readSettings'): widget.readSettings(settings)
def get_screen_size(): """Get **available** screen size/resolution.""" if mpl.get_backend().startswith('Qt'): # Inspired by spyder/widgets/shortcutssummary.py from qtpy.QtWidgets import QDesktopWidget widget = QDesktopWidget() sg = widget.availableGeometry(widget.primaryScreen()) x0 = sg.x() y0 = sg.y() w0 = sg.width() h0 = sg.height() else: # Mac Retina Early 2013 x0 = 0 y0 = 23 w0 = 1280 h0 = 773 return x0, y0, w0, h0
def readSettings(self, settings): qapp = QApplication.instance() qapp.setAttribute(Qt.AA_UseHighDpiPixmaps) if hasattr(Qt, 'AA_EnableHighDpiScaling'): qapp.setAttribute(Qt.AA_EnableHighDpiScaling, settings.get('main/high_dpi_scaling')) # get the saved window geometry window_size = settings.get('main/window/size') if not isinstance(window_size, QSize): window_size = QSize(*window_size) window_pos = settings.get('main/window/position') if not isinstance(window_pos, QPoint): window_pos = QPoint(*window_pos) # make sure main window is smaller than the desktop desktop = QDesktopWidget() # this gives the maximum screen number if the position is off screen screen = desktop.screenNumber(window_pos) # recalculate the window size desktop_geom = desktop.screenGeometry(screen) w = min(desktop_geom.size().width(), window_size.width()) h = min(desktop_geom.size().height(), window_size.height()) window_size = QSize(w, h) # and position it on the supplied desktop screen x = max(window_pos.x(), desktop_geom.left()) y = max(window_pos.y(), desktop_geom.top()) window_pos = QPoint(x, y) # set the geometry self.resize(window_size) self.move(window_pos) # restore window state if settings.has('main/window/state'): self.restoreState(settings.get('main/window/state')) else: self.setWindowState(Qt.WindowMaximized) # have algorithm dialogs do their thing AlgorithmInputHistory().readSettings(settings)
def ensure_widget_is_on_screen(widget): """If the supplied widget is off the screen it will be moved so it is on the screen. The widget must already be 'shown' """ # this gives the maximum screen number if the position is off screen desktop = QDesktopWidget() screen = desktop.screenNumber(widget.pos()) # get the window size desktop_geom = desktop.availableGeometry(screen) # get the widget dimensions with any os added extras widget_geom = widget.frameGeometry() # and position it on the supplied desktop screen x = max(widget_geom.x(), desktop_geom.left()) y = max(widget_geom.y(), desktop_geom.top()) if x + widget_geom.width() > desktop_geom.right(): x = desktop_geom.right() - widget_geom.width() if y + widget_geom.height() > desktop_geom.bottom(): y = desktop_geom.bottom() - widget_geom.height() window_pos = QPoint(x, y) widget.move(window_pos)
def alignToDisplay(self, alignment): """ Determines where on the monitor the widget should be located Args: Alignment (QtCore.Qt.Alignment): Determines where on the monitor to position the widget. AlignLeft AlignRight AlignTop AlignBottom """ # set screen properties self.screen_geometry = QDesktopWidget().screenGeometry(-1) self.screen_width = self.screen_geometry.width() self.screen_height = self.screen_geometry.height() self.screen_pos = self.screen_geometry.topLeft() if alignment == Qt.AlignLeft: height = self.screen_height width = self.getDepth() pos = self.screen_pos elif alignment == Qt.AlignRight: height = self.screen_height width = self.getDepth() pos_x = (self.screen_pos.x() + self.screen_width - self.getDepth()) pos = QPoint(pos_x, self.screen_pos.y()) elif alignment == Qt.AlignTop: height = self.getDepth() width = self.screen_width pos = self.screen_pos elif alignment == Qt.AlignBottom: height = self.getDepth() width = self.screen_width pos_y = (self.screen_pos.y() + self.screen_height - self.getDepth()) pos = QPoint(self.screen_pos.x(), pos_y) self.setFixedHeight(height) self.setFixedWidth(width) self.move(pos)
def toggle_fullscreen(self): """ Toggle option to show the mainwindow in fullscreen or windowed. Returns ------- None. """ main = self.main if self._fullscreen_flag: self._fullscreen_flag = False if os.name == 'nt': main.setWindowFlags(main.windowFlags() ^ (Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)) main.setGeometry(self._saved_normal_geometry) main.showNormal() if self._maximized_flag: main.showMaximized() else: self._maximized_flag = main.isMaximized() self._fullscreen_flag = True self._saved_normal_geometry = main.normalGeometry() if os.name == 'nt': # Due to limitations of the Windows DWM, compositing is not # handled correctly for OpenGL based windows when going into # full screen mode, so we need to use this workaround. # See spyder-ide/spyder#4291. main.setWindowFlags(main.windowFlags() | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) screen_number = QDesktopWidget().screenNumber(main) if screen_number < 0: screen_number = 0 r = QApplication.desktop().screenGeometry(screen_number) main.setGeometry(r.left() - 1, r.top() - 1, r.width() + 2, r.height() + 2) main.showNormal() else: main.showFullScreen() self._update_fullscreen_action()
def eventloop(shell, init_code=None, init_file=None, console_id=0, pictures=None): """ The GUI Process and Thread running the eventloop """ shell.logdir.find_log_path() qapp = GuiApplication(shell, sys.argv) qapp.setShortCuts() qapp.newWindow('main') #To run in a new thread but on the same gui process #panid = qapp.mainWindow.newThread() qapp.mainWindow.show() desktopGeometry = QDesktopWidget().availableGeometry() qapp.mainWindow.resize(int(desktopGeometry.width() * 3 / 5), int(desktopGeometry.height() * 3 / 5)) qtRectangle = qapp.mainWindow.frameGeometry() centerPoint = desktopGeometry.center() qtRectangle.moveCenter(centerPoint) qapp.mainWindow.move(qtRectangle.topLeft()) # Make sure the gui proxy for the main thread is created qapp.panels.restore_state_from_config('base') # if not config['debug']['skip_restore_perspective']: # if config['default_perspective'] != 'base': # qapp.panels.restore_state_from_config(config['default_perspective']) qapp.processEvents() qapp.cmdserver = CommandServer(shell) if not init_file is None: cmd = {'cmd': 'execute_file', 'args': (init_file, console_id)} qapp.cmdserver.cmd_queue.put(cmd) if not init_code is None: cmd = {'cmd': 'execute_code', 'args': (init_code, console_id)} qapp.cmdserver.cmd_queue.put(cmd) if not pictures is None: cmd = {'cmd': 'open_images', 'args': pictures} qapp.cmdserver.cmd_queue.put(cmd) cmd = config.get('init_command') qapp.cmdserver.cmd_queue.put(cmd) qapp.cmdserver.start_queue_loop(qapp) qapp.cmdserver.start(qapp) exit_code = qapp.exec_() #Kill all the children parent = psutil.Process(os.getpid()) for child in parent.children(recursive=True): child.kill() from pylab import plt plt.close('all') sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ print(f'Exiting {PROGNAME}. Releasing lock.') shell.logdir.release_lock_file()
def center_window(window: QWidget): screen = QDesktopWidget().screenGeometry() size = window.geometry() window.move(int((screen.width() - size.width()) / 2), int((screen.height() - size.height()) / 2))
def get_screen_resolution(self): """Return the screen resolution of the primary screen.""" widget = QDesktopWidget() geometry = widget.availableGeometry(widget.primaryScreen()) return geometry.width(), geometry.height()
def center_widget_on_screen(widget): rect = widget.frameGeometry() center = QDesktopWidget().availableGeometry().center() rect.moveCenter(center) widget.move(rect.topLeft())
def getAllScreensWorkspace() -> list: """Returns workspaces of all the available screen.s""" return [ QDesktopWidget().availableGeometry(x) for x in range(QDesktopWidget().screenCount()) ]
def getAllScreensGeometry() -> list: """Returns geometries of all the available screens.""" return [ QDesktopWidget().screenGeometry(x) for x in range(QDesktopWidget().screenCount()) ]
def screen_resolutions(self): width = 0 for displayNr in range(QDesktopWidget().screenCount()): sizeObject = QDesktopWidget().screenGeometry(displayNr) width += sizeObject.width() return width - 5
def placescreen(self, pos): resolution = QDesktopWidget().screenGeometry() self.move( (resolution.width() / pos) - (self.frameSize().width() / pos), (resolution.height() / pos) - (self.frameSize().height() / pos))
def center(self): """居中显示""" qr = self.frameGeometry() # 获得frame cp = QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft())
def move_to(self, position='top', *, win_ratio=0.9, min_length=0): """Move popup to a position relative to the QMainWindow. Parameters ---------- position : {str, tuple}, optional position in the QMainWindow to show the pop, by default 'top' if str: must be one of {'top', 'bottom', 'left', 'right' } if tuple: must be length 4 with (left, top, width, height) win_ratio : float, optional Fraction of the width (for position = top/bottom) or height (for position = left/right) of the QMainWindow that the popup will occupy. Only valid when isinstance(position, str). by default 0.9 min_length : int, optional Minimum size of the long dimension (width for top/bottom or height fort left/right). Raises ------ ValueError if position is a string and not one of {'top', 'bottom', 'left', 'right' } """ if isinstance(position, str): window = self.parent().window() if self.parent() else None if not window: raise ValueError( "Specifying position as a string is only posible if " "the popup has a parent") left = window.pos().x() top = window.pos().y() if position in ('top', 'bottom'): width = window.width() * win_ratio width = max(width, min_length) left += (window.width() - width) / 2 height = self.sizeHint().height() top += (24 if position == 'top' else (window.height() - height - 12)) elif position in ('left', 'right'): height = window.height() * win_ratio height = max(height, min_length) # 22 is for the title bar top += 22 + (window.height() - height) / 2 width = self.sizeHint().width() left += (12 if position == 'left' else (window.width() - width - 12)) else: raise ValueError('position must be one of ' '["top", "left", "bottom", "right"]') elif isinstance(position, (tuple, list)): assert len(position) == 4, '`position` argument must have length 4' left, top, width, height = position else: raise ValueError(f"Wrong type of position {position}") # necessary for transparent round corners self.resize(self.sizeHint()) # make sure the popup is completely on the screen # In Qt ≥5.10 we can use screenAt to know which monitor the mouse is on if hasattr(QGuiApplication, "screenAt"): screen_geometry: QRect = QGuiApplication.screenAt( QCursor.pos()).geometry() else: # This widget is deprecated since Qt 5.11 from qtpy.QtWidgets import QDesktopWidget screen_num = QDesktopWidget().screenNumber(QCursor.pos()) screen_geometry = QGuiApplication.screens()[screen_num].geometry() left = max(min(screen_geometry.right() - width, left), screen_geometry.left()) top = max(min(screen_geometry.bottom() - height, top), screen_geometry.top()) self.setGeometry(left, top, width, height)
class AbstractSlideDisplay(QWidget): """ Abstract class for all slide bars. This will be inherited by the HSVSlideDisplay and UnitSlideDisplay. The base properties of this widget are to create the containter for these widgets, and then subclass this widget and draw the visuals. Kwargs: ** alignment (QtCore.Qt.Align): where the widget should be align relative to the display ** depth (int): how wide/tall the widget should be depending on its orientation ** display_widget (QWidget): optional argument. If entered, the display will show up over that widget rather than over the main display. Attributes: alignment (Qt.Alignment): Where widget should be aligned depth (int): width/height of the slideBar (depends on orientation) display_widget (QWidget): optional argument. If entered, the display will show up over that widget rather than over the main display. Notes: - This should be abstracted for SliderBar--> HueSlideDisplay SatSlideDisplay ValueSlideDisplay UnitSlideDisplay """ def __init__(self, parent=None, alignment=Qt.AlignBottom, depth=50, display_widget=None): super(AbstractSlideDisplay, self).__init__(parent) setAsTool(self) # set properties self.setDisplayWidget(display_widget) self.setDepth(depth) self.setAlignment(alignment) """ API """ def getDepth(self): return self._depth def setDepth(self, depth): self._depth = depth def getAlignment(self): return self._alignment def setAlignment(self, alignment): self._alignment = alignment def getDisplayWidget(self): return self._display_widget def setDisplayWidget(self, display_widget): self._display_widget = display_widget """ UTILS """ def setWidgetPosition(self, alignment, widget=None): """ Picks which algorithm to use to determine the widgets position If 'display_widget' is defined, then it will align to that widget, if not, it will align to the main display on the system. """ _accepted = [Qt.AlignLeft, Qt.AlignRight, Qt.AlignTop, Qt.AlignBottom] if alignment in _accepted: if widget: self.alignToWidget(alignment, widget) else: self.alignToDisplay(alignment) def alignToWidget(self, alignment, widget): """ Determines where on the monitor the widget should be located Args: * alignment (QtCore.Qt.Alignment): Determines where on the monitor to position the widget. AlignLeft AlignRight AlignTop AlignBottom * widget (QWidget): The QWidget that the slide bar should be aligned to. """ screen_pos = getGlobalPos(widget) if alignment == Qt.AlignLeft: height = widget.height() width = self.getDepth() pos = screen_pos elif alignment == Qt.AlignRight: height = widget.height() width = self.getDepth() pos_x = (screen_pos.x() + widget.width() - self.getDepth()) pos = QPoint(pos_x, screen_pos.y()) elif alignment == Qt.AlignTop: height = self.getDepth() width = widget.width() pos = screen_pos elif alignment == Qt.AlignBottom: height = self.getDepth() width = widget.width() pos_y = (screen_pos.y() + widget.height() - self.getDepth()) pos = QPoint(screen_pos.x(), pos_y) self.setFixedHeight(height) self.setFixedWidth(width) self.move(pos) def alignToDisplay(self, alignment): """ Determines where on the monitor the widget should be located Args: Alignment (QtCore.Qt.Alignment): Determines where on the monitor to position the widget. AlignLeft AlignRight AlignTop AlignBottom """ # set screen properties self.screen_geometry = QDesktopWidget().screenGeometry(-1) self.screen_width = self.screen_geometry.width() self.screen_height = self.screen_geometry.height() self.screen_pos = self.screen_geometry.topLeft() if alignment == Qt.AlignLeft: height = self.screen_height width = self.getDepth() pos = self.screen_pos elif alignment == Qt.AlignRight: height = self.screen_height width = self.getDepth() pos_x = (self.screen_pos.x() + self.screen_width - self.getDepth()) pos = QPoint(pos_x, self.screen_pos.y()) elif alignment == Qt.AlignTop: height = self.getDepth() width = self.screen_width pos = self.screen_pos elif alignment == Qt.AlignBottom: height = self.getDepth() width = self.screen_width pos_y = (self.screen_pos.y() + self.screen_height - self.getDepth()) pos = QPoint(self.screen_pos.x(), pos_y) self.setFixedHeight(height) self.setFixedWidth(width) self.move(pos) def update(self, *args, **kwargs): print('you need to reimplement this on: {}'.format(self)) return QWidget.update(self, *args, **kwargs) """ EVENTS""" def keyPressEvent(self, event, *args, **kwargs): if event.key() == Qt.Key_Escape: self.close() return QWidget.keyPressEvent(self, event, *args, **kwargs)
def screen_center(self): return QDesktopWidget().availableGeometry().center()