def setup_gui(self, two_columns=True): if qt_version_below_5: widget_layout = QtGui.QHBoxLayout() else: widget_layout = QtWidgets.QHBoxLayout() widget_layout.addLayout(self._column_1) if two_columns: widget_layout.addLayout(self._column_2) if qt_version_below_5: main_layout = QtGui.QHBoxLayout() else: main_layout = QtWidgets.QHBoxLayout() main_layout = QtWidgets.QVBoxLayout() main_layout.addLayout(widget_layout) self._column_1.setAlignment(QtCore.Qt.AlignTop) if two_columns: self._column_2.setAlignment(QtCore.Qt.AlignTop) widget_layout.setAlignment(QtCore.Qt.AlignTop) main_layout.setAlignment(QtCore.Qt.AlignTop) self.setLayout(main_layout) self._update_info_timer = QtCore.QTimer(self) self._update_info_timer.timeout.connect(self.update_gui) self._update_info_timer.start(100)
def setup_ui(self, name, max_value=100000, min_value=-100000, default_max_value=100, default_min_value=-100, initial_value=0): self._min_spin_box = QtWidgets.QSpinBox() self._min_spin_box.setMaximum(max_value) self._min_spin_box.setMinimum(min_value) self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self._slider.setTickPosition(QtWidgets.QSlider.TicksBelow) self._slider.valueChanged.connect(self.slider_changed) self._max_spin_box = QtWidgets.QSpinBox() self._max_spin_box.setMaximum(max_value) self._max_spin_box.setMinimum(min_value) self._lcd = QtWidgets.QLCDNumber() self._lcd.setMaximumHeight(self.LCD_HEIGHT) self._min_spin_box.valueChanged.connect(self._slider.setMinimum) self._max_spin_box.valueChanged.connect(self._slider.setMaximum) self._min_spin_box.setValue(default_min_value) self._max_spin_box.setValue(default_max_value) self._slider.setValue(initial_value) zero_button = QtWidgets.QPushButton('reset') zero_button.clicked.connect(lambda x: self._slider.setValue(0)) self._horizontal_layout.addWidget(self._min_spin_box) self._horizontal_layout.addWidget(self._slider) self._horizontal_layout.addWidget(self._max_spin_box) self._horizontal_layout.addWidget(self._lcd) self._horizontal_layout.addWidget(zero_button) self.setLayout(self._horizontal_layout)
def setupUi(self, MainWindow): self.lock = Lock() self.talker = Talker('taskview') rospy.Subscriber('BbSync', bbsynch, self.taskview) MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 600) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.listView = QtWidgets.QListWidget(self.centralwidget) self.listView.setGeometry(QtCore.QRect(10, 40, 771, 521)) self.listView.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.listView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) self.listView.setObjectName("listView") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(10, 10, 67, 17)) self.label.setObjectName("label") MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.tasklist = [] self.markers = rviz_tools.RvizMarkers('/map', 'markers')
def __init_menu(self): self.filemenu = self.menuBar().addMenu("File") self.viewmenu = self.menuBar().addMenu("View") load_action = QtWidgets.QAction("Load Profile", self) load_action.setShortcut("Ctrl+L") load_action.triggered.connect(self.load_profile) save_action = QtWidgets.QAction("Save Profile", self) save_action.setShortcut("Ctrl+S") save_action.triggered.connect(self.save_profile) save_as_action = QtWidgets.QAction("Save Profile As", self) save_as_action.setShortcut("Ctrl+A") save_as_action.triggered.connect(self.save_profile_as) export_action = QtWidgets.QAction("Export Profile", self) export_action.setShortcut("Ctrl+E") export_action.triggered.connect(self.export_profile) self.filemenu.addAction(load_action) self.filemenu.addAction(save_action) self.filemenu.addAction(save_as_action) self.filemenu.addAction(export_action)
def __init__(self, guimgr): super(AwLgsvlSimulatorWidget, self).__init__() self.process = QtCore.QProcess(self) self.console = AwProcessViewer(self.process) self.button = QtWidgets.QPushButton("Launch Simulator") self.button.setCheckable(True) self.button.toggled.connect(self.launch_lgsvm) self.server_addr = QtWidgets.QLineEdit() self.server_port = QtWidgets.QLineEdit() self.client_addr = QtWidgets.QLineEdit() self.client_port = QtWidgets.QLineEdit() self.server_addr.setText("10.100.2.1") self.server_port.setText("5000") for host in QtNetwork.QNetworkInterface.allAddresses(): if not host.isLoopback(): if host.protocol() == QtNetwork.QAbstractSocket.IPv4Protocol: self.client_addr.setText(host.toString()) self.client_port.setText("9090") layout = QtWidgets.QGridLayout() layout.addWidget(QtWidgets.QLabel("Server Address"), 0, 0) layout.addWidget(QtWidgets.QLabel("Server Port"), 1, 0) layout.addWidget(QtWidgets.QLabel("Client Address"), 2, 0) layout.addWidget(QtWidgets.QLabel("Client Port"), 3, 0) layout.addWidget(self.server_addr, 0, 1) layout.addWidget(self.server_port, 1, 1) layout.addWidget(self.client_addr, 2, 1) layout.addWidget(self.client_port, 3, 1) layout.addWidget(self.button, 4, 0, 1, 2) layout.addWidget(self.console, 5, 0, 1, 2) self.setLayout(layout)
def setup_ui(self, name): self._min_spin_box = QtWidgets.QDoubleSpinBox() self._min_spin_box.setMaximum(10000) self._min_spin_box.setMinimum(-10000) self._min_spin_box.setValue(self.DEFAULT_MIN_VALUE) self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) self._slider.setTickPosition(QtWidgets.QSlider.TicksBelow) self._slider.valueChanged.connect(self.slider_changed) self._max_spin_box = QtWidgets.QDoubleSpinBox() self._max_spin_box.setMaximum(10000) self._max_spin_box.setMinimum(-10000) self._max_spin_box.setValue(self.DEFAULT_MAX_VALUE) self._lcd = QtWidgets.QLCDNumber() self._lcd.setMaximumHeight(self.LCD_HEIGHT) self._slider.setValue(50) zero_button = QtWidgets.QPushButton('reset') zero_button.clicked.connect( lambda x: self._slider.setValue(self.value_to_slider(0.0))) self._horizontal_layout.addWidget(self._min_spin_box) self._horizontal_layout.addWidget(self._slider) self._horizontal_layout.addWidget(self._max_spin_box) self._horizontal_layout.addWidget(self._lcd) self._horizontal_layout.addWidget(zero_button) self.setLayout(self._horizontal_layout)
def __init__(self): super(CenteredCheckBox, self).__init__() checkbox = QtWidgets.QCheckBox() layout = QtWidgets.QHBoxLayout(self) layout.addWidget(checkbox) layout.setAlignment(QtCore.Qt.AlignCenter) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def __init__(self): super(PluginEditWidget, self).__init__() self.fields = collections.OrderedDict() self.setLayout(QtWidgets.QGridLayout()) for col,text in enumerate(PluginEditWidget.header): self.layout().addWidget(QtWidgets.QLabel(text), 0, col) self.export = QtWidgets.QPushButton("Export") self.export.clicked.connect(self.export_yaml)
def __init__(self, topic_name, attributes, array_index, publisher, parent, label_text=None): super(ValueWidget, self).__init__(topic_name, publisher, parent=parent) self._parent = parent self._attributes = attributes self._array_index = array_index self._text = ez_model.make_text(topic_name, attributes, array_index) self._horizontal_layout = QtWidgets.QHBoxLayout() if label_text is None: self._topic_label = QtWidgets.QLabel(self._text) else: self._topic_label = QtWidgets.QLabel(label_text) self.close_button = QtWidgets.QPushButton() self.close_button.setMaximumWidth(30) self.close_button.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_TitleBarCloseButton)) self.up_button = QtWidgets.QPushButton() self.up_button.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_ArrowUp)) self.up_button.setMaximumWidth(30) self.down_button = QtWidgets.QPushButton() self.down_button.setMaximumWidth(30) self.down_button.setIcon(self.style().standardIcon( QtWidgets.QStyle.SP_ArrowDown)) repeat_label = QtWidgets.QLabel('repeat') self._repeat_box = QtWidgets.QCheckBox() self._repeat_box.stateChanged.connect(self.repeat_changed) self._repeat_box.setChecked(publisher.is_repeating()) self._publish_button = QtWidgets.QPushButton('Publish') self._publish_button.clicked.connect(publisher.publish) self._horizontal_layout.addWidget(self._topic_label) self._horizontal_layout.addWidget(self.close_button) self._horizontal_layout.addWidget(self.up_button) self._horizontal_layout.addWidget(self.down_button) if self._array_index is not None: self.add_button = QtWidgets.QPushButton('+') self.add_button.setMaximumWidth(30) self._horizontal_layout.addWidget(self.add_button) else: self.add_button = None self.close_button.clicked.connect( lambda x: self._parent.close_slider(self)) self.up_button.clicked.connect( lambda x: self._parent.move_up_widget(self)) self.down_button.clicked.connect( lambda x: self._parent.move_down_widget(self)) self.setup_ui(self._text) self._horizontal_layout.addWidget(self._publish_button) self._horizontal_layout.addWidget(repeat_label) self._horizontal_layout.addWidget(self._repeat_box)
def __init__(self): super(QuadWidgetCommon, self).__init__() # the name widget is separate since we need to access it directly self._name_widget = QuadNameWidget(self) if qt_version_below_5: self._column_1 = QtGui.QVBoxLayout() self._column_2 = QtGui.QVBoxLayout() else: self._column_1 = QtWidgets.QVBoxLayout() self._column_2 = QtWidgets.QVBoxLayout()
def main(sys_argv): parser = argparse.ArgumentParser( description='Autoware Launcher Plugin Editor') parser.add_argument("plugin", help="plugin file path") args = parser.parse_args() application = QtWidgets.QApplication(sys_argv) wizard = QtWidgets.QWizard() wizard.setWindowTitle("Plugin Editor") wizard.addPage(LaunchFileSelect()) wizard.show() return application.exec_()
def __init__(self, widget): self.pkgbox = QtWidgets.QComboBox() self.pkgbox.setEditable(True) self.pkgbox.setInsertPolicy(QtWidgets.QComboBox.NoInsert) self.xmlbox = QtWidgets.QComboBox() self.xmlbox.setEditable(True) widget.setTitle("Launch File Select") widget.setLayout(QtWidgets.QFormLayout()) widget.layout().addRow("Package", self.pkgbox) widget.layout().addRow("File", self.xmlbox)
def __frame_setup(self, widget): widget.title = QtWidgets.QLabel("No Title") widget.title.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) layout = self.create_frame_header_hlayout() layout.addWidget(widget.title) widget.header = QtWidgets.QWidget() widget.header.setObjectName("FrameHeader") widget.header.setLayout(layout) layout = self.create_frame_entire_vlayout() layout.addWidget(widget.header) widget.setLayout(layout)
def __init__(self, guimgr, node, view): super(AwTransformFrame, self).__init__(guimgr, node, view) super(AwTransformFrame, self).setup_widget() self.set_title(frame_title(self.view, "Transform")) widget = QtWidgets.QWidget() widget.setLayout(QtWidgets.QHBoxLayout()) for idx, txt in enumerate(["Tx", "Ty", "Tz", "Rx", "Ry", "Rz"]): field = AwRealField(self.node.get_config(self.view.target[idx])) field.target = self.view.target[idx] field.value_updated.connect(self.apply) widget.layout().addWidget(QtWidgets.QLabel(txt + ":")) widget.layout().addWidget(field) self.add_widget(widget)
def __init__(self, guimgr): super(AwRosbagSimulatorWidget, self).__init__() self.rosbag_mode_proc = QtCore.QProcess(self) self.rosbag_info_proc = QtCore.QProcess(self) self.rosbag_play_proc = QtCore.QProcess(self) self.rosbag_file = widgets.AwFileSelect(self) self.rosbag_info = QtWidgets.QPushButton("Info") self.rosbag_text = QtWidgets.QLabel("No information") self.rosbag_enable = QtWidgets.QCheckBox() self.rosbag_label = QtWidgets.QLabel("Simulation Mode") self.rosbag_play = QtWidgets.QPushButton("Play") self.rosbag_stop = QtWidgets.QPushButton("Stop") self.rosbag_pause = QtWidgets.QPushButton("Pause") self.rosbag_state = QtWidgets.QLabel() #self.rosbag_stime = QtWidgets.QLineEdit() #start time #repeat #rate self.rosbag_enable.stateChanged.connect(self.simulation_mode_changed) self.rosbag_info.clicked.connect(self.rosbag_info_requested) self.rosbag_info_proc.finished.connect(self.rosbag_info_completed) self.rosbag_play.clicked.connect(self.rosbag_started) self.rosbag_stop.clicked.connect(self.rosbag_stopped) self.rosbag_play_proc.finished.connect(self.rosbag_finished) self.rosbag_play_proc.readyReadStandardOutput.connect( self.rosbag_output) self.rosbag_pause.setCheckable(True) self.rosbag_pause.toggled.connect(self.rosbag_paused) self.setStyleSheet( "QCheckBox::indicator { width: 28px; height: 28px; }") self.rosbag_label.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self.rosbag_text.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) layout = QtWidgets.QGridLayout() layout.addWidget(self.rosbag_enable, 0, 0) layout.addWidget(self.rosbag_label, 0, 1) layout.addWidget(self.rosbag_play, 0, 2) layout.addWidget(self.rosbag_stop, 0, 3) layout.addWidget(self.rosbag_pause, 0, 4) layout.addWidget(self.rosbag_state, 1, 0, 1, 5) layout.addWidget(self.rosbag_file.path, 2, 0, 1, 3) layout.addWidget(self.rosbag_file.button, 2, 3) layout.addWidget(self.rosbag_info, 2, 4) layout.addWidget(self.rosbag_text, 3, 0, 1, 5) self.setLayout(layout) self.simulation_mode_disabled()
def __init__(self, attr): self.name = QtWidgets.QLabel() self.type = QtWidgets.QComboBox() self.list = QtWidgets.QComboBox() self.default = QtWidgets.QLineEdit() self.name.setText(attr["name"]) self.type.addItems(["str", "int", "real", "bool"]) self.list.addItems(["none", "space", "yaml"]) self.default.setText(attr.get("default")) self.type.setCurrentIndex(-1) if attr.get("default"): itype = self.type_inference(attr["default"]) self.type.setCurrentIndex(self.type.findText(itype))
def update_hosts_status(self): ''' Updates the text and color of the displayed hosts table elements. ''' rows = self.hosts["current"].hosts columns = ["ip", "status"] for row in range(len(rows)): column_color = [] # Assigns colors to each item in the row if (getattr(rows[row], "ip") == "Unknown"): column_color.append(self.colors["red"]) column_color.append(self.colors["red"]) else: column_color.append(self.colors["green"]) if (getattr(rows[row], "status") == "Online"): column_color.append(self.colors["green"]) else: column_color.append(self.colors["red"]) # Updates the host's IP address and status in the devices table for column in range(len(columns)): entry = QtWidgets.QLabel(getattr(rows[row], columns[column])) entry.setAlignment(QtCore.Qt.AlignCenter) entry.setStyleSheet(column_color[column]) self.device_table.setCellWidget(row, column, entry) # Set the cached host data to the host data that was just displayed self.hosts["displayed"] = copy(self.hosts["current"])
def __init__(self, context): super(Shooter, self).__init__(context) # Create the widget and name it self._widget = QtWidgets.QWidget() self._widget.setObjectName("Shooter") self.setObjectName("Shooter") # Extend the widget with all attributes and children in the UI file ui_file = os.path.join(rospkg.RosPack().get_path("navigator_gui"), "resource", "shooter.ui") loadUi(ui_file, self._widget) self.remote = RemoteControl("shooter gui") self.remote.is_timed_out = True self.shooter_status = { "received": "Unknown", "stamp": rospy.Time.now(), "cached": "Unknown" } self.disc_speed_setting = 0 self.connect_ui() rospy.Subscriber("/shooter/status", String, self.cache_shooter_status) # Deals with problem of multiple instances of same plugin 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)
def __setup_widget(self): # Frame Header self.title = QtWidgets.QLabel("No Title") self.title.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) layout = self.guimgr.create_frame_header_hlayout() layout.addWidget(self.title) self.header = QtWidgets.QWidget() self.header.setObjectName("FrameHeader") self.header.setLayout(layout) # Frame Layout layout = self.guimgr.create_frame_entire_vlayout() layout.addWidget(self.header) self.setLayout(layout)
def __panel_setup(self, widget, spacer): footer_layout = QtWidgets.QHBoxLayout() footer_layout.setContentsMargins(2, 2, 2, 2) footer_layout.setSpacing(2) footer_layout.addStretch() widget.footer = QtWidgets.QWidget() widget.footer.setLayout(footer_layout) widget_layout = QtWidgets.QVBoxLayout() widget_layout.setContentsMargins(16, 16, 16, 16) widget_layout.setSpacing(16) if not spacer: widget_layout.addStretch() else: widget_layout.addWidget(spacer) widget_layout.addWidget(widget.footer) widget.setLayout(widget_layout)
def __init__(self, context): super(MyPlugin, self).__init__(context) # Give QObjects reasonable names self.setObjectName('MyPlugin') # 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 = QtWidgets.QWidget() # Get path to UI file which should be in the "resource" folder of this package ui_file = os.path.join(rospkg.RosPack().get_path('robot_rqt_plugin'), 'resource', 'MyPlugin.ui') # Extend the widget with all attributes and children from UI file loadUi(ui_file, self._widget) # Give QObjects reasonable names self._widget.setObjectName('MyPluginUi') # Show _widget.windowTitle on left-top of each plugin (when # it's set in _widget). This is useful when you open multiple # plugins at once. Also if you open multiple instances of your # plugin at once, these lines add number to make it easy to # tell from pane to pane. 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) # Sets up the functions to be called on clicking on buttons self._widget.hard_stop.clicked[bool].connect(self._hardstop) self._widget.soft_stop.clicked[bool].connect(self._softstop) self._widget.control.clicked[bool].connect(self._switchmode) # Sets up the variables and the text label self.mode_val = False self.soft_stop = False self.decide_text() # Sets the topics and the publishing rate self.control_publisher = rospy.Publisher("control_mode", Bool, queue_size=0) self.stop_publisher = rospy.Publisher("soft_stop", Bool, queue_size=0) self.rate = rospy.Rate(10) # Starts a thread to run in parallel publishing messages threading.Thread(target=self.publish_manually).start()
def __init__(self, guimgr): super(AwGazeboSimulatorWidget, self).__init__() self.gazebo_process = QtCore.QProcess(self) self.launch_button = QtWidgets.QPushButton("Launch") self.setup_button = QtWidgets.QPushButton("Initial Setup") self.world_buttons = [] self.world_buttons.append( self.__create_radio_button("simple", "simple")) self.world_buttons.append(self.__create_radio_button("mcity", "mcity")) self.world_buttons.append( self.__create_radio_button("city sim", "citysim_gazebo7")) self.use_gpu_box = QtWidgets.QCheckBox("Use GPU") self.world_buttons[0].setChecked(True) self.setup_button.clicked.connect(self.__exec_setup_script) self.launch_button.setCheckable(True) self.launch_button.toggled.connect(self.__exec_simulator) self.gazebo_process.finished.connect(self.__simulator_finished) world_group = QtWidgets.QGroupBox("World") world_group.setLayout(QtWidgets.QVBoxLayout()) for world_button in self.world_buttons: world_group.layout().addWidget(world_button) world_group.layout().addStretch() config_group = QtWidgets.QGroupBox("Config") config_group.setLayout(QtWidgets.QVBoxLayout()) config_group.layout().addWidget(self.use_gpu_box) config_group.layout().addStretch() hlayout1 = QtWidgets.QHBoxLayout() hlayout1.addStretch() hlayout1.addWidget(self.setup_button) hlayout2 = QtWidgets.QHBoxLayout() hlayout2.addWidget(world_group) hlayout2.addWidget(config_group) self.setLayout(QtWidgets.QVBoxLayout()) self.layout().addLayout(hlayout1) self.layout().addLayout(hlayout2) self.layout().addWidget(self.launch_button)
def __setup_widget(self): self.window().setWindowTitle(self.__class__.__name__) # Panel Footer layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(2, 2, 2, 2) layout.setSpacing(2) layout.addStretch() self.footer = QtWidgets.QWidget() self.footer.setLayout(layout) # Panel Layout layout = QtWidgets.QVBoxLayout() layout.setContentsMargins(16, 16, 16, 16) layout.setSpacing(16) layout.addStretch() layout.addWidget(self.footer) self.setLayout(layout)
def __init__(self, guimgr): super(AwQuickStartPanel, self).__init__() self.guimgr = guimgr self.frames = {"root/" + name: None for name in ["map", "vehicle", "sensing", "visualization"]} self.awlogo = QtWidgets.QLabel() pixmap = QtGui.QPixmap(myutils.package("resources/autoware_logo.png")) self.awlogo.setPixmap(pixmap) self.awlogo.setAlignment(QtCore.Qt.AlignCenter) self.awlogo.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
def btn_color_clicked(self, checked): frame = self.editor.active_frame color = QtWidgets.QColorDialog.getColor( QtWidgets.QColor(frame.color[0] * 255, frame.color[1] * 255, frame.color[2] * 255, frame.color[3] * 255), None, "Select Color", options=QtWidgets.QColorDialog.ShowAlphaChannel) self.editor.command( Command_SetStyleColor(self.editor, frame, color.getRgbF()))
def __init__(self, client): super(AwProcessPanel, self).__init__() self.__client = client self.__items = {} self.__server = None self.__dummy = QtWidgets.QLabel("This is node") self.addWidget(self.__dummy) self.__tmpdir = "/tmp/autoware_launcher" myutils.makedirs(self.__tmpdir, mode=0o700, exist_ok=True)
def node_ui_created(self, lnode): panel = self.__client.guimgr().create_widget(lnode, lnode.plugin().panel()) panel.setup_widget() #self.__panels[lnode.path()] = panel #self.addWidget(panel) scroll = QtWidgets.QScrollArea() scroll.setWidget(panel) scroll.setWidgetResizable(True) self.__panels[lnode.path()] = scroll self.addWidget(scroll)
def chained_tasks_drop_cb(self, event): ''' Called when a task is dropped from the available_tasks_list to the chained_tasks_table, or when a task is moved (reordered) within the chained_tasks_table. ''' idx = self.chained_tasks_table.indexAt(event.pos()).row() if idx == -1: # Handle insertion at end of table idx = self.chained_tasks_table.rowCount() # If drop is from itself, do a reorder if event.source() == self.chained_tasks_table: # Now swap the two rows selected_index = self.chained_tasks_table.selectedIndexes()[0].row( ) if idx == selected_index: return self.chained_tasks_table.insertRow(idx) if selected_index > idx: selected_index += 1 for i in range(self.chained_tasks_table.columnCount()): self.chained_tasks_table.setCellWidget( idx, i, self.chained_tasks_table.cellWidget(selected_index, i)) self.chained_tasks_table.removeRow(selected_index) # If drop is from available list, insert it at the dropped row elif event.source() == self.available_tasks_list: selected_item = self.available_tasks_list.selectedItems()[0] task = QtWidgets.QLabel(selected_item.text()) required = CenteredCheckBox() required.setChecked(True) # Start with default required timeout = QtWidgets.QDoubleSpinBox() timeout.setValue(0) timeout.setMaximum(10000) timeout.setSuffix('s') parameters = QtWidgets.QLineEdit('') self.chained_tasks_table.insertRow(idx) self.chained_tasks_table.setCellWidget(idx, 0, task) self.chained_tasks_table.setCellWidget(idx, 1, required) self.chained_tasks_table.setCellWidget(idx, 2, timeout) self.chained_tasks_table.setCellWidget(idx, 3, parameters)
def load_chained_missions(self, list_of_missions): for i in reversed(range(self.chained_missions_table.rowCount())): self.chained_missions_table.removeRow(i) for idx, m in enumerate(list_of_missions): mission = m['mission'] timeout = m['timeout'] required = m['required'] parameters = m['parameters'] mission = QtWidgets.QLabel(m['mission']) required = CenteredCheckBox() required.setChecked(m['required']) # Start with default required timeout = QtWidgets.QDoubleSpinBox() timeout.setValue(m['timeout']) timeout.setMaximum(10000) timeout.setSuffix('s') parameters = QtWidgets.QLineEdit(m['parameters']) self.chained_missions_table.insertRow(idx) self.chained_missions_table.setCellWidget(idx, 0, mission) self.chained_missions_table.setCellWidget(idx, 1, required) self.chained_missions_table.setCellWidget(idx, 2, timeout) self.chained_missions_table.setCellWidget(idx, 3, parameters)
def __init__(self, guimgr, launch, parent): super(AwPluginRemoveWindow, self).__init__(parent) self.guimgr = guimgr self.node = launch settings = QtCore.QSettings("Autoware", "AutowareLauncher") if settings.contains("geometry"): self.restoreGeometry(settings.value("geometry")) # select self.nodelist = QtWidgets.QListWidget() for child in self.node.children(): self.nodelist.addItem(child.name()) # footer cancel = QtWidgets.QPushButton("Cancel") cancel.clicked.connect(self.close) remove = QtWidgets.QPushButton("Remove") remove.clicked.connect(self.remove_launch_node) footer = QtWidgets.QHBoxLayout() footer.addStretch() footer.addWidget(cancel) footer.addWidget(remove) # widget layout = QtWidgets.QVBoxLayout() layout.addWidget(self.nodelist) layout.addLayout(footer) widget = QtWidgets.QWidget() widget.setLayout(layout) self.setCentralWidget(widget) self.setWindowTitle("Remove Launch Node")