本文整理汇总了Python中python_qt_binding.QtGui.QWidget.setLayout方法的典型用法代码示例。如果您正苦于以下问题:Python QWidget.setLayout方法的具体用法?Python QWidget.setLayout怎么用?Python QWidget.setLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QWidget
的用法示例。
在下文中一共展示了QWidget.setLayout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restore_settings
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
def restore_settings(self, settings):
serial_number = settings.value('parent', None)
#print 'DockWidget.restore_settings()', 'parent', serial_number, 'settings group', settings._group
if serial_number is not None:
serial_number = int(serial_number)
if self._parent_container_serial_number() != serial_number and self._container_manager is not None:
floating = self.isFloating()
pos = self.pos()
new_container = self._container_manager.get_container(serial_number)
if new_container is not None:
new_parent = new_container.main_window
else:
new_parent = self._container_manager.get_root_main_window()
area = self.parent().dockWidgetArea(self)
new_parent.addDockWidget(area, self)
if floating:
self.setFloating(floating)
self.move(pos)
title_bar = self.titleBarWidget()
title_bar.restore_settings(settings)
if title_bar.hide_title_bar and not self.features() & DockWidget.DockWidgetFloatable and \
not self.features() & DockWidget.DockWidgetMovable:
self._title_bar_backup = title_bar
title_widget = QWidget(self)
layout = QHBoxLayout(title_widget)
layout.setContentsMargins(0, 0, 0, 0)
title_widget.setLayout(layout)
self.setTitleBarWidget(title_widget)
示例2: GhostRobotControlPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class GhostRobotControlPlugin(Plugin):
updateStateSignal = Signal(object)
def __init__(self, context):
super(GhostRobotControlPlugin, self).__init__(context)
self.setObjectName('GhostRobotControlPlugin')
self.joint_states_to_ghost_pub = rospy.Publisher('/joint_states_to_ghost', JointState, queue_size=10)
self.ghost_joint_states_sub = rospy.Subscriber('/ghost/joint_states', JointState, self.ghost_joint_states_cb)
self.real_joint_states_sub = rospy.Subscriber('/atlas/joint_states', JointState, self.real_joint_states_cb)
self.ghost_joint_states = JointState()
self.real_joint_states = JointState()
self.move_real_robot = False
self.widget = QWidget()
vbox = QVBoxLayout()
self.real_to_ghost_push_button = QPushButton('Set Ghost from real robot')
self.real_to_ghost_push_button.clicked.connect(self.handle_set_real_to_ghost)
vbox.addWidget(self.real_to_ghost_push_button)
self.send_motion_plan_to_real_robot_check_box = QCheckBox('Motion GUI moves real robot')
self.send_motion_plan_to_real_robot_check_box.stateChanged.connect(self.handle_send_motion_plan_to_real_robot_check_box)
vbox.addWidget(self.send_motion_plan_to_real_robot_check_box)
self.widget.setLayout(vbox)
context.add_widget(self.widget)
def ghost_joint_states_cb(self, data):
self.ghost_joint_states = data
def real_joint_states_cb(self, data):
self.real_joint_states = data
def handle_set_real_to_ghost(self):
self.joint_states_to_ghost_pub.publish(self.real_joint_states)
@Slot(bool)
def handle_send_motion_plan_to_real_robot_check_box(self, checked):
self.move_real_robot = checked
示例3: TriangleGUI
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class TriangleGUI(Plugin):
def __init__(self, context):
super(TriangleGUI, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('TriangleGUI')
# 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())
self._toolbar = QToolBar()
self._toolbar.addWidget(QLabel('Triangle'))
# Create a container widget and give it a layout
self._container = QWidget()
self._layout = QVBoxLayout()
self._container.setLayout(self._layout)
self._layout.addWidget(self._toolbar)
# Add a button for killing nodes
self._go_button = QPushButton('Go')
self._go_button.clicked.connect(self._go)
self._layout.addWidget(self._go_button)
self._clear_button = QPushButton('Clear')
self._clear_button.clicked.connect(self._clear)
self._layout.addWidget(self._clear_button)
# self._step_run_button.setStyleSheet('QPushButton {color: black}')
context.add_widget(self._container)
def _go(self):
go = rospy.ServiceProxy('/triangle_screenpoint/go', Empty)
go()
def _clear(self):
clear = rospy.ServiceProxy('/triangle_screenpoint/cancel', Empty)
clear()
def shutdown_plugin(self):
pass
def save_settings(self, plugin_settings, instance_settings):
pass
def restore_settings(self, plugin_settings, instance_settings):
pass
示例4: __init__
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
def __init__(self, context):
super(BiasCalibrationDialog, self).__init__(context)
self.setObjectName('BiasCalibrationDialog')
self._widget = QWidget()
vbox = QVBoxLayout()
controller_widget = QWidget()
hbox = QHBoxLayout()
# Left to right layout
self.joint_control = JointBias(self, roslib.packages.get_pkg_dir('vigir_rqt_bias_calibration') + '/launch/joints.txt',hbox)
controller_widget.setLayout(hbox)
self.marker = Marker()
self.marker.header.frame_id = "/world"
self.marker.type = self.marker.CUBE
self.marker.action = self.marker.ADD
self.marker.scale.x = 14.0
self.marker.scale.y = 14.0
self.marker.scale.z = 0.02
self.marker.color.a = 0.25
self.marker.color.r = 1.0
self.marker.color.g = 1.0
self.marker.color.b = 0.0
#self.marker.points = [[0.0, 0.0, 0.0], [7.0, -4.0, 0.0], [7.0, 4.0, 0.0]]
self.marker.pose.orientation.w = 1.0
self.marker.pose.position.x = 0.0
self.marker.pose.position.y = 0.0
self.marker.pose.position.z = 0.0
self.bias_pub = rospy.Publisher('/flor/controller/atlas_biases', JointState, queue_size=10)
self.flor_marker_pub = rospy.Publisher('/flor_plane_marker', Marker, queue_size=10)
self.feet_state_sub = rospy.Subscriber('/atlas/atlas_sim_interface_state', AtlasSimInterfaceState, self.stateCallbackFnc)
vbox.addWidget(controller_widget)
self.save_button = QPushButton("Save Biases")
self.save_button.pressed.connect(self.on_savePressed)
vbox.addWidget(self.save_button)
self._widget.setLayout(vbox)
context.add_widget(self._widget)
示例5: EusGUI
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class EusGUI(Plugin):
def __init__(self, context):
super(EusGUI, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('EusGUI')
self.msg = None
# Create a container widget and give it a layout
self._toolbar = QToolBar()
self._toolbar.addWidget(QLabel('EusGUI'))
self._container = QWidget()
self._layout = QVBoxLayout()
self._container.setLayout(self._layout)
self._layout.addWidget(self._toolbar)
self._prev_button = QPushButton('PREV')
self._prev_button.clicked.connect(self._prev_cb)
self._layout.addWidget(self._prev_button)
self._refresh_button = QPushButton('DO IT AGAIN')
self._refresh_button.clicked.connect(self._refresh_cb)
self._layout.addWidget(self._refresh_button)
self._next_button = QPushButton('NEXT')
self._next_button.clicked.connect(self._next_cb)
self._layout.addWidget(self._next_button)
context.add_widget(self._container)
def _prev_cb(self):
func = rospy.ServiceProxy('prev', Empty)
func()
def _next_cb(self):
func = rospy.ServiceProxy('next', Empty)
func()
def _refresh_cb(self):
func = rospy.ServiceProxy('refresh', Empty)
func()
def shutdown_plugin(self):
pass
def save_settings(self, plugin_settings, instance_settings):
pass
def restore_settings(self, plugin_settings, instance_settings):
pass
示例6: MotionEditorPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class MotionEditorPlugin(Plugin):
updateStateSignal = Signal(object)
def __init__(self, context):
super(MotionEditorPlugin, self).__init__(context)
self.setObjectName('MotionEditorPlugin')
config_loader = RobotConfigLoader()
try:
robot_config_name = rospy.get_param('/motion_editor/robot_config')
except KeyError:
rospy.logwarn('Could not find robot config param in /motion_editor/robot_config. Using default config for '
'Thor Mang.')
robot_config_name = 'thor'
config_loader.load_xml_by_name(robot_config_name + '_config.xml')
motion_publishers = {}
for target in config_loader.targets:
motion_publishers[target.name] = MotionPublisher(config_loader.robot_config, target.joint_state_topic, target.publisher_prefix)
input_output_selector = InputOutputSelectorWidget(motion_publishers)
self._motion_editor = MotionEditorWidget(input_output_selector, config_loader.robot_config)
position_editor = PositionEditorWidget(input_output_selector, config_loader.robot_config)
position_editor.position_list_updated.connect(self._motion_editor.update_positions_lists)
position_editor.position_list_updated.emit(position_editor._position_data)
self._motion_editor.position_renamed.connect(position_editor.on_position_renamed)
layout = QVBoxLayout()
layout.addWidget(input_output_selector)
layout.addWidget(position_editor)
layout.addWidget(self._motion_editor)
self._widget = QWidget()
self._widget.setLayout(layout)
context.add_widget(self._widget)
def save_settings(self, plugin_settings, instance_settings):
self._motion_editor.save_settings(plugin_settings, instance_settings)
def restore_settings(self, plugin_settings, instance_settings):
self._motion_editor.restore_settings(plugin_settings, instance_settings)
示例7: TabGroup
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class TabGroup(GroupWidget):
def __init__(self, parent, updater, config, nodename):
super(TabGroup, self).__init__(updater, config, nodename)
self.parent = parent
if not self.parent.tab_bar:
self.parent.tab_bar = QTabWidget()
self.wid = QWidget()
self.wid.setLayout(self.grid)
parent.tab_bar.addTab(self.wid, self.param_name)
def display(self, grid):
if not self.parent.tab_bar_shown:
grid.addRow(self.parent.tab_bar)
self.parent.tab_bar_shown = True
def close(self):
super(TabGroup, self).close()
self.parent.tab_bar = None
self.parent.tab_bar_shown = False
示例8: WoZPlugin
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class WoZPlugin(Plugin):
def __init__(self, context):
super(WoZPlugin, self).__init__(context)
self._widget = QWidget()
self._widget.setFixedSize(600, 600)
QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
large_box = QtGui.QVBoxLayout()
#Button for outreaching to recieve book from Human
button_box = QtGui.QVBoxLayout()
box_1 = QtGui.QHBoxLayout()
box_2 = QtGui.QHBoxLayout()
box_3 = QtGui.QHBoxLayout()
box_4 = QtGui.QHBoxLayout()
box_5 = QtGui.QHBoxLayout()
box_6 = QtGui.QHBoxLayout()
box_7 = QtGui.QHBoxLayout()
box_8 = QtGui.QHBoxLayout()
box_9 = QtGui.QHBoxLayout()
box_10 = QtGui.QHBoxLayout()
box_1.addWidget(self.create_button('print nice', self.printCallback))
self._widget.setObjectName('TrashbotGUI')
self._widget.setLayout(large_box)
context.add_widget(self._widget)
def create_button(self, name, callback):
btn = QtGui.QPushButton(name, self._widget)
btn.clicked.connect(callback)
btn.setAutoRepeat(True)
return btn
def printCallback(self):
print 'nice'
示例9: StableStepDialog
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class StableStepDialog(Plugin):
def __init__(self, context):
super(StableStepDialog, self).__init__(context)
self.setObjectName('StableStepDialog')
self.bdi_state_msg = AtlasSimInterfaceState()
self.footstep_plan = rospy.Publisher('/flor/controller/footstep_plan',AtlasFootstepPlan, None, False, True, None, queue_size=10)
self.bdi_state_sub = rospy.Subscriber("/atlas/atlas_sim_interface_state", AtlasSimInterfaceState, self.simStateCallback)
self._widget = QWidget()
vbox = QVBoxLayout()
apply_command = QPushButton("Re-Center Steps")
apply_command.clicked.connect(self.apply_command_callback)
vbox.addWidget(apply_command)
vbox.addStretch(1)
self._widget.setLayout(vbox)
context.add_widget(self._widget)
def shutdown_plugin(self):
print "Shutting down ..."
self.footstep_plan.unregister()
self.bdi_state_sub.unregister()
print "Done!"
def apply_command_callback(self):
print "Generate re-centering footsteps ..."
steps = []
L = 0.15 #self.params["Forward Stride Length"]["value"]
L_lat = 0.15 #self.params["Lateral Stride Length"]["value"]
W = 0.25 #self.params["Stride Width"]["value"]
dX = copy.deepcopy(self.bdi_state_msg.foot_pos_est[1].position.x - self.bdi_state_msg.foot_pos_est[0].position.x)
dY = copy.deepcopy(self.bdi_state_msg.foot_pos_est[1].position.y - self.bdi_state_msg.foot_pos_est[0].position.y)
dW = math.sqrt(dX*dX + dY*dY)
if (dW < 0.01):
print "Invalid starting feet position! dW=",dW
return
if (math.fabs(dW-W) < 0.01):
print "Feet are OK as is - publish empty plan !"
footstep_plan = AtlasFootStepPlan()
footstep_plan.header.stamp = rospy.get_rostime()
footstep_plan.pos_est = self.bdi_state_msg.pos_est
footstep_plan.step_plan = []
self.footstep_plan.publish(footstep_plan)
else:
# Need to centering step
center_x = copy.deepcopy(self.bdi_state_msg.foot_pos_est[0].position.x + 0.5*dX)
center_y = copy.deepcopy(self.bdi_state_msg.foot_pos_est[0].position.y + 0.5*dY)
# unit vector pointing from left foot to right
dx = dX/dW
dy = dY/dW
left_x = copy.deepcopy(center_x - W*0.5*dx - 0.1*dy)
left_y = copy.deepcopy(center_y - W*0.5*dy + 0.1*dx)
right_x = copy.deepcopy(center_x + W*0.5*dx - 0.1*dy)
right_y = copy.deepcopy(center_y + W*0.5*dy + 0.1*dx)
# Right stance
home_step = VigirBehaviorStepData()
home_step.step_index = 0
home_step.foot_index = 1
home_step.pose = copy.deepcopy(self.bdi_state_msg.foot_pos_est[1]) # use right as dummy footstep to calc offset properly
home_step.duration = 0.6
home_step.swing_height = 0.1
steps.append(home_step)
# Left mid point
home_step = VigirBehaviorStepData()
home_step.step_index = 1
home_step.foot_index = 0
home_step.pose = copy.deepcopy(self.bdi_state_msg.foot_pos_est[0]) # use right as dummy footstep to calc offset properly
home_step.pose.position.x = copy.deepcopy(0.5*(self.bdi_state_msg.foot_pos_est[0].position.x + left_x))
home_step.pose.position.y = copy.deepcopy(0.5*(self.bdi_state_msg.foot_pos_est[0].position.y + left_y))
home_step.duration = 0.6
home_step.swing_height = 0.1
steps.append(home_step)
# Right mid point
home_step = VigirBehaviorStepData()
home_step.step_index = 2
home_step.foot_index = 1
home_step.pose = copy.deepcopy(self.bdi_state_msg.foot_pos_est[1]) # use right as dummy footstep to calc offset properly
home_step.pose.position.x = 0.5*(self.bdi_state_msg.foot_pos_est[1].position.x + right_x)
home_step.pose.position.y = 0.5*(self.bdi_state_msg.foot_pos_est[1].position.y + right_y)
home_step.duration = 0.6
home_step.swing_height = 0.1
steps.append(home_step)
# Left center
home_step = VigirBehaviorStepData()
home_step.step_index = 3
#.........这里部分代码省略.........
示例10: QComboBox
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
combo = QComboBox()
combo.setEditable(True)
combo_completer = TopicCompleter(combo)
#combo_completer.setCompletionMode(QCompleter.InlineCompletion)
combo.lineEdit().setCompleter(combo_completer)
model_tree = QTreeView()
model_tree.setModel(combo_completer.model())
model_tree.expandAll()
for column in range(combo_completer.model().columnCount()):
model_tree.resizeColumnToContents(column)
completion_tree = QTreeView()
completion_tree.setModel(combo_completer.completionModel())
completion_tree.expandAll()
for column in range(combo_completer.completionModel().columnCount()):
completion_tree.resizeColumnToContents(column)
layout.addWidget(model_tree)
layout.addWidget(completion_tree)
layout.addWidget(edit)
layout.addWidget(combo)
layout.setStretchFactor(model_tree, 1)
widget.setLayout(layout)
mw.setCentralWidget(widget)
mw.move(300, 0)
mw.resize(800, 900)
mw.show()
app.exec_()
示例11: SystemCommandDialog
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class SystemCommandDialog(Plugin):
def __init__(self, context):
super(SystemCommandDialog, self).__init__(context)
self.setObjectName('SystemCommandDialog')
self.sys_command_pub = rospy.Publisher('/syscommand',String, None, False, True, None, queue_size=10)
self._widget = QWidget()
vbox = QVBoxLayout()
reset_world_command = QPushButton("Reset World Model")
reset_world_command.clicked.connect(self.apply_reset_world_command_callback)
vbox.addWidget(reset_world_command)
save_octomap = QPushButton("Save Octomap")
save_octomap.clicked.connect(self.apply_save_octomap_command_callback)
vbox.addWidget(save_octomap)
save_pointcloud = QPushButton("Save Pointcloud")
save_pointcloud.clicked.connect(self.apply_save_pointcloud_command_callback)
vbox.addWidget(save_pointcloud)
save_image_left_eye = QPushButton("Save Image Head")
save_image_left_eye.clicked.connect(self.apply_save_image_left_eye_command_callback)
vbox.addWidget(save_image_left_eye)
save_image_left_hand = QPushButton("Save Left Hand Image")
save_image_left_hand.clicked.connect(self.apply_save_image_left_hand_command_callback)
vbox.addWidget(save_image_left_hand)
save_image_right_hand = QPushButton("Save Right Hand Image")
save_image_right_hand.clicked.connect(self.apply_save_image_right_hand_command_callback)
vbox.addWidget(save_image_right_hand)
vbox.addStretch(1)
self._widget.setLayout(vbox)
context.add_widget(self._widget)
def shutdown_plugin(self):
print "Shutting down ..."
self.sys_command_pub.unregister()
print "Done!"
# Define system command strings
def apply_reset_world_command_callback(self):
msg = String("reset")
print "Send system command = <",msg.data,">"
self.sys_command_pub.publish(msg)
def apply_save_octomap_command_callback(self):
msg = String("save_octomap")
print "Send system command = <",msg.data,">"
self.sys_command_pub.publish(msg)
def apply_save_pointcloud_command_callback(self):
msg = String("save_pointcloud")
print "Send system command = <",msg.data,">"
self.sys_command_pub.publish(msg)
def apply_save_image_left_eye_command_callback(self):
msg = String("save_image_left_eye")
print "Send system command = <",msg.data,">"
self.sys_command_pub.publish(msg)
def apply_save_image_left_hand_command_callback(self):
msg = String("save_image_left_hand")
print "Send system command = <",msg.data,">"
self.sys_command_pub.publish(msg)
def apply_save_image_right_hand_command_callback(self):
msg = String("save_image_right_hand")
print "Send system command = <",msg.data,">"
self.sys_command_pub.publish(msg)
示例12: TrapezoidalTrajectoryDialog
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
#.........这里部分代码省略.........
vbox_ramp_down.addWidget(QLabel("Down"))
self.ramp_down_time_spinbox = QDoubleSpinBox()
self.ramp_down_time_spinbox.setDecimals(5)
self.ramp_down_time_spinbox.setRange(0, 10.0)
self.ramp_down_time_spinbox.setSingleStep(0.1)
self.ramp_down_time_spinbox.valueChanged.connect(self.on_ramp_down_time_value)
self.ramp_down_time_spinbox.setValue(self.ramp_down_time)
vbox_ramp_down.addWidget(self.ramp_down_time_spinbox)
time_hbox.addLayout(vbox_ramp_down)
vbox_hold = QVBoxLayout()
vbox_hold.addWidget(QLabel("Hold"))
self.hold_time_spinbox = QDoubleSpinBox()
self.hold_time_spinbox.setDecimals(5)
self.hold_time_spinbox.setRange(0, 10.0)
self.hold_time_spinbox.setSingleStep(0.1)
self.hold_time_spinbox.valueChanged.connect(self.on_hold_time_value)
self.hold_time_spinbox.setValue(self.hold_time)
vbox_hold.addWidget(self.hold_time_spinbox)
time_hbox.addLayout(vbox_hold)
vbox.addLayout(time_hbox)
# Joints title
title_frame = QFrame()
title_frame.setFrameShape(QFrame.StyledPanel)
title_frame.setFrameShadow(QFrame.Raised)
title_hbox = QHBoxLayout()
title_hbox.addWidget(QLabel("Joints"))
title_hbox.addWidget(QLabel("Start"))
title_hbox.addWidget(QLabel("Ramp Up"))
title_hbox.addWidget(QLabel("Ramp Down"))
title_frame.setLayout(title_hbox)
vbox.addWidget(title_frame)
# Define the widgets for each joint
for i, joint in enumerate(self.chain):
# print i,",",joint
self.joint_widget(vbox, i)
# add stretch at end so all GUI elements are at top of dialog
vbox.addStretch(1)
self._widget.setLayout(vbox)
# Define the connections to the outside world
self.jointSubscriber = rospy.Subscriber(self.joint_state_topic, JointState, self.stateCallbackFnc)
self.commandPublisher = rospy.Publisher(self.trajectory_topic, JointTrajectory, queue_size=10)
# Add the widget
context.add_widget(self._widget)
@Slot()
def snap_current_callback(self):
self.blockSignals(True)
print "Snapping positions to actual values"
for index, joint in enumerate(self.chain):
for index_state, name_state in enumerate(self.robot_joint_state.name):
if name_state == joint.name:
joint.position = copy.deepcopy(self.robot_joint_state.position[index_state])
self.cmd_spinbox[index].setValue(joint.position)
break
self.blockSignals(False)
示例13: BiasCalibrationDialog
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class BiasCalibrationDialog(Plugin):
def __init__(self, context):
super(BiasCalibrationDialog, self).__init__(context)
self.setObjectName('BiasCalibrationDialog')
self._widget = QWidget()
vbox = QVBoxLayout()
controller_widget = QWidget()
hbox = QHBoxLayout()
# Left to right layout
self.joint_control = JointBias(self, roslib.packages.get_pkg_dir('vigir_rqt_bias_calibration') + '/launch/joints.txt',hbox)
controller_widget.setLayout(hbox)
self.marker = Marker()
self.marker.header.frame_id = "/world"
self.marker.type = self.marker.CUBE
self.marker.action = self.marker.ADD
self.marker.scale.x = 14.0
self.marker.scale.y = 14.0
self.marker.scale.z = 0.02
self.marker.color.a = 0.25
self.marker.color.r = 1.0
self.marker.color.g = 1.0
self.marker.color.b = 0.0
#self.marker.points = [[0.0, 0.0, 0.0], [7.0, -4.0, 0.0], [7.0, 4.0, 0.0]]
self.marker.pose.orientation.w = 1.0
self.marker.pose.position.x = 0.0
self.marker.pose.position.y = 0.0
self.marker.pose.position.z = 0.0
self.bias_pub = rospy.Publisher('/flor/controller/atlas_biases', JointState, queue_size=10)
self.flor_marker_pub = rospy.Publisher('/flor_plane_marker', Marker, queue_size=10)
self.feet_state_sub = rospy.Subscriber('/atlas/atlas_sim_interface_state', AtlasSimInterfaceState, self.stateCallbackFnc)
vbox.addWidget(controller_widget)
self.save_button = QPushButton("Save Biases")
self.save_button.pressed.connect(self.on_savePressed)
vbox.addWidget(self.save_button)
self._widget.setLayout(vbox)
context.add_widget(self._widget)
def shutdown_plugin(self):
print "Shutdown ..."
self.bias_pub.unregister()
self.flor_marker_pub.unregister()
self.feet_state_sub.unregister()
print "Done!"
def stateCallbackFnc(self, atlasState_msg):
self.marker.pose.position.x = (atlasState_msg.foot_pos_est[0].position.x + atlasState_msg.foot_pos_est[1].position.x)*0.5
self.marker.pose.position.y = (atlasState_msg.foot_pos_est[0].position.y + atlasState_msg.foot_pos_est[1].position.y)*0.5
self.marker.pose.position.z = (atlasState_msg.foot_pos_est[0].position.z + atlasState_msg.foot_pos_est[1].position.z)*0.5
#self.marker.pose.orientation = atlasState_msg.foot_pos_est[0].orientation
self.flor_marker_pub.publish(self.marker)
def on_savePressed(self):
print "Save data to file..."
self.joint_control.saveData(roslib.packages.get_pkg_dir('vigir_rqt_bias_calibration') + '/launch/new_biases.txt')
示例14: Top
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class Top(Plugin):
NODE_FIELDS = [ 'pid', 'get_cpu_percent', 'get_memory_percent', 'get_num_threads']
OUT_FIELDS = ['node_name', 'pid', 'cpu_percent', 'memory_percent', 'num_threads' ]
FORMAT_STRS = ['%s', '%s', '%0.2f', '%0.2f', '%s' ]
NODE_LABELS = ['Node', 'PID', 'CPU %', 'Mem %', 'Num Threads' ]
SORT_TYPE = [str, str, float, float, float ]
TOOLTIPS = {
0: ('cmdline', lambda x: '\n'.join(textwrap.wrap(' '.join(x)))),
3: ('memory_info', lambda x: ('Resident: %0.2f MiB, Virtual: %0.2f MiB' % (x[0]/2**20, x[1]/2**20)))
}
_node_info = NodeInfo()
name_filter = re.compile('')
def __init__(self, context):
super(Top, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('Top')
# 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
self._selected_node = ''
self._selected_node_lock = RLock()
# Setup the toolbar
self._toolbar = QToolBar()
self._filter_box = QLineEdit()
self._regex_box = QCheckBox()
self._regex_box.setText('regex')
self._toolbar.addWidget(QLabel('Filter'))
self._toolbar.addWidget(self._filter_box)
self._toolbar.addWidget(self._regex_box)
self._filter_box.returnPressed.connect(self.update_filter)
self._regex_box.stateChanged.connect(self.update_filter)
# Create a container widget and give it a layout
self._container = QWidget()
self._container.setWindowTitle('Process Monitor')
self._layout = QVBoxLayout()
self._container.setLayout(self._layout)
self._layout.addWidget(self._toolbar)
# Create the table widget
self._table_widget = QTreeWidget()
self._table_widget.setObjectName('TopTable')
self._table_widget.setColumnCount(len(self.NODE_LABELS))
self._table_widget.setHeaderLabels(self.NODE_LABELS)
self._table_widget.itemClicked.connect(self._tableItemClicked)
self._table_widget.setSortingEnabled(True)
self._table_widget.setAlternatingRowColors(True)
self._layout.addWidget(self._table_widget)
context.add_widget(self._container)
# Add a button for killing nodes
self._kill_button = QPushButton('Kill Node')
self._layout.addWidget(self._kill_button)
self._kill_button.clicked.connect(self._kill_node)
# Update twice since the first cpu% lookup will always return 0
self.update_table()
self.update_table()
self._table_widget.resizeColumnToContents(0)
# Start a timer to trigger updates
self._update_timer = QTimer()
self._update_timer.setInterval(1000)
self._update_timer.timeout.connect(self.update_table)
self._update_timer.start()
def _tableItemClicked(self, item, column):
with self._selected_node_lock:
self._selected_node = item.text(0)
def update_filter(self, *args):
if self._regex_box.isChecked():
expr = self._filter_box.text()
else:
expr = re.escape(self._filter_box.text())
self.name_filter = re.compile(expr)
self.update_table()
def _kill_node(self):
self._node_info.kill_node(self._selected_node)
#.........这里部分代码省略.........
示例15: SensorParamControlDialog
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import setLayout [as 别名]
class SensorParamControlDialog(Plugin):
def __init__(self, context):
super(SensorParamControlDialog, self).__init__(context)
self.setObjectName('SensorParamControlDialog')
self._widget = QWidget()
vbox = QVBoxLayout()
### Multisense ###
ms_groupbox = QGroupBox( "Multisense" )
ms_vbox = QVBoxLayout()
ms_gain_hbox = QHBoxLayout()
self.ms_gain_label = QLabel("Image Gain [1, 1, 8]")
ms_gain_hbox.addWidget( self.ms_gain_label )
self.ms_gain = QDoubleSpinBox()
self.ms_gain.setSingleStep(.01)
self.ms_gain.setRange(1,8)
ms_gain_hbox.addWidget( self.ms_gain )
ms_vbox.addLayout( ms_gain_hbox )
ms_exp_hbox = QHBoxLayout()
self.ms_exp_auto = QCheckBox("Image Exposure [.03, 0.5]")
ms_exp_hbox.addWidget( self.ms_exp_auto )
self.ms_exp = QDoubleSpinBox()
self.ms_exp.setSingleStep( .001 )
self.ms_exp.setRange( .025,.5 )
ms_exp_hbox.addWidget( self.ms_exp )
ms_vbox.addLayout( ms_exp_hbox )
ms_spindle_hbox = QHBoxLayout()
ms_spindle_label = QLabel("Spindle Speed [0, 5.2]")
ms_spindle_hbox.addWidget( ms_spindle_label )
self.ms_spindle = QDoubleSpinBox()
self.ms_spindle.setSingleStep(.01)
self.ms_spindle.setRange( 0,15.2 )
ms_spindle_hbox.addWidget( self.ms_spindle )
ms_vbox.addLayout( ms_spindle_hbox )
ms_light_hbox = QHBoxLayout()
ms_light_label = QLabel("Light Brightness")
ms_light_hbox.addWidget(ms_light_label)
self.ms_light = QSlider(Qt.Horizontal)
self.ms_light.setRange(0,100)
ms_light_hbox.addWidget( self.ms_light )
ms_vbox.addLayout( ms_light_hbox )
ms_button_hbox = QHBoxLayout()
ms_button_hbox.addStretch(1)
ms_button_get = QPushButton("Get Settings")
ms_button_get.pressed.connect(self.ms_get_callback)
#ms_button_hbox.addWidget( ms_button_get )
ms_button_set = QPushButton("Set Settings")
ms_button_set.pressed.connect(self.ms_set_callback)
ms_button_hbox.addWidget( ms_button_set )
ms_vbox.addLayout( ms_button_hbox )
ms_groupbox.setLayout( ms_vbox )
vbox.addWidget( ms_groupbox )
### Left SA ###
sa_left_groupbox = QGroupBox( "Left SA Camera" )
sa_left_vbox = QVBoxLayout()
sa_left_gain_hbox = QHBoxLayout()
sa_left_gain_label = QLabel("Image Gain [0, 0, 25]")
sa_left_gain_hbox.addWidget( sa_left_gain_label )
#.........这里部分代码省略.........