当前位置: 首页>>代码示例>>Python>>正文


Python Qt.QThread类代码示例

本文整理汇总了Python中PyQt5.Qt.QThread的典型用法代码示例。如果您正苦于以下问题:Python QThread类的具体用法?Python QThread怎么用?Python QThread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QThread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self,
              party_1,
              party_2,
              number_of_pairs,
              random_source,
              cancellation_event,
              key_manager,
              console_signal,
              key_directory,
              parent,
              key_length=1000000):
     QThread.__init__(self, parent)
     self._party_1 = party_1
     self._party_2 = party_2
     self._number_of_pairs = int(number_of_pairs)
     self._random_source = random_source
     # Select appropriate random function.
     if self._random_source == '/dev/random (slow!)':
         self._random_function = self._dev_random
     else:
         self._random_function = self._os_urandom
     # Attach cancel button signal to cancel function.
     self._cancellation_event = cancellation_event
     self._km = key_manager
     self._cs = console_signal
     self._key_directory = key_directory
     self._parent = parent
     self._key_length = key_length
     self._VERSION = self._km.VERSION
开发者ID:theonaun,项目名称:brickton,代码行数:29,代码来源:generator_thread.py

示例2: __init__

 def __init__(self, parent, db, root, single, tdir=None):
     QThread.__init__(self, parent)
     self.db = db
     self.path = root
     self.tdir = tdir
     self.single_book_per_directory = single
     self.canceled = False
开发者ID:aliloac,项目名称:calibre,代码行数:7,代码来源:add.py

示例3: __init__

 def __init__(self, parent, lrf_stream, logger, opts):
     QThread.__init__(self, parent)
     self.stream, self.logger, self.opts = lrf_stream, logger, opts
     self.aborted = False
     self.lrf = None
     self.document = None
     self.exception = None
开发者ID:JimmXinu,项目名称:calibre,代码行数:7,代码来源:main.py

示例4: __init__

 def __init__(self, plugin_id, address, socket):
     QThread.__init__(self)
     self.plugin_id = plugin_id
     self.address = address
     self.udp_socket = socket
     self.finished.connect(self.quit)
     self.wait = QWaitCondition()
     self.mutex = QMutex()
开发者ID:n3rd-bugs,项目名称:weird-rtos,代码行数:8,代码来源:plugin_switch.py

示例5: must_use_qt

def must_use_qt(headless=True):
    ''' This function should be called if you want to use Qt for some non-GUI
    task like rendering HTML/SVG or using a headless browser. It will raise a
    RuntimeError if using Qt is not possible, which will happen if the current
    thread is not the main GUI thread. On linux, it uses a special QPA headless
    plugin, so that the X server does not need to be running. '''
    global gui_thread
    ensure_app(headless=headless)
    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')
开发者ID:AEliu,项目名称:calibre,代码行数:12,代码来源:__init__.py

示例6: __init__

 def __init__(self,
              import_path,
              key_manager,
              console_signal,
              key_directory,
              parent):
     QThread.__init__(self, parent)
     self._import_path = import_path
     self._km = key_manager
     self._console_signal = console_signal
     self._key_directory = key_directory
     self._parent = parent
     self._total_key_count = 0
     self._successful_key_count = 0
     self._unsuccessful_key_count = 0
开发者ID:theonaun,项目名称:brickton,代码行数:15,代码来源:import_thread.py

示例7: must_use_qt

def must_use_qt():
    ''' This function should be called if you want to use Qt for some non-GUI
    task like rendering HTML/SVG or using a headless browser. It will raise a
    RuntimeError if using Qt is not possible, which will happen if the current
    thread is not the main GUI thread. On linux, it uses a special QPA headless
    plugin, so that the X server does not need to be running. '''
    global gui_thread, _store_app
    if _store_app is None and QApplication.instance() is None:
        args = sys.argv[:1]
        if islinux or isbsd:
            args += ['-platformpluginpath', sys.extensions_location, '-platform', 'headless']
        _store_app = QApplication(args)
    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')
开发者ID:kba,项目名称:calibre,代码行数:16,代码来源:__init__.py

示例8: __init__

    def __init__(self, parent, db, device, annotation_map, done_callback):
        QThread.__init__(self, parent)
        self.errors = {}
        self.db = db
        self.keep_going = True
        self.pd = ProgressDialog(_('Merging user annotations into database'), '',
                0, len(annotation_map), parent=parent)

        self.device = device
        self.annotation_map = annotation_map
        self.done_callback = done_callback
        self.pd.canceled_signal.connect(self.canceled)
        self.pd.setModal(True)
        self.pd.show()
        self.update_progress.connect(self.pd.set_value,
                type=Qt.QueuedConnection)
        self.update_done.connect(self.pd.hide, type=Qt.QueuedConnection)
开发者ID:AEliu,项目名称:calibre,代码行数:17,代码来源:annotate.py

示例9: __init__

    def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False, color_prefs=gprefs):
        self.file_event_hook = None
        if override_program_name:
            args = [override_program_name] + args[1:]
        if headless:
            if not args:
                args = sys.argv[:1]
            args.extend(['-platformpluginpath', sys.extensions_location, '-platform', 'headless'])
        qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args]
        self.pi = plugins['progress_indicator'][0]
        QApplication.__init__(self, qargs)
        self.setup_styles(force_calibre_style)
        f = QFont(QApplication.font())
        if (f.family(), f.pointSize()) == ('Sans Serif', 9):  # Hard coded Qt settings, no user preference detected
            f.setPointSize(10)
            QApplication.setFont(f)
        f = QFontInfo(f)
        self.original_font = (f.family(), f.pointSize(), f.weight(), f.italic(), 100)
        if not self.using_calibre_style and self.style().objectName() == 'fusion':
            # Since Qt is using the fusion style anyway, specialize it
            self.load_calibre_style()
        fi = gprefs['font']
        if fi is not None:
            font = QFont(*(fi[:4]))
            s = gprefs.get('font_stretch', None)
            if s is not None:
                font.setStretch(s)
            QApplication.setFont(font)

        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()

        if not isosx:
            # OS X uses a native color dialog that does not support custom
            # colors
            self.color_prefs = color_prefs
            self.read_custom_colors()
            self.lastWindowClosed.connect(self.save_custom_colors)

        if isxp:
            error_dialog(None, _('Windows XP not supported'), '<p>' + _(
                'calibre versions newer than 2.0 do not run on Windows XP. This is'
                ' because the graphics toolkit calibre uses (Qt 5) crashes a lot'
                ' on Windows XP. We suggest you stay with <a href="%s">calibre 1.48</a>'
                ' which works well on Windows XP.') % 'http://download.calibre-ebook.com/1.48.0/', show=True)
            raise SystemExit(1)
开发者ID:GaryMMugford,项目名称:calibre,代码行数:54,代码来源:__init__.py

示例10: detect_ncpus

def detect_ncpus():
    """Detects the number of effective CPUs in the system"""
    if iswindows:
        import win32api
        ans = win32api.GetSystemInfo()[5]
    else:
        import multiprocessing
        ans = -1
        try:
            ans = multiprocessing.cpu_count()
        except Exception:
            from PyQt5.Qt import QThread
            ans = QThread.idealThreadCount()
    return max(1, ans)
开发者ID:kba,项目名称:calibre,代码行数:14,代码来源:__init__.py

示例11: __init__

 def __init__(self,
              party_1,
              party_2,
              all_keys,
              console_signal,
              key_directory,
              main_export_directory,
              parent):
     QThread.__init__(self, parent)
     self._party_1 = party_1
     self._party_2 = party_2
     self._parent = parent
     self._keys = all_keys
     self._console_signal = console_signal
     self._main_export_directory = main_export_directory
     self._key_directory = key_directory
     self._timestamp = '{0:.7f}'.format(time.time())
     self._export_package_dir = os.path.join(self._main_export_directory,
                                             self._timestamp)
     os.makedirs(self._export_package_dir)
     self._keys_to_copy = []
     self._keys_copied_count = 0
     self._keys_missed_count = 0
开发者ID:theonaun,项目名称:brickton,代码行数:23,代码来源:export_thread.py

示例12: __init__

    def __init__(self, parent):
        QThread.__init__(self, parent)
        self.keep_going = True
        self.current_command = None

        self.out_queue = Queue()
        self.address = arbitrary_address('AF_PIPE' if iswindows else 'AF_UNIX')
        self.auth_key = os.urandom(32)
        if iswindows and self.address[1] == ':':
            self.address = self.address[2:]
        self.listener = Listener(address=self.address,
                authkey=self.auth_key, backlog=4)

        self.env = {
            'CALIBRE_SIMPLE_WORKER':
                'calibre.utils.pyconsole.interpreter:main',
            'CALIBRE_WORKER_ADDRESS':
                hexlify(cPickle.dumps(self.listener.address, -1)),
            'CALIBRE_WORKER_KEY': hexlify(self.auth_key)
        }
        self.process = Process(self.env)
        self.output_file_buf = self.process(redirect_output=False)
        self.conn = self.listener.accept()
        self.start()
开发者ID:Mymei2,项目名称:calibre,代码行数:24,代码来源:controller.py

示例13: __init__

    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()
开发者ID:AEliu,项目名称:calibre,代码行数:16,代码来源:__init__.py

示例14: _initServer

 def _initServer(self):
     self.message("Server - initServer / threadId=" + str(int(QThread.currentThreadId())))
     
     try:
         self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     except socket.error as exc:
         raise ServerException("Socket creation failed: {0}".format(exc));
    
     try:    
         # Bind socket to ip 127.0.0.1 on port 1234
         self.socket.bind(('127.0.0.1', 1234));
     except socket.error as exc:
         self.socket.close();
         raise ServerException("Socket bind failed: {0}".format(exc));
     
     self.message("Server - Bind successfull")
     # Accept 1 connection 
     self.socket.listen(5);
开发者ID:DocDilbert,项目名称:socket_tests,代码行数:18,代码来源:server.py

示例15: __init__

    def __init__(self, args, force_calibre_style=False, override_program_name=None, headless=False):
        self.file_event_hook = None
        if override_program_name:
            args = [override_program_name] + args[1:]
        if headless:
            if not args:
                args = sys.argv[:1]
            args.extend(['-platformpluginpath', sys.extensions_location, '-platform', 'headless'])
        qargs = [i.encode('utf-8') if isinstance(i, unicode) else i for i in args]
        self.pi = plugins['progress_indicator'][0]
        self.setup_styles(force_calibre_style)
        QApplication.__init__(self, qargs)
        f = QFont(QApplication.font())
        if (f.family(), f.pointSize()) == ('Sans Serif', 9):  # Hard coded Qt settings, no user preference detected
            f.setPointSize(10)
            QApplication.setFont(f)
        f = QFontInfo(f)
        self.original_font = (f.family(), f.pointSize(), f.weight(), f.italic(), 100)
        if not self.using_calibre_style and self.style().objectName() == 'fusion':
            # Since Qt is using the fusion style anyway, specialize it
            self.load_calibre_style()
        fi = gprefs['font']
        if fi is not None:
            font = QFont(*(fi[:4]))
            s = gprefs.get('font_stretch', None)
            if s is not None:
                font.setStretch(s)
            QApplication.setFont(font)

        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()
开发者ID:kba,项目名称:calibre,代码行数:39,代码来源:__init__.py


注:本文中的PyQt5.Qt.QThread类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。