本文整理汇总了Python中python_qt_binding.QtGui.QPushButton.setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.setStyleSheet方法的具体用法?Python QPushButton.setStyleSheet怎么用?Python QPushButton.setStyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QPushButton
的用法示例。
在下文中一共展示了QPushButton.setStyleSheet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ButtonSetPopupSelector
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setStyleSheet [as 别名]
class ButtonSetPopupSelector(QDialog):
'''
An interactive dialog that displays successive sets of
buttons. When each set is displayed, user may ask for the
next available set, the previous. already seen set, or the
user may accept the currently displayed set. A cancel is
available as well.
The call and return protocol is as follows:
- The caller creates a fresh dialog instance of this class,
passing an iterator. The iterator's next() method returns
an array of ButtonProgram instances each time it is called. (When the
iterator is exhausted, the user is able to use a 'Previous'
button to view the previously seen sets again).
- The caller invokes the exec_() method on the dialog instance.
- The exec_() method returns:
- -1, if the iterator yielded no button label arrays at all.
- 0, if the user canceled, and
- 1 if the user accepted one of the sets.
- If the exec_() method returned 1, the caller may obtain an array with the
ButtonProgram instances of the currently showing (and therefore accepted) buttons.
The array is obtained from the dialog instance via method getCurrentlyShowingSetLabels(self).
'''
#------------------------------------------------------ Public Methods ---------------------------
def __init__(self, buttonProgramArrayIterator):
super(ButtonSetPopupSelector, self).__init__();
self.setStyleSheet(SpeakEasyGUI.stylesheetAppBG);
self.programButtonDict = {};
self.buttonProgramArrayIt = buttonProgramArrayIterator;
self.buttonProgramArrays = []; # saved ButtonProgram arrays
self.shownLabelArrays = [];
self.currentlyShowingSetIndex = None;
self.rootLayout = None;
self.cancelButton = QPushButton("Cancel");
self.cancelButton.setStyleSheet(SpeakEasyGUI.recorderButtonStylesheet);
self.cancelButton.setMinimumHeight(SpeakEasyGUI.BUTTON_MIN_HEIGHT);
#self.cancelButton.clicked.connect(partial(QDialog.done, self, 0));
self.cancelButton.clicked.connect(self.clickedCancelButton);
self.OKButton = QPushButton("Pick this One");
self.OKButton.setStyleSheet(SpeakEasyGUI.recorderButtonStylesheet);
self.OKButton.setMinimumHeight(SpeakEasyGUI.BUTTON_MIN_HEIGHT);
self.OKButton.clicked.connect(self.clickedOKButton);
self.currentNextPrevDirection = NextPrev.NEXT;
self.nextButton = QPushButton("Next");
self.nextButton.setStyleSheet(SpeakEasyGUI.recorderButtonStylesheet);
self.nextButton.setMinimumHeight(SpeakEasyGUI.BUTTON_MIN_HEIGHT);
self.nextButton.clicked.connect(self.clickedNextButton);
self.prevButton = QPushButton("Previous");
self.prevButton.setStyleSheet(SpeakEasyGUI.recorderButtonStylesheet);
self.prevButton.setMinimumHeight(SpeakEasyGUI.BUTTON_MIN_HEIGHT);
self.prevButton.clicked.connect(self.clickedPrevButton);
self.setNextPrevButtonsEnabledness();
self.endOfSetsLabel = QLabel("<b>No more button sets.</b>")
self.noSetsLabel = QLabel("<b>No button sets available.</b>")
self.noAvailableSets = False;
self.offerNewButtonSet();
def exec_(self):
'''
If the prior initialization revealed that the caller does not
deliver any sets of button labels at all, then return -1, without
displaying any dialog.
@return: -1 if no button sets available. 1 if user accepted one of the button
label sets as the one they want, or 0, if the user cancelled.
@rtype: int
'''
if self.noAvailableSets:
return -1;
return super(ButtonSetPopupSelector, self).exec_();
def getCurrentlyShowingSet(self):
'''
Returns an array of ButtonProgram instances that are currently showing on
the dialog, or were showing when the user clicked OK.
@return: Array of ButtonProgram instances.
@rtype: [ButtonProgram]
'''
return self.buttonProgramArrays[self.currentlyShowingSetIndex];
def getCurrentlyShowingSetLabels(self):
'''
Returns an array of labels of buttons that are currently showing on
the dialog, or were showing when the user clicked OK.
@return: Array of labels.
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setStyleSheet [as 别名]
class ControlModeWidget:
def __init__(self, context):
self.control_mode = 0
self.mode_pub = rospy.Publisher('/flor/controller/mode_command', VigirControlModeCommand, queue_size=10)
self._widget = context
self.vbox = QVBoxLayout()
#Add input for setting the spindle speed
list_label = QLabel("Select Control Mode")
self.vbox.addWidget(list_label)
# Indexed list of allowed control modes from feedback
self.allowed_modes = rospy.get_param("/atlas_controller/allowed_control_modes")
self.allowed_modes=rospy.get_param("/atlas_controller/allowed_control_modes")
self.mode_ids={}
self.mode_ids
for ndx,txt in enumerate(self.allowed_modes):
self.mode_ids[txt] = ndx
# API 2.13 ordering
self.bdi_mode_names=['NONE ', 'FREEZE ', 'STAND_PREP ', \
'STAND ', 'WALK ', 'STEP ', 'MANIPULATE ', \
'USER ', 'CALIBRATE ']
self.list_box = QListWidget(None)
self.list_box.addItems(self.allowed_modes)
self.list_box.currentItemChanged.connect(self.handle_selection_change)
self.vbox.addWidget(self.list_box)
self.selection_label = QLabel("Flor Selected: "+self.allowed_modes[0]+"("+str(self.control_mode)+")")
self.vbox.addWidget(self.selection_label)
self.label = QLabel("Flor Command : "+self.allowed_modes[0]+"("+str(self.control_mode)+")")
self.vbox.addWidget(self.label)
self.flor_mode = 0
self.bdi_current_mode = 0
self.bdi_desired_mode = 0
self.flor_mode_label = QLabel("Flor Mode : "+self.allowed_modes[self.flor_mode]+"("+str(self.flor_mode)+")"+" BDI:("+str(self.bdi_current_mode)+", "+str(self.bdi_desired_mode)+")")
self.vbox.addWidget(self.flor_mode_label)
#Add combo box for available settings
self.available_modes = QComboBox();
self.available_modes.addItem("");
self.available_modes.addItem("BDI");
self.available_modes.addItem("Enable Upper Body");
self.available_modes.addItem("Enable Whole Body");
self.available_modes.currentIndexChanged.connect(self.handle_avail_modes_changed)
self.vbox.addWidget(self.available_modes);
self.vbox.addStretch(1)
#Add Button for sending the behavior mode command
self.push_button = QPushButton("Set Mode")
self.push_button.clicked.connect(self.handle_set_mode)
self.vbox.addWidget(self.push_button)
self.vbox.addStretch(1)
hbox = QHBoxLayout()
hbox.addStretch(1)
self.stop_enable= QCheckBox()
self.stop_enable.setChecked(False)
hbox.addWidget(self.stop_enable)
self.stop_enable.clicked.connect(self.handle_stop_enable)
self.stop_button = QPushButton("STOP!")
self.stop_button.clicked.connect(self.handle_stop)
self.stop_button.setStyleSheet('QPushButton {background-color: gray }')
hbox.addWidget(self.stop_button)
hbox.addStretch(1)
self.vbox.addLayout(hbox)
self._widget.setLayout(self.vbox)
#add stretch at end so all GUI elements are at top of dialog
self.vbox.addStretch(1)
self.flor_mode_cmd_sub = rospy.Subscriber("/flor/controller/mode", FlorControlMode, self.florModeCallback)
def shutdown_plugin(self):
print "Shutting down ..."
self.flor_mode_cmd_sub.unregister()
self.mode_pub.unregister()
print "Done!"
# Update BDI state
def simStateCallback(self, state):
if ((self.bdi_current_state != state.current_behavior) or (self.bdi_desired_state != state.desired_behavior) or (self.bdi_error_code != state.error_code) or (self.bdi_behavior_status != state.behavior_feedback.status_flags) ):
self.bdi_current_state = state.current_behavior
self.bdi_desired_state = state.desired_behavior
self.bdi_error_code = state.error_code
#.........这里部分代码省略.........