def _createEntries(self): entryWidget = QWidget(self) entryLayout = QHBoxLayout(entryWidget) inputWidgets = (self._createParamBox(), self._createAutoRange(), self._createLower(), self._createUpper(), self._createBins(), self._createXScale(), self._createYWeight()) self._labels = dict() # assumes same ordering of entryWidgets above and Histogram.displayData for col, inputWidget in zip(Histogram.displayData, inputWidgets): fieldWidget = QWidget(self) # combines label + input fieldLayout = QVBoxLayout(fieldWidget) fieldLayout.setContentsMargins(QMargins()) # create label, text is set in _selectParam() self._labels[col] = QLabel(self) self._labels[col].setAlignment(Qt.AlignHCenter) # stack label + input fieldLayout.addWidget(self._labels[col]) fieldLayout.addWidget(inputWidget) fieldWidget.setLayout(fieldLayout) # add field to row of inputs entryLayout.addWidget(fieldWidget) entryWidget.setLayout(entryLayout) self.pbox.setCurrentIndex(0) self.lentry.selectAll() # select the first input by default return entryWidget
def __init__(self, context): Plugin.__init__(self, context) self.setObjectName('RqtGraspViewer') self._widget = QWidget() ui_file = os.path.join(rospkg.RosPack().get_path('rqt_grasp_viewer'), 'ui', 'RqtGraspViewer.ui') loadUi(ui_file, self._widget) self._widget.setObjectName('RqtGraspViewerUi') context.add_widget(self._widget) main_layout = QHBoxLayout() self._default_labels = [ "obj_id", "object", "grasp_id", "grasp", "quality" ] self._filemodel = QStandardItemModel(0, 5) self._filemodel.setHorizontalHeaderLabels(self._default_labels) self._table_view = QTableView() self._table_view.setModel(self._filemodel) self._table_view.resizeColumnsToContents() main_layout.addWidget(self._table_view) self._widget.scrollarea.setLayout(main_layout) self.init_services() self.init_subscribers() # self._table_view.clicked.connect(self.on_table_view_clicked) self._table_view.selectionModel().selectionChanged.connect( self.on_table_view_select)
def setupUi(self, *args): # called in MainWindowBase.__init__() # put the log widget at the bottom self.addDockWidget(Qt.BottomDockWidgetArea, self._setupLogWidget()) # file widget at the top self.toolbox = ToolBox(self) self._addToolboxItem(self._setupFileWidget()) self._addToolboxItem(self._setupDataWidget()) self._addToolboxItem(self._setupOptimWidget()) self._addToolboxItem(self._setupModelWidget()) self._addToolboxItem(self._setupStatsWidget()) # set up central widget of the main window self.centralLayout = QVBoxLayout() # put buttons in central widget self.centralLayout.addWidget(self.toolbox) self.centralLayout.addWidget(self._setupStartButton()) centralWidget = QWidget(self) centralWidget.setLayout(self.centralLayout) centralWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) self.setCentralWidget(centralWidget) self.onStartupSignal.connect(self.initUi) # set program icon, same for Win+Lin icopath = "resources/icon/mcsas.ico" if isMac(): icopath = "resources/icon/mcsas.icns" icopath = QFileInfo(makeAbsolutePath(icopath)).absoluteFilePath() self.setWindowIcon(QIcon(icopath))
def _createButtons(self): btnWidget = QWidget(self) btnLayout = QHBoxLayout(btnWidget) okBtn = QPushButton("add", self) okBtn.clicked.connect(self.accept) cancelBtn = QPushButton("cancel", self) cancelBtn.clicked.connect(self.reject) btnLayout.addWidget(okBtn) btnLayout.addWidget(cancelBtn) btnWidget.setLayout(btnLayout) return btnWidget
def _setupStartButton(self): """Set up "Start/Stop" - button.""" self.startStopBtn = QPushButton() self.startStopBtn.setCheckable(True) self.startStopBtn.clicked[bool].connect(self.onStartStopClick) btnLayout = QHBoxLayout() btnLayout.setContentsMargins(0, 0, 0, 0) self.startStopBtn.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) btnLayout.addWidget(self.startStopBtn) btnWidget = QWidget(self) btnWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum) btnWidget.setLayout(btnLayout) return btnWidget
def __init__(self, parent, calculator, *args): super(ModelWidget, self).__init__(parent, None, *args) self._calculator = calculator self.title = TitleHandler.setup(self, "Model") # get all loadable ScatteringModels from model directory self._models = FindModels() layout = QVBoxLayout(self) layout.setObjectName("modelLayout") self.setLayout(layout) self.modelBox = QComboBox(self) self.modelBox.setFixedWidth(FIXEDWIDTH) layout.addWidget(self.modelBox) self.modelWidget = QWidget(self) paramLayout = QVBoxLayout(self.modelWidget) self.modelWidget.setLayout(paramLayout) layout.addWidget(self.modelWidget)
def __init__(self, context): super(HipViewerPlugin, self).__init__(context) self.setObjectName('HipViewer') self._current_dotcode = None self._widget = QWidget() ui_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'hip_viewer.ui') loadUi(ui_file, self._widget, {'InteractiveGraphicsView': InteractiveGraphicsView}) self._widget.setObjectName('HipViewerUi') if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) self._scene = QGraphicsScene() self._widget.graphics_view.setScene(self._scene) self._widget.graph_type_combo_box.insertItem(0, self.tr('infinite'), -1) self._widget.graph_type_combo_box.insertItem(1, self.tr('1'), 2) self._widget.graph_type_combo_box.insertItem(2, self.tr('2'), 3) self._widget.graph_type_combo_box.insertItem(3, self.tr('3'), 4) self._widget.graph_type_combo_box.insertItem(4, self.tr('4'), 5) self._widget.graph_type_combo_box.setCurrentIndex(0) self._widget.refresh_graph_push_button.setIcon( QIcon.fromTheme('view-refresh')) self._widget.highlight_connections_check_box.toggled.connect( self._redraw_graph_view) self._widget.auto_fit_graph_check_box.toggled.connect( self._redraw_graph_view) self._widget.fit_in_view_push_button.setIcon( QIcon.fromTheme('zoom-original')) self._widget.fit_in_view_push_button.pressed.connect(self._fit_in_view) self._widget.load_dot_push_button.setIcon( QIcon.fromTheme('document-open')) self._widget.load_dot_push_button.pressed.connect(self._load_dot) self._widget.save_dot_push_button.setIcon( QIcon.fromTheme('document-save-as')) self._widget.save_dot_push_button.pressed.connect(self._save_dot) self._widget.save_as_svg_push_button.setIcon( QIcon.fromTheme('document-save-as')) self._widget.save_as_svg_push_button.pressed.connect(self._save_svg) self._widget.save_as_image_push_button.setIcon( QIcon.fromTheme('image')) self._widget.save_as_image_push_button.pressed.connect( self._save_image) self._deferred_fit_in_view.connect(self._fit_in_view, Qt.QueuedConnection) self._deferred_fit_in_view.emit() context.add_widget(self._widget) self.connect(self, SIGNAL('update_planning_graph'), self.update_planning_graph_synchronous) # start the planner in a separate thread planning_node = HipViewerNode(ex_callback=self.update_planning_graph) planning_node.start()
def removeWidgets(widget): """Removes all widgets from the layout of the given widget.""" AlgorithmWidget.clearLayout(widget.layout(), QWidget())
def makeSetting(self, param, activeBtns=False): """Creates an input widget for the provided Parameter and configures it appropriately. """ if param is None: return None widget = QWidget(self) layout = QHBoxLayout(widget) layout.setContentsMargins(0, 0, 0, 0) layout.addStretch() try: suffix = param.suffix() except AttributeError: suffix = None if suffix is None: layout.addWidget(self._makeLabel(param.displayName())) else: layout.addWidget( self._makeLabel(u"{} ({})".format(param.displayName(), suffix))) widget.setLayout(layout) if isString(param.__doc__): # word wrapping by rich text: https://stackoverflow.com/a/4796057 txt = "<span>{0}</span>".format(param.__doc__) # add description as tooltip if available for parameter widget.setToolTip(txt) # create scalar value input widget with min/max limits minmaxValue, widgets = None, [] if isinstance(param, ParameterNumerical): minmaxValue = param.min(), param.max() if isinstance(param, ParameterFloat): minmaxValue = param.displayValueRange() decimals = None if hasattr(param, "decimals"): decimals = param.decimals() w = self._makeEntry(param.name(), param.dtype, param.displayValue(), decimals=decimals, minmax=minmaxValue, parent=widget) try: # set special value text for lower bound, simple solution special = param.displayValues(w.minimum()) w.setSpecialValueText(special) except: pass w.setFixedWidth(FIXEDWIDTH) widgets.insert(old_div(len(widgets), 2), w) # Special widget settings for active fitting parameters: activeBtns = activeBtns and isinstance(param, FitParameterBase) if activeBtns: # create input boxes for user specified active fitting range # within default upper/lower from class definition # minmaxValue = type(param).min(), type(param).max() activeRange = { "min": param.displayActiveRange()[0], "max": param.displayActiveRange()[1] } for bound in "min", "max": w = self._makeEntry(param.name() + bound, param.dtype, activeRange[bound], decimals=decimals, minmax=minmaxValue, parent=widget) w.setPrefix(bound + ": ") w.setFixedWidth(FIXEDWIDTH) widgets.append(w) # create *active* buttons for FitParameters only w = self._makeEntry(param.name() + "active", bool, param.isActive(), widgetType=QPushButton, parent=widget) w.setText("Active") w.setFixedWidth(FIXEDWIDTH * .5) widgets.append(w) # add input widgets to the layout for w in widgets: layout.addWidget(w) # store the parameter name w.parameterName = param.name() # configure UI accordingly (hide/show widgets) # no backend update, ui was just built, data is still in sync self.updateParam(param, emitBackendUpdated=False) return widget