当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QPushButton类代码示例

本文整理汇总了Python中python_qt_binding.QtGui.QPushButton的典型用法代码示例。如果您正苦于以下问题:Python QPushButton类的具体用法?Python QPushButton怎么用?Python QPushButton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QPushButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: WarningMessageBox

class WarningMessageBox(QMessageBox):

    def __init__(self, icon, title, text, detailed_text="", buttons=QMessageBox.Ok):
        QMessageBox.__init__(self, icon, title, text, buttons)
        if detailed_text:
            self.setDetailedText(detailed_text)
            horizontalSpacer = QSpacerItem(480, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)
            layout = self.layout()
            layout.addItem(horizontalSpacer, layout.rowCount(), 0, 1, layout.columnCount())

        if QMessageBox.Abort & buttons:
            self.setEscapeButton(QMessageBox.Abort)
        elif QMessageBox.Ignore & buttons:
            self.setEscapeButton(QMessageBox.Ignore)
        else:
            self.setEscapeButton(buttons)

        self.textEdit = textEdit = self.findChild(QTextEdit)
        if textEdit is not None:
            textEdit.setMinimumHeight(0)
            textEdit.setMaximumHeight(600)
            textEdit.setMinimumWidth(0)
            textEdit.setMaximumWidth(600)
            textEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        self.ignore_all_btn = QPushButton('Don\'t display again')
        self.addButton(self.ignore_all_btn, QMessageBox.HelpRole)

    def paintEvent(self, event):
        QMessageBox.paintEvent(self, event)
        self.ignore_all_btn.setVisible(self.textEdit.isVisible() if self.textEdit else False)
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:31,代码来源:detailed_msg_box.py

示例2: __init__

    def __init__(self, context):
        super(MultiRobotPasserGUIPlugin, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('MultiRobotPasserGUIPlugin')

        # Create QWidget
        self.widget = QWidget()
        self.master_layout = QVBoxLayout(self.widget)

        self.buttons = {}
        self.button_layout = QHBoxLayout()
        self.master_layout.addLayout(self.button_layout)
        for button_text in ["Enable", "Disable"]:
            button = QPushButton(button_text, self.widget)
            button.clicked[bool].connect(self.handle_button)
            button.setCheckable(True)
            self.button_layout.addWidget(button)
            self.buttons[button_text] = button

        self.widget.setObjectName('MultiRobotPasserGUIPluginUI')
        if context.serial_number() > 1:
            self.widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
        context.add_widget(self.widget)

        self.status_subscriber = rospy.Subscriber("status", Bool, self.status_callback)
        self.enable = rospy.ServiceProxy("enable", Empty)
        self.disable = rospy.ServiceProxy("disable", Empty)

        self.enabled = False
        self.connect(self.widget, SIGNAL("update"), self.update)
开发者ID:utexas-bwi,项目名称:segbot_rocon,代码行数:30,代码来源:plugins.py

示例3: MasterSyncButtonHelper

class MasterSyncButtonHelper(QObject):
    '''
    This is helper class to which contains a button and can emit signals. The
    MasterSyncItem can not emit signals, but is used in QStandardModel.
    '''
    clicked = Signal(bool, str)

    NOT_SYNC = 0
    SWITCHED = 1
    SYNC = 2

    ICON_PREFIX = 'irondevil'
#  ICON_PREFIX = 'crystal_clear'

    def __init__(self, master):
        QObject.__init__(self)
        self.name = master.name
        self._master = master
        self._syncronized = MasterSyncButtonHelper.NOT_SYNC
        self.ICONS = {MasterSyncButtonHelper.SYNC: QIcon(":/icons/%s_sync.png" % self.ICON_PREFIX),
                      MasterSyncButtonHelper.NOT_SYNC: QIcon(":/icons/%s_not_sync.png" % self.ICON_PREFIX),
                      MasterSyncButtonHelper.SWITCHED: QIcon(":/icons/%s_start_sync.png" % self.ICON_PREFIX)}
        self.widget = QPushButton()
#    self.widget.setFlat(True)
        self.widget.setIcon(self.ICONS[MasterSyncButtonHelper.NOT_SYNC])
        self.widget.setMaximumSize(48, 48)
        self.widget.setCheckable(True)
        self.widget.clicked.connect(self.on_sync_clicked)

    def on_sync_clicked(self, checked):
        self.set_sync_state(MasterSyncButtonHelper.SWITCHED)
        self.clicked.emit(checked, self._master.uri)

    def master(self):
        return self._master

    def get_sync_state(self):
        return self._syncronized

    def set_sync_state(self, value):
        if self._syncronized != value:
            self._syncronized = value
            if value in self.ICONS:
                self.widget.setIcon(self.ICONS[value])
                self.widget.setChecked(value == MasterSyncButtonHelper.SYNC)

    def __eq__(self, item):
        if isinstance(item, str) or isinstance(item, unicode):
            return self.master.name.lower() == item.lower()
        elif not (item is None):
            return self.master.name.lower() == item.master.name.lower()
        return False

    def __gt__(self, item):
        if isinstance(item, str) or isinstance(item, unicode):
            return self.master.name.lower() > item.lower()
        elif not (item is None):
            return self.master.name.lower() > item.master.name.lower()
        return False
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:59,代码来源:master_list_model.py

示例4: _create_buttons

    def _create_buttons(self):
        # create the buttons line
        self.buttons = QWidget(self)
        self.horizontalLayout = QHBoxLayout(self.buttons)
        self.horizontalLayout.setContentsMargins(4, 0, 4, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        # add the search button
        self.searchButton = QPushButton(self)
        self.searchButton.setObjectName("searchButton")
#        self.searchButton.clicked.connect(self.on_shortcut_find)
        self.searchButton.toggled.connect(self.on_toggled_find)
        self.searchButton.setText(self._translate("&Find"))
        self.searchButton.setToolTip('Open a search dialog (Ctrl+F)')
        self.searchButton.setFlat(True)
        self.searchButton.setCheckable(True)
        self.horizontalLayout.addWidget(self.searchButton)
        # add the replace button
        self.replaceButton = QPushButton(self)
        self.replaceButton.setObjectName("replaceButton")
#        self.replaceButton.clicked.connect(self.on_shortcut_replace)
        self.replaceButton.toggled.connect(self.on_toggled_replace)
        self.replaceButton.setText(self._translate("&Replace"))
        self.replaceButton.setToolTip('Open a search&replace dialog (Ctrl+R)')
        self.replaceButton.setFlat(True)
        self.replaceButton.setCheckable(True)
        self.horizontalLayout.addWidget(self.replaceButton)
        # add the goto button
        self.gotoButton = QPushButton(self)
        self.gotoButton.setObjectName("gotoButton")
        self.gotoButton.clicked.connect(self.on_shortcut_goto)
        self.gotoButton.setText(self._translate("&Goto line"))
        self.gotoButton.setShortcut("Ctrl+G")
        self.gotoButton.setToolTip('Open a goto dialog (Ctrl+G)')
        self.gotoButton.setFlat(True)
        self.horizontalLayout.addWidget(self.gotoButton)
        # add a tag button
        self.tagButton = self._create_tag_button(self)
        self.horizontalLayout.addWidget(self.tagButton)
        # add spacer
        spacerItem = QSpacerItem(515, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # add line number label
        self.pos_label = QLabel()
        self.horizontalLayout.addWidget(self.pos_label)
        # add spacer
        spacerItem = QSpacerItem(515, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # add save button
        self.saveButton = QPushButton(self)
        self.saveButton.setObjectName("saveButton")
        self.saveButton.clicked.connect(self.on_saveButton_clicked)
        self.saveButton.setText(self._translate("&Save"))
        self.saveButton.setShortcut("Ctrl+S")
        self.saveButton.setToolTip('Save the changes to the file (Ctrl+S)')
        self.saveButton.setFlat(True)
        self.horizontalLayout.addWidget(self.saveButton)
        return self.buttons
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:57,代码来源:editor.py

示例5: __init__

    def __init__(self, parent = None, logger = Logger(), step_plan_topic = str()):
        QWidgetWithLogger.__init__(self, parent, logger)

        # start widget
        vbox = QVBoxLayout()
        vbox.setMargin(0)
        vbox.setContentsMargins(0, 0, 0, 0)

        # step plan input topic selection
        if len(step_plan_topic) == 0:
            step_plan_topic_widget = QTopicWidget(topic_type = 'vigir_footstep_planning_msgs/StepPlan')
            step_plan_topic_widget.topic_changed_signal.connect(self._init_step_plan_subscriber)
            vbox.addWidget(step_plan_topic_widget)
        else:
            self._init_step_plan_subscriber(step_plan_topic)

        # execute action server topic selection
        execute_topic_widget = QTopicWidget(topic_type = 'vigir_footstep_planning_msgs/ExecuteStepPlanAction', is_action_topic = True)
        execute_topic_widget.topic_changed_signal.connect(self._init_execute_action_client)
        vbox.addWidget(execute_topic_widget)

        # start button part
        buttons_hbox = QHBoxLayout()
        buttons_hbox.setMargin(0)

        # execute
        self.execute_command = QPushButton("Execute (Steps: 0)")
        self.execute_command.clicked.connect(self.execute_command_callback)
        self.execute_command.setEnabled(False)
        buttons_hbox.addWidget(self.execute_command)

        # repeat
        self.repeat_command = QPushButton("Repeat")
        self.repeat_command.clicked.connect(self.execute_command_callback)
        self.repeat_command.setEnabled(False)
        buttons_hbox.addWidget(self.repeat_command)

        # stop
        self.stop_command = QPushButton("Stop")
        self.stop_command.clicked.connect(self.stop_command_callback)
        self.stop_command.setEnabled(False)
        buttons_hbox.addWidget(self.stop_command)

        # end button part
        vbox.addLayout(buttons_hbox)

        # end widget
        self.setLayout(vbox)

        # init widget
        if len(step_plan_topic) == 0:
            step_plan_topic_widget.emit_topic_name()
        execute_topic_widget.emit_topic_name()
开发者ID:TRECVT,项目名称:vigir_footstep_planning_basics,代码行数:53,代码来源:execute_step_plan_widget.py

示例6: __init__

 def __init__(self, parent=None):
     super(ComboBoxDialog, self).__init__()
     self.number = 0
     vbox = QtGui.QVBoxLayout(self)
     self.combo_box = QComboBox(self)
     self.combo_box.activated.connect(self.onActivated)
     vbox.addWidget(self.combo_box)
     button = QPushButton()
     button.setText("Done")
     button.clicked.connect(self.buttonCallback)
     vbox.addWidget(button)
     self.setLayout(vbox)
开发者ID:CPFL,项目名称:jsk_visualization_packages,代码行数:12,代码来源:image_view2_wrapper.py

示例7: update_buttons

    def update_buttons(self):
        self.clean()
        for index, level in enumerate(self.levels):
            self.text_label.setText("Choose Level: ")
            button = QPushButton(level.level_id, self._widget)
            button.clicked[bool].connect(self.handle_button)
            button.setCheckable(True)
            self._button_layout.addWidget(button)
            self.buttons.append(button)

        # Subscribe to the current level we are on.
        if self.status_subscriber is None:
            self.status_subscriber = rospy.Subscriber("level_mux/current_level", LevelMetaData, self.process_level_status)
开发者ID:nj1407,项目名称:bwi_common,代码行数:13,代码来源:plugins.py

示例8: startPropertyEdit

    def startPropertyEdit(self):

        self.editing_properties = True
        self.edit_existing_location = self.edit_properties_location

        self.edit_area_button[LocationFunction.ADD_LOCATION_AREA].setEnabled(True)
        self.edit_area_button[LocationFunction.EDIT_EXISTING_AREA].setEnabled(True)

        # Construct the configuration layout.
        clearLayoutAndFixHeight(self.configuration_layout)

        self.update_name_label = QLabel("Location (" + self.edit_properties_location + ")      New Name: ", self.widget)
        self.configuration_layout.addWidget(self.update_name_label)

        self.update_name_textedit = QLineEdit(self.widget)
        self.update_name_textedit.setText(self.edit_properties_location)
        self.update_name_textedit.textEdited.connect(self.locationNameTextEdited)
        self.configuration_layout.addWidget(self.update_name_textedit)

        self.update_name_button = QPushButton("Update location Name", self.widget)
        self.update_name_button.clicked[bool].connect(self.updateLocationName)
        self.update_name_button.setEnabled(False)
        self.configuration_layout.addWidget(self.update_name_button)

        self.remove_location_button = QPushButton("Remove Location", self.widget)
        self.remove_location_button.clicked[bool].connect(self.removeCurrentLocation)
        self.configuration_layout.addWidget(self.remove_location_button)

        self.configuration_layout.addStretch(1)

        self.updateOverlay()
开发者ID:YuqianJiang,项目名称:bwi_common,代码行数:31,代码来源:location_function.py

示例9: __init__

    def __init__(self, parent):
        super(TimelineWidget, self).__init__()
        self.parent = parent

        self._layout = QHBoxLayout()

        #self._view = QGraphicsView()
        self._view = TimelineWidget.TimelineView(self)

        self._scene = QGraphicsScene()
        self._colors = [QColor('green'), QColor('yellow'), QColor('red')]

        self._messages = [None for x in range(20)]
        self._mq = [1 for x in range(20)] 

        self._view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._view.setScene(self._scene)
        self._layout.addWidget(self._view, 1)

        self.pause_button = QPushButton('Pause')
        self.pause_button.setCheckable(True)
        self.pause_button.clicked.connect(self.pause)
        self._layout.addWidget(self.pause_button)

        self.setLayout(self._layout)

        self.update.connect(self.redraw)
开发者ID:zklapow,项目名称:robot_monitor,代码行数:28,代码来源:robot_monitor.py

示例10: __init__

    def __init__(self, parent = None, logger = Logger()):
        QWidgetWithLogger.__init__(self, parent, logger)

        # start widget
        hbox = QHBoxLayout()
        hbox.setMargin(0)
        hbox.setContentsMargins(0, 0, 0, 0)

        # get system icon
        icon = QIcon.fromTheme("view-refresh")
        size = icon.actualSize(QSize(32, 32))

        # add combo box
        self.parameter_set_names_combo_box = QComboBox()
        self.parameter_set_names_combo_box.currentIndexChanged[str].connect(self.param_changed)
        hbox.addWidget(self.parameter_set_names_combo_box)

        # add refresh button
        self.get_all_parameter_set_names_button = QPushButton()
        self.get_all_parameter_set_names_button.clicked.connect(self._get_all_parameter_set_names)

        self.get_all_parameter_set_names_button.setIcon(icon)
        self.get_all_parameter_set_names_button.setFixedSize(size.width()+2, size.height()+2)

        hbox.addWidget(self.get_all_parameter_set_names_button)

        # end widget
        self.setLayout(hbox)

        # init widget
        self.reset_parameter_set_selection()
开发者ID:TRECVT,项目名称:vigir_footstep_planning_basics,代码行数:31,代码来源:parameter_set_widget.py

示例11: __init__

    def __init__(self):
        super(TopicSelection, self).__init__()
        master = rosgraph.Master('rqt_bag_recorder')
        self.setWindowTitle("Select the topics you want to record")
        self.resize(500, 700)

        self.topic_list = []
        self.selected_topics = []
        self.items_list = []

        self.area = QScrollArea(self)
        self.main_widget = QWidget(self.area)
        self.ok_button = QPushButton("Record", self)
        self.ok_button.clicked.connect(self.onButtonClicked)
        self.ok_button.setEnabled(False)

        self.main_vlayout = QVBoxLayout(self)
        self.main_vlayout.addWidget(self.area)
        self.main_vlayout.addWidget(self.ok_button)
        self.setLayout(self.main_vlayout)

        self.selection_vlayout = QVBoxLayout(self)
        self.item_all = QCheckBox("All", self)
        self.item_all.stateChanged.connect(self.updateList)
        self.selection_vlayout.addWidget(self.item_all)
        topic_data_list = master.getPublishedTopics('')
        topic_data_list.sort()
        for topic, datatype in topic_data_list:
            self.addCheckBox(topic)

        self.main_widget.setLayout(self.selection_vlayout)

        self.area.setWidget(self.main_widget)
        self.show()
开发者ID:OSUrobotics,项目名称:rqt_common_plugins,代码行数:34,代码来源:topic_selection.py

示例12: PathEditor

class PathEditor(QWidget):
    '''
    This is a path editor used as ItemDeligate in settings view. This editor
    provides an additional button for directory selection dialog.
    '''

    editing_finished_signal = Signal()

    def __init__(self, path, parent=None):
        QWidget.__init__(self, parent)
        self.path = path
        self._layout = QHBoxLayout(self)
        self._layout.setContentsMargins(0, 0, 0, 0)
        self._layout.setSpacing(0)
        self._button = QPushButton('...')
        self._button.setMaximumSize(QSize(24, 20))
        self._button.clicked.connect(self._on_path_select_clicked)
        self._layout.addWidget(self._button)
        self._lineedit = QLineEdit(path)
        self._lineedit.returnPressed.connect(self._on_editing_finished)
        self._layout.addWidget(self._lineedit)
        self.setLayout(self._layout)
        self.setFocusProxy(self._button)
        self.setAutoFillBackground(True)

    def _on_path_select_clicked(self):
        # Workaround for QFileDialog.getExistingDirectory because it do not
        # select the configuration folder in the dialog
        self.dialog = QFileDialog(self, caption='Select a new settings folder')
        self.dialog.setOption(QFileDialog.HideNameFilterDetails, True)
        self.dialog.setFileMode(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 _on_editing_finished(self):
        if self._lineedit.text():
            self.path = self._lineedit.text()
            self.editing_finished_signal.emit()
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:45,代码来源:settings_widget.py

示例13: __init__

 def __init__(self):
     super(Tester, self).__init__();
     vlayout = QVBoxLayout();
     self.testButton = QPushButton("Exactly one row of buttons");
     vlayout.addWidget(self.testButton);
     self.testButton.clicked.connect(self.exactlyOneRow);
     
     self.setLayout(vlayout);
     self.show();
开发者ID:ros-visualization,项目名称:speakeasy,代码行数:9,代码来源:buttonSetPopupSelector_ui.py

示例14: activateFunction

    def activateFunction(self):

        # Add all the necessary buttons to the subfunction layout.
        clearLayoutAndFixHeight(self.subfunction_layout)
        for button_text in [LocationFunction.ADD_LOCATION_AREA, 
                            LocationFunction.EDIT_EXISTING_AREA]:
            button = QPushButton(button_text, self.widget)
            button.clicked[bool].connect(partial(self.startAreaEdit, button_text))
            button.setCheckable(True)
            self.subfunction_layout.addWidget(button)
            self.edit_area_button[button_text] = button
        self.edit_area_button[LocationFunction.EDIT_EXISTING_AREA].setEnabled(False)
        self.subfunction_layout.addStretch(1)

        # ActivateMouseHooks.
        self.image.mousePressEvent = self.mousePressEvent
        self.image.mouseMoveEvent = self.mouseMoveEvent
        self.image.mouseReleaseEvent = self.mouseReleaseEvent

        self.updateOverlay()
开发者ID:YuqianJiang,项目名称:bwi_common,代码行数:20,代码来源:location_function.py

示例15: generate_task_buttons

    def generate_task_buttons(self, task_list):
        # remove existing tasks that aren't in received list
        # two steps to avoid modifying the dict while iterating
        tasks_to_remove = [name
                           for name in self._task_map
                           if name not in task_list]
        for name in tasks_to_remove:
            self._task_map[name].button.setParent(None)
            del self._task_map[name]

        # add received tasks that we don't have yet
        for name in task_list:
            if name not in self._task_map:
                button = QPushButton(name, self._widget.scrollAreaWidgetContents)
                button.clicked.connect(self.task_buttons_click_slot)
                button.setSizePolicy(QSizePolicy.MinimumExpanding,
                                     QSizePolicy.MinimumExpanding)
                self._layout.addWidget(button)
                self._task_map[name] = TaskInfo(name, button)

        self.refresh_button_highlighting()
开发者ID:felix-kolbe,项目名称:uashh-rvl-catkin-ros-pkg,代码行数:21,代码来源:task_control.py


注:本文中的python_qt_binding.QtGui.QPushButton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。