本文整理汇总了Python中python_qt_binding.QtGui.QWidget.connect方法的典型用法代码示例。如果您正苦于以下问题:Python QWidget.connect方法的具体用法?Python QWidget.connect怎么用?Python QWidget.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QWidget
的用法示例。
在下文中一共展示了QWidget.connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RqtSrVisualServoing
# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import connect [as 别名]
class RqtSrVisualServoing(Plugin):
def __init__(self, context):
super(RqtSrVisualServoing, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('RqtSrVisualServoing')
# # 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.ui = QWidget()
# Get path to UI file which is in our packages resource directory
rp = rospkg.RosPack()
self.ui_file = os.path.join(rp.get_path(PKG), 'resource', 'gui.ui')
# Extend the widget with all attributes and children from UI file
loadUi(self.ui_file, self.ui)
# Give QObjects reasonable names
self.ui.setObjectName('RqtSrVisualServoingUi')
# Show ui.windowTitle on left-top of each plugin (when it's set in ui).
# 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.ui.setWindowTitle(self.ui.windowTitle() + (' (%d)' % context.serial_number()))
# Wire up the buttons
self.ui.startBtn.clicked.connect( self.start_clicked )
self.ui.stopBtn.clicked.connect( self.stop_clicked )
# Annoyingly setting the icon theme in designer only works in designer,
# we have to set it again here for it to work at run time
self.ui.startBtn.setIcon(QIcon.fromTheme('media-playback-start'))
self.ui.stopBtn.setIcon(QIcon.fromTheme('media-playback-stop'))
# Add widget to the user interface
context.add_widget(self.ui)
# Setup a model for the feedback and link to the view.
self.feedback_model = QStandardItemModel(0,2)
self.feedback_model.setHorizontalHeaderLabels(['Name','Value'])
self.ui.feedbackView.setModel(self.feedback_model)
self.ui.connect( self.ui, SIGNAL('feedback(QString)'), self.update_feedback )
# ROS setup
self.last_feedback = None
self.client = actionlib.SimpleActionClient('visual_servo', VisualServoingAction)
msg = ""
if self.client.wait_for_server(rospy.Duration(2.0)):
msg = "Found action server, servoing appears to be running"
rospy.loginfo(msg)
else:
msg = "Can't find action server, servoing not running"
rospy.logerr(msg)
self.ui.statusValue.setText(msg)
def shutdown_plugin(self):
# TODO unregister all publishers here
pass
def save_settings(self, plugin_settings, instance_settings):
# TODO save intrinsic configuration, usually using:
# instance_settings.set_value(k, v)
pass
def restore_settings(self, plugin_settings, instance_settings):
# TODO restore intrinsic configuration, usually using:
# v = instance_settings.value(k)
pass
#def trigger_configuration(self):
# Comment in to signal that the plugin has a way to configure it
# Usually used to open a configuration dialog
def start_clicked(self):
goal = VisualServoingActionGoal()
self.client.send_goal(goal, feedback_cb = self._feedback_cb)
self.ui.statusValue.setText("Starting")
def stop_clicked(self):
self.client.cancel_all_goals()
self.ui.statusValue.setText("Stopped")
self.feedback_model.clear()
def _feedback_cb(self, feedback):
# We can't update the UI in this thread so stash the data and emit a
# signal that can be traped by the main thread and update the ui.
self.last_feedback = feedback
self.ui.emit( SIGNAL('feedback(QString)'), "" )
def update_feedback(self, data):
#.........这里部分代码省略.........