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 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 __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")
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 __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 __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, parent=None): super(LineEditDialog, self).__init__() self.value = None vbox = QtWidgets.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 = QtWidgets.QComboBox(self) self.line_edit = QtWidgets.QLineEdit() self.combo_box.setLineEdit(self.line_edit) self.combo_box.setCompleter(QtWidgets.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 __init__(self, plugin): super(ConfigDialog, self).__init__() self._plugin = plugin self._interval_spin_box = QtWidgets.QSpinBox() self._interval_spin_box.setMaximum(10000) self._interval_spin_box.setMinimum(1) self._interval_spin_box.setValue( publisher.TopicPublisherWithTimer.publish_interval) self._interval_spin_box.valueChanged.connect(self.update_interval) self._vertical_layout = QtWidgets.QVBoxLayout() self.configurable_checkbox = QtWidgets.QCheckBox() self.configurable_checkbox.setChecked(plugin.configurable) configurable_label = QtWidgets.QLabel('Configurable') self._configurable_horizontal_layout = QtWidgets.QHBoxLayout() self._configurable_horizontal_layout.addWidget(configurable_label) self._configurable_horizontal_layout.addWidget(self.configurable_checkbox) self._vertical_layout.addLayout(self._configurable_horizontal_layout) self._horizontal_layout = QtWidgets.QHBoxLayout() spin_label = QtWidgets.QLabel('Publish Interval for repeat [ms]') self._horizontal_layout.addWidget(spin_label) self._horizontal_layout.addWidget(self._interval_spin_box) self._vertical_layout.addLayout(self._horizontal_layout) save_button = QtWidgets.QPushButton(parent=self) save_button.setIcon( self.style().standardIcon(QtWidgets.QStyle.SP_DialogSaveButton)) save_button.setText('Save to file') save_button.clicked.connect(self.save_to_file) load_button = QtWidgets.QPushButton(parent=self) load_button.setIcon( self.style().standardIcon(QtWidgets.QStyle.SP_DialogOpenButton)) load_button.setText('Load from file') load_button.clicked.connect(self.load_from_file) self._vertical_layout.addWidget(save_button) self._vertical_layout.addWidget(load_button) self.setLayout(self._vertical_layout) self.adjustSize()
def show_select_window(self): # window window = QtWidgets.QMainWindow(self) window.setCentralWidget(QtWidgets.QWidget()) window.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) window.setWindowModality(QtCore.Qt.ApplicationModal) window.setGeometry(self.window().geometry()) # widget window.setWindowTitle("Create Node") widget = window.centralWidget() widget.setLayout(QtWidgets.QVBoxLayout()) # plugin select pname_select = QtWidgets.QListWidget() for pname in self.rule.plugins: pname_select.addItem(pname) widget.layout().addWidget(QtWidgets.QLabel("Node Type")) widget.layout().addWidget(pname_select) # footer error_label = QtWidgets.QLabel() error_label.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) cancel_button = QtWidgets.QPushButton("Cancel") select_button = QtWidgets.QPushButton("Select") cancel_button.clicked.connect(window.close) select_button.clicked.connect(self.onselected) footer = QtWidgets.QHBoxLayout() footer.addWidget(error_label) footer.addWidget(cancel_button) footer.addWidget(select_button) widget.layout().addLayout(footer) self.ui_window = window self.ui_error = error_label self.ui_pname = pname_select window.show()
def __init__(self, client): super(AwControlPanel, self).__init__() self.__client = client self.__exec_button = QtWidgets.QPushButton("Exec") self.__term_button = QtWidgets.QPushButton("Term") self.__exec_button.clicked.connect(self.exec_config) self.__term_button.clicked.connect(self.term_config) self.__lpath = QtWidgets.QLabel() self.setLayout(QtWidgets.QVBoxLayout()) layout = QtWidgets.QHBoxLayout() layout.addWidget(QtWidgets.QLabel("Path: ")) layout.addWidget(self.__lpath) self.__lpath.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self.layout().addLayout(layout) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.__exec_button) layout.addWidget(self.__term_button) self.layout().addLayout(layout)
def create_frame_entire_vlayout(self): layout = QtWidgets.QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) return layout
def start(self, profile=None, skin=None): application = QtWidgets.QApplication(self.__sysarg) resolution = application.desktop().screenGeometry() resolution = min(resolution.width(), resolution.height()) skin = skin or "autoware" with open(myutils.package("resources/skins/{}.css").format(skin)) as fp: stylesheet = fp.read() stylesheet += "* { font-size: " + str(resolution/100) + "px; }" application.setStyleSheet(stylesheet) self.__treeview = AwTreeViewPanel(self) # ToDo: consider moving to guimgr self.__control = AwControlPanel(self) # ToDo: consider moving to guimgr self.__summary = AwSummaryPanel(self) # ToDo: consider moving to guimgr self.__process = AwProcessPanel(self) # ToDo: consider moving to guimgr self.__network = AwTcpServerPanel() self.__quickstart = AwQuickStartPanel(self.__guimgr) self.__sim_rosbag = AwRosbagSimulatorWidget(self.__guimgr) self.__sim_lgsvl = AwLgsvlSimulatorWidget (self.__guimgr) self.__sim_gazebo = AwGazeboSimulatorWidget(self.__guimgr) tabwidget = QtWidgets.QTabWidget() tabwidget.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) tabwidget.addTab(self.__summary, "Summary") tabwidget.addTab(self.__process, "Process") #vsplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical) vsplitter = QtWidgets.QWidget() vsplitter.setLayout(QtWidgets.QVBoxLayout()) vsplitter.layout().setContentsMargins(0, 0, 0, 0) vsplitter.layout().setSpacing(0) vsplitter.layout().addWidget(self.__treeview) vsplitter.layout().addWidget(self.__control) self.__develop = QtWidgets.QSplitter(QtCore.Qt.Horizontal) self.__develop.addWidget(vsplitter) self.__develop.addWidget(tabwidget) #mainwidget = QtWidgets.QTabWidget() #mainwidget.addTab(hsplitter, "Profile Edit") #mainwidget.addTab(self.__quickstart, "Quick Start") #mainwidget.addTab(self.__network, "Server Debug") mainwidget = QtWidgets.QStackedWidget() mainwidget.addWidget(self.__quickstart) mainwidget.addWidget(self.__develop) mainwidget.addWidget(self.__network) simulations = QtWidgets.QTabWidget() simulations.addTab(self.__sim_rosbag, "Rosbag") simulations.addTab(self.__sim_lgsvl, "LGSVL") simulations.addTab(self.__sim_gazebo, "Gazebo") mainsplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical) mainsplitter.addWidget(mainwidget) mainsplitter.addWidget(simulations) #dock = QtWidgets.QDockWidget() #dock.setWidget( ) #window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock) window = AwMainWindow(self) window.setCentralWidget(mainsplitter) window.show() simulations.hide() window.addViewMenu("Simulation", simulations.setVisible) def switch_develop_mode(checked): if checked: mainwidget.setCurrentWidget(self.__develop) else: mainwidget.setCurrentWidget(self.__quickstart) window.addViewMenu("Develop Mode", switch_develop_mode) # Debug #mainwidget.setCurrentWidget(self.__develop) simulations.hide() self.__sim_rosbag.rosbag_file.path.setText(myutils.userhome(".autoware/log/20150324.bag")) # connect objects self.__server.register_runner(self.__process) self.__process.register_server(self.__server) self.__server.register_client(self.__network) self.__network.register_server(self.__server) self.__panels.append(self.__treeview) self.__panels.append(self.__summary) self.__panels.append(self.__process) self.__panels.append(self.__quickstart) self.__treeview.register_select_listener(self.__summary) self.__treeview.register_select_listener(self.__process) self.__treeview.register_select_listener(self.__control) if profile: self.__server.load_profile(profile) else: self.__server.make_profile("root/default") return application.exec_()
def setupButtons(self, yaml_file): """ Parse yaml file and setup Buttons. Format of the yaml file should be: - name: 'button name' (required) image: 'path to image for icon' (optional) image_size: 'width and height of icon' (optional) command: 'command' (required) column: 'column index' (optional, defaults to 0) """ self.buttons = [] with open(yaml_file) as f: yaml_data = yaml.load(f) # lookup colum direction direction = 'vertical' for d in yaml_data: if d.has_key('direction'): if d['direction'] == 'horizontal': direction = 'horizontal' else: # d['direction'] == 'vertical': direction = 'vertical' yaml_data.remove(d) break # lookup column num column_indices = [d['column'] for d in yaml_data] max_column_index = max(*column_indices) if direction == 'vertical': self.layout = QtWidgets.QHBoxLayout() self.layout_boxes = [QtWidgets.QVBoxLayout() for i in range(max_column_index + 1)] else: # direction == 'horizontal' self.layout = QtWidgets.QVBoxLayout() self.layout_boxes = [QtWidgets.QHBoxLayout() for i in range(max_column_index + 1)] self.button_groups = [QtWidgets.QGroupBox() for i in range(max_column_index + 1)] for button_data in yaml_data: # check if all the field is available if not button_data.has_key("name"): self.showError("name field is missed in yaml") raise Exception("name field is missed in yaml") if not button_data.has_key("command"): self.showError("command field is missed in yaml") raise Exception("command field is missed in yaml") if self.button_type == "push": button = QtWidgets.QToolButton() else: # self.button_type == "Radio": button = QtWidgets.QRadioButton() button.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) if button_data.has_key("image"): image_file = get_filename(button_data["image"])[len("file://"):] if os.path.exists(image_file): icon = QtGui.QIcon(image_file) button.setIcon(icon) if button_data.has_key("image_size"): button.setIconSize(QSize(button_data["image_size"][0], button_data["image_size"][1])) else: button.setIconSize(QSize(100, 100)) if button_data.has_key("name"): name = button_data['name'] button.setText(name) button.clicked.connect(self.buttonCallback(button_data['command'])) if self.button_type == "push": button.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) else: # self.button_type == "Radio": if button_data.has_key("default_value") and button_data['default_value']: button.setChecked(True) self.layout_boxes[button_data['column']].addWidget(button) self.buttons.append(button) for i in range(len(self.button_groups)): self.button_groups[i].setLayout(self.layout_boxes[i]) for group in self.button_groups: self.layout.addWidget(group) self.setLayout(self.layout)
def __init__(self, context): super(BehaviorTreePlugin, self).__init__(context) self.setObjectName('BehaviorTreePlugin') self.tree = None self.initialized_buttons = False self.prev_graphviz = '' self.behavior_tree_graphviz_sub = rospy.Subscriber('behavior_tree_graphviz', String, self.behavior_tree_graphviz_callback) self.timer = rospy.Timer(rospy.Duration(0.1), self.timer_callback) self.functions_mutex = Lock() self.functions = {} self.last_graphviz_string = '' self.widget = QWidget() self.vbox = qt.QVBoxLayout() self.widget.setLayout(self.vbox) context.add_widget(self.widget) #self.widget.setStyleSheet('QWidget{margin-left:-1px;}') self.top_widget = qt.QWidget() self.top_layout = qt.QVBoxLayout() self.top_widget.setLayout(self.top_layout) self.graph_widget = qt.QWidget() self.graph_layout = qt.QVBoxLayout() self.graph_widget.setLayout(self.graph_layout) self.image_label = qt.QLabel('asdfadsf') #self.graph_layout.addWidget(self.image_label) self.xdot_widget = DotWidget() self.graph_layout.addWidget(self.xdot_widget) self.top_layout.addWidget(self.graph_widget) self.graph_widget.setStyleSheet("background-color: rgb(255, 255, 255);") self.config_widget = qt.QWidget() self.config_widget.setStyleSheet('QWidget{margin-left:-1px;}') self.config_layout = qt.QHBoxLayout() self.config_widget.setLayout(self.config_layout) self.config_widget.setFixedHeight(50) self.config_button = qt.QPushButton('Open Config...') self.config_button.clicked.connect(self.select_config_file) self.config_layout.addWidget(self.config_button) self.tree_label = qt.QLabel('tree filename: ') self.config_layout.addWidget(self.tree_label) self.debug_checkbox = qt.QCheckBox('Debug Mode') self.config_layout.addWidget(self.debug_checkbox) self.debug_checkbox.stateChanged.connect(self.debug_mode_changed) #self.config_widget.setStyleSheet("background-color: rgb(255, 0, 0);") self.top_layout.addWidget(self.config_widget) #self.vbox.addWidget(self.top_widget) self.button_container_widget = qt.QWidget() self.button_container_layout = qt.QVBoxLayout() self.button_container_widget.setLayout(self.button_container_layout) #self.vbox.addWidget(self.button_container_widget) self.button_widget = qt.QWidget() self.button_layout = qt.QHBoxLayout() self.button_widget.setLayout(self.button_layout) #self.button_widget.setStyleSheet("background-color: rgb(0, 0, 255);") self.condition_widget = qt.QWidget() self.condition_layout = qt.QVBoxLayout() self.condition_widget.setLayout(self.condition_layout) self.button_layout.addWidget(self.condition_widget) self.condition_label = qt.QLabel() self.condition_label.setText('Conditions') self.condition_label.setAlignment(Qt.AlignCenter) self.condition_label.setFont(gui.QFont("SansSerif", 18, gui.QFont.Bold)) self.condition_layout.addWidget(self.condition_label) self.action_widget = qt.QWidget() self.action_layout = qt.QVBoxLayout() self.action_widget.setLayout(self.action_layout) self.button_layout.addWidget(self.action_widget) self.action_label = qt.QLabel() self.action_label.setText('Actions') self.action_label.setAlignment(Qt.AlignCenter) self.action_label.setFont(gui.QFont("SansSerif", 18, gui.QFont.Bold)) self.action_layout.addWidget(self.action_label) self.button_scroll_area = qt.QScrollArea() self.button_scroll_area.setWidget(self.button_widget) #self.button_scroll_area.setFixedHeight(200) #self.button_container_widget.setFixedHeight(200) self.button_container_layout.addWidget(self.button_scroll_area) self.button_widget.setMinimumWidth(self.button_scroll_area.sizeHint().width()) self.button_scroll_area.setWidgetResizable(True) self.horizontal_splitter = qt.QSplitter(core.Qt.Vertical) self.horizontal_splitter.addWidget(self.top_widget) self.horizontal_splitter.addWidget(self.button_container_widget) self.vbox.addWidget(self.horizontal_splitter) self.button_container_widget.hide()