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


Python QWidget.update方法代码示例

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


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

示例1: update

# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import update [as 别名]
 def update(self, *args):
     # the +4 is used to compensate for the current line being bold.
     width = self.fontMetrics().width(str(self.highest_line)) + 4
     if self.width() != width:
         self.setFixedWidth(width)
     QWidget.update(self, *args)
开发者ID:zhouchengming1,项目名称:multimaster_fkie,代码行数:8,代码来源:line_number_widget.py

示例2: Battery_state

# 需要导入模块: from python_qt_binding.QtGui import QWidget [as 别名]
# 或者: from python_qt_binding.QtGui.QWidget import update [as 别名]
class Battery_state(Plugin):
    max_x_vel  = 0.4
    max_ang_vel  = 1.0
    tar_x_vel  = 0.0
    tar_ang_vel  = 0.0
    cur_x_vel = 0.0
    cur_ang_vel = 0.0
    acc_x_vel  = 0.1 #linear accelaration - meters/(time step)
    acc_ang_vel = 0.1 #angular accelaration - rad/(time step)

    def __init__(self, context):
        super(Battery_state, self).__init__(context)
        # Give QObjects reasonable names
        self.setObjectName('Battery_state')

        # 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._widget = QWidget()
        ui_file = os.path.join(rospkg.RosPack().get_path('rqt_battery_state'), 'resource', 'qt_gui3.ui')
        loadUi(ui_file, self._widget)
        self._widget.setObjectName('qt_gui3')
        if context.serial_number() > 0:
            self._widget.setWindowTitle('Battery State')
        # Add widget to the user interface
        context.add_widget(self._widget)
        self._update_timer = QTimer(self)
        self._update_timer.timeout.connect(self._handle_update)
        self._update_timer.start(1000)#time step
        
        self.subscriber = rospy.Subscriber('/my_roomba/battery_state', BatteryState, self.subscriber_callback)
	#self._publisher = rospy.Publisher('/cmd_vel', Twist)


    def shutdown_plugin(self):
        #self._publisher.unregister()
	    #self._publisher = None
        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 _handle_update(self):
        #print 'timer'
	    self._widget.update()
    
    def subscriber_callback(self, msg):
        voltage  = msg.voltage
        current  = msg.current
        f_capacity  = msg.capacity
        capacity  = msg.charge
        percentage  = msg.percentage
        charging = msg.power_supply_status
        
        if math.isnan(percentage):
            percentage = 0
            
        if math.isnan(current):
            current = 0
            
        if math.isnan(f_capacity):
            f_capacity = 0

        if math.isnan(capacity):
            capacity = 0

        self._widget.label_voltage.setText('Voltage: ' + ('%.2f' % voltage) + ' V')
        self._widget.label_current.setText('Current: ' + ('%.2f' % current) + ' A')
        self._widget.label_f_capacity.setText('Full capacity: ' + ('%.2f' % f_capacity) + ' A*h')
        self._widget.label_capacity.setText('Capacity: ' + ('%.2f' % capacity) + ' A*h')
        self._widget.progressBar.setValue(int(percentage))
        
        if (charging == 0):
            self._widget.label_charge.setText('Charging: N/A')
        elif (charging == 1):
            self._widget.label_charge.setText('Charging: Charge')
        elif (charging == 2):
            self._widget.label_charge.setText('Charging: Discharge')
        elif (charging == 3):
            self._widget.label_charge.setText('Charging: Not charging')
        elif (charging == 4):
            self._widget.label_charge.setText('Charging: Full')
        else:
            self._widget.label_charge.setText('Charging: N/A')
开发者ID:iliasam,项目名称:ROS_files,代码行数:100,代码来源:rqt_battery_state.py


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