def _setup_relative_button(self): self._relative_button = QtWidgets.QPushButton() self._relative_button.setMinimumSize(QtCore.QSize(20, 20)) self._relative_button.setMaximumSize(QtCore.QSize(20, 20)) self._relative_button.setCheckable(True) self._relative_button.setIconSize(QtCore.QSize(20, 20)) self._relative_button.setIcon(QtGui.QIcon(":/icons/light/references.svg")) # self._relative_button.setAutoRaise(True) self._relative_button.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET) self._relative_button.toggled.connect(self._handle_relative_toggle) self._relative_button.setFocusPolicy(QtCore.Qt.NoFocus) self._relative_button.setCursor(QtCore.Qt.PointingHandCursor) return self._relative_button
def _setup_info_button(self): self._info = QtWidgets.QPushButton() self._info.setMinimumSize(QtCore.QSize(20, 20)) self._info.setMaximumSize(QtCore.QSize(20, 20)) # self._info.setCheckable(True) self._info.setIconSize(QtCore.QSize(20, 20)) self._info.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET) self._info.setIcon(QtGui.QIcon(":/icons/light/info.svg")) self._info.setFocusPolicy(QtCore.Qt.NoFocus) self._info.setCursor(QtCore.Qt.PointingHandCursor) self._info.clicked.connect(self.show_description) # self._info.setAutoRaise(True) return self._info
def _setup_enable_button(self): self._enabled_button = QtWidgets.QPushButton() self._enabled_button.setMinimumSize(QtCore.QSize(35, 25)) self._enabled_button.setMaximumSize(QtCore.QSize(35, 25)) self._enabled_button.setCheckable(True) self._enabled_button.setIconSize(QtCore.QSize(34, 25)) self._enabled_button.setIcon(QtGui.QIcon(":/icons/off.png")) # self._enabled_button.setAutoRaise(True) self._enabled_button.setStyleSheet(CHECK_TOOLBUTTON_STYLESHEET) self._enabled_button.toggled.connect(self._handle_enabled_toggle) self._enabled_button.setFocusPolicy(QtCore.Qt.NoFocus) self._enabled_button.setCursor(QtCore.Qt.PointingHandCursor) return self._enabled_button
def start(self): """Main method of this class It will create a BackgroundProcess that will be interacting with Deadline. The Background process is a Daemon Thread. It will be triggered every 30 secs. It will get any new job that is Active (Rendering, Queried) or Pending Once this BackgroundProcess timedout, it will automatically pass all the results through the method ``_results_emitted`` """ if not self._started: if not self._background_process: only_new_jobs = self.actionWrangler_only_jobs_from_now_on.isChecked() self._background_process = BackgroundProcess(only_new_jobs=only_new_jobs, parent=self) self._background_process.finished.connect(self._thread_finished) self._background_process.emit_results.connect(self._results_emitted) self._timer = QtCore.QTimer(self) self._timer.setInterval(30000) # self._timer.setSingleShot(True) self._timer.timeout.connect(self._background_process.start) self._timer.start() self._started = True self.actionStart.setText("Pause") self.actionStart.setIcon(QtGui.QIcon(":/icons/light/pause.svg")) logger.info("Starting") else: self._timer.stop() self._background_process.terminate() self._background_process.wait() self.actionStart.setText("Start") self.actionStart.setIcon(QtGui.QIcon(":/icons/light/play.svg")) self._started = False logger.info("Pausing") self.rules_tabs_widget.setDisabled(self._started)
class RuleWidget(QtWidgets.QWidget): delete = QtCore.Signal(object) def __init__(self, parent=None): """This widget corresponds with each Individual Rule that will be applied to a Rule. It gives a Visual representation of a rule Args: parent (QWidget, optional): Widget's parent. Defaults to None. """ super(RuleWidget, self).__init__(parent=parent) QtCompat.loadUi(_RULE_WIDGET_UI, self) self.delete_bt.clicked.connect(functools.partial(self.delete.emit, self)) def get_rule(self): """Get the values from the Widget, and give the ``Rule`` rule Returns: tuple: Tuple with all the needed information to create a Rule rule """ key = self.key_le.text() operator = self.operators_cb.currentText() value = self.value_le.text() regex = self.regex_cb.isChecked() if not key and not value: return None return (key, operator, value, regex) def set_rule_values(self, key, operator, value, regex): """Imports and set the UI with the corresponding values Args: key (str): Key operator (str): Operator to use value (str): Value regex (bool): Used of regex """ self.key_le.setText(key) index = self.operators_cb.findText(operator) self.operators_cb.setCurrentIndex(index) self.value_le.setText(value) self.regex_cb.setChecked(regex)
class CustomTabBar(QtWidgets.QTabBar): change_name = QtCore.Signal(int) def __init__(self, parent=None): super(CustomTabBar, self).__init__(parent=parent) self.setMovable(True) def change_tab_name(self, tab_index, name=None): if not name: name, accepted = QtWidgets.QInputDialog.getText( self, "Tab name", "New Tab name") if accepted and name: self.setTabText(tab_index, name) def mouseDoubleClickEvent(self, event): tab = self.tabAt(event.pos()) self.change_tab_name(tab) self.change_name.emit(tab) super(CustomTabBar, self).mouseDoubleClickEvent(event)
def sizeHint(self, option, index): name = index.data(QtCore.Qt.DisplayRole) return QtCore.QSize(option.fontMetrics.width(name) + 8, 21)