def __init__(self, parent): super(ManualInstallWidget, self).__init__() self._parent = parent vbox = QVBoxLayout(self) form = QFormLayout() self._txtName = QLineEdit() self._txtVersion = QLineEdit() form.addRow(self.tr("Plugin Name:"), self._txtName) form.addRow(self.tr("Plugin Version:"), self._txtVersion) vbox.addLayout(form) hPath = QHBoxLayout() self._txtFilePath = QLineEdit() self._btnFilePath = QPushButton(QIcon(":img/open"), '') hPath.addWidget(QLabel(self.tr("Plugin File:"))) hPath.addWidget(self._txtFilePath) hPath.addWidget(self._btnFilePath) vbox.addLayout(hPath) vbox.addSpacerItem( QSpacerItem(0, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) self._btnInstall = QPushButton(self.tr("Install")) hbox.addWidget(self._btnInstall) vbox.addLayout(hbox) #Signals self.connect(self._btnFilePath, SIGNAL("clicked()"), self._load_plugin_path) self.connect(self._btnInstall, SIGNAL("clicked()"), self.install_plugin)
def initAppletDrawerUi(self): training_controls = EdgeTrainingGui.createDrawerControls(self) training_controls.layout().setContentsMargins(5,0,5,0) training_layout = QVBoxLayout() training_layout.addWidget( training_controls ) training_layout.setContentsMargins(0,15,0,0) training_box = QGroupBox( "Training", parent=self ) training_box.setLayout(training_layout) training_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_controls = MulticutGuiMixin.createDrawerControls(self) multicut_controls.layout().setContentsMargins(5,0,5,0) multicut_layout = QVBoxLayout() multicut_layout.addWidget( multicut_controls ) multicut_layout.setContentsMargins(0,15,0,0) multicut_box = QGroupBox( "Multicut", parent=self ) multicut_box.setLayout(multicut_layout) multicut_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) drawer_layout = QVBoxLayout() drawer_layout.addWidget(training_box) drawer_layout.addWidget(multicut_box) drawer_layout.setSpacing(2) drawer_layout.setContentsMargins(5,5,5,5) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) self._drawer = QWidget(parent=self) self._drawer.setLayout(drawer_layout)
def fillSpTab(self): spWidget = QWidget() spLayout = QVBoxLayout() generalBox = SkillBox('General', 'SP', 'General', 'SP') albertBox = SkillBox('Albert', 'SP', self.mainClass, self.subClass) commonBox = SkillBox('Common', 'SP', self.mainClass, 'Common') classBox = SkillBox('Class', 'SP', self.mainClass, self.subClass) spLayout.addLayout(getLayout(generalBox, albertBox)) spLayout.addLayout(getLayout(commonBox)) spLayout.addLayout(getLayout(classBox)) spLayout.addSpacerItem(QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.spDict['General'] = generalBox self.spDict['Albert'] = albertBox self.spDict['Common'] = commonBox self.spDict['Class'] = classBox spWidget.setLayout(spLayout) self.scrollAreaSP.setWidget(spWidget) for skillBox in self.spDict.values(): skillBox.totalChanged.connect(self.updateUsedSP)
def __init__(self, parent): super(ManualInstallWidget, self).__init__() self._parent = parent vbox = QVBoxLayout(self) form = QFormLayout() self._txtName = QLineEdit() self._txtVersion = QLineEdit() form.addRow(self.tr("Plugin Name:"), self._txtName) form.addRow(self.tr("Plugin Version:"), self._txtVersion) vbox.addLayout(form) hPath = QHBoxLayout() self._txtFilePath = QLineEdit() self._btnFilePath = QPushButton(QIcon(":img/open"), '') hPath.addWidget(QLabel(self.tr("Plugin File:"))) hPath.addWidget(self._txtFilePath) hPath.addWidget(self._btnFilePath) vbox.addLayout(hPath) vbox.addSpacerItem(QSpacerItem(0, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) self._btnInstall = QPushButton(self.tr("Install")) hbox.addWidget(self._btnInstall) vbox.addLayout(hbox) #Signals self.connect(self._btnFilePath, SIGNAL("clicked()"), self._load_plugin_path) self.connect(self._btnInstall, SIGNAL("clicked()"), self.install_plugin)
def __init__(self): QWidget.__init__(self) # Layout vbox = QVBoxLayout(self) # Model for Watches self.model = [] # View for Watches self.view = WatchesView() self.view.setContentProvider(debugger_plugin.gui.providers.WatchesContentProvider()) self.view.setLabelProvider(debugger_plugin.gui.providers.WatchesExprLabelProvider(), 0) self.view.setLabelProvider(debugger_plugin.gui.providers.WatchesValueLabelProvider(), 1) self.view.setInput(self.model) # Step over btn_add = QPushButton("Add Watch", self) self.connect(btn_add, SIGNAL("clicked()"), self.add_watch) vbox.setContentsMargins(0,0,0,0) vbox.addWidget(self.view) vbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) vbox.addWidget(btn_add) self.connect(self.view, SIGNAL("itemDoubleClicked(QTreeWidgetItem*, int)"), self.edit_item) self.connect(self.view, SIGNAL("itemChanged(QTreeWidgetItem*, int)"), self.__item_changed) # Expand top level item a = self.view.topLevelItem(0) self.view.expandItem(a)
def initAppletDrawerUi(self): training_controls = EdgeTrainingGui.createDrawerControls(self) training_controls.layout().setContentsMargins(5,0,5,0) training_layout = QVBoxLayout() training_layout.addWidget( training_controls ) training_layout.setContentsMargins(0,0,0,0) training_box = QGroupBox( "Training", parent=self ) training_box.setLayout(training_layout) training_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) multicut_controls = MulticutGuiMixin.createDrawerControls(self) multicut_controls.layout().setContentsMargins(5,0,5,0) multicut_layout = QVBoxLayout() multicut_layout.addWidget( multicut_controls ) multicut_layout.setContentsMargins(0,0,0,0) multicut_box = QGroupBox( "Multicut", parent=self ) multicut_box.setLayout(multicut_layout) multicut_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) drawer_layout = QVBoxLayout() drawer_layout.addWidget(training_box) drawer_layout.addWidget(multicut_box) drawer_layout.setSpacing(2) drawer_layout.setContentsMargins(5,5,5,5) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) self._drawer = QWidget(parent=self) self._drawer.setLayout(drawer_layout)
def __init__(self, parent): super(FindInFilesWidget, self).__init__(parent) self._main_container = IDE.get_service('main_container') self._explorer_container = IDE.get_service('explorer') self._result_widget = FindInFilesResult() self._open_find_button = QPushButton(translations.TR_FIND + "!") self._stop_button = QPushButton(translations.TR_STOP + "!") self._clear_button = QPushButton(translations.TR_CLEAR + "!") self._replace_button = QPushButton(translations.TR_REPLACE) self._find_widget = FindInFilesDialog(self._result_widget, self) self._error_label = QLabel(translations.TR_NO_RESULTS) self._error_label.setVisible(False) #Replace Area self.replace_widget = QWidget() hbox_replace = QHBoxLayout(self.replace_widget) hbox_replace.setContentsMargins(0, 0, 0, 0) self.lbl_replace = QLabel(translations.TR_REPLACE_RESULTS_WITH) self.lbl_replace.setTextFormat(Qt.PlainText) self.replace_edit = QLineEdit() hbox_replace.addWidget(self.lbl_replace) hbox_replace.addWidget(self.replace_edit) self.replace_widget.setVisible(False) #Main Layout main_hbox = QHBoxLayout(self) #Result Layout tree_vbox = QVBoxLayout() tree_vbox.addWidget(self._result_widget) tree_vbox.addWidget(self._error_label) tree_vbox.addWidget(self.replace_widget) main_hbox.addLayout(tree_vbox) #Buttons Layout vbox = QVBoxLayout() vbox.addWidget(self._open_find_button) vbox.addWidget(self._stop_button) vbox.addWidget(self._clear_button) vbox.addSpacerItem( QSpacerItem(0, 50, QSizePolicy.Fixed, QSizePolicy.Expanding)) vbox.addWidget(self._replace_button) main_hbox.addLayout(vbox) self._open_find_button.setFocus() #signals self.connect(self._open_find_button, SIGNAL("clicked()"), self.open) self.connect(self._stop_button, SIGNAL("clicked()"), self._find_stop) self.connect(self._clear_button, SIGNAL("clicked()"), self._clear_results) self.connect(self._result_widget, SIGNAL("itemActivated(QTreeWidgetItem *, int)"), self._go_to) self.connect(self._result_widget, SIGNAL("itemClicked(QTreeWidgetItem *, int)"), self._go_to) self.connect(self._find_widget, SIGNAL("finished()"), self._find_finished) self.connect(self._find_widget, SIGNAL("findStarted()"), self._find_started) self.connect(self._replace_button, SIGNAL("clicked()"), self._replace_results)
def __init__(self, parent): QWidget.__init__(self, parent) self._main_container = main_container.MainContainer() self._explorer_container = explorer_container.ExplorerContainer() self._result_widget = FindInFilesResult() self._open_find_button = QPushButton(self.tr("Find!")) self._stop_button = QPushButton(self.tr("Stop")) self._clear_button = QPushButton(self.tr("Clear!")) self._replace_button = QPushButton(self.tr("Replace")) self._find_widget = FindInFilesDialog(self._result_widget, self) self._error_label = QLabel(self.tr("No Results")) self._error_label.setVisible(False) #Replace Area self.replace_widget = QWidget() hbox_replace = QHBoxLayout(self.replace_widget) hbox_replace.setContentsMargins(0, 0, 0, 0) self.lbl_replace = QLabel(self.tr("Replace results with:")) self.lbl_replace.setTextFormat(Qt.PlainText) self.replace_edit = QLineEdit() hbox_replace.addWidget(self.lbl_replace) hbox_replace.addWidget(self.replace_edit) self.replace_widget.setVisible(False) #Main Layout main_hbox = QHBoxLayout(self) #Result Layout tree_vbox = QVBoxLayout() tree_vbox.addWidget(self._result_widget) tree_vbox.addWidget(self._error_label) tree_vbox.addWidget(self.replace_widget) main_hbox.addLayout(tree_vbox) #Buttons Layout vbox = QVBoxLayout() vbox.addWidget(self._open_find_button) vbox.addWidget(self._stop_button) vbox.addWidget(self._clear_button) vbox.addSpacerItem( QSpacerItem(0, 50, QSizePolicy.Fixed, QSizePolicy.Expanding)) vbox.addWidget(self._replace_button) main_hbox.addLayout(vbox) self._open_find_button.setFocus() #signals self.connect(self._open_find_button, SIGNAL("clicked()"), self.open) self.connect(self._stop_button, SIGNAL("clicked()"), self._find_stop) self.connect(self._clear_button, SIGNAL("clicked()"), self._clear_results) self.connect(self._result_widget, SIGNAL("itemActivated(QTreeWidgetItem *, int)"), self._go_to) self.connect(self._result_widget, SIGNAL("itemClicked(QTreeWidgetItem *, int)"), self._go_to) self.connect(self._find_widget, SIGNAL("finished()"), self._find_finished) self.connect(self._find_widget, SIGNAL("findStarted()"), self._find_started) self.connect(self._replace_button, SIGNAL("clicked()"), self._replace_results)
def initAppletDrawerUi(self): localDir = os.path.split(__file__)[0] self._drawer = self._cropControlUi data_has_z_axis = True if self.topLevelOperatorView.InputImage.ready(): tShape = self.topLevelOperatorView.InputImage.meta.getTaggedShape() if not 'z' in tShape or tShape['z']==1: data_has_z_axis = False self._cropControlUi._minSliderZ.setVisible(data_has_z_axis) self._cropControlUi._minSliderZ.setVisible(data_has_z_axis) self._cropControlUi._maxSliderZ.setVisible(data_has_z_axis) self._cropControlUi._minSpinZ.setVisible(data_has_z_axis) self._cropControlUi._maxSpinZ.setVisible(data_has_z_axis) self._cropControlUi.labelMinZ.setVisible(data_has_z_axis) self._cropControlUi.labelMaxZ.setVisible(data_has_z_axis) self._cropControlUi.AddCropButton.clicked.connect( bind (self.newCrop) ) self._cropControlUi.SetCropButton.clicked.connect( bind (self.setCrop) ) self.topLevelOperatorView.MinValueT.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MaxValueT.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MinValueX.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MaxValueX.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MinValueY.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MaxValueY.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MinValueZ.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.MaxValueZ.notifyDirty(self.apply_operator_settings_to_gui) self.topLevelOperatorView.InputImage.notifyDirty(self.setDefaultValues) self.topLevelOperatorView.PredictionImage.notifyDirty(self.setDefaultValues) layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget( self._cropControlUi ) layout.addSpacerItem( QSpacerItem(0,0,vPolicy=QSizePolicy.Expanding) ) self.setDefaultValues() self.apply_operator_settings_to_gui() self.editor.showCropLines(True) self.editor.cropModel.setEditable (True) self.editor.cropModel.changed.connect(self.onCropModelChanged) self.editor.posModel.timeChanged.connect(self.updateTime) self._cropControlUi._minSliderT.valueChanged.connect(self._onMinSliderTMoved) self._cropControlUi._maxSliderT.valueChanged.connect(self._onMaxSliderTMoved) self._cropControlUi._minSliderX.valueChanged.connect(self._onMinSliderXMoved) self._cropControlUi._maxSliderX.valueChanged.connect(self._onMaxSliderXMoved) self._cropControlUi._minSliderY.valueChanged.connect(self._onMinSliderYMoved) self._cropControlUi._maxSliderY.valueChanged.connect(self._onMaxSliderYMoved) self._cropControlUi._minSliderZ.valueChanged.connect(self._onMinSliderZMoved) self._cropControlUi._maxSliderZ.valueChanged.connect(self._onMaxSliderZMoved) self._cropControlUi.cropListView.deleteCrop.connect(self.onDeleteCrop) self._cropControlUi.cropListView.colorsChanged.connect(self.onColorsChanged) self._initCropListView()
def __init__(self, parent): QWidget.__init__(self, parent) self._main_container = main_container.MainContainer() self._explorer_container = explorer_container.ExplorerContainer() self._result_widget = FindInFilesResult() self._open_find_button = QPushButton(self.tr("Find!")) self._stop_button = QPushButton(self.tr("Stop")) self._clear_button = QPushButton(self.tr("Clear!")) self._replace_button = QPushButton(self.tr("Replace")) self._find_widget = FindInFilesDialog(self._result_widget, self) self._error_label = QLabel(self.tr("No Results")) self._error_label.setVisible(False) #Replace Area self.replace_widget = QWidget() hbox_replace = QHBoxLayout(self.replace_widget) hbox_replace.setContentsMargins(0, 0, 0, 0) self.lbl_replace = QLabel(self.tr("Replace results with:")) self.lbl_replace.setTextFormat(Qt.PlainText) self.replace_edit = QLineEdit() hbox_replace.addWidget(self.lbl_replace) hbox_replace.addWidget(self.replace_edit) self.replace_widget.setVisible(False) #Main Layout main_hbox = QHBoxLayout(self) #Result Layout tree_vbox = QVBoxLayout() tree_vbox.addWidget(self._result_widget) tree_vbox.addWidget(self._error_label) tree_vbox.addWidget(self.replace_widget) main_hbox.addLayout(tree_vbox) #Buttons Layout vbox = QVBoxLayout() vbox.addWidget(self._open_find_button) vbox.addWidget(self._stop_button) vbox.addWidget(self._clear_button) vbox.addSpacerItem(QSpacerItem(0, 50, QSizePolicy.Fixed, QSizePolicy.Expanding)) vbox.addWidget(self._replace_button) main_hbox.addLayout(vbox) self._open_find_button.setFocus() #signals self.connect(self._open_find_button, SIGNAL("clicked()"), self.open) self.connect(self._stop_button, SIGNAL("clicked()"), self._find_stop) self.connect(self._clear_button, SIGNAL("clicked()"), self._clear_results) self.connect(self._result_widget, SIGNAL( "itemActivated(QTreeWidgetItem *, int)"), self._go_to) self.connect(self._result_widget, SIGNAL( "itemClicked(QTreeWidgetItem *, int)"), self._go_to) self.connect(self._find_widget, SIGNAL("finished()"), self._find_finished) self.connect(self._find_widget, SIGNAL("findStarted()"), self._find_started) self.connect(self._replace_button, SIGNAL("clicked()"), self._replace_results)
def createDrawerControls(self): op = self.topLevelOperatorView def configure_update_handlers( qt_signal, op_slot ): qt_signal.connect( self.configure_operator_from_gui ) cleanup_fn = op_slot.notifyDirty( self.configure_gui_from_operator, defer=True ) self.__cleanup_fns.append( cleanup_fn ) # Controls feature_selection_button = QPushButton(text="Select Features", icon=QIcon(ilastikIcons.AddSel), toolTip="Select edge/superpixel features to use for classification.", clicked=self._open_feature_selection_dlg) self.train_from_gt_button = QPushButton(text="Auto-label", icon=QIcon(ilastikIcons.Segment), toolTip="Automatically label all edges according to your pre-loaded groundtruth volume.", clicked=self._handle_label_from_gt_clicked) self.clear_labels_button = QPushButton(text="Clear Labels", icon=QIcon(ilastikIcons.Clear), toolTip="Remove all edge labels. (Start over on this image.)", clicked=self._handle_clear_labels_clicked) self.live_update_button = QPushButton(text="Live Predict", checkable=True, icon=QIcon(ilastikIcons.Play)) configure_update_handlers( self.live_update_button.toggled, op.FreezeCache ) # Layout label_layout = QHBoxLayout() label_layout.addWidget(self.clear_labels_button) label_layout.addWidget(self.train_from_gt_button) label_layout.setSpacing(1) layout = QVBoxLayout() layout.addWidget(feature_selection_button) layout.setSpacing(1) layout.addLayout(label_layout) layout.addWidget(self.live_update_button) layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(layout) # Widget Shortcuts mgr = ShortcutManager() ActionInfo = ShortcutManager.ActionInfo shortcut_group = "Edge Training" mgr.register( "l", ActionInfo( shortcut_group, "Live Predict", "Toggle live edge classifier update mode", self.live_update_button.toggle, self.live_update_button, self.live_update_button ) ) return drawer
def __init__(self, distributedObjects, parent=None): QWidget.__init__(self, parent, Qt.Tool | Qt.FramelessWindowHint) self.setPalette(QToolTip.palette()) self.__do = distributedObjects self.__allowHide = True self.treeItemView = TreeItemView() self.treeItemView.setVerticalScrollMode(QAbstractItemView.ScrollPerItem) self.treeItemView.verticalScrollBar().rangeChanged.connect(self.resizeViewVertically) self.hide() self.exp = None addToWatchButton = QPushButton(Icons.watch, "") addToWatchButton.setMinimumSize(self.ICON_SIZE, self.ICON_SIZE) addToWatchButton.setMaximumSize(self.ICON_SIZE, self.ICON_SIZE) addToWatchButton.setToolTip("Add to Watch") addToWatchButton.clicked.connect(self.__addToWatch) addToDatagraphButton = QPushButton(Icons.datagraph, "") addToDatagraphButton.setMinimumSize(self.ICON_SIZE, self.ICON_SIZE) addToDatagraphButton.setMaximumSize(self.ICON_SIZE, self.ICON_SIZE) addToDatagraphButton.setToolTip("Add to Data Graph") addToDatagraphButton.clicked.connect(self.__addToDatagraph) setWatchpointButton = QPushButton(Icons.wp, "") setWatchpointButton.setMinimumSize(self.ICON_SIZE, self.ICON_SIZE) setWatchpointButton.setMaximumSize(self.ICON_SIZE, self.ICON_SIZE) setWatchpointButton.setToolTip("Set Watchpoint") setWatchpointButton.clicked.connect(self.__setWatchpoint) self.__layout = QHBoxLayout(self) self.__layout.addWidget(self.treeItemView) l = QVBoxLayout() l.addWidget(addToWatchButton) l.addWidget(addToDatagraphButton) l.addWidget(setWatchpointButton) l.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) # show a size grip in the corner to allow the user to resize the window l.addWidget(QSizeGrip(self)) l.setSpacing(0) self.__layout.addLayout(l) self.__layout.setContentsMargins(0, 0, 0, 0) self.__layout.setSpacing(0) self.__hideTimer = QTimer() self.__hideTimer.setSingleShot(True) self.__hideTimer.timeout.connect(self.hideNow) self.treeItemView.contextMenuOpen.connect(self.__setDisallowHide) self.treeItemView.setRootIsDecorated(False) self.treeItemView.setHeaderHidden(True)
def createDrawerControls(self): # Controls feature_selection_button = QPushButton(text="Select Features", icon=QIcon(ilastikIcons.AddSel), toolTip="Select edge/superpixel features to use for classification.", clicked=self._open_feature_selection_dlg) self.train_from_gt_button = QPushButton(text="Auto-label", icon=QIcon(ilastikIcons.Segment), toolTip="Automatically label all edges according to your pre-loaded groundtruth volume.", clicked=self._handle_label_from_gt_clicked) self.clear_labels_button = QPushButton(text="Clear Labels", icon=QIcon(ilastikIcons.Clear), toolTip="Remove all edge labels. (Start over on this image.)", clicked=self._handle_clear_labels_clicked) self.live_update_button = QPushButton(text="Live Predict", checkable=True, icon=QIcon(ilastikIcons.Play), toggled=self._handle_live_update_clicked) # Layout label_layout = QHBoxLayout() label_layout.addWidget(self.clear_labels_button) label_layout.addWidget(self.train_from_gt_button) label_layout.setSpacing(1) layout = QVBoxLayout() layout.addWidget(feature_selection_button) layout.setSpacing(1) layout.addLayout(label_layout) layout.addWidget(self.live_update_button) layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(layout) # Widget Shortcuts mgr = ShortcutManager() ActionInfo = ShortcutManager.ActionInfo shortcut_group = "Edge Training" mgr.register( "l", ActionInfo( shortcut_group, "Live Predict", "Toggle live edge classifier update mode", self.live_update_button.toggle, self.live_update_button, self.live_update_button ) ) return drawer
class SettingsPage(QWidget): """Settings page for OpenTerm plugin """ def __init__(self, parent, autodetectedCommand): QWidget.__init__(self, parent) text = "<html>Terminal emulator command.<br/>" + \ "Leave empty to autodetect.<br/>" + \ "Autodetected value is <i>{}</i></html>".format(autodetectedCommand) self._label = QLabel(text, self) self.edit = QLineEdit(self) self._vLayout = QVBoxLayout(self) self._vLayout.addWidget(self._label) self._vLayout.addWidget(self.edit) self._vLayout.addSpacerItem(QSpacerItem(0, 0, QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding))
def fillQpTab(self): qpWidget = QWidget() qpLayout = QVBoxLayout() generalBox = SkillBox('General', 'QP', 'General', 'QP') qpLayout.addLayout(getLayout(generalBox)) qpLayout.addSpacerItem(QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.qpDict['General'] = generalBox qpWidget.setLayout(qpLayout) self.scrollAreaQP.setWidget(qpWidget) for skillBox in self.qpDict.values(): skillBox.totalChanged.connect(self.updateUsedQP)
def _activate_ui(self): """Creates and sets up the ui elements of the plugin.""" # Model for Threads self.threads_model = debugger_plugin.core.models.ThreadGroup( "Debug Session") # View for Threads self.threadsView = debugger_plugin.gui.threads.ThreadsView() self.threadsView.setContentProvider( debugger_plugin.gui.providers.ThreadsContentProvider()) self.threadsView.setLabelProvider( debugger_plugin.gui.providers.ThreadsLabelProvider()) self.threadsView.setInput(self.threads_model) self.connect(self.threadsView, SIGNAL("itemSelectionChanged()"), self.select_thread) # Expand top level item a = self.threadsView.topLevelItem(0) self.threadsView.expandItem(a) # Watches Widget self.watchesWidget = debugger_plugin.gui.watches.WatchesWidget() self.watchesWidget.itemChanged.connect(self.reevaluate_watch) # Save current widget before debug starts (to restore it later) self._old_active_widget_widget = self.explorer._explorer.currentWidget( ) # Configure tabs in explorer self.tabWidget = QWidget() vbox = QVBoxLayout(self.tabWidget) vbox.addWidget(self.threadsView) vbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) vbox.addWidget(self.watchesWidget) #self.tabWidget.addTab(self.threadsView, "Threads") #self.tabWidget.addTab(self.watchesWidget, "Watches") self.explorer.add_tab(self.tabWidget, "Debug") self.explorer._explorer.setCurrentWidget(self.tabWidget) # Install mouse handler self.__install_mouse_handler()
def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir+"/drawer.ui") # Init threshold widget self.thresholdWidget = ThresholdingWidget(self) self.thresholdWidget.valueChanged.connect( self.apply_gui_settings_to_operator ) # Add widget to a layout layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget( self.thresholdWidget ) layout.addSpacerItem( QSpacerItem(0,0,vPolicy=QSizePolicy.Expanding) ) # Apply layout to the drawer self._drawer.setLayout( layout ) # Initialize the gui with the operator's current values self.apply_operator_settings_to_gui()
def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir + "/drawer.ui") # Init threshold widget self.thresholdWidget = ThresholdingWidget(self) self.thresholdWidget.valueChanged.connect( self.apply_gui_settings_to_operator) # Add widget to a layout layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget(self.thresholdWidget) layout.addSpacerItem(QSpacerItem(0, 0, vPolicy=QSizePolicy.Expanding)) # Apply layout to the drawer self._drawer.setLayout(layout) # Initialize the gui with the operator's current values self.apply_operator_settings_to_gui()
def _activate_ui(self): """Creates and sets up the ui elements of the plugin.""" # Model for Threads self.threads_model = debugger_plugin.core.models.ThreadGroup("Debug Session") # View for Threads self.threadsView = debugger_plugin.gui.threads.ThreadsView() self.threadsView.setContentProvider(debugger_plugin.gui.providers.ThreadsContentProvider()) self.threadsView.setLabelProvider(debugger_plugin.gui.providers.ThreadsLabelProvider()) self.threadsView.setInput(self.threads_model) self.connect(self.threadsView, SIGNAL("itemSelectionChanged()"), self.select_thread) # Expand top level item a = self.threadsView.topLevelItem(0) self.threadsView.expandItem(a) # Watches Widget self.watchesWidget = debugger_plugin.gui.watches.WatchesWidget() self.watchesWidget.itemChanged.connect(self.reevaluate_watch) # Save current widget before debug starts (to restore it later) self._old_active_widget_widget = self.explorer._explorer.currentWidget() # Configure tabs in explorer self.tabWidget = QWidget() vbox = QVBoxLayout(self.tabWidget) vbox.addWidget(self.threadsView) vbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) vbox.addWidget(self.watchesWidget) #self.tabWidget.addTab(self.threadsView, "Threads") #self.tabWidget.addTab(self.watchesWidget, "Watches") self.explorer.add_tab(self.tabWidget, "Debug") self.explorer._explorer.setCurrentWidget(self.tabWidget) # Install mouse handler self.__install_mouse_handler()
def __init__(self, parent): super(ManualInstallWidget, self).__init__() self._parent = parent vbox = QVBoxLayout(self) form = QFormLayout() self._txtName = QLineEdit() self._txtName.setPlaceholderText('my_plugin') self._txtVersion = QLineEdit() self._txtVersion.setPlaceholderText('0.1') form.addRow(translations.TR_PROJECT_NAME, self._txtName) form.addRow(translations.TR_VERSION, self._txtVersion) vbox.addLayout(form) hPath = QHBoxLayout() self._txtFilePath = QLineEdit() self._txtFilePath.setPlaceholderText( os.path.join(os.path.expanduser('~'), 'full', 'path', 'to', 'plugin.zip')) self._btnFilePath = QPushButton(QIcon(":img/open"), '') self.completer, self.dirs = QCompleter(self), QDirModel(self) self.dirs.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot) self.completer.setModel(self.dirs) self._txtFilePath.setCompleter(self.completer) hPath.addWidget(QLabel(translations.TR_FILENAME)) hPath.addWidget(self._txtFilePath) hPath.addWidget(self._btnFilePath) vbox.addLayout(hPath) vbox.addSpacerItem( QSpacerItem(0, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) self._btnInstall = QPushButton(translations.TR_INSTALL) hbox.addWidget(self._btnInstall) vbox.addLayout(hbox) # Signals self.connect(self._btnFilePath, SIGNAL("clicked()"), self._load_plugin_path) self.connect(self._btnInstall, SIGNAL("clicked()"), self.install_plugin)
def __init__(self, parent): super(ManualInstallWidget, self).__init__() self._parent = parent vbox = QVBoxLayout(self) form = QFormLayout() self._txtName = QLineEdit() self._txtName.setPlaceholderText('my_plugin') self._txtVersion = QLineEdit() self._txtVersion.setPlaceholderText('0.1') form.addRow(translations.TR_PROJECT_NAME, self._txtName) form.addRow(translations.TR_VERSION, self._txtVersion) vbox.addLayout(form) hPath = QHBoxLayout() self._txtFilePath = QLineEdit() self._txtFilePath.setPlaceholderText(os.path.join( os.path.expanduser('~'), 'full', 'path', 'to', 'plugin.zip')) self._btnFilePath = QPushButton(QIcon(":img/open"), '') self.completer, self.dirs = QCompleter(self), QDirModel(self) self.dirs.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot) self.completer.setModel(self.dirs) self._txtFilePath.setCompleter(self.completer) hPath.addWidget(QLabel(translations.TR_FILENAME)) hPath.addWidget(self._txtFilePath) hPath.addWidget(self._btnFilePath) vbox.addLayout(hPath) vbox.addSpacerItem(QSpacerItem(0, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)) hbox = QHBoxLayout() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) self._btnInstall = QPushButton(translations.TR_INSTALL) hbox.addWidget(self._btnInstall) vbox.addLayout(hbox) #Signals self.connect(self._btnFilePath, SIGNAL("clicked()"), self._load_plugin_path) self.connect(self._btnInstall, SIGNAL("clicked()"), self.install_plugin)
def fillTpTab(self): tpWidget = QWidget() tpLayout = QVBoxLayout() generalBox = SkillBox('General', 'TP', 'General', 'TP') commonBox = SkillBox('Common', 'TP', self.mainClass, 'Common') classBox = SkillBox('Class', 'TP', self.mainClass, self.subClass) tpLayout.addLayout(getLayout(generalBox)) tpLayout.addLayout(getLayout(commonBox)) tpLayout.addLayout(getLayout(classBox)) tpLayout.addSpacerItem(QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.tpDict['General'] = generalBox self.tpDict['Common'] = commonBox self.tpDict['Class'] = classBox tpWidget.setLayout(tpLayout) self.scrollAreaTP.setWidget(tpWidget) for skillBox in self.tpDict.values(): skillBox.totalChanged.connect(self.updateUsedTP)
def _create_run(self): run = QSplitter() buttons = QWidget() layout = QVBoxLayout() buttons.setLayout(layout) button = QPushButton("Run blockMesh") button.clicked.connect(self.shampoo.run) layout.addWidget(button) button_terminate = QPushButton("Terminate") button_terminate.clicked.connect(self.shampoo.run) button_terminate.setEnabled(False) layout.addWidget(button_terminate) layout.addSpacerItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) run.addWidget(buttons) self.console = Console() run.addWidget(self.console) return run
def createDrawerControls(self): """ This is a separate function from initAppletDrawer() so that it can be called and used within another applet (this class is a mixin). """ op = self.__topLevelOperatorView def configure_update_handlers(qt_signal, op_slot): qt_signal.connect(self.configure_operator_from_gui) op_slot.notifyDirty(self.configure_gui_from_operator) self.__cleanup_fns.append(partial(op_slot.unregisterDirty, self.configure_gui_from_operator)) def control_layout(label_text, widget): row_layout = QHBoxLayout() row_layout.addWidget(QLabel(label_text)) row_layout.addSpacerItem(QSpacerItem(10, 0, QSizePolicy.Expanding)) row_layout.addWidget(widget) return row_layout drawer_layout = QVBoxLayout() drawer_layout.setSpacing(1) # Beta beta_box = QDoubleSpinBox( decimals=2, minimum=0.01, maximum=0.99, singleStep=0.1, toolTip="Bias parameter for the multicut optimization.", ) configure_update_handlers(beta_box.valueChanged, op.Beta) beta_layout = control_layout("Beta", beta_box) drawer_layout.addLayout(beta_layout) self.beta_box = beta_box # Solver solver_name_combo = QComboBox( toolTip="Multicut optimization technique. Available solvers depend on which optimizer library you have installed." ) for solver_name in AVAILABLE_SOLVER_NAMES: solver_name_combo.addItem(solver_name) configure_update_handlers(solver_name_combo.currentIndexChanged, op.SolverName) drawer_layout.addLayout(control_layout("Solver", solver_name_combo)) self.solver_name_combo = solver_name_combo # Update Button update_button = QPushButton( text="Update Multicut", icon=QIcon(ilastikIcons.Play), clicked=self.onUpdateMulticutButton ) drawer_layout.addWidget(update_button) # Layout drawer_layout.addSpacerItem(QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(drawer_layout) # Widget Shortcuts mgr = ShortcutManager() ActionInfo = ShortcutManager.ActionInfo shortcut_group = "Multicut" mgr.register( "u", ActionInfo( shortcut_group, "UpdateMulticut", "Run the multicut optimization using the current edge probabilities", update_button.click, update_button, update_button, ), ) return drawer
def initAppletDrawerUi(self): """ Overridden from base class (LayerViewerGui) """ op = self.topLevelOperatorView def configure_update_handlers(qt_signal, op_slot): qt_signal.connect(self.configure_operator_from_gui) op_slot.notifyDirty(self.configure_gui_from_operator) self.__cleanup_fns.append( partial(op_slot.unregisterDirty, self.configure_gui_from_operator)) def control_layout(label_text, widget): row_layout = QHBoxLayout() row_layout.addWidget(QLabel(label_text)) row_layout.addSpacerItem(QSpacerItem(10, 0, QSizePolicy.Expanding)) row_layout.addWidget(widget) return row_layout drawer_layout = QVBoxLayout() channel_button = QPushButton() self.channel_menu = QMenu( self) # Must retain menus (in self) or else they get deleted. channel_button.setMenu(self.channel_menu) channel_button.clicked.connect(channel_button.showMenu) def populate_channel_menu(*args): if sip.isdeleted(channel_button): return self.channel_menu.clear() self.channel_actions = [] for ch in range(op.Input.meta.getTaggedShape()['c']): action = QAction("Channel {}".format(ch), self.channel_menu) action.setCheckable(True) self.channel_menu.addAction(action) self.channel_actions.append(action) configure_update_handlers(action.toggled, op.ChannelSelections) populate_channel_menu() op.Input.notifyMetaChanged(populate_channel_menu) self.__cleanup_fns.append( partial(op.Input.unregisterMetaChanged, populate_channel_menu)) channel_button.setToolTip( "Boundary channel index in the probability map") drawer_layout.addLayout(control_layout("Input Channel", channel_button)) self.channel_button = channel_button threshold_box = QDoubleSpinBox() threshold_box.setDecimals(2) threshold_box.setMinimum(0.00) threshold_box.setMaximum(1.0) threshold_box.setSingleStep(0.1) configure_update_handlers(threshold_box.valueChanged, op.Pmin) threshold_box.setToolTip("Boundary probability threshold") drawer_layout.addLayout(control_layout("Threshold", threshold_box)) self.threshold_box = threshold_box membrane_size_box = QSpinBox() membrane_size_box.setMinimum(0) membrane_size_box.setMaximum(1000000) configure_update_handlers(membrane_size_box.valueChanged, op.MinMembraneSize) membrane_size_box.setToolTip( "Size filter for boundary pieces, in pixels") drawer_layout.addLayout( control_layout("Min Boundary Size", membrane_size_box)) self.membrane_size_box = membrane_size_box seed_presmoothing_box = QDoubleSpinBox() seed_presmoothing_box.setDecimals(1) seed_presmoothing_box.setMinimum(0.0) seed_presmoothing_box.setMaximum(10.0) seed_presmoothing_box.setSingleStep(0.1) configure_update_handlers(seed_presmoothing_box.valueChanged, op.SigmaMinima) seed_presmoothing_box.setToolTip( "Smooth the distance transform map with this sigma") drawer_layout.addLayout( control_layout("Presmooth before Seeds", seed_presmoothing_box)) self.seed_presmoothing_box = seed_presmoothing_box seed_method_combo = QComboBox() seed_method_combo.addItem("Connected") seed_method_combo.addItem("Clustered") configure_update_handlers(seed_method_combo.currentIndexChanged, op.GroupSeeds) seed_method_combo.setToolTip( "Connected: combine directly adjacent pixels into seeds (more superpixels). Clustered: group pixels into seeds by distance heuristic (less superpixels)" ) drawer_layout.addLayout( control_layout("Seed Labeling", seed_method_combo)) self.seed_method_combo = seed_method_combo superpixel_size_box = QSpinBox() superpixel_size_box.setMinimum(0) superpixel_size_box.setMaximum(1000000) configure_update_handlers(superpixel_size_box.valueChanged, op.MinSegmentSize) superpixel_size_box.setToolTip("Minimal size of a superpixel") drawer_layout.addLayout( control_layout("Min Superpixel Size", superpixel_size_box)) self.superpixel_size_box = superpixel_size_box preserve_pmaps_box = QCheckBox() configure_update_handlers(preserve_pmaps_box.toggled, op.PreserveMembranePmaps) preserve_pmaps_box.setToolTip( "Preserve thin structures. Use that option when some of your foreground objects have long and thin parts" ) drawer_layout.addLayout( control_layout("Preserve Thin Structures", preserve_pmaps_box)) self.preserve_pmaps_box = preserve_pmaps_box enable_debug_box = QCheckBox() configure_update_handlers(enable_debug_box.toggled, op.EnableDebugOutputs) drawer_layout.addLayout( control_layout("Show Debug Layers", enable_debug_box)) self.enable_debug_box = enable_debug_box op.Superpixels.notifyReady(self.configure_gui_from_operator) op.Superpixels.notifyUnready(self.configure_gui_from_operator) self.__cleanup_fns.append( partial(op.Superpixels.unregisterReady, self.configure_gui_from_operator)) self.__cleanup_fns.append( partial(op.Superpixels.unregisterUnready, self.configure_gui_from_operator)) self.update_ws_button = QPushButton( "Update Watershed", clicked=self.onUpdateWatershedsButton) drawer_layout.addWidget(self.update_ws_button) drawer_layout.setSpacing(0) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(drawer_layout) # Save these members for later use self._drawer = drawer # Initialize everything with the operator's initial values self.configure_gui_from_operator()
class FeatureDlg(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) # init # ------------------------------------------------ self.setWindowTitle("Spatial Features") # widgets and layouts # ------------------------------------------------ self.layout = QHBoxLayout() self.setLayout(self.layout) self.tableAndViewGroupBox = QGroupBox(" Scales and Groups") self.tableAndViewGroupBox.setFlat(True) self.featureTableWidget = featureTableWidget.FeatureTableWidget() self.tableAndViewLayout = QVBoxLayout() self.tableAndViewLayout.setSizeConstraint(QLayout.SetNoConstraint) self.tableAndViewLayout.addWidget(self.featureTableWidget) self.viewAndButtonLayout = QVBoxLayout() self.preView = preView.PreView() self.viewAndButtonLayout.addWidget(self.preView) self.viewAndButtonLayout.addStretch() self.buttonsLayout = QHBoxLayout() self.memReqLabel = QLabel() self.buttonsLayout.addWidget(self.memReqLabel) self.buttonsLayout.addStretch() # Add Cancel self.cancel = QToolButton() self.cancel.setText("Cancel") self.cancel.clicked.connect(self.on_cancelClicked) self.buttonsLayout.addWidget(self.cancel) # Add OK self.ok = QToolButton() self.ok.setText("OK") self.ok.clicked.connect(self.on_okClicked) self.buttonsLayout.addWidget(self.ok) self.buttonsLayout.addSpacerItem(QSpacerItem(10, 0)) self.viewAndButtonLayout.addSpacerItem(QSpacerItem(0, 10)) self.tableAndViewGroupBox.setLayout(self.tableAndViewLayout) self.tableAndViewLayout.addLayout(self.buttonsLayout) self.layout.addWidget(self.tableAndViewGroupBox) self.layout.setContentsMargins(0, 0, 0, 0) self.tableAndViewGroupBox.setContentsMargins(4, 10, 4, 4) self.tableAndViewLayout.setContentsMargins(0, 10, 0, 0) self.featureTableWidget.brushSizeChanged.connect(self.preView.setFilledBrsuh) self.setMemReq() # methods # ------------------------------------------------ @property def selectedFeatureBoolMatrix(self): """Return the bool matrix of features that the user selected.""" return self.featureTableWidget.createSelectedFeaturesBoolMatrix() @selectedFeatureBoolMatrix.setter def selectedFeatureBoolMatrix(self, newMatrix): """Populate the table of selected features with the provided matrix.""" self.featureTableWidget.setSelectedFeatureBoolMatrix(newMatrix) def createFeatureTable(self, features, sigmas, brushNames=None): self.featureTableWidget.createTableForFeatureDlg(features, sigmas, brushNames) def setImageToPreView(self, image): self.preView.setVisible(image is not None) if image is not None: self.preView.setPreviewImage(qimage2ndarray.array2qimage(image)) def setIconsToTableWidget(self, checked, partiallyChecked, unchecked): self.featureTableWidget.itemDelegate.setCheckBoxIcons(checked, partiallyChecked, unchecked) def setMemReq(self): # featureSelectionList = self.featureTableWidget.createFeatureList() # TODO # memReq = self.ilastik.project.dataMgr.Classification.featureMgr.computeMemoryRequirement(featureSelectionList) # self.memReqLabel.setText("%8.2f MB" % memReq) pass def on_okClicked(self): # featureSelectionList = self.featureTableWidget.createFeatureList() # selectedFeatureList = self.featureTableWidget.createSelectedFeatureList() # sigmaList = self.featureTableWidget.createSigmaList() # featureMgr.ilastikFeatureGroups.newGroupScaleValues = sigmaList # featureMgr.ilastikFeatureGroups.newSelection = selectedFeatureList # res = self.parent().project.dataMgr.Classification.featureMgr.setFeatureItems(featureSelectionList) # if res is True: # self.parent().labelWidget.setBorderMargin(int(self.parent().project.dataMgr.Classification.featureMgr.maxContext)) # self.ilastik.project.dataMgr.Classification.featureMgr.computeMemoryRequirement(featureSelectionList) # self.accept() # else: # QErrorMessage.qtHandler().showMessage("Not enough Memory, please select fewer features !") # self.on_cancelClicked() self.accept() def on_cancelClicked(self): self.reject()
def __init__(self, parent=None): super(SleepTimer, self).__init__(parent) self.forceSpinBoxWidget = global_vars.configuration.get("GENERAL").get( "sleeptimerdigitalspinbox") self.setStyleSheet( "SleepTimer {" "background-color: rgb(76, 76, 76);" "color: rgb(240, 240, 240);" "}" "QLabel {" "color: white;" "}" "QSpinBox {" "padding-right: 10px; /* make room for the arrows */" "border-width: 3;" "}" "QSpinBox::up-button {" "width: 26px;" "}" "QSpinBox::down-button {" "width: 26px;" "}") self.value = 0 # the value is calculated in self.active (calculated seconds in total) self.isActive = False if self.forceSpinBoxWidget: self.sb_hours = LeadingZeroSpinBox() self.sb_hours.setRange(0, 23) self.sb_hours.setAlignment(Qt.AlignCenter) self.sb_hours.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) else: self.sb_hours = QDeclarativeView() self.sb_hours.setSource(QUrl(os.path.join(cwd, 'sb_hours.qml'))) self.sb_hours.setResizeMode(QDeclarativeView.SizeViewToRootObject) self.sb_hours.setStyleSheet("background:transparent;") self.sb_hours.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.sb_hours_obj = self.sb_hours.rootObject().findChild( QObject, "spinner") self.sb_hours_value = QDeclarativeProperty( self.sb_hours.rootObject().findChild(QDeclarativeItem, name="spinner"), "currentIndex") if self.forceSpinBoxWidget: self.sb_minutes = LeadingZeroSpinBox() self.sb_minutes.setRange(0, 59) self.sb_minutes.setAlignment(Qt.AlignCenter) self.sb_minutes.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) else: self.sb_minutes = QDeclarativeView() self.sb_minutes.setSource(QUrl(os.path.join(cwd, 'sb_minutes.qml'))) self.sb_minutes.setResizeMode( QDeclarativeView.SizeViewToRootObject) self.sb_minutes.setStyleSheet("background:transparent;") self.sb_minutes.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.sb_minutes_obj = self.sb_minutes.rootObject().findChild( QObject, "spinner") self.sb_minutes_value = QDeclarativeProperty( self.sb_minutes.rootObject().findChild(QDeclarativeItem, name="spinner"), "currentIndex") tmpFont = QFont() tmpFont.setPointSize(18) self.lbl_hours = QLabel(QString("h")) self.lbl_hours.setFont(tmpFont) self.lbl_minutes = QLabel(QString("min")) self.lbl_minutes.setFont(tmpFont) # Load QML Widget Bomb self.bomb = QDeclarativeView() self.bomb.setSource(QUrl(os.path.join(cwd, 'timebomb.qml'))) self.bomb.setResizeMode(QDeclarativeView.SizeViewToRootObject) #self.bomb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.bomb.setStyleSheet("background:transparent;") self.bomb_text = QDeclarativeProperty( self.bomb.rootObject().findChild(QDeclarativeItem, name="counter_text"), "text") #setup layouts tmpLayout = QHBoxLayout() tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding)) tmpLayout.addWidget(self.sb_hours) tmpLayout.addWidget(self.lbl_hours) tmpLayout.addWidget(self.sb_minutes) tmpLayout.addWidget(self.lbl_minutes) tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding)) tmp2Layout = QVBoxLayout() tmp2Layout.addLayout(tmpLayout) tmp2Layout.addWidget(self.bomb) tmp2Layout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding)) self.setLayout(tmp2Layout) self.blockValueSignal = False # if this is true, valueChanged signal is not evaluated if self.forceSpinBoxWidget: self.sb_hours.valueChanged.connect(self.onValueChanged) self.sb_minutes.valueChanged.connect(self.onValueChanged) else: self.sb_hours_obj.currentIndexChanged.connect(self.onValueChanged) self.sb_minutes_obj.currentIndexChanged.connect( self.onValueChanged) # setup Timer which is started as soon as a value is changed in any of the spinboxes self.timer = QTimer() self.timer.setSingleShot(True) self.timer.setInterval( 2000) # 2 seconds until timer starts automatically self.connect(self.timer, SIGNAL("timeout()"), self.activate) #setup Timer which is a second-timer. It is startet with the self.timer (see self.active) self.countDown = QTimer() self.countDown.setInterval(1000) #sec self.connect(self.countDown, SIGNAL("timeout()"), self.check)
class MyWindow(QMainWindow): text_update = pyqtSignal(str) # Create main window def __init__(self, parent=None): QMainWindow.__init__(self, parent) # self. self.central = QWidget(self) self.control_side = QVBoxLayout() self.textbox = QTextEdit(self.central) self.textbox.setFont(TEXT_FONT) self.textbox.setMinimumSize(50, 50) self.text_update.connect(self.append_text) sys.stdout = self print("Camera number %u" % camera_num) self.logic = 0 self.value = 1 self.V_Logic = 0 self.ImageName = "" #LoginForm.center(self) #PickName.valueChanged.connect(print(PickName)) #print(PickName) if DISP_SCALE > 1: print("Display scale %u:1" % DISP_SCALE) self.vlayout = QVBoxLayout() # Window layout self.displays = QHBoxLayout() self.control = QVBoxLayout() self.textboxs = QHBoxLayout() self.co2 = QVBoxLayout() self.buttons = QVBoxLayout() self.disp = ImageWidget(self) self.controls = QTabWidget() self.vlayout.addLayout(self.displays) self.displays.addWidget(self.disp) self.label = QLabel(self) # self.displays.addLayout(self.control) self.displays.addLayout(self.textboxs) self.vlayout.addWidget(self.label) self.vlayout.addWidget(self.textbox) self.central.setLayout(self.vlayout) self.setCentralWidget(self.central) self.central.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) self.displays.addLayout(self.control_side) self.control_side.addWidget(self.controls) self.control_side.addLayout(self.control) #widget self.Pictures = QWidget() self.Pictures.layout = QVBoxLayout() self.Pictures.setLayout(self.Pictures.layout) self.Videos = QWidget() self.Videos.layout = QVBoxLayout() self.Videos.setLayout(self.Videos.layout) self.controls.addTab(self.Pictures, "Pictures") self.controls.addTab(self.Videos, "Videos") #carbon self.control.addLayout(self.co2) # C02(+) self.btnco2p = QPushButton('CO2+') self.btnco2p.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.co2.addWidget(self.btnco2p) #Labels self.setco2 = QLabel("mmHg") self.co2.addWidget(self.setco2) self.setco2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) self.setco2.setAlignment(Qt.AlignCenter) # CO2(-) self.btnco2m = QPushButton('CO2-') self.co2.addWidget(self.btnco2m) self.btnco2m.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.mainMenu = self.menuBar() # Menu bar exitAction = QAction('&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.triggered.connect(self.close) self.fileMenu = self.mainMenu.addMenu('&File') self.fileMenu.addAction(exitAction) #spacers self.verticalSpacer = QSpacerItem(150, 100, QSizePolicy.Expanding) self.verticalSpacerb = QSpacerItem(70, 50, QSizePolicy.Expanding) #sizes size = QSize(60, 60) # Camera self.btnc = QPushButton('Capture') self.btnc.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) self.Pictures.layout.addLayout(self.buttons) self.buttons.addWidget(self.btnc) self.buttons.addSpacerItem(self.verticalSpacer) self.btnc.setIcon(QIcon('camera.png')) #self.btnc.setStyleSheet("border-radius : 50;") self.btnc.setIconSize(size) #Video self.btnr = QPushButton('Record') self.btnr.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) self.Videos.layout.addWidget(self.btnr) self.Videos.layout.addSpacerItem(self.verticalSpacerb) self.btnr.setIcon(QIcon('video.png')) self.btnr.setIconSize(size) self.btns = QPushButton('Stop') self.btns.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) self.Videos.layout.addWidget(self.btns) self.btns.setIcon(QIcon('stop.png')) self.btns.setIconSize(size) self.Videos.layout.addSpacerItem(self.verticalSpacerb) self.btnc.clicked.connect(self.CaptureClicked) # Capture Photo trigger self.btnr.clicked.connect( self.RecordingClicked) # Recording Video trigger self.btns.clicked.connect(self.StopClicked) #Stop recording Trigger # capturing image def CaptureClicked(self): self.now = datetime.now() self.dt_string = self.now.strftime("%d_%m-%H_%M_%S") self.ImageName = PatientName + "-" + self.dt_string self.logic = 2 #print(self.ImageName) ##recording video def RecordingClicked(self): self.V_Logic = 3 self.FileName = self.ImageName + ".avi" def StopClicked(self): self.V_Logic = 4 def change_res(cap, width, height): cap.set(3, width) cap.set(4, height) # grab resolution dimensions and set video capture to it. def get_dims(cap, res='720p'): width, height = STD_DIMENSIONS["480p"] if res in STD_DIMENSIONS: width, height = STD_DIMENSIONS[res] ## change the current caputre device ## to the resulting resolution MyWindow.change_res(cap, width, height) return width, height def get_video_type(FileName): FileName, ext = os.path.splitext(FileName) if ext in VIDEO_TYPE: return VIDEO_TYPE[ext] return VIDEO_TYPE['avi'] #>>>>>>>>>>>>>>>>>>>>>>>> # Start image capture & display def start(self): self.timer = QTimer(self) # Timer to trigger display self.timer.timeout.connect( lambda: self.show_image(image_queue, self.disp, DISP_SCALE)) self.timer.start(DISP_MSEC) self.capture_thread = threading.Thread(target=grab_images, args=(camera_num, image_queue)) self.capture_thread.start() # Thread to grab images # Fetch camera image from queue, and display it def show_image(self, imageq, display, scale): if not imageq.empty(): image = imageq.get() if image is not None and len(image) > 0: img = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) self.display_image(img, display, scale) #capturing if (self.logic == 2): self.value = self.value + 1 cv2.imwrite('%s.jpg' % self.ImageName, image) print('your Image have been Saved') self.logic = 1 #else: #print("error printing") #video recording if (self.V_Logic == 3): out.write(image) print("Recording...") if (self.V_Logic == 4): out.release() print("Recording Stopped.") self.V_Logic = 0 def DisplayPatient(self): # self.setco2.setText(B.PatientName) print("Patient Name:", PatientName) # Display an image, reduce size if required def display_image(self, img, display, scale=1): disp_size = img.shape[1] // scale, img.shape[0] // scale disp_bpl = disp_size[0] * 3 if scale > 1: img = cv2.resize(img, disp_size, interpolation=cv2.INTER_CUBIC) qimg = QImage(img.data, disp_size[0], disp_size[1], disp_bpl, IMG_FORMAT) display.setImage(qimg) # Handle sys.stdout.write: update text display def write(self, text): self.text_update.emit(str(text)) def flush(self): pass # Append to text display def append_text(self, text): cur = self.textbox.textCursor() # Move cursor to end of text cur.movePosition(QTextCursor.End) s = str(text) while s: head, sep, s = s.partition("\n") # Split line at LF cur.insertText(head) # Insert text at cursor if sep: # New line if LF cur.insertBlock() self.textbox.setTextCursor(cur) # Update visible cursor # Window is closing: stop video capture def closeEvent(self, event): global capturing capturing = False self.capture_thread.join()
class FeatureDlg(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) # init # ------------------------------------------------ self.setWindowTitle("Spatial Features") # widgets and layouts # ------------------------------------------------ self.layout = QHBoxLayout() self.setLayout(self.layout) self.tableAndViewGroupBox = QGroupBox(" Scales and Groups") self.tableAndViewGroupBox.setFlat(True) self.featureTableWidget = featureTableWidget.FeatureTableWidget() self.tableAndViewLayout = QVBoxLayout() self.tableAndViewLayout.setSizeConstraint(QLayout.SetNoConstraint) self.tableAndViewLayout.addWidget(self.featureTableWidget) self.viewAndButtonLayout = QVBoxLayout() self.preView = preView.PreView() self.viewAndButtonLayout.addWidget(self.preView) self.viewAndButtonLayout.addStretch() self.buttonsLayout = QHBoxLayout() self.memReqLabel = QLabel() self.buttonsLayout.addWidget(self.memReqLabel) self.buttonsLayout.addStretch() # Add Cancel self.cancel = QToolButton() self.cancel.setText("Cancel") self.cancel.clicked.connect(self.on_cancelClicked) self.buttonsLayout.addWidget(self.cancel) # Add OK self.ok = QToolButton() self.ok.setText("OK") self.ok.clicked.connect(self.on_okClicked) self.buttonsLayout.addWidget(self.ok) self.buttonsLayout.addSpacerItem(QSpacerItem(10, 0)) self.viewAndButtonLayout.addSpacerItem(QSpacerItem(0, 10)) self.tableAndViewGroupBox.setLayout(self.tableAndViewLayout) self.tableAndViewLayout.addLayout(self.buttonsLayout) self.layout.addWidget(self.tableAndViewGroupBox) self.layout.setContentsMargins(0, 0, 0, 0) self.tableAndViewGroupBox.setContentsMargins(4, 10, 4, 4) self.tableAndViewLayout.setContentsMargins(0, 10, 0, 0) self.featureTableWidget.brushSizeChanged.connect( self.preView.setFilledBrsuh) self.setMemReq() # methods # ------------------------------------------------ @property def selectedFeatureBoolMatrix(self): """Return the bool matrix of features that the user selected.""" return self.featureTableWidget.createSelectedFeaturesBoolMatrix() @selectedFeatureBoolMatrix.setter def selectedFeatureBoolMatrix(self, newMatrix): """Populate the table of selected features with the provided matrix.""" self.featureTableWidget.setSelectedFeatureBoolMatrix(newMatrix) def createFeatureTable(self, features, sigmas, brushNames=None): self.featureTableWidget.createTableForFeatureDlg( features, sigmas, brushNames) def setImageToPreView(self, image): self.preView.setVisible(image is not None) if image is not None: self.preView.setPreviewImage(qimage2ndarray.array2qimage(image)) def setIconsToTableWidget(self, checked, partiallyChecked, unchecked): self.featureTableWidget.itemDelegate.setCheckBoxIcons( checked, partiallyChecked, unchecked) def setMemReq(self): # featureSelectionList = self.featureTableWidget.createFeatureList() #TODO #memReq = self.ilastik.project.dataMgr.Classification.featureMgr.computeMemoryRequirement(featureSelectionList) #self.memReqLabel.setText("%8.2f MB" % memReq) pass def on_okClicked(self): # featureSelectionList = self.featureTableWidget.createFeatureList() # selectedFeatureList = self.featureTableWidget.createSelectedFeatureList() # sigmaList = self.featureTableWidget.createSigmaList() # featureMgr.ilastikFeatureGroups.newGroupScaleValues = sigmaList # featureMgr.ilastikFeatureGroups.newSelection = selectedFeatureList # res = self.parent().project.dataMgr.Classification.featureMgr.setFeatureItems(featureSelectionList) # if res is True: # self.parent().labelWidget.setBorderMargin(int(self.parent().project.dataMgr.Classification.featureMgr.maxContext)) # self.ilastik.project.dataMgr.Classification.featureMgr.computeMemoryRequirement(featureSelectionList) # self.accept() # else: # QErrorMessage.qtHandler().showMessage("Not enough Memory, please select fewer features !") # self.on_cancelClicked() self.accept() def on_cancelClicked(self): self.reject()
def __init__(self, parent, app): super(QWidget, self).__init__() self.lcdwidget = LCDWidget(self, app) self.lcdwidget.hide() self.text_agent = QLineEdit(self) self.text_agent.setText(self.xively_agent) self.text_channel = QLineEdit(self) self.text_channel.setText(self.xively_channel) self.text_api_key = QLineEdit(self) self.text_api_key.setText(self.xively_api_key) self.number_update_rate = QSpinBox(self) self.number_update_rate.setRange(1, 1440) self.number_update_rate.setSuffix(' min') self.number_update_rate.setValue(self.xively_update_rate) layout1 = QHBoxLayout() layout2 = QVBoxLayout() layout1.addStretch() layout1.addLayout(layout2) layout1.addStretch() layout2.addSpacerItem(QSpacerItem(LCDWidget.FIXED_WIDGTH, 0)) label = QLabel(self) label.setText("Project: <b>Connect to Xively</b>. This project uploads the measured values to Xively. Please find documentation how to configure it and program sources in Python <a href=\"http://www.tinkerforge.com/en/doc/Kits/WeatherStation/WeatherStation.html#connect-to-xively\">here</a>.<br>") label.setTextFormat(Qt.RichText) label.setTextInteractionFlags(Qt.TextBrowserInteraction) label.setOpenExternalLinks(True) label.setWordWrap(True) label.setAlignment(Qt.AlignJustify) layout2.addSpacing(10) layout2.addWidget(label) layout2.addSpacing(10) layout3a = QHBoxLayout() label = QLabel("Agent Description:") label.setMinimumWidth(150) layout3a.addWidget(label) layout3a.addWidget(self.text_agent, 1) layout2.addLayout(layout3a) layout2.addSpacing(10) layout3b = QHBoxLayout() label = QLabel("Feed:") label.setMinimumWidth(150) layout3b.addWidget(label) layout3b.addWidget(self.text_channel, 1) layout2.addLayout(layout3b) layout2.addSpacing(10) layout3c = QHBoxLayout() label = QLabel("API Key:") label.setMinimumWidth(150) layout3c.addWidget(label) layout3c.addWidget(self.text_api_key, 1) layout2.addLayout(layout3c) layout2.addSpacing(10) layout3d = QHBoxLayout() label = QLabel("Update Rate:") label.setMinimumWidth(150) layout3d.addWidget(label) layout3d.addWidget(self.number_update_rate, 1) layout2.addLayout(layout3d) layout2.addSpacing(10) self.label_upload_active = QLabel("Not Active", self) self.label_upload_active.setMinimumWidth(150) font = QFont() font.setPixelSize(20) self.label_upload_active.setFont(font) self.set_active_label(False) self.save_button = QPushButton("Save/Activate") layout4 = QHBoxLayout() layout4.addWidget(self.label_upload_active) layout4.addWidget(self.save_button, 1) layout2.addLayout(layout4) layout2.addStretch() self.setLayout(layout1) self.qtcb_update_illuminance.connect(self.update_illuminance_data_slot) self.qtcb_update_air_pressure.connect(self.update_air_pressure_data_slot) self.qtcb_update_temperature.connect(self.update_temperature_data_slot) self.qtcb_update_humidity.connect(self.update_humidity_data_slot) self.qtcb_button_pressed.connect(self.button_pressed_slot) self.save_button.clicked.connect(self.save_configuration) self.lcdwidget.clear(self) self.error_message = QErrorMessage(self)
class CommanderWindow(QDialog): def __init__(self, parent, canvas): self.canvas = canvas QDialog.__init__(self, parent, Qt.FramelessWindowHint) self.commands = imp.load_source('commands', self.commandsFile()) self.initGui() def commandsFolder(self): folder = unicode(os.path.join(userFolder(), 'commander')) mkdir(folder) return os.path.abspath(folder) def commandsFile(self): f = os.path.join(self.commandsFolder(), 'commands.py') if not os.path.exists(f): out = open(f, 'w') out.write('from qgis.core import *\n') out.write('import processing\n\n') out.write('def removeall():\n') out.write('\tmapreg = QgsMapLayerRegistry.instance()\n') out.write('\tmapreg.removeAllMapLayers()\n\n') out.write('def load(*args):\n') out.write('\tprocessing.load(args[0])\n') out.close() return f def algsListHasChanged(self): self.fillCombo() def initGui(self): self.combo = ExtendedComboBox() self.fillCombo() self.combo.setEditable(True) self.label = QLabel('Enter command:') self.errorLabel = QLabel('Enter command:') self.vlayout = QVBoxLayout() self.vlayout.setSpacing(2) self.vlayout.setMargin(0) self.vlayout.addSpacerItem( QSpacerItem(0, OFFSET, QSizePolicy.Maximum, QSizePolicy.Expanding)) self.hlayout = QHBoxLayout() self.hlayout.addWidget(self.label) self.vlayout.addLayout(self.hlayout) self.hlayout2 = QHBoxLayout() self.hlayout2.addWidget(self.combo) self.vlayout.addLayout(self.hlayout2) self.vlayout.addSpacerItem( QSpacerItem(0, OFFSET, QSizePolicy.Maximum, QSizePolicy.Expanding)) self.setLayout(self.vlayout) self.combo.lineEdit().returnPressed.connect(self.run) self.prepareGui() def fillCombo(self): self.combo.clear() # Add algorithms for providerName in Processing.algs.keys(): provider = Processing.algs[providerName] algs = provider.values() for alg in algs: self.combo.addItem('Processing algorithm: ' + alg.name) # Add functions for command in dir(self.commands): if isinstance(self.commands.__dict__.get(command), types.FunctionType): self.combo.addItem('Command: ' + command) #Add menu entries menuActions = [] actions = iface.mainWindow().menuBar().actions() for action in actions: menuActions.extend(self.getActions(action)) for action in menuActions: self.combo.addItem('Menu action: ' + unicode(action.text())) def prepareGui(self): self.combo.setEditText('') self.combo.setMaximumSize( QSize(self.canvas.rect().width() - 2 * OFFSET, ITEMHEIGHT)) self.combo.view().setStyleSheet('min-height: 150px') self.combo.setFocus(Qt.OtherFocusReason) self.label.setMaximumSize(self.combo.maximumSize()) self.label.setVisible(False) self.adjustSize() pt = self.canvas.rect().topLeft() absolutePt = self.canvas.mapToGlobal(pt) self.move(absolutePt) self.resize(self.canvas.rect().width(), HEIGHT) self.setStyleSheet('CommanderWindow {background-color: #e7f5fe; \ border: 1px solid #b9cfe4;}') def getActions(self, action): menuActions = [] menu = action.menu() if menu is None: menuActions.append(action) return menuActions else: actions = menu.actions() for subaction in actions: if subaction.menu() is not None: menuActions.extend(self.getActions(subaction)) elif not subaction.isSeparator(): menuActions.append(subaction) return menuActions def run(self): s = unicode(self.combo.currentText()) if s.startswith('Processing algorithm: '): algName = s[len('Processing algorithm: '):] alg = Processing.getAlgorithmFromFullName(algName) if alg is not None: self.close() self.runAlgorithm(alg) elif s.startswith("Command: "): command = s[len("Command: "):] try: self.runCommand(command) self.close() except Exception as e: self.label.setVisible(True) self.label.setText('Error:' + unicode(e)) elif s.startswith('Menu action: '): actionName = s[len('Menu action: '):] menuActions = [] actions = iface.mainWindow().menuBar().actions() for action in actions: menuActions.extend(self.getActions(action)) for action in menuActions: if action.text() == actionName: self.close() action.trigger() return else: try: self.runCommand(s) self.close() except Exception as e: self.label.setVisible(True) self.label.setText('Error:' + unicode(e)) def runCommand(self, command): tokens = command.split(' ') if len(tokens) == 1: method = self.commands.__dict__.get(command) if method is not None: method() else: raise Exception('Wrong command') else: method = self.commands.__dict__.get(tokens[0]) if method is not None: method(*tokens[1:]) else: raise Exception('Wrong command') def runAlgorithm(self, alg): alg = alg.getCopy() message = alg.checkBeforeOpeningParametersDialog() if message: dlg = MessageDialog() dlg.setTitle(self.tr('Missing dependency')) dlg.setMessage(message) dlg.exec_() return dlg = alg.getCustomParametersDialog() if not dlg: dlg = AlgorithmDialog(alg) canvas = iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool() != prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool)
def initAppletDrawerUi(self): """ Overridden from base class (LayerViewerGui) """ op = self.topLevelOperatorView def configure_update_handlers(qt_signal, op_slot): qt_signal.connect(self.configure_operator_from_gui) op_slot.notifyDirty(self.configure_gui_from_operator) self.__cleanup_fns.append( partial(op_slot.unregisterDirty, self.configure_gui_from_operator)) def control_layout(label_text, widget): row_layout = QHBoxLayout() row_layout.addWidget(QLabel(label_text)) row_layout.addSpacerItem(QSpacerItem(10, 0, QSizePolicy.Expanding)) row_layout.addWidget(widget) return row_layout drawer_layout = QVBoxLayout() channel_box = QSpinBox() def set_channel_box_range(*args): if sip.isdeleted(channel_box): return channel_box.setMinimum(0) channel_box.setMaximum(op.Input.meta.getTaggedShape()['c'] - 1) set_channel_box_range() op.Input.notifyMetaChanged(set_channel_box_range) configure_update_handlers(channel_box.valueChanged, op.ChannelSelection) drawer_layout.addLayout(control_layout("Input Channel", channel_box)) self.channel_box = channel_box threshold_box = QDoubleSpinBox() threshold_box.setDecimals(2) threshold_box.setMinimum(0.00) threshold_box.setMaximum(1.0) threshold_box.setSingleStep(0.1) configure_update_handlers(threshold_box.valueChanged, op.Pmin) drawer_layout.addLayout(control_layout("Threshold", threshold_box)) self.threshold_box = threshold_box membrane_size_box = QSpinBox() membrane_size_box.setMinimum(0) membrane_size_box.setMaximum(1000000) configure_update_handlers(membrane_size_box.valueChanged, op.MinMembraneSize) drawer_layout.addLayout( control_layout("Min Membrane Size", membrane_size_box)) self.membrane_size_box = membrane_size_box seed_presmoothing_box = QDoubleSpinBox() seed_presmoothing_box.setDecimals(1) seed_presmoothing_box.setMinimum(0.0) seed_presmoothing_box.setMaximum(10.0) seed_presmoothing_box.setSingleStep(0.1) configure_update_handlers(seed_presmoothing_box.valueChanged, op.SigmaMinima) drawer_layout.addLayout( control_layout("Presmooth before seeds", seed_presmoothing_box)) self.seed_presmoothing_box = seed_presmoothing_box seed_method_combo = QComboBox() seed_method_combo.addItem("Connected") seed_method_combo.addItem("Clustered") configure_update_handlers(seed_method_combo.currentIndexChanged, op.GroupSeeds) drawer_layout.addLayout( control_layout("Seed Labeling", seed_method_combo)) self.seed_method_combo = seed_method_combo watershed_presmoothing_box = QDoubleSpinBox() watershed_presmoothing_box.setDecimals(1) watershed_presmoothing_box.setMinimum(0.0) watershed_presmoothing_box.setMaximum(10.0) watershed_presmoothing_box.setSingleStep(0.1) configure_update_handlers(watershed_presmoothing_box.valueChanged, op.SigmaWeights) drawer_layout.addLayout( control_layout("Presmooth before watershed", watershed_presmoothing_box)) self.watershed_presmoothing_box = watershed_presmoothing_box superpixel_size_box = QSpinBox() superpixel_size_box.setMinimum(0) superpixel_size_box.setMaximum(1000000) configure_update_handlers(superpixel_size_box.valueChanged, op.MinSegmentSize) drawer_layout.addLayout( control_layout("Min Superpixel Size", superpixel_size_box)) self.superpixel_size_box = superpixel_size_box enable_debug_box = QCheckBox() configure_update_handlers(enable_debug_box.toggled, op.EnableDebugOutputs) drawer_layout.addLayout( control_layout("Show Debug Layers", enable_debug_box)) self.enable_debug_box = enable_debug_box compute_button = QPushButton("Update Watershed", clicked=self.onUpdateWatershedsButton) drawer_layout.addWidget(compute_button) drawer_layout.setSpacing(0) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(drawer_layout) # Save these members for later use self._drawer = drawer # Initialize everything with the operator's initial values self.configure_gui_from_operator()
class CommanderWindow(QDialog): def __init__(self, parent, canvas): self.canvas = canvas QDialog.__init__(self, parent, Qt.FramelessWindowHint) self.commands = imp.load_source('commands', self.commandsFile()) self.initGui() def commandsFolder(self): folder = unicode(os.path.join(userFolder(), 'commander')) mkdir(folder) return os.path.abspath(folder) def commandsFile(self): f = os.path.join(self.commandsFolder(), 'commands.py') if not os.path.exists(f): out = open(f, 'w') out.write('from qgis.core import *\n') out.write('import processing\n\n') out.write('def removeall():\n') out.write('\tmapreg = QgsMapLayerRegistry.instance()\n') out.write('\tmapreg.removeAllMapLayers()\n\n') out.write('def load(*args):\n') out.write('\tprocessing.load(args[0])\n') out.close() return f def algsListHasChanged(self): self.fillCombo() def initGui(self): self.combo = ExtendedComboBox() self.fillCombo() self.combo.setEditable(True) self.label = QLabel('Enter command:') self.errorLabel = QLabel('Enter command:') self.vlayout = QVBoxLayout() self.vlayout.setSpacing(2) self.vlayout.setMargin(0) self.vlayout.addSpacerItem(QSpacerItem(0, OFFSET, QSizePolicy.Maximum, QSizePolicy.Expanding)) self.hlayout = QHBoxLayout() self.hlayout.addWidget(self.label) self.vlayout.addLayout(self.hlayout) self.hlayout2 = QHBoxLayout() self.hlayout2.addWidget(self.combo) self.vlayout.addLayout(self.hlayout2) self.vlayout.addSpacerItem(QSpacerItem(0, OFFSET, QSizePolicy.Maximum, QSizePolicy.Expanding)) self.setLayout(self.vlayout) self.combo.lineEdit().returnPressed.connect(self.run) self.prepareGui() def fillCombo(self): self.combo.clear() # Add algorithms for providerName in Processing.algs.keys(): provider = Processing.algs[providerName] algs = provider.values() for alg in algs: self.combo.addItem('Processing algorithm: ' + alg.name) # Add functions for command in dir(self.commands): if isinstance(self.commands.__dict__.get(command), types.FunctionType): self.combo.addItem('Command: ' + command) #Add menu entries menuActions = [] actions = iface.mainWindow().menuBar().actions() for action in actions: menuActions.extend(self.getActions(action)) for action in menuActions: self.combo.addItem('Menu action: ' + unicode(action.text())) def prepareGui(self): self.combo.setEditText('') self.combo.setMaximumSize(QSize(self.canvas.rect().width() - 2 * OFFSET, ITEMHEIGHT)) self.combo.view().setStyleSheet('min-height: 150px') self.combo.setFocus(Qt.OtherFocusReason) self.label.setMaximumSize(self.combo.maximumSize()) self.label.setVisible(False) self.adjustSize() pt = self.canvas.rect().topLeft() absolutePt = self.canvas.mapToGlobal(pt) self.move(absolutePt) self.resize(self.canvas.rect().width(), HEIGHT) self.setStyleSheet('CommanderWindow {background-color: #e7f5fe; \ border: 1px solid #b9cfe4;}') def getActions(self, action): menuActions = [] menu = action.menu() if menu is None: menuActions.append(action) return menuActions else: actions = menu.actions() for subaction in actions: if subaction.menu() is not None: menuActions.extend(self.getActions(subaction)) elif not subaction.isSeparator(): menuActions.append(subaction) return menuActions def run(self): s = unicode(self.combo.currentText()) if s.startswith('Processing algorithm: '): algName = s[len('Processing algorithm: '):] alg = Processing.getAlgorithmFromFullName(algName) if alg is not None: self.close() self.runAlgorithm(alg) elif s.startswith("Command: "): command = s[len("Command: "):] try: self.runCommand(command) self.close() except Exception as e: self.label.setVisible(True) self.label.setText('Error:' + unicode(e)) elif s.startswith('Menu action: '): actionName = s[len('Menu action: '):] menuActions = [] actions = iface.mainWindow().menuBar().actions() for action in actions: menuActions.extend(self.getActions(action)) for action in menuActions: if action.text() == actionName: self.close() action.trigger() return else: try: self.runCommand(s) self.close() except Exception as e: self.label.setVisible(True) self.label.setText('Error:' + unicode(e)) def runCommand(self, command): tokens = command.split(' ') if len(tokens) == 1: method = self.commands.__dict__.get(command) if method is not None: method() else: raise Exception('Wrong command') else: method = self.commands.__dict__.get(tokens[0]) if method is not None: method(*tokens[1:]) else: raise Exception('Wrong command') def runAlgorithm(self, alg): alg = alg.getCopy() message = alg.checkBeforeOpeningParametersDialog() if message: dlg = MessageDialog() dlg.setTitle(self.tr('Missing dependency')) dlg.setMessage(message) dlg.exec_() return dlg = alg.getCustomParametersDialog() if not dlg: dlg = AlgorithmDialog(alg) canvas = iface.mapCanvas() prevMapTool = canvas.mapTool() dlg.show() dlg.exec_() if canvas.mapTool() != prevMapTool: try: canvas.mapTool().reset() except: pass canvas.setMapTool(prevMapTool)
def __init__(self, parent=None): super(SleepTimer, self).__init__(parent) self.forceSpinBoxWidget = global_vars.configuration.get("GENERAL").get("sleeptimerdigitalspinbox") self.setStyleSheet("SleepTimer {" "background-color: rgb(76, 76, 76);" "color: rgb(240, 240, 240);" "}" "QLabel {" "color: white;" "}" "QSpinBox {" "padding-right: 10px; /* make room for the arrows */" "border-width: 3;" "}" "QSpinBox::up-button {" "width: 26px;" "}" "QSpinBox::down-button {" "width: 26px;" "}" ) self.value = 0 # the value is calculated in self.active (calculated seconds in total) self.isActive = False if self.forceSpinBoxWidget: self.sb_hours = LeadingZeroSpinBox() self.sb_hours.setRange(0,23) self.sb_hours.setAlignment(Qt.AlignCenter) self.sb_hours.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) else: self.sb_hours = QDeclarativeView() self.sb_hours.setSource(QUrl(os.path.join(cwd,'sb_hours.qml'))) self.sb_hours.setResizeMode(QDeclarativeView.SizeViewToRootObject) self.sb_hours.setStyleSheet("background:transparent;") self.sb_hours.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.sb_hours_obj = self.sb_hours.rootObject().findChild(QObject, "spinner") self.sb_hours_value = QDeclarativeProperty(self.sb_hours.rootObject().findChild(QDeclarativeItem, name="spinner"),"currentIndex") if self.forceSpinBoxWidget: self.sb_minutes = LeadingZeroSpinBox() self.sb_minutes.setRange(0,59) self.sb_minutes.setAlignment(Qt.AlignCenter) self.sb_minutes.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) else: self.sb_minutes = QDeclarativeView() self.sb_minutes.setSource(QUrl(os.path.join(cwd,'sb_minutes.qml'))) self.sb_minutes.setResizeMode(QDeclarativeView.SizeViewToRootObject) self.sb_minutes.setStyleSheet("background:transparent;") self.sb_minutes.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.sb_minutes_obj = self.sb_minutes.rootObject().findChild(QObject, "spinner") self.sb_minutes_value = QDeclarativeProperty(self.sb_minutes.rootObject().findChild(QDeclarativeItem, name="spinner"),"currentIndex") tmpFont = QFont() tmpFont.setPointSize(18) self.lbl_hours = QLabel(QString("h")) self.lbl_hours.setFont(tmpFont) self.lbl_minutes = QLabel(QString("min")) self.lbl_minutes.setFont(tmpFont) # Load QML Widget Bomb self.bomb = QDeclarativeView() self.bomb.setSource(QUrl(os.path.join(cwd,'timebomb.qml'))) self.bomb.setResizeMode(QDeclarativeView.SizeViewToRootObject) #self.bomb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.bomb.setStyleSheet("background:transparent;") self.bomb_text = QDeclarativeProperty(self.bomb.rootObject().findChild(QDeclarativeItem, name="counter_text"),"text") #setup layouts tmpLayout = QHBoxLayout() tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding)) tmpLayout.addWidget(self.sb_hours) tmpLayout.addWidget(self.lbl_hours) tmpLayout.addWidget(self.sb_minutes) tmpLayout.addWidget(self.lbl_minutes) tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding)) tmp2Layout = QVBoxLayout() tmp2Layout.addLayout(tmpLayout) tmp2Layout.addWidget(self.bomb) tmp2Layout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding)) self.setLayout(tmp2Layout) self.blockValueSignal = False # if this is true, valueChanged signal is not evaluated if self.forceSpinBoxWidget: self.sb_hours.valueChanged.connect(self.onValueChanged) self.sb_minutes.valueChanged.connect(self.onValueChanged) else: self.sb_hours_obj.currentIndexChanged.connect(self.onValueChanged) self.sb_minutes_obj.currentIndexChanged.connect(self.onValueChanged) # setup Timer which is started as soon as a value is changed in any of the spinboxes self.timer = QTimer() self.timer.setSingleShot(True) self.timer.setInterval(2000) # 2 seconds until timer starts automatically self.connect(self.timer, SIGNAL("timeout()"), self.activate) #setup Timer which is a second-timer. It is startet with the self.timer (see self.active) self.countDown = QTimer() self.countDown.setInterval(1000) #sec self.connect(self.countDown, SIGNAL("timeout()"), self.check)
def initAppletDrawerUi(self): """ Overridden from base class (LayerViewerGui) """ op = self.topLevelOperatorView def configure_update_handlers( qt_signal, op_slot ): qt_signal.connect( self.configure_operator_from_gui ) op_slot.notifyDirty( self.configure_gui_from_operator ) self.__cleanup_fns.append( partial( op_slot.unregisterDirty, self.configure_gui_from_operator ) ) def control_layout( label_text, widget ): row_layout = QHBoxLayout() row_layout.addWidget( QLabel(label_text) ) row_layout.addSpacerItem( QSpacerItem(10, 0, QSizePolicy.Expanding) ) row_layout.addWidget(widget) return row_layout drawer_layout = QVBoxLayout() channel_box = QSpinBox() def set_channel_box_range(*args): if sip.isdeleted(channel_box): return channel_box.setMinimum(0) channel_box.setMaximum( op.Input.meta.getTaggedShape()['c']-1 ) set_channel_box_range() op.Input.notifyMetaChanged( set_channel_box_range ) configure_update_handlers( channel_box.valueChanged, op.ChannelSelection ) drawer_layout.addLayout( control_layout( "Input Channel", channel_box ) ) self.channel_box = channel_box threshold_box = QDoubleSpinBox() threshold_box.setDecimals(2) threshold_box.setMinimum(0.00) threshold_box.setMaximum(1.0) threshold_box.setSingleStep(0.1) configure_update_handlers( threshold_box.valueChanged, op.Pmin ) drawer_layout.addLayout( control_layout( "Threshold", threshold_box ) ) self.threshold_box = threshold_box membrane_size_box = QSpinBox() membrane_size_box.setMinimum(0) membrane_size_box.setMaximum(1000000) configure_update_handlers( membrane_size_box.valueChanged, op.MinMembraneSize ) drawer_layout.addLayout( control_layout( "Min Membrane Size", membrane_size_box ) ) self.membrane_size_box = membrane_size_box seed_presmoothing_box = QDoubleSpinBox() seed_presmoothing_box.setDecimals(1) seed_presmoothing_box.setMinimum(0.0) seed_presmoothing_box.setMaximum(10.0) seed_presmoothing_box.setSingleStep(0.1) configure_update_handlers( seed_presmoothing_box.valueChanged, op.SigmaMinima ) drawer_layout.addLayout( control_layout( "Presmooth before seeds", seed_presmoothing_box ) ) self.seed_presmoothing_box = seed_presmoothing_box seed_method_combo = QComboBox() seed_method_combo.addItem("Connected") seed_method_combo.addItem("Clustered") configure_update_handlers( seed_method_combo.currentIndexChanged, op.GroupSeeds ) drawer_layout.addLayout( control_layout( "Seed Labeling", seed_method_combo ) ) self.seed_method_combo = seed_method_combo watershed_presmoothing_box = QDoubleSpinBox() watershed_presmoothing_box.setDecimals(1) watershed_presmoothing_box.setMinimum(0.0) watershed_presmoothing_box.setMaximum(10.0) watershed_presmoothing_box.setSingleStep(0.1) configure_update_handlers( watershed_presmoothing_box.valueChanged, op.SigmaWeights ) drawer_layout.addLayout( control_layout( "Presmooth before watershed", watershed_presmoothing_box ) ) self.watershed_presmoothing_box = watershed_presmoothing_box superpixel_size_box = QSpinBox() superpixel_size_box.setMinimum(0) superpixel_size_box.setMaximum(1000000) configure_update_handlers( superpixel_size_box.valueChanged, op.MinSegmentSize ) drawer_layout.addLayout( control_layout( "Min Superpixel Size", superpixel_size_box ) ) self.superpixel_size_box = superpixel_size_box preserve_pmaps_box = QCheckBox() configure_update_handlers( preserve_pmaps_box.toggled, op.PreserveMembranePmaps ) drawer_layout.addLayout( control_layout( "Preserve membrane probabilities", preserve_pmaps_box ) ) self.preserve_pmaps_box = preserve_pmaps_box enable_debug_box = QCheckBox() configure_update_handlers( enable_debug_box.toggled, op.EnableDebugOutputs ) drawer_layout.addLayout( control_layout( "Show Debug Layers", enable_debug_box ) ) self.enable_debug_box = enable_debug_box compute_button = QPushButton("Update Watershed", clicked=self.onUpdateWatershedsButton) drawer_layout.addWidget( compute_button ) drawer_layout.setSpacing(0) drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) ) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(drawer_layout) # Save these members for later use self._drawer = drawer # Initialize everything with the operator's initial values self.configure_gui_from_operator()
def __init__(self, parent, app): super(QWidget, self).__init__() self.lcdwidget = LCDWidget(self, app) self.lcdwidget.hide() self.text_agent = QLineEdit(self) self.text_agent.setText(self.xively_agent) self.text_channel = QLineEdit(self) self.text_channel.setText(self.xively_channel) self.text_api_key = QLineEdit(self) self.text_api_key.setText(self.xively_api_key) self.number_update_rate = QSpinBox(self) self.number_update_rate.setRange(1, 1440) self.number_update_rate.setSuffix(' min') self.number_update_rate.setValue(self.xively_update_rate) layout1 = QHBoxLayout() layout2 = QVBoxLayout() layout1.addStretch() layout1.addLayout(layout2) layout1.addStretch() layout2.addSpacerItem(QSpacerItem(LCDWidget.FIXED_WIDGTH, 0)) label = QLabel(self) label.setText( "Project: <b>Connect to Xively</b>. This project uploads the measured values to Xively. Please find documentation how to configure it and program sources in Python <a href=\"http://www.tinkerforge.com/en/doc/Kits/WeatherStation/WeatherStation.html#connect-to-xively\">here</a>.<br>" ) label.setTextFormat(Qt.RichText) label.setTextInteractionFlags(Qt.TextBrowserInteraction) label.setOpenExternalLinks(True) label.setWordWrap(True) label.setAlignment(Qt.AlignJustify) layout2.addSpacing(10) layout2.addWidget(label) layout2.addSpacing(10) layout3a = QHBoxLayout() label = QLabel("Agent Description:") label.setMinimumWidth(150) layout3a.addWidget(label) layout3a.addWidget(self.text_agent, 1) layout2.addLayout(layout3a) layout2.addSpacing(10) layout3b = QHBoxLayout() label = QLabel("Feed:") label.setMinimumWidth(150) layout3b.addWidget(label) layout3b.addWidget(self.text_channel, 1) layout2.addLayout(layout3b) layout2.addSpacing(10) layout3c = QHBoxLayout() label = QLabel("API Key:") label.setMinimumWidth(150) layout3c.addWidget(label) layout3c.addWidget(self.text_api_key, 1) layout2.addLayout(layout3c) layout2.addSpacing(10) layout3d = QHBoxLayout() label = QLabel("Update Rate:") label.setMinimumWidth(150) layout3d.addWidget(label) layout3d.addWidget(self.number_update_rate, 1) layout2.addLayout(layout3d) layout2.addSpacing(10) self.label_upload_active = QLabel("Not Active", self) self.label_upload_active.setMinimumWidth(150) font = QFont() font.setPixelSize(20) self.label_upload_active.setFont(font) self.set_active_label(False) self.save_button = QPushButton("Save/Activate") layout4 = QHBoxLayout() layout4.addWidget(self.label_upload_active) layout4.addWidget(self.save_button, 1) layout2.addLayout(layout4) layout2.addStretch() self.setLayout(layout1) self.qtcb_update_illuminance.connect(self.update_illuminance_data_slot) self.qtcb_update_air_pressure.connect( self.update_air_pressure_data_slot) self.qtcb_update_temperature.connect(self.update_temperature_data_slot) self.qtcb_update_humidity.connect(self.update_humidity_data_slot) self.qtcb_button_pressed.connect(self.button_pressed_slot) self.save_button.clicked.connect(self.save_configuration) self.lcdwidget.clear(self) self.error_message = QErrorMessage(self)
def createDrawerControls(self): """ This is a separate function from initAppletDrawer() so that it can be called and used within another applet (this class is a mixin). """ op = self.__topLevelOperatorView def configure_update_handlers(qt_signal, op_slot): qt_signal.connect(self.configure_operator_from_gui) op_slot.notifyDirty(self.configure_gui_from_operator) self.__cleanup_fns.append( partial(op_slot.unregisterDirty, self.configure_gui_from_operator)) def control_layout(label_text, widget): row_layout = QHBoxLayout() row_layout.addWidget(QLabel(label_text)) row_layout.addSpacerItem(QSpacerItem(10, 0, QSizePolicy.Expanding)) row_layout.addWidget(widget) return row_layout drawer_layout = QVBoxLayout() drawer_layout.setSpacing(1) # Beta beta_box = QDoubleSpinBox( decimals=2, minimum=0.01, maximum=0.99, singleStep=0.1, toolTip="Bias parameter for the multicut optimization.") configure_update_handlers(beta_box.valueChanged, op.Beta) beta_layout = control_layout("Beta", beta_box) drawer_layout.addLayout(beta_layout) self.beta_box = beta_box # Solver solver_name_combo = QComboBox( toolTip= "Multicut optimization technique. Available solvers depend on which optimizer library you have installed." ) for solver_name in AVAILABLE_SOLVER_NAMES: solver_name_combo.addItem(solver_name) configure_update_handlers(solver_name_combo.currentIndexChanged, op.SolverName) drawer_layout.addLayout(control_layout("Solver", solver_name_combo)) self.solver_name_combo = solver_name_combo # Update Button update_button = QPushButton(text="Update Multicut", icon=QIcon(ilastikIcons.Play), clicked=self.onUpdateMulticutButton) drawer_layout.addWidget(update_button) # Layout drawer_layout.addSpacerItem( QSpacerItem(0, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)) # Finally, the whole drawer widget drawer = QWidget(parent=self) drawer.setLayout(drawer_layout) # Widget Shortcuts mgr = ShortcutManager() ActionInfo = ShortcutManager.ActionInfo shortcut_group = "Multicut" mgr.register( "u", ActionInfo( shortcut_group, "UpdateMulticut", "Run the multicut optimization using the current edge probabilities", update_button.click, update_button, update_button)) return drawer