本文整理汇总了Python中python_qt_binding.QtGui.QPushButton.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.setSizePolicy方法的具体用法?Python QPushButton.setSizePolicy怎么用?Python QPushButton.setSizePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QPushButton
的用法示例。
在下文中一共展示了QPushButton.setSizePolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_task_buttons
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setSizePolicy [as 别名]
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()
示例2: TaskControl
# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setSizePolicy [as 别名]
class TaskControl(Plugin):
_receive_task_list_signal = Signal(list)
_refresh_button_highlighting_signal = Signal()
state_colors = {GoalStatus.PENDING: 'greenyellow',
GoalStatus.ACTIVE: 'yellow',
GoalStatus.PREEMPTED: 'orangered',
GoalStatus.SUCCEEDED: 'lightgreen',
GoalStatus.ABORTED: 'red',
GoalStatus.REJECTED: 'darkred',
GoalStatus.PREEMPTING: 'darkorange',
GoalStatus.RECALLING: 'violet',
GoalStatus.RECALLED: 'darkviolet',
GoalStatus.LOST: 'MediumSlateBlue'}
def __init__(self, context):
super(TaskControl, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('TaskControl')
# 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 = QWidget()
rp = rospkg.RosPack()
ui_file = os.path.join(rp.get_path('rqt_task_control'), 'resource', 'task_control.ui')
# Extend the widget with all attributes and children from UI file
loadUi(ui_file, self._widget)
# Give QObjects reasonable names
self._widget.setObjectName('TaskControlWidget')
# 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)
# Data
self._task_map = {} # mapping id strings to TaskInfo objects
self._active_task_name = None
# Additional widgets
self._layout = QBoxLayout(QBoxLayout.TopToBottom)
self._widget.scrollAreaWidgetContents.setLayout(self._layout)
self._cancel_button = QPushButton('cancel all tasks', self._widget.scrollAreaWidgetContents)
self._cancel_button.clicked.connect(self.cancel_button_click_slot)
self._cancel_button.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.MinimumExpanding)
self._layout.addWidget(self._cancel_button)
# Signals
self._receive_task_list_signal.connect(self.receive_task_list_slot)
self._refresh_button_highlighting_signal.connect(self.refresh_button_highlighting)
# ROS
self._task_list_sub = rospy.Subscriber('/task/available_tasks', String, self.task_list_callback)
self._task_pub = rospy.Publisher('/task', String)
self._action_client = SimpleActionClient('activate_task', TaskActivationAction)
def task_list_callback(self, msg):
task_list = [task.strip() for task in msg.data.split(',')]
rospy.logdebug("received tasks list: %s", msg)
self._receive_task_list_signal.emit(task_list)
@Slot(list)
def receive_task_list_slot(self, task_list):
rospy.logdebug("slot received task list: %s", task_list)
self.generate_task_buttons(task_list)
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
#.........这里部分代码省略.........