def _poll(self): for id, v in self._views.items(): label = v.tabLabel() self._tab_bar.setTabLabel(id, label) if hasattr(v, 'updateTitle'): v.updateTitle() vd.set_timeout(self._poll, 2)
def _check_init(self): if not self._unit_table_widget: if self._connection_to_init.poll(): msg = self._connection_to_init.recv() if msg['name'] == 'log': self._init_log_text = self._init_log_text + msg['text'] self.refresh() elif msg['name'] == 'result': self._on_init_completed(msg['result']) return vd.set_timeout(self._check_init, 1)
def __init__(self, context): vd.Component.__init__(self) self._context = context self._size = (100, 100) self._unit_table_widget = None self._connection_to_init, connection_to_parent = multiprocessing.Pipe() self._init_process = multiprocessing.Process( target=_initialize, args=(context, connection_to_parent)) self._init_process.start() self._init_log_text = '' vd.set_timeout(self._check_init, 0.5)
def __init__(self, context): vd.Component.__init__(self) self._context = context self._unit_id = context.currentUnitId() self._size = (100, 100) self._unit_detail_widget = None if self._unit_id is None: return self._connection_to_init, connection_to_parent = multiprocessing.Pipe() self._init_process = multiprocessing.Process( target=_initialize, args=(context, self._unit_id, connection_to_parent)) self._init_process.start() self._init_log_text = '' vd.set_timeout(self._check_init, 0.5)
def _check_prepare(self): if not self._view: if self._connection_to_prepare.poll(): msg = self._connection_to_prepare.recv() if msg['name'] == 'log': self._prepare_log_text = self._prepare_log_text + msg[ 'text'] self._prepare_log_text_view.setText(self._prepare_log_text) elif msg['name'] == 'result': self._on_prepare_completed(msg['result']) return self._check_prepare_count = self._check_prepare_count + 1 if self._check_prepare_count < 3: timeout = 0.2 elif self._check_prepare_count < 5: timeout = 0.5 elif self._check_prepare_count < 10: timeout = 1 else: timeout = 5 vd.set_timeout(self._check_prepare, timeout)
def initialize(self): view_launcher = self._view_launcher context = view_launcher['context'] opts = view_launcher['opts'] view_class = view_launcher['view_class'] if hasattr(view_class, 'prepareView'): self._connection_to_prepare, connection_to_parent = multiprocessing.Pipe( ) self._init_process = multiprocessing.Process( target=_prepare_in_worker, args=(view_class, context, opts, connection_to_parent)) self._init_process.start() self._check_prepare_count = 0 vd.set_timeout(self._check_prepare, 0.1) else: if hasattr(context, 'initialize'): context.initialize() self._view = view_class(context=context, opts=opts) self._update_view_size() self.updateTitle() self.refresh()