def Turn(): global T_Backgrnd,T_Backgrnd_copy,Yaw,Yaw_auto if Mode_num == 1: pygame.event.get() Yaw = float("{:>6.3f}".format(joystick.get_axis( 2 ))) - float("{:>6.3f}".format(joystick.get_axis( 5 ))) elif Mode_num == -1: Yaw = Yaw_auto Yaw = Yaw*(-25) for c in range(0,3): T_Backgrnd[19:19+14, 98+Yaw:98+Yaw+14, c] = Ball[:,:,c] * (Ball[:,:,3]/255.0) + T_Backgrnd[19:19+14, 98+Yaw:98+Yaw+14, c] * (1.0 - Ball[:,:,3]/255.0) ui.Turn_Image.setPixmap(QPixmap(QtGui.QImage(T_Backgrnd,T_Backgrnd.shape[1],T_Backgrnd.shape[0],T_Backgrnd.strides[0],QtGui.QImage.Format_RGB888))) T_Backgrnd = T_Backgrnd_copy.copy() cv2.waitKey(1)
def __init__(self, parent=None): super(LineEditDialog, self).__init__() self.value = None vbox = QVBoxLayout(self) # combo box model = QtGui.QStandardItemModel(self) for elm in rospy.get_param_names(): model.setItem(model.rowCount(), 0, QtGui.QStandardItem(elm)) self.combo_box = QComboBox(self) self.line_edit = QLineEdit() self.combo_box.setLineEdit(self.line_edit) self.combo_box.setCompleter(QCompleter()) self.combo_box.setModel(model) self.combo_box.completer().setModel(model) self.combo_box.lineEdit().setText('') vbox.addWidget(self.combo_box) # button button = QPushButton() button.setText("Done") button.clicked.connect(self.buttonCallback) vbox.addWidget(button) self.setLayout(vbox)
def addManualCommand(self): indexes = self._widget.EstadosDeConexion.selectedIndexes() # SI no se ha seleccionado ningun robot SDV arrojar error if not indexes: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText(u"Error de Asignación de Comando:") msg.setInformativeText( "Seleccione al menos un robot de la lista de conexiones") msg.setWindowTitle("Error") ret = msg.exec_() else: for index in indexes: sdv = index.data() self._comm = [ QtGui.QStandardItem(str(sdv)), QtGui.QStandardItem( str(self._widget.ListaInstrucciones.currentText())), QtGui.QStandardItem( str(self._widget.ListaMaquinas.currentText())) ] self.TablaInstrucciones_model.appendRow(self._comm)
def __init__(self, name, path, id, parent=None): ''' Initialize the topic item. @param name: the topic name @type name: C{str} ''' QtGui.QStandardItem.__init__(self, name) self.parent_item = parent self.name = name self.path = path self.package_name = package_name(os.path.dirname(self.path))[0] self.id = id if self.id == LaunchItem.FOLDER: self.setIcon(QtGui.QIcon(":/icons/crystal_clear_folder.png")) elif self.id == LaunchItem.PACKAGE: self.setIcon(QtGui.QIcon(":/icons/crystal_clear_package.png")) elif self.id == LaunchItem.LAUNCH_FILE: self.setIcon(QtGui.QIcon(":/icons/crystal_clear_launch_file.png")) elif self.id == LaunchItem.RECENT_FILE: self.setIcon(QtGui.QIcon(":/icons/crystal_clear_launch_file_recent.png")) elif self.id == LaunchItem.STACK: self.setIcon(QtGui.QIcon(":/icons/crystal_clear_stack.png"))
def crosshair_cursor(): if os.name == 'nt': # On windows, cursors support "inversion" mode, where they invert the # underlying color. This is achived with two bitmap. # Final cursor has mask all 0 # When main bitmap is 0, this means transparent, when 1, inversion. bm = QtGui.QBitmap(16, 16) ma = QtGui.QBitmap(16, 16) bm.clear() ma.clear() # Paint a crosshair on the main bitmap with color1. pbm = QtGui.QPainter(bm) pbm.setPen(QtCore.Qt.color1) pbm.drawLine(8, 0, 8, 15) pbm.drawLine(0, 8, 15, 8) pbm.setPen(QtCore.Qt.color0) pbm.drawPoint(8, 8) pbm.end() return QtGui.QCursor(bm, ma, 8, 8) else: fn = os.path.dirname(__file__) + '/images/picker.svg' return load_cursor(fn, 8, 8)
def _create_context_substitution_menu(self): text = self.toPlainText() pos = self.textCursor().position() - 1 try: if text[pos] == '$' or (text[pos] == '(' and text[pos-1] == '$'): menu = QtGui.QMenu(self) menu.triggered.connect(self._context_activated) for arg in self.SUBSTITUTION_ARGS: action = menu.addAction("%s"%arg) action.setData("(%s"%arg if text[pos] == '$' else "%s"%arg) return menu except: pass return None
def build_tree_from_json(tree, json_hierarchy): '''Helper function for pretty-printing json''' root_tree = tree if not isinstance(json_hierarchy, dict): print "Couldn't render non-dict properly" return for name, item in json_hierarchy.items(): table_item = qtg.QTreeWidgetItem([name]) root_tree.addTopLevelItem(table_item) children = recurse_on_tree(item) add_all_children(table_item, children) tree.expandItem(table_item)
def recurse_on_tree(tree): '''Helper function for pretty-printing json''' children = [] if tree is None: children.append(qtg.QTreeWidgetItem(["N/A"])) elif isinstance(tree, (str, int, float, unicode)): children.append(qtg.QTreeWidgetItem([str(tree)])) elif isinstance(tree, list): for item in tree: children.append(qtg.QTreeWidgetItem([str(item)])) elif isinstance(tree, dict): for name, item in tree.items(): new_item = qtg.QTreeWidgetItem([name]) items_children = recurse_on_tree(item) add_all_children(new_item, items_children) children.append(new_item) else: print "Encountered unparseable json entity of type {}".format( type(tree)) return children
def __createNodeListWidget(self): """Create a list widget to display all possible nodes.""" frame = QtGui.QFrame() layout = QtGui.QVBoxLayout() frame.setLayout(layout) # Add a label label = QtGui.QLabel("Nodes:") layout.addWidget(label) # Add the list of known nodes self.__nodeListWidget = QtGui.QListWidget() layout.addWidget(self.__nodeListWidget) # Display nodes in alphabetical order sortedNodes = sorted(self.__graph.getNodes()) for node in sortedNodes: self.__nodeListWidget.addItem(node) # Update the graph with the currently selected widget self.__nodeListWidget.currentItemChanged.connect(self.__onNodeClicked) self.__layout.addWidget(frame)
def __init__(self, parent=None): QtGui.QSyntaxHighlighter.__init__(self, parent) self.rules = [] self.commentStart = QtCore.QRegExp("<!--") self.commentEnd = QtCore.QRegExp("-->") self.commentFormat = QtGui.QTextCharFormat() f = QtGui.QTextCharFormat() r = QtCore.QRegExp() r.setMinimal(True) f.setFontWeight(QtGui.QFont.Normal) f.setForeground(QtCore.Qt.darkBlue) # create patterns for TAG tagList = ["\\b%s\\b" % t for t in self.LAUNCH_CHILDS.keys()] for tag in tagList: r.setPattern(tag) self.rules.append((QtCore.QRegExp(r), QtGui.QTextCharFormat(f))) # create patterns for ATTRIBUTES f.setForeground(QtCore.Qt.darkGreen) attrList = set([ "\\b%s" % attr for v in self.LAUNCH_ATTR.values() for attr in v.keys() ]) for attr in attrList: r.setPattern(attr) self.rules.append((QtCore.QRegExp(r), QtGui.QTextCharFormat(f))) # create patterns for strings f.setForeground(QtCore.Qt.magenta) r.setPattern("\".*\"") self.rules.append((QtCore.QRegExp(r), QtGui.QTextCharFormat(f))) # create patterns for substitutions f.setForeground(QtGui.QColor(127, 64, 127)) r.setPattern("\\$\\(.*\\)") self.rules.append((QtCore.QRegExp(r), QtGui.QTextCharFormat(f))) # create patterns for DOCTYPE f.setForeground(QtCore.Qt.lightGray) r.setPattern("<!DOCTYPE.*>") self.rules.append((QtCore.QRegExp(r), QtGui.QTextCharFormat(f))) r.setPattern("<\\?xml.*\\?>") self.rules.append((QtCore.QRegExp(r), QtGui.QTextCharFormat(f))) self.commentFormat.setFontItalic(True) self.commentFormat.setForeground(QtCore.Qt.darkGray)
def __init__(self, ui_file, user): ''' Start window and declare initial values ''' # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) self.user = user # Give QObjects reasonable names self._widget.setObjectName('SDVoice') self.EstadosDeConexion_model = QtGui.QStandardItemModel() self._widget.EstadosDeConexion.setModel(self.EstadosDeConexion_model) self.TablaInstrucciones_model = QtGui.QStandardItemModel() self.TablaInstrucciones_model.setHorizontalHeaderLabels( ['Robot', u'Acción', u'Máquina']) self._widget.TablaInstrucciones.setModel(self.TablaInstrucciones_model) # Cargar complementos de la GUI self._widget.ListaMaquinas.addItems( inc.PLACES) # Cargar lista de máquinas self._widget.ListaInstrucciones.addItems( inc.COMMANDS) # Cargar lista de comandos # Definir callbacks de cada elemento de la gui self._widget.Conectar.clicked.connect(lambda: self.connectSSH()) self._widget.Desconectar.clicked.connect(lambda: self.disconnectSSH()) self._widget.Anadir.clicked.connect(lambda: self.addManualCommand()) self._widget.Ejectutar.clicked.connect(lambda: self.sendCommand()) self._widget.Stop.clicked.connect(lambda: self.stopSDV()) self._widget.Reset.clicked.connect(lambda: self.resetSDV()) # LOGIN Y OTRAS COSAS # Crear robots SDV self.sdvs = [] for i, uname in enumerate(inc.SERVER_USERNAME): self.sdvs.append( SDV(inc.SERVER_USERNAME[i], inc.SERVER_IP[i], inc.SERVER_USERNAME[i], inc.SERVER_PASSWORD[i], self.user)) # inicializar conexion con SDVs self.initSocket() self._widget.statusBar.showMessage("System Status | Ready. Welcome!")
def __init__(self, argv, key): QtGui.QApplication.__init__(self, argv) self._memory = QtCore.QSharedMemory(self) self._memory.setKey(key) if self._memory.attach(): self._running = True else: self._running = False if not self._memory.create(1): raise RuntimeError(self._memory.errorString()) # Set correct logo base_path = os.path.abspath(os.path.dirname(__file__)) icon_path = os.path.join(base_path, 'images', 'hyperspy.svg') QtGui.QApplication.setWindowIcon(QtGui.QIcon(icon_path))
def resizeFont(self): # gets new window dimensions, the self is needed because we are referencing # our VoltageWidget class height = VoltageWidget.frameGeometry(self).height() # The ratio change in width and height caused by the resize heightRatio = height / self.height # update to current self.height = height # Fonts like 16, 24 are references to height of letters. So I thought it would # Make sense to change font size proportionally to changes in window height self.fontSize = self.fontSize * heightRatio newfont = QtGui.QFont("Times", self.fontSize, QtGui.QFont.Bold) self.labelMain.setFont(newfont) self.labelFL.setFont(newfont) self.labelFR.setFont(newfont) self.labelBL.setFont(newfont) self.labelBR.setFont(newfont) threshFont = QtGui.QFont("Times", (self.fontSize) / 3, QtGui.QFont.Bold) self.labelThresh.setFont(threshFont)
def createTypedWidget(self, parent): result = None if self.isPrimitiveType(): value = self._value if 'bool' in self.baseType(): result = QtGui.QCheckBox(parent=parent) result.setObjectName(self.name()) if not isinstance(value, bool): value = str2bool(value[0] if isinstance(value, list) else value) self._value_org = value result.setChecked(value) else: result = MyComboBox(parent=parent) result.setObjectName(self.name()) result.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)) result.setEditable(True) result.remove_item_signal.connect(self.removeCachedValue) items = [] if isinstance(value, list): if self.isArrayType(): items.append(','.join([str(val) for val in value])) else: items[len(items):] = value else: if not value is None and value: items.append(unicode(value) if not isinstance(value, Binary) else '{binary data!!! updates will be ignored!!!}') elif self.isTimeType(): items.append('now') self._value_org = items[0] if items else '' result.addItems(items) else: if self.isArrayType(): result = ArrayBox(self.name(), self._type, parent=parent) else: result = GroupBox(self.name(), self._type, parent=parent) return result
def getItemList(self, topic, root): ''' Creates the list of the items from topic. This list is used for the visualization of topic data as a table row. @param name: the topic name @type name: C{str} @param root: The parent QStandardItem @type root: L{PySide.QtGui.QStandardItem} @return: the list for the representation as a row @rtype: C{[L{TopicItem} or L{PySide.QtGui.QStandardItem}, ...]} ''' items = [] item = TopicItem(topic.name, topic, parent=root) items.append(item) pubItem = QtGui.QStandardItem() # TopicItem.updatePublisherView(topic, pubItem) items.append(pubItem) subItem = QtGui.QStandardItem() # TopicItem.updateSubscriberView(topic, subItem) items.append(subItem) typeItem = QtGui.QStandardItem() # TopicItem.updateTypeView(topic, typeItem) items.append(typeItem) return items
def __init__(self, icon, title, text, detailed_text="", buttons=QtGui.QMessageBox.Ok): QtGui.QMessageBox.__init__(self, icon, title, text, buttons) if detailed_text: self.setDetailedText(detailed_text) # self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) # self.setSizeGripEnabled(True) horizontalSpacer = QtGui.QSpacerItem(480, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) layout = self.layout() layout.addItem(horizontalSpacer, layout.rowCount(), 0, 1, layout.columnCount()) if QtGui.QMessageBox.Abort & buttons: self.setEscapeButton(QtGui.QMessageBox.Abort) elif QtGui.QMessageBox.Ignore & buttons: self.setEscapeButton(QtGui.QMessageBox.Ignore) else: self.setEscapeButton(buttons) self.textEdit = textEdit = self.findChild(QtGui.QTextEdit) if textEdit != None: textEdit.setMinimumHeight(0) textEdit.setMaximumHeight(600) textEdit.setMinimumWidth(0) textEdit.setMaximumWidth(600) textEdit.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.ignore_all_btn = QtGui.QPushButton('Don\'t display again') self.addButton(self.ignore_all_btn, QtGui.QMessageBox.HelpRole)
def __init__(self, context): super(dvrkDashboard, self).__init__(context) # give QObjects reasonable names self.setObjectName('dvrkDashboard') # process standalone plugin command-line arguments from argparse import ArgumentParser parser = ArgumentParser() # add argument(s) to the parser. parser.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="Put plugin in silent mode") args, unknowns = parser.parse_known_args(context.argv()) if not args.quiet: print 'arguments: ', args print 'unknowns: ', unknowns # create qwidget self._widget = QtGui.QWidget() self._widget.setObjectName('dvrkDashboardUI') # serial number if context.serial_number() > 1: self._widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number())) # add widget to the user interface context.add_widget(self._widget) self.context = context # ---- Get Widget ----- self.init_ui() # ---- States ----- self.namespace = 'dvrk_mtmr' self.jnt_pos = [] self.jnt_eff = [] self.init_ros() # ---- Timer ----- self.update_timer = QtCore.QTimer(self) self.update_timer.setInterval(50) self.update_timer.timeout.connect(self.update_widget_values) self.update_timer.start() pass
def _on_path_select_clicked(self): # Workaround for QtGui.QFileDialog.getExistingDirectory because it do not # select the configuration folder in the dialog self.dialog = QtGui.QFileDialog(self, caption='Select a new settings folder') self.dialog.setOption(QtGui.QFileDialog.HideNameFilterDetails, True) self.dialog.setFileMode(QtGui.QFileDialog.Directory) self.dialog.setDirectory(self.path) if self.dialog.exec_(): fileNames = self.dialog.selectedFiles() path = fileNames[0] if os.path.isfile(path): path = os.path.basename(path) self._lineedit.setText(path) self.path = dir self.editing_finished_signal.emit()
def __init__(self, parent, index, clickCallback): QtGui.QGridLayout.__init__(self) self.setSpacing(0) path = os.popen('rospack find pr2_pbd_gui').read() path = path[0:len(path) - 1] self.notSelectedIconPath = path + '/icons/actions0.png' self.selectedIconPath = path + '/icons/actions1.png' self.selected = True self.actionIconWidth = 50 self.index = index self.icon = ClickableLabel(parent, index, clickCallback) self.text = QtGui.QLabel(parent) self.text.setText(self.getName()) self.updateView() self.addWidget(self.icon, 0, 0, QtCore.Qt.AlignCenter) self.addWidget(self.text, 1, 0, QtCore.Qt.AlignCenter)
def add_button(self, text, row, col): """ Adds a button with an option to the GUI :param text: text of the button to add :param row: row where to add the button :param col: column where to add the button """ if text == "": return # self.clear_buttons() b = QtGui.QPushButton() b.setText(text.replace("_", " ")) bcb = ButtonCB(self, text) self._button_cbs.append(bcb) self.button_layout.addWidget(b, row, col) b.clicked.connect(bcb.callback)
def fileWithText(self, search_text): ''' Searches for given text in this document and all included files. @param search_text: text to find @type search_text: C{str} @return: the list with all files contain the text @rtype: C{[str, ...]} ''' result = [] start_pos = QtGui.QTextCursor() search_result = self.document().find(search_text, start_pos.position()+1) if not search_result.isNull(): result.append(self.filename) inc_files = self.includedFiles() for f in inc_files: editor = Editor(f, None) result[len(result):] = editor.fileWithText(search_text) return result
def Attitude(): pygame.event.get() global Needle,H_Backgrnd,Grnd_sky,Pitch,Roll,Sky,flag Pitch = float("{:>6.3f}".format(joystick.get_axis( 4 ))) Pitch = Pitch * (-40) Roll = float("{:>6.3f}".format(joystick.get_axis( 3 ))) Roll = Roll * (-20) Sky = Grnd_sky[Pitch+197:Pitch+197+210,0:210].copy() for c in range(0,3): Sky[0:210,0:210, c] = H_Backgrnd[:,:,c] * (H_Backgrnd[:,:,3]/255.0) + Sky[0:0+210, 0:210, c] * (1.0 - H_Backgrnd[:,:,3]/255.0) M = cv2.getRotationMatrix2D((210/2,210/2),Roll,1) Mark = cv2.warpAffine(Needle,M,(210,210)) for c in range(0,3): Sky[0:210,0:210, c] = Mark[:,:,c] * (Mark[:,:,3]/255.0) + Sky[0:210, 0:210, c] * (1.0 - Mark[:,:,3]/255.0) flag = 1 ui.Attitude_Image.setPixmap(QPixmap(QtGui.QImage(Sky,Sky.shape[1],Sky.shape[0],Sky.strides[0],QtGui.QImage.Format_RGB888)))
def getItemList(self, service): ''' Creates the list of the items from service. This list is used for the visualization of service data as a table row. @param service: the service data @type service: L{master_discovery_fkie.ServiceInfo} @return: the list for the representation as a row @rtype: C{[L{ServiceItem} or L{PySide.QtGui.QStandardItem}, ...]} ''' items = [] item = ServiceItem(service) # removed tooltip for clarity !!! # item.setToolTip(''.join(['<div><h4>', str(service.name), '</h4><dl><dt>', str(service.uri),'</dt></dl></div>'])) items.append(item) typeItem = QtGui.QStandardItem() ServiceItem.updateTypeView(service, typeItem) items.append(typeItem) return items
def main(name): try: from python_qt_binding import QtGui except: print >> sys.stderr, "please install 'python_qt_binding' package!!" sys.exit(-1) init_settings() masteruri = settings().masteruri() parser = init_arg_parser() args = rospy.myargv(argv=sys.argv) parsed_args = parser.parse_args(args[1:]) # Initialize Qt global app app = QtGui.QApplication(sys.argv) # decide to show main or echo dialog global main_form try: if parsed_args.echo: main_form = init_echo_dialog(name, masteruri, parsed_args.echo[0], parsed_args.echo[1], parsed_args.hz, parsed_args.ssh) else: main_form = init_main_window(name, masteruri, parsed_args.file) except Exception as e: sys.exit("%s" % e) exit_code = 0 # resize and show the qt window if not rospy.is_shutdown(): os.chdir(settings().PACKAGE_DIR ) # change path to be able to the images of descriptions # main_form.resize(1024, 720) screen_size = QtGui.QApplication.desktop().availableGeometry() if main_form.size().width() >= screen_size.width() or main_form.size( ).height() >= screen_size.height() - 24: main_form.showMaximized() else: main_form.show() exit_code = -1 rospy.on_shutdown(finish) exit_code = app.exec_() return exit_code
def create_controls(self): self.lbl_nav = QtGui.QLabel(tr("Navigate"), self) self.lst_nav = AxesListWidget(self) self.btn_up = QtGui.QToolButton(self) self.btn_up.setArrowType(QtCore.Qt.UpArrow) self.btn_down = QtGui.QToolButton(self) self.btn_down.setArrowType(QtCore.Qt.DownArrow) self.lbl_sig = QtGui.QLabel(tr("Signal"), self) self.lst_sig = AxesListWidget(self) sp = self.lst_sig.sizePolicy() sp.setVerticalPolicy(QtGui.QSizePolicy.Fixed) self.lst_sig.setSizePolicy(sp) sp = self.lst_nav.sizePolicy() sp.setVerticalPolicy(QtGui.QSizePolicy.Fixed) self.lst_nav.setSizePolicy(sp) self.btn_down.clicked.connect(self._move_down) self.btn_up.clicked.connect(self._move_up) self.lst_nav.inserted.connect(self._list_insert) self.lst_sig.inserted.connect(self._list_insert) self.lst_nav.moved.connect(self._list_move) self.lst_sig.moved.connect(self._list_move) self.btn_flip = QtGui.QPushButton(tr("Reverse axes")) self.btn_flip.clicked.connect(self._flip_clicked) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.lbl_nav) vbox.addWidget(self.lst_nav) hbox = QtGui.QHBoxLayout() hbox.addWidget(self.btn_up) hbox.addWidget(self.btn_down) vbox.addLayout(hbox) vbox.addWidget(self.lbl_sig) vbox.addWidget(self.lst_sig) vbox.addWidget(self.btn_flip) w = QtGui.QWidget() w.setLayout(vbox) self.setWidget(w)
def __init__(self): super(StringLabelWidget, self).__init__() self.lock = Lock() vbox = QtGui.QVBoxLayout(self) self.label = QLabel() self.label.setAlignment(Qt.AlignLeft) self.label.setSizePolicy( QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)) font = QFont("Helvetica", 14) self.label.setFont(font) self.label.setWordWrap(True) vbox.addWidget(self.label) self.string_sub = None self._string_topics = [] self._update_topic_timer = QTimer(self) self._update_topic_timer.timeout.connect(self.updateTopics) self._update_topic_timer.start(1) self._active_topic = None self._dialog = ComboBoxDialog()
def setDescription(self, index, cfg, name, displayed_name, robot_type, description, images): ''' Sets the values of an existing item to the given items. ''' if index < len(self._data): obj = self._data[index] if not cfg in obj['cfgs']: obj['cfgs'].append(cfg) obj['name'] = name obj['displayed_name'] = displayed_name obj['type'] = robot_type obj['description'] = resolve_paths(description) del obj['images'][:] for image_path in images: img = resolve_paths(image_path) if img and img[0] != os.path.sep: img = os.path.join(nm.settings().PACKAGE_DIR, image_path) if os.path.isfile(img): obj['images'].append(QtGui.QPixmap(img))
def __init__(self, topic_name, attributes, array_index, publisher, parent=None): super(RPYWidget, self).__init__(topic_name, publisher, parent=parent) self._attributes = attributes self._publisher = publisher self._array_index = array_index self._topic_name = topic_name self._text = ez_model.make_text(topic_name, attributes, array_index) self._vertical_layout = QtGui.QVBoxLayout() self._widgets = [] for i in range(3): widget = rpy_value_widget.RPYValueWidget( topic_name, attributes, array_index, publisher, i, self) self._widgets.append(widget) self._vertical_layout.addWidget(widget) self.set_range([-math.pi, math.pi]) self.setLayout(self._vertical_layout) self.add_button = None
def launch_standalone(name, GuiT, RosT, resource=""): import rospy, os, sys import python_qt_binding as pyqt from python_qt_binding import QtGui app = QtGui.QApplication(sys.argv) rospy.init_node(name, sys.argv) gui = GuiT() ros = RosT() if resource == "": resource = _resource(name) #Load the UI pyqt.loadUi(resource, gui) #Connect the user interface and ROS ros.setup(gui) gui.setup(name, ros) #Start GUI gui.show() sys.exit(app.exec_())
def create_add_component_actions(parent, callback, prefix="", postfix=""): actions = {} compnames = [ 'Arctan', 'Bleasdale', 'DoubleOffset', 'DoublePowerLaw', 'Erf', 'Exponential', 'Gaussian', 'GaussianHF', 'Logistic', 'Lorentzian', 'Offset', 'PowerLaw', 'SEE', 'RC', 'Vignetting', 'Voigt', 'Polynomial', 'PESCoreLineShape', 'Expression', 'VolumePlasmonDrude' ] for name in compnames: try: t = getattr(hyperspy.components1d, name) except AttributeError: continue ac_name = 'add_component_' + name f = partial(callback, t) ac = QtGui.QAction(prefix + name + postfix, parent) ac.setStatusTip(tr("Add a component of type ") + name) ac.connect(ac, QtCore.SIGNAL('triggered()'), f) actions[ac_name] = ac return actions