def must_use_qt(): global gui_thread, _store_app if (islinux or isbsd) and ":" not in os.environ.get("DISPLAY", ""): raise RuntimeError("X server required. If you are running on a" " headless machine, use xvfb") if _store_app is None and QApplication.instance() is None: _store_app = QApplication([]) if gui_thread is None: gui_thread = QThread.currentThread() if gui_thread is not QThread.currentThread(): raise RuntimeError("Cannot use Qt in non GUI thread")
def must_use_qt(): global gui_thread, _store_app if (islinux or isbsd) and ':' not in os.environ.get('DISPLAY', ''): raise RuntimeError('X server required. If you are running on a' ' headless machine, use xvfb') if _store_app is None and QApplication.instance() is None: _store_app = QApplication([]) if gui_thread is None: gui_thread = QThread.currentThread() if gui_thread is not QThread.currentThread(): raise RuntimeError('Cannot use Qt in non GUI thread')
def __init__(self, args, force_calibre_style=False, override_program_name=None): self.file_event_hook = None if override_program_name: args = [override_program_name] + args[1:] qargs = [ i.encode('utf-8') if isinstance(i, unicode) else i for i in args ] self.pi = plugins['progress_indicator'][0] if DEBUG: self.redirect_notify = True QApplication.__init__(self, qargs) dl = QLocale(get_lang()) if unicode(dl.bcp47Name()) != u'C': QLocale.setDefault(dl) global gui_thread, qt_app gui_thread = QThread.currentThread() self._translator = None self.load_translations() qt_app = self self._file_open_paths = [] self._file_open_lock = RLock() self.setup_styles(force_calibre_style)
def __init__(self, func, queued=True, parent=None): global gui_thread if gui_thread is None: gui_thread = QThread.currentThread() if not is_gui_thread(): raise ValueError("You can only create a FunctionDispatcher in the GUI thread") QObject.__init__(self, parent) self.func = func typ = Qt.QueuedConnection if not queued: typ = Qt.AutoConnection if queued is None else Qt.DirectConnection self.dispatch_signal.connect(self.dispatch, type=typ) self.q = Queue.Queue() self.lock = threading.Lock()
def __init__(self, func, queued=True, parent=None): global gui_thread if gui_thread is None: gui_thread = QThread.currentThread() if not is_gui_thread(): raise ValueError( 'You can only create a FunctionDispatcher in the GUI thread') QObject.__init__(self, parent) self.func = func typ = Qt.QueuedConnection if not queued: typ = Qt.AutoConnection if queued is None else Qt.DirectConnection self.dispatch_signal.connect(self.dispatch, type=typ) self.q = Queue.Queue() self.lock = threading.Lock()
def __init__(self, args, force_calibre_style=False, override_program_name=None): self.file_event_hook = None if override_program_name: args = [override_program_name] + args[1:] qargs = [i.encode("utf-8") if isinstance(i, unicode) else i for i in args] self.pi = plugins["progress_indicator"][0] if DEBUG: self.redirect_notify = True QApplication.__init__(self, qargs) global gui_thread, qt_app gui_thread = QThread.currentThread() self._translator = None self.load_translations() qt_app = self self._file_open_paths = [] self._file_open_lock = RLock() self.setup_styles(force_calibre_style)
def __init__(self, args, force_calibre_style=False, override_program_name=None): self.file_event_hook = None if override_program_name: args = [override_program_name] + args[1:] qargs = [ i.encode('utf-8') if isinstance(i, unicode) else i for i in args ] QApplication.__init__(self, qargs) global gui_thread, qt_app gui_thread = QThread.currentThread() self._translator = None self.load_translations() qt_app = self self._file_open_paths = [] self._file_open_lock = RLock() self.setup_styles(force_calibre_style)
def is_gui_thread(): global gui_thread return gui_thread is QThread.currentThread()