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


Python QPushButton.setText方法代码示例

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


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

示例1: _create_tag_button

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setText [as 别名]
 def _create_tag_button(self, parent=None):
     btn = QPushButton(parent)
     btn.setObjectName("tagButton")
     btn.setText(self._translate("Add &tag"))
     btn.setShortcut("Ctrl+T")
     btn.setToolTip('Adds a ROS launch tag to launch file (Ctrl+T)')
     btn.setMenu(self._create_tag_menu(btn))
     btn.setFlat(True)
     return btn
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:11,代码来源:editor.py

示例2: __init__

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setText [as 别名]
 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,代码行数:14,代码来源:image_view2_wrapper.py

示例3: __init__

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setText [as 别名]
 def __init__(self, parent=None):
     super(LineEditDialog, self).__init__()
     self.value = None
     vbox = QtGui.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 = QtGui.QComboBox(self)
     self.line_edit = QtGui.QLineEdit()
     self.combo_box.setLineEdit(self.line_edit)
     self.combo_box.setCompleter(QtGui.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)
开发者ID:CPFL,项目名称:jsk_visualization_packages,代码行数:24,代码来源:button_general.py

示例4: QExecuteStepPlanWidget

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setText [as 别名]
class QExecuteStepPlanWidget(QWidgetWithLogger):

    step_plan_sub = None
    execute_step_plan_client = None
    step_plan = None

    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()

    def shutdown_plugin(self):
        print "Shutting down ..."
        if self.step_plan_sub is None:
            self.step_plan_sub.unregister()
        print "Done!"

    def _init_step_plan_subscriber(self, topic_name):
        if len(topic_name) > 0:
            if self.step_plan_sub is not None:
                self.step_plan_sub.unregister()
            self.step_plan_sub = rospy.Subscriber(topic_name, StepPlan, self.step_plan_callback)
            print "Step Plan topic changed: " + topic_name

    def _init_execute_action_client(self, topic_name):
        if len(topic_name) > 0:
            self.execute_step_plan_client = actionlib.SimpleActionClient(topic_name, ExecuteStepPlanAction)
            self.execute_command.setEnabled(self.step_plan is not None)
            self.repeat_command.setEnabled(False)
            self.stop_command.setEnabled(False)
            print "Execution topic changed: " + topic_name

    def step_plan_callback(self, step_plan):
        self.step_plan = step_plan
        self.execute_command.setText("Execute (Steps: " + str(len(step_plan.steps)) + ")")
        if len(step_plan.steps) > 0:
            self.execute_command.setEnabled(self.execute_step_plan_client is not None)
            self.repeat_command.setEnabled(False)

    def execute_command_callback(self):
        if (self.execute_step_plan_client.wait_for_server(rospy.Duration(0.5))):
            self.execute_command.setEnabled(False)
            self.repeat_command.setEnabled(True)
            self.stop_command.setEnabled(True)

            self.logger.log_info("Executing footstep plan...")
            goal = ExecuteStepPlanGoal()
            goal.step_plan = self.step_plan
            self.execute_step_plan_client.send_goal(goal)
        else:
            self.logger.log_error("Can't connect to footstep controller action server!")
#.........这里部分代码省略.........
开发者ID:TRECVT,项目名称:vigir_footstep_planning_basics,代码行数:103,代码来源:execute_step_plan_widget.py

示例5: Tester

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setText [as 别名]
class Tester(QDialog):
    '''
    Testing class. Invoked from main() of this file. Shows different
    button sets. Not automatic, must be run by hand.
    '''
    
    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();
        
    def exactlyOneRow(self):
        # Exactly one row even:    
        testButtonSetArray = [
                              ["Button1.1", "Button2.1", "Button3.1", "Button4.1"],
                              ["Button1.2", "Button2.2", "Button3.2", "Button4.2"],
                              ["Button1.3", "Button2.3", "Button3.3", "Button4.3"]
                              ];
        buttonSetChoiceDialog = ButtonSetPopupSelector(iter(testButtonSetArray));
        buttonSetChoiceDialog.show();
        choiceResult = buttonSetChoiceDialog.exec_();
        print "Choice result: " + str(choiceResult); 
        buttonSetChoiceDialog.deleteLater();
        
        # Rewire the test button for the next text:
        self.testButton.setText("One button available");
        self.testButton.clicked.disconnect(self.exactlyOneRow);
        self.testButton.clicked.connect(self.oneButtonAvailable);
        
    def oneButtonAvailable(self):
        # One button available
        testButtonSetArray = [["Single button."]];
        buttonSetChoiceDialog = ButtonSetPopupSelector(iter(testButtonSetArray));
        buttonSetChoiceDialog.show();
        choiceResult = buttonSetChoiceDialog.exec_();
        print "Choice result: " + str(choiceResult);
        buttonSetChoiceDialog.deleteLater();

        self.testButton.setText("No button set available");
        self.testButton.clicked.disconnect(self.oneButtonAvailable);        
        self.testButton.clicked.connect(self.noSetAvailable);
        
    def noSetAvailable(self):
        testButtonSetArray = [];
        buttonSetChoiceDialog = ButtonSetPopupSelector(iter(testButtonSetArray));
        #buttonSetChoiceDialog.show();
        choiceResult = buttonSetChoiceDialog.exec_();
        print "Choice result: " + str(choiceResult);
        buttonSetChoiceDialog.deleteLater();
        
        # Rewire the test button for the next text:
        self.testButton.setText("Exit");
        self.testButton.clicked.disconnect(self.noSetAvailable);        
        self.testButton.clicked.connect(self.close);
        
    def exitApp(self):
        self.close();
开发者ID:ros-visualization,项目名称:speakeasy,代码行数:64,代码来源:buttonSetPopupSelector_ui.py

示例6: Editor

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setText [as 别名]
class Editor(QMainWindow):
    '''
    Creates a dialog to edit a launch file.
    '''
    finished_signal = Signal(list)
    '''
    finished_signal has as parameter the filenames of the initialization and is emitted, if this
    dialog was closed.
    '''

    def __init__(self, filenames, search_text='', parent=None):
        '''
        @param filenames: a list with filenames. The last one will be activated.
        @type filenames: C{[str, ...]}
        @param search_text: if not empty, searches in new document for first occurrence of the given text
        @type search_text: C{str} (Default: C{Empty String})
        '''
        QMainWindow.__init__(self, parent)
        self.setObjectName(' - '.join(['Editor', str(filenames)]))
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setWindowFlags(Qt.Window)
        self.mIcon = QIcon(":/icons/crystal_clear_edit_launch.png")
        self._error_icon = QIcon(":/icons/crystal_clear_warning.png")
        self._empty_icon = QIcon()
        self.setWindowIcon(self.mIcon)
        window_title = "ROSLaunch Editor"
        if filenames:
            window_title = self.__getTabName(filenames[0])
        self.setWindowTitle(window_title)
        self.init_filenames = list(filenames)
        self._search_thread = None
        # list with all open files
        self.files = []
        # create tabs for files
        self.main_widget = QWidget(self)
        self.verticalLayout = QVBoxLayout(self.main_widget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setSpacing(1)
        self.verticalLayout.setObjectName("verticalLayout")

        self.tabWidget = EditorTabWidget(self)
        self.tabWidget.setTabPosition(QTabWidget.North)
        self.tabWidget.setDocumentMode(True)
        self.tabWidget.setTabsClosable(True)
        self.tabWidget.setMovable(False)
        self.tabWidget.setObjectName("tabWidget")
        self.tabWidget.tabCloseRequested.connect(self.on_close_tab)

        self.verticalLayout.addWidget(self.tabWidget)
        self.buttons = self._create_buttons()
        self.verticalLayout.addWidget(self.buttons)
        self.setCentralWidget(self.main_widget)

        self.find_dialog = TextSearchFrame(self.tabWidget, self)
        self.find_dialog.search_result_signal.connect(self.on_search_result)
        self.find_dialog.replace_signal.connect(self.on_replace)
        self.addDockWidget(Qt.RightDockWidgetArea, self.find_dialog)
        # open the files
        for f in filenames:
            if f:
                self.on_load_request(os.path.normpath(f), search_text)
        self.readSettings()
        self.find_dialog.setVisible(False)

#  def __del__(self):
#    print "******** destroy", self.objectName()

    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)')
#.........这里部分代码省略.........
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:103,代码来源:editor.py

示例7: CapabilityControlWidget

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setText [as 别名]
class CapabilityControlWidget(QFrame):
    '''
    The control widget contains buttons for control a capability. Currently this
    are C{On} and C{Off} buttons. Additionally, the state of the capability is
    color coded.
    '''

    start_nodes_signal = Signal(str, str, list)
    '''@ivar: the signal is emitted to start on host(described by masteruri) the nodes described in the list, Parameter(masteruri, config, nodes).'''

    stop_nodes_signal = Signal(str, list)
    '''@ivar: the signal is emitted to stop on masteruri the nodes described in the list.'''

    def __init__(self, masteruri, cfg, ns, nodes, parent=None):
        QFrame.__init__(self, parent)
        self._masteruri = masteruri
        self._nodes = {cfg: {ns: nodes}}
        frame_layout = QVBoxLayout(self)
        frame_layout.setContentsMargins(0, 0, 0, 0)
        # create frame for warning label
        self.warning_frame = warning_frame = QFrame(self)
        warning_layout = QHBoxLayout(warning_frame)
        warning_layout.setContentsMargins(0, 0, 0, 0)
        warning_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.warning_label = QLabel()
        icon = QIcon(':/icons/crystal_clear_warning.png')
        self.warning_label.setPixmap(icon.pixmap(QSize(40, 40)))
        self.warning_label.setToolTip('Multiple configuration for same node found!\nA first one will be selected for the start a node!')
        warning_layout.addWidget(self.warning_label)
        warning_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        frame_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        frame_layout.addWidget(warning_frame)
        # create frame for start/stop buttons
        buttons_frame = QFrame()
        buttons_layout = QHBoxLayout(buttons_frame)
        buttons_layout.setContentsMargins(0, 0, 0, 0)
        buttons_layout.addItem(QSpacerItem(20, 20))
        self.on_button = QPushButton()
        self.on_button.setFlat(False)
        self.on_button.setText("On")
        self.on_button.clicked.connect(self.on_on_clicked)
        buttons_layout.addWidget(self.on_button)

        self.off_button = QPushButton()
        self.off_button.setFlat(True)
        self.off_button.setText("Off")
        self.off_button.clicked.connect(self.on_off_clicked)
        buttons_layout.addWidget(self.off_button)
        buttons_layout.addItem(QSpacerItem(20, 20))
        frame_layout.addWidget(buttons_frame)
        frame_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.warning_frame.setVisible(False)

    def hasConfigs(self):
        '''
        @return: True, if a configurations for this widget are available.
        @rtype: bool
        '''
        return len(self._nodes) > 0

    def nodes(self, cfg=''):
        '''
        @return: the list with nodes required by this capability. The nodes are
        defined by ROS full name.
        @rtype: C{[str]}
        '''
        try:
            if cfg:
                return [n for l in self._nodes[cfg].itervalues() for n in l]
            else:
                return [n for c in self._nodes.itervalues() for l in c.itervalues() for n in l]
        except:
            return []

    def setNodeState(self, running_nodes, stopped_nodes, error_nodes):
        '''
        Sets the state of this capability.
        @param running_nodes: a list with running nodes.
        @type running_nodes: C{[str]}
        @param stopped_nodes: a list with not running nodes.
        @type stopped_nodes: C{[str]}
        @param error_nodes: a list with nodes having a problem.
        @type error_nodes: C{[str]}
        '''
        self.setAutoFillBackground(True)
        self.setBackgroundRole(QPalette.Base)
        palette = QPalette()
        if error_nodes:
            brush = QBrush(QColor(255, 100, 0))
        elif running_nodes and stopped_nodes:
            brush = QBrush(QColor(140, 185, 255))  # 30, 50, 255
        elif running_nodes:
            self.on_button.setFlat(True)
            self.off_button.setFlat(False)
            brush = QBrush(QColor(59, 223, 18))  # 59, 223, 18
        else:
            brush = QBrush(QColor(255, 255, 255))
            self.on_button.setFlat(False)
            self.off_button.setFlat(True)
        palette.setBrush(QPalette.Active, QPalette.Base, brush)
#.........这里部分代码省略.........
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:103,代码来源:capability_table.py

示例8: Top

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setText [as 别名]

#.........这里部分代码省略.........

                self.merge_ind = 0
                self.merge_width = 2 * self.merge_width
                self._i0 = self.merge_ind
                self._i1 = min(self.merge_ind + self.merge_width, self.length)
                self._j = self.merge_ind
                print "ALL LISTS ARE MERGED"
                print self.traj_list
                self.merge_traj_files()
        else:
            print "ALL TRAJECTORIES ARE RANKED"
            f_ = open('ranked_traj.txt','w')
            for item in self.traj_list:
                f_.write("%s\n" % item)
            f_.close()


    def merge(self):
        print self._i0
        print self._i1
        try:
            self.fileA = self.traj_list[self._i0]
            self.fileB = self.traj_list[self._i1]
        except:
            try:
                self.fileA = self.work_list[0]
                self.fileB = self.work_list[min(2 * self.merge_width, self.length)]
            except:
                self.fileA = self.traj_list[0]
                self.fileB = self.traj_list[1]
        print " new files assigned are: %s, %s " % (self.fileA, self.fileB)
        


    def _play_traj_A(self):
        if (self.paused):
            self._pause_btn.setText("Pause current trajectory")
            self.paused = False
        req = UiState(Header(), self.fileA, True, False,-1)
        resp = self.play_traj(req)


    def _change_slider_A(self):
        self._slider_B.setValue(0)
        req = UiState(Header(), self.fileA, False, True, float(self._slider_A.value()))
        resp = self.play_traj(req)


    def _play_traj_B(self):
        if (self.paused):
            self._pause_btn.setText("Pause current trajectory")
            self.paused = False
        req = UiState(Header(), self.fileB, True, False,-1)
        resp = self.play_traj(req)


    def _change_slider_B(self):
        self._slider_A.setValue(0)
        req = UiState(Header(), self.fileB, False, True, float(self._slider_B.value()))
        resp = self.play_traj(req)


    def _pause_traj(self):
        if (self.paused):
            req = UiState(Header(), "", False, False,-1)
            resp = self.play_traj(req)
            self._pause_btn.setText("Pause current trajectory")
            self.paused = False
        else:
            req = UiState(Header(), "", False, True,-1)
            resp = self.play_traj(req)
            self._pause_btn.setText("Continue playing current trajectory")
            self.paused = True


    def _pick_traj_A(self):
        self.comp_res = True
        self.valid_comp = True
        self.merge_traj_files()

    def _pick_traj_B(self):
        self.comp_res = False
        self.valid_comp = True
        self.merge_traj_files()


    def _pick_none(self):
        #reinvoke the traj ranodm generator
        self.rand_traj_files()
    

    # produce two new filenames from the trajectory directory
    def rand_traj_files(self):
        first_to_pick = random.randint(0,len(self.traj_list)-1)
        while (True):
            second_to_pick = random.randint(0,len(self.traj_list)-1)
            if (second_to_pick != first_to_pick):
                break
        self.fileA = self.traj_list[first_to_pick]
        self.fileB = self.traj_list[second_to_pick]
开发者ID:GartStav,项目名称:LfHP,代码行数:104,代码来源:pick_traj.py


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