def __init__(self, parent, batch_manager): super().__init__(parent) self.task_count = 0 self.calculation_manager = batch_manager self.whole_progress = QProgressBar(self) self.whole_progress.setMinimum(0) self.whole_progress.setMaximum(1) self.whole_progress.setFormat("%v of %m") self.whole_progress.setTextVisible(True) self.part_progress = QProgressBar(self) self.part_progress.setMinimum(0) self.part_progress.setMaximum(1) self.part_progress.setFormat("%v of %m") self.whole_label = QLabel("All batch progress:", self) self.part_label = QLabel("Single batch progress:", self) self.cancel_remove_btn = QPushButton("Remove task") self.cancel_remove_btn.setDisabled(True) self.logs = ExceptionList(self) self.logs.setToolTip("Logs") self.task_view = QListView() self.task_que = QStandardItemModel(self) self.task_view.setModel(self.task_que) self.process_num_timer = QTimer() self.process_num_timer.setInterval(1000) self.process_num_timer.setSingleShot(True) self.process_num_timer.timeout.connect(self.change_number_of_workers) self.number_of_process = QSpinBox(self) self.number_of_process.setRange(1, multiprocessing.cpu_count()) self.number_of_process.setValue(1) self.number_of_process.setToolTip( "Number of process used in batch calculation") self.number_of_process.valueChanged.connect( self.process_num_timer_start) self.progress_item_dict = {} layout = QGridLayout() layout.addWidget(self.whole_label, 0, 0, Qt.AlignRight) layout.addWidget(self.whole_progress, 0, 1, 1, 2) layout.addWidget(self.part_label, 1, 0, Qt.AlignRight) layout.addWidget(self.part_progress, 1, 1, 1, 2) lab = QLabel("Number of process:") lab.setToolTip("Number of process used in batch calculation") layout.addWidget(lab, 2, 0) layout.addWidget(self.number_of_process, 2, 1) layout.addWidget(self.logs, 3, 0, 2, 3) layout.addWidget(self.task_view, 0, 4, 4, 1) layout.addWidget(self.cancel_remove_btn, 4, 4, 1, 1) layout.setColumnMinimumWidth(2, 10) layout.setColumnStretch(2, 1) self.setLayout(layout) self.preview_timer = QTimer() self.preview_timer.setInterval(1000) self.preview_timer.timeout.connect(self.update_info) self.task_view.selectionModel().currentChanged.connect( self.task_selection_change) self.cancel_remove_btn.clicked.connect(self.task_cancel_remove)
def __init__(self, parent): super(MemoryView, self).__init__(parent) self.critical = CRITICAL_PERCENTAGE self.mantid_memory_bar = QProgressBar(self) self.mantid_memory_bar.setAlignment(Qt.AlignCenter) self.set_mantid_value.connect(self._set_mantid_value) self.memory_bar = QProgressBar(self) self.memory_bar.setAlignment(Qt.AlignCenter) self.set_value.connect(self._set_value)
def __init__(self, parent: Optional[QWidget] = None, prog: progress = None) -> None: super().__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.progress = prog self.qt_progress_bar = QProgressBar() self.description_label = QLabel() self.eta_label = QLabel() base_layout = QVBoxLayout() pbar_layout = QHBoxLayout() pbar_layout.addWidget(self.description_label) pbar_layout.addWidget(self.qt_progress_bar) pbar_layout.addWidget(self.eta_label) base_layout.addLayout(pbar_layout) line = QFrame(self) line.setObjectName("QtCustomTitleBarLine") line.setFixedHeight(1) base_layout.addWidget(line) self.setLayout(base_layout)
def __init__(self, parent=None): """ init abort or notification ui. Displays while smoothing freezes the application. Allows abort button to be added if needed. """ super(AbortWindow, self).__init__(parent) self.setModal(False) self.setWindowFlags(self.windowFlags() | Qt.Tool) self.parent = parent self.label_a_1 = QLabel("Executing smoothing algorithm.") self.label_a_2 = QLabel("This may take several minutes.") self.abort_button = QPushButton("Abort") self.abort_button.clicked.connect(self.abort) self.pb = QProgressBar(self) self.pb_counter = 0 self.abort_flag = False # vbl is short for Vertical Box Layout vbl = QVBoxLayout() vbl.addWidget(self.label_a_1) vbl.addWidget(self.label_a_2) vbl.addWidget(self.pb) vbl.addWidget(self.abort_button) self.setLayout(vbl) self.show()
def setup_ui(self): self.setWindowTitle("Steering Panel") self.draw_timer = QTimer(self) self.draw_timer.setInterval(int(1000 / 5)) self.setLayout(QVBoxLayout()) self.current_progress = 0 self.total_progress = 0 self.loading_label = QLabel(self) self.progress_bar = QProgressBar(self) self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(100) self.x_magnet_list = None self.layout().addStretch() self.layout().addWidget(self.loading_label) self.layout().addWidget(self.progress_bar) self.layout().addStretch() position_scale = 2.0 self.orbit_view = OrbitView(parent=self, axis="x", name="X Orbit", label="X Orbit", units="mm", ymin=-position_scale, ymax=position_scale, draw_timer=self.draw_timer) self.orbit_view.hide() self.layout().addWidget(self.orbit_view) self.layout().setStretchFactor(self.orbit_view, 1) QTimer.singleShot(50, self.initialize_orbit)
def __init__(self, parent=None) -> None: super(ProgressView, self).__init__(parent) self._progress_tree_view = QTreeView(self) self._progress_tree_view.setHeaderHidden(True) self._progress_tree_view.setItemsExpandable(False) self._progress_tree_view.setItemDelegate(ProgressDelegate(self)) self._progress_tree_view.setRootIsDecorated(False) self._progress_tree_view.setFixedHeight(30) self._progress_tree_view.setVerticalScrollBarPolicy( Qt.ScrollBarAlwaysOff) self._progress_bar = QProgressBar(self) self._progress_bar.setRange(0, 0) self._progress_bar.setFixedHeight(30) self._progress_bar.setVisible(False) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._progress_tree_view) layout.addWidget(self._progress_bar) self.setLayout(layout) self.setFixedHeight(30)
def __init__(self, title): super().__init__() self.setWindowTitle(title) self.lib_path = "" self.final_title = "" analysis_icon = QIcon(os.path.join(icons_dir, "icon.png")) stack_icon = QIcon(os.path.join(icons_dir, "icon_stack.png")) self.analysis_button = QToolButton(self) self.analysis_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.analysis_button.setIcon(analysis_icon) # TODO use more general solution for text wrapping self.analysis_button.setText(SEGMENTATION_NAME.replace(" ", "\n")) self.analysis_button.setIconSize(QSize(100, 100)) self.mask_button = QToolButton(self) self.mask_button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) self.mask_button.setIcon(stack_icon) self.mask_button.setText(MASK_NAME.replace(" ", "\n")) self.mask_button.setIconSize(QSize(100, 100)) self.analysis_button.clicked.connect(self.launch_analysis) self.mask_button.clicked.connect(self.launch_mask) self.progress = QProgressBar() self.progress.setHidden(True) layout = QGridLayout() layout.addWidget(self.progress, 0, 0, 1, 2) layout.addWidget(self.analysis_button, 1, 1) layout.addWidget(self.mask_button, 1, 0) widget = QWidget() widget.setLayout(layout) self.setCentralWidget(widget) self.setWindowIcon(analysis_icon) self.prepare = None self.wind = None
def createProgressBar(self): self.progressBar = QProgressBar() self.progressBar.setRange(0, 10000) self.progressBar.setValue(0) timer = QTimer(self) timer.timeout.connect(self.advanceProgressBar) timer.start(1000)
def __init__(self, parent, batch_manager): QWidget.__init__(self, parent) self.calculation_manager = batch_manager self.whole_progress = QProgressBar(self) self.whole_progress.setMinimum(0) self.whole_progress.setMaximum(1) self.whole_progress.setFormat("%v of %m") self.whole_progress.setTextVisible(True) self.part_progress = QProgressBar(self) self.part_progress.setMinimum(0) self.part_progress.setMaximum(1) self.part_progress.setFormat("%v of %m") self.whole_label = QLabel("All batch progress:", self) self.part_label = QLabel("Single batch progress:", self) self.logs = ExceptionList(self) self.logs.setToolTip("Logs") self.task_que = QListWidget() self.process_num_timer = QTimer() self.process_num_timer.setInterval(1000) self.process_num_timer.setSingleShot(True) self.process_num_timer.timeout.connect(self.change_number_of_workers) self.number_of_process = QSpinBox(self) self.number_of_process.setRange(1, multiprocessing.cpu_count()) self.number_of_process.setValue(1) self.number_of_process.setToolTip( "Number of process used in batch calculation") self.number_of_process.valueChanged.connect( self.process_num_timer_start) layout = QGridLayout() layout.addWidget(self.whole_label, 0, 0, Qt.AlignRight) layout.addWidget(self.whole_progress, 0, 1, 1, 2) layout.addWidget(self.part_label, 1, 0, Qt.AlignRight) layout.addWidget(self.part_progress, 1, 1, 1, 2) lab = QLabel("Number of process:") lab.setToolTip("Number of process used in batch calculation") layout.addWidget(lab, 2, 0) layout.addWidget(self.number_of_process, 2, 1) layout.addWidget(self.logs, 3, 0, 1, 3) layout.addWidget(self.task_que, 0, 4, 0, 1) layout.setColumnMinimumWidth(2, 10) layout.setColumnStretch(2, 1) self.setLayout(layout) self.preview_timer = QTimer() self.preview_timer.setInterval(1000) self.preview_timer.timeout.connect(self.update_info)
def createScaleBar(self, barlen): pb = QProgressBar(self) pb.setAlignment(Qt.AlignCenter) pb.setStyleSheet("QProgressBar {border: solid grey; border-radius: 0px; color: black; } \ QProgressBar::chunk {background-color: #00AAFF; border-radius:0px;}") pb.setValue(100) pb.setFixedSize(barlen, 6) pb.setTextVisible(False) return pb
def __init__(self, theme='dark', emphasized=False): super().__init__(None) self.setProperty('emphasized', emphasized) self.setStyleSheet(template(raw_stylesheet, **palettes[theme])) lay = QVBoxLayout() self.setLayout(lay) lay.addWidget(QPushButton('push button')) box = QComboBox() box.addItems(['a', 'b', 'c', 'cd']) lay.addWidget(box) lay.addWidget(QFontComboBox()) hbox = QHBoxLayout() chk = QCheckBox('tristate') chk.setToolTip('I am a tooltip') chk.setTristate(True) chk.setCheckState(Qt.PartiallyChecked) chk3 = QCheckBox('checked') chk3.setChecked(True) hbox.addWidget(QCheckBox('unchecked')) hbox.addWidget(chk) hbox.addWidget(chk3) lay.addLayout(hbox) lay.addWidget(TabDemo(emphasized=emphasized)) sld = QSlider(Qt.Horizontal) sld.setValue(50) lay.addWidget(sld) scroll = QScrollBar(Qt.Horizontal) scroll.setValue(50) lay.addWidget(scroll) lay.addWidget(QHRangeSlider(parent=self)) text = QTextEdit() text.setMaximumHeight(100) text.setHtml(blurb) lay.addWidget(text) lay.addWidget(QTimeEdit()) edit = QLineEdit() edit.setPlaceholderText('LineEdit placeholder...') lay.addWidget(edit) lay.addWidget(QLabel('label')) prog = QProgressBar() prog.setValue(50) lay.addWidget(prog) groupBox = QGroupBox("Exclusive Radio Buttons") radio1 = QRadioButton("&Radio button 1") radio2 = QRadioButton("R&adio button 2") radio3 = QRadioButton("Ra&dio button 3") radio1.setChecked(True) hbox = QHBoxLayout() hbox.addWidget(radio1) hbox.addWidget(radio2) hbox.addWidget(radio3) hbox.addStretch(1) groupBox.setLayout(hbox) lay.addWidget(groupBox)
def __init__(self, parent, *args, **kwargs): QWidget.__init__(self, parent) self.pap = parent self.status_text = QLabel(self) self.bar = QProgressBar(self) self.bar.setRange(0, 0) layout = QVBoxLayout() layout.addWidget(self.status_text) layout.addWidget(self.bar) self.setLayout(layout)
def __init__(self): super().__init__() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.progress_bar = QProgressBar() self.log_area = QTextEdit() layout.addWidget(self.progress_bar) layout.addWidget(self.log_area) self.setLayout(layout)
def __init__(self): """Create our windgets. """ super().__init__() layout = QVBoxLayout() # For our "uptime" timer. self.start_time = time.time() # Label for our progress bar. bar_label = QLabel("Draw Time:") layout.addWidget(bar_label) # Progress bar is not used for "progress", it's just a bar graph to show # the "draw time", the duration of the "UpdateRequest" event. bar = QProgressBar() bar.setRange(0, 100) bar.setValue(50) bar.setFormat("%vms") layout.addWidget(bar) self.bar = bar # We let the user set the "slow event" threshold. self.thresh_ms = self.THRESH_DEFAULT self.thresh_combo = QComboBox() self.thresh_combo.addItems(self.THRESH_OPTIONS) self.thresh_combo.activated[str].connect(self._change_thresh) self.thresh_combo.setCurrentText(str(self.thresh_ms)) combo_layout = QHBoxLayout() combo_layout.addWidget(QLabel("Show Events Slower Than:")) combo_layout.addWidget(self.thresh_combo) combo_layout.addWidget(QLabel("milliseconds")) combo_layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) ) layout.addLayout(combo_layout) # We log slow events to this window. self.log = TextLog() layout.addWidget(self.log) # Uptime label. To indicate if the widget is getting updated. label = QLabel('') layout.addWidget(label) self.timer_label = label self.setLayout(layout) # Update us with a timer. self.timer = QTimer(self) self.timer.timeout.connect(self.update) self.timer.setInterval(self.UPDATE_MS) self.timer.start()
def create_progress_bar(self, bar_len: int = 10) -> QProgressBar: """ Create a progress bar with the given length Params: bar_len (int): length of progress bar to be created """ self.progress_bar: QProgressBar = QProgressBar() self.progress_bar.setRange(0, bar_len) self.progress_bar.setValue(0) self.progress_bar.setTextVisible(False) return self.progress_bar
def __init__(self, parent=None) -> None: super().__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.pbar = QProgressBar() self.description_label = QLabel() self.eta_label = QLabel() layout = QHBoxLayout() layout.addWidget(self.description_label) layout.addWidget(self.pbar) layout.addWidget(self.eta_label) self.setLayout(layout)
def _setup_ui(self): """ Set up the UI for the BatchProcessingView """ layout = QVBoxLayout() self.setLayout(layout) # Workflow config self.field_workflow_config = FileInput( mode=FileInputMode.FILE, filter="Json file (*.json)", placeholder_text="Load a JSON workflow file..." ) self.field_workflow_config.file_selected.connect(self._form_field_changed) row1 = FormRow("1. Load workflow:", self.field_workflow_config) # Channel index self.field_channel = QLineEdit("0") self.field_channel.setValidator(QIntValidator(bottom=0)) self.field_channel.textChanged.connect(self._form_field_changed) row2 = FormRow("2. Structure channel index:", self.field_channel) # Input dir self.field_input_dir = FileInput(mode=FileInputMode.DIRECTORY, placeholder_text="Select a directory...") self.field_input_dir.file_selected.connect(self._form_field_changed) row3 = FormRow("3. Input directory:", self.field_input_dir) # Output dir self.field_output_dir = FileInput(mode=FileInputMode.DIRECTORY, placeholder_text="Select a directory...") self.field_output_dir.file_selected.connect(self._form_field_changed) row4 = FormRow("4. Output directory:", self.field_output_dir) # Help label = QLabel() label.setText("Supported file formats: .tif, .tiff, .czi, .ome.tif, .ome.tiff") form = QWidget() form.setLayout(Form([row1, row2, row3, row4])) layout.addWidget(form) layout.addWidget(label) # Submit self.btn_run_batch = QPushButton("Run Batch") self.btn_run_batch.clicked.connect(self._btn_run_batch_clicked) self.update_button(enabled=False) layout.addWidget(self.btn_run_batch) # Progress bar self.progress_bar = QProgressBar() self.progress_bar.setRange(0, 100) self.progress_bar.setValue(0) self.progress_bar.setTextVisible(True) self.progress_bar.setVisible(False) layout.addWidget(self.progress_bar)
def __init__(self, title, maximum, parent=None): super(LoadingDialog, self).__init__(parent) #self.setAttribute(Qt.WA_DeleteOnClose) self._may_close = False layout = QVBoxLayout() layout.addWidget(QLabel("Loading...", self)) self.progress = QProgressBar(self) self.progress.setMinimum(0) self.progress.setMaximum(maximum) layout.addWidget(self.progress) self.setWindowTitle(title) self.setLayout(layout)
def __on_reporter_created(reporter): initial_geometry = self.geometry() self.progress_bar_container_widget.setVisible(True) self.progress_bar_divider_line.setVisible(True) progress_bar = QProgressBar(self.progress_bar_container_widget) progress_bar.setAlignment(Qt.AlignCenter) reporter.progress_bar = progress_bar self.__reporter_map[reporter] = progress_bar self.progress_bar_container_layout.addWidget(progress_bar) progress_bar.show() current_geometry = self.geometry() current_geometry.moveCenter(initial_geometry.center()) self.setGeometry(current_geometry)
def __init__(self, log_file, windows_title, percentage_pattern): super(ProgressMonitor, self).__init__() self.setGeometry(50, 50, 500, 100) self.setWindowTitle(windows_title) self.setWindowIcon(QtGui.QIcon("pythonlogo.png")) closeAction = QAction("close", self) closeAction.setShortcut("Ctrl+Q") closeAction.setStatusTip("close this window") closeAction.triggered.connect(self.close_application) self.polling_interval_in_seconds = 2 self.elapsed_time = 0.0 self.elapsed_time_label = QLabel() self.elapsed_time_label.setText("elapsed time: 0 second") self.progress_bar = QProgressBar(self) # self.progress_bar.resize(400, 25) # self.progress_bar.setGeometry(200, 50, 250, 20) self.progress = 0.0 # 100 as completion self.last_line_number = 0 self.percentage_pattern = percentage_pattern killbtn = QPushButton("Interrupt", self) killbtn.clicked.connect(self.interrupt_application) btn = QPushButton("Quit", self) btn.clicked.connect(self.close_application) btn.resize(btn.minimumSizeHint()) hbox = QHBoxLayout() hbox.addWidget(killbtn) hbox.addStretch() hbox.addWidget(btn) vbox = QVBoxLayout() vbox.addWidget(self.elapsed_time_label) vbox.addWidget(self.progress_bar) vbox.addLayout(hbox) widget = QWidget(self) widget.setLayout(vbox) self.setCentralWidget(widget) self.setup_monitor(log_file)
def __init__(self): super().__init__() layout = QGridLayout() self.setLayout(layout) self.status = QLabel('Click "Start"', self) self.play_btn = QPushButton("Start", self) self.abort_btn = QPushButton("Abort!", self) self.reset_btn = QPushButton("Reset", self) self.progress_bar = QProgressBar() layout.addWidget(self.play_btn, 0, 0) layout.addWidget(self.reset_btn, 0, 1) layout.addWidget(self.abort_btn, 0, 2) layout.addWidget(self.status, 0, 3) layout.setColumnStretch(3, 1) layout.addWidget(self.progress_bar, 1, 0, 1, 4)
def initUI(self): ml = QVBoxLayout(self) ul = QHBoxLayout(self) dl = QHBoxLayout(self) ml.addLayout(ul) ml.addLayout(dl) col = QColor(0, 0, 0) self.colorText = 'Color Nmae: {}' self.btn = QPushButton('Dialog', self) self.btn.move(20, 20) self.btn.clicked.connect(self.showDialog) self.btn2 = QPushButton('Color', self) self.btn2.move(20, 40) self.btn2.clicked.connect(self.showColorDialoge) self.frm = QFrame(self) self.frm.setStyleSheet("QWidget { background-color: %s }" % col.name()) self.frm.setGeometry(130, 50, 100, 100) self.le = QLineEdit(self) self.le.move(130, 22) self.label = QLabel(self.colorText.format(None), self) self.label.setGeometry(20, 80, 100, 30) self.timer = QBasicTimer() self.pb = QProgressBar(self) self.step = 0 self.pb.setGeometry(20, 170, 300, 20) # calendar self.timeLable = QLabel('time is: ', self) # self.timeLable.setGeometry(20, 120, 100, 30) cal = QCalendarWidget(self) cal.clicked[QDate].connect(self.showDate) ul.addWidget(self.timeLable) dl.addWidget(cal) self.setLayout(ml) self.setGeometry(300, 300, 550, 550) self.setWindowTitle('Dialog') self.show()
def update(self, data): """ Update the gui elements. :param data: Data in format of AlgorithmProgressModel.get_running_algorithm_data() """ self.tree.clear() for alg_data in data: name, id, properties = alg_data item = QTreeWidgetItem([name]) self.tree.addTopLevelItem(item) progress_bar = QProgressBar() progress_bar.setAlignment(Qt.AlignHCenter) self.presenter.add_progress_bar(id, progress_bar) cancel_button = CancelButton(self.presenter, id) self.tree.setItemWidget(item, 1, progress_bar) self.tree.setItemWidget(item, 2, cancel_button) for prop in properties: item.addChild(QTreeWidgetItem(prop))
def _setup_ui(self): self.layout = QVBoxLayout() self.dlg_label = QLabel(self) self.cur_item_label = QLabel(self) self.progress_bar = QProgressBar(self) self.cancel = QPushButton('Cancel', self) self.layout.addWidget(self.dlg_label) self.layout.addWidget(self.cur_item_label) self.layout.addWidget(self.progress_bar) self.layout.addWidget(self.cancel) self.setLayout(self.layout) # Set initial value self.progress_bar.setValue(0) # Set progress bar limits and connect signals self.progress_bar.setMinimum(0) if hasattr(self._task, '__iter__'): self.dlg_label.setText(self._label[0]) self._task[0].currentItem.connect(self.cur_item_label.setText) self._task[0].itemDone.connect(self.inc_value) pb_max = self._task[0].size() for i in range(1, len(self._task)): self._task[i].currentItem.connect(self.cur_item_label.setText) self._task[i].itemDone.connect(self.inc_value) self._task[i - 1].completed.connect(self._update_label) self._task[i - 1].completed.connect(self._task[i].start) pb_max += self._task[i].size() self.progress_bar.setMaximum(pb_max) self._task[-1].completed.connect(lambda: self._exit_dlg(1)) else: self.dlg_label.setText(self._label) self._task.currentItem.connect(self.cur_item_label.setText) self._task.itemDone.connect(self.inc_value) self._task.completed.connect(lambda: self._exit_dlg(1)) self.progress_bar.setMaximum(self._task.size()) self.cancel.pressed.connect(self.canceled.emit) self.canceled.connect(lambda: self._exit_dlg(0)) self.progress_bar.valueChanged.connect(self._is_finished)
def __init__(self, run_button=None, qwidgets_to_disable=None, text_edit=None, busy=None, timer_label=None, parent=None, setup_layout=True, **kwargs): super(JobRunner, self).__init__(parent, **kwargs) self.is_passed = False self._iteration_edit = QLineEdit(self, placeholderText="Iteration (n)") self._iteration_edit.setText('5') if run_button is None: run_button = QPushButton("Calculate Prime", self) run_button.clicked.connect(self.prime_requested) if text_edit is None: text_edit = QTextEdit("Result:<br>", self) text_edit.setReadOnly(True) if busy is None: busy = QProgressBar(self) self._busy = busy if timer_label is None: timer_label = QLabel('0:00') self._timer_label = timer_label self._busy.setVisible(False) self._timer_label.setVisible(False) self._run_button = run_button self._text_edit = text_edit self._time0 = None self.process = None if qwidgets_to_disable is None: qwidgets_to_disable = [self._run_button, self._iteration_edit] self.qwidgets_to_disable = qwidgets_to_disable if setup_layout: self.setup_layout()
def __init__(self, parent=None, standalone=False): super(GcodeBackplot, self).__init__(parent) # This prevents doing unneeded initialization # when QtDesginer loads the plugin. if parent is None and not standalone: return self.show_overlay = False # no DRO or DRO overlay self.program_alpha = True self.grid_size = 1 self._reload_filename = None # Add loading progress bar and abort button self.progressBar = QProgressBar(visible=False) self.progressBar.setFormat("Loading backplot: %p%") self.abortButton = QPushButton('Abort', visible=False) hBox = QHBoxLayout() hBox.addWidget(self.progressBar) hBox.addWidget(self.abortButton) vBox = QVBoxLayout(self) vBox.addStretch() vBox.addLayout(hBox) self.abortButton.clicked.connect(self.abort) STATUS.actual_position.onValueChanged(self.update) STATUS.joint_actual_position.onValueChanged(self.update) STATUS.homed.onValueChanged(self.update) STATUS.limit.onValueChanged(self.update) STATUS.tool_in_spindle.onValueChanged(self.update) STATUS.motion_mode.onValueChanged(self.update) STATUS.current_vel.onValueChanged(self.update) STATUS.g5x_offset.onValueChanged(self.reloadBackplot) STATUS.g92_offset.onValueChanged(self.reloadBackplot) # Connect status signals STATUS.file.notify(self.loadBackplot) # STATUS.reload_backplot.notify(self.reloadBackplot) STATUS.program_units.notify(lambda v: self.setMetricUnits(v == 2))
def __init__(self, svid, svname, parent=None): super().__init__(title=svname, collapsible=True, removable=True, editable=True, parent=parent) self.svid = svid self.svname = svname from qtpy.QtWidgets import QProgressBar self.pbar = QProgressBar(self) self.add_row(self.pbar) from survos2.frontend.plugins.features import FeatureComboBox self.svsource = FeatureComboBox() self.svsource.setMaximumWidth(250) self.svshape = LineEdit(parse=int, default=10) self.svshape.setMaximumWidth(250) self.svspacing = LineEdit3D(parse=float, default=1) self.svspacing.setMaximumWidth(250) self.svcompactness = LineEdit(parse=float, default=20) self.svcompactness.setMaximumWidth(250) self.int64_checkbox = CheckBox(checked=False) self.compute_btn = PushButton("Compute") self.view_btn = PushButton("View", accent=True) self.add_row(HWidgets("Source:", self.svsource, stretch=1)) self.add_row(HWidgets("Shape:", self.svshape, stretch=1)) self.add_row(HWidgets("Spacing:", self.svspacing, stretch=1)) self.add_row(HWidgets("Compactness:", self.svcompactness, stretch=1)) self.add_row(HWidgets("Int64:", self.int64_checkbox, stretch=1)) self.add_row(HWidgets(None, self.compute_btn)) self.add_row(HWidgets(None, self.view_btn)) self.compute_btn.clicked.connect(self.compute_supervoxels) self.view_btn.clicked.connect(self.view_regions)
def __init__(self, thread: QThread, text="", parent=None, exception_hook=None): super().__init__(parent) label = QLabel(text) self.exception_hook = exception_hook self.progress = QProgressBar() self.progress.setRange(0, 0) self.cancel_btn = QPushButton("Cancel") self.cancel_btn.setDisabled(True) self._error_caught = False layout = QHBoxLayout() layout.addWidget(label) layout.addWidget(self.progress) layout.addWidget(self.cancel_btn) self.cancel_btn.clicked.connect(self.close) thread.finished.connect(self.accept_if_no_reject) self.thread_to_wait = thread self.setLayout(layout) self.setResult(QDialog.Accepted) if isinstance(thread, ProgressTread): thread.range_changed.connect(self.progress.setRange) thread.step_changed.connect(self.progress.setValue) thread.error_signal.connect(self.error_catch)
def __init__(self, parent=None, title=None, minimum=0, maximum=1, value=0): super(ProgressBar, self).__init__(parent) layout = QGridLayout(self) self.progressbar = QProgressBar(self) self.progressbar.setMinimum(minimum) self.progressbar.setMaximum(maximum) self.progressbar.setValue(value) self.progressbar.setStyleSheet(self.style) self.label = QLabel("") self.label.setStyleSheet("Qlabel { font-size: 20px }") self.label.setAlignment(QtCore.Qt.AlignCenter) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setFixedSize(256, 64) # self.progressbar.setValue(1) layout.addWidget(self.progressbar, 0, 0) layout.addWidget(self.label, 0, 0) self.setLayout(layout) if title: self.setWindowTitle(title)
def __init__(self, parent=None, options_button=None, handle_links=True): QWidget.__init__(self, parent) self.home_url = None self.webview = WebView(self, handle_links=handle_links) self.webview.setup() self.webview.loadFinished.connect(self.load_finished) self.webview.titleChanged.connect(self.setWindowTitle) self.webview.urlChanged.connect(self.url_changed) home_button = create_toolbutton(self, icon=ima.icon('home'), tip=_("Home"), triggered=self.go_home) zoom_out_button = action2button(self.webview.zoom_out_action) zoom_in_button = action2button(self.webview.zoom_in_action) def pageact2btn(prop, icon=None): return action2button(self.webview.pageAction(prop), parent=self.webview, icon=icon) refresh_button = pageact2btn(QWebEnginePage.Reload, icon=ima.icon('refresh')) stop_button = pageact2btn(QWebEnginePage.Stop, icon=ima.icon('stop')) previous_button = pageact2btn(QWebEnginePage.Back, icon=ima.icon('previous')) next_button = pageact2btn(QWebEnginePage.Forward, icon=ima.icon('next')) stop_button.setEnabled(False) self.webview.loadStarted.connect(lambda: stop_button.setEnabled(True)) self.webview.loadFinished.connect( lambda: stop_button.setEnabled(False)) progressbar = QProgressBar(self) progressbar.setTextVisible(False) progressbar.hide() self.webview.loadStarted.connect(progressbar.show) self.webview.loadProgress.connect(progressbar.setValue) self.webview.loadFinished.connect(lambda _state: progressbar.hide()) label = QLabel(self.get_label()) self.url_combo = UrlComboBox(self) self.url_combo.valid.connect(self.url_combo_activated) if not WEBENGINE: self.webview.iconChanged.connect(self.icon_changed) self.find_widget = FindReplace(self) self.find_widget.set_editor(self.webview) self.find_widget.hide() find_button = create_toolbutton(self, icon=ima.icon('find'), tip=_("Find text"), toggled=self.toggle_find_widget) self.find_widget.visibility_changed.connect(find_button.setChecked) hlayout = QHBoxLayout() for widget in (previous_button, next_button, home_button, find_button, label, self.url_combo, zoom_out_button, zoom_in_button, refresh_button, progressbar, stop_button): hlayout.addWidget(widget) if options_button: hlayout.addWidget(options_button) layout = create_plugin_layout(hlayout) layout.addWidget(self.webview) layout.addWidget(self.find_widget) self.setLayout(layout)