qt_helper.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import rospy
00004 
00005 from python_qt_binding.QtCore import Qt
00006 from python_qt_binding.QtGui import QHBoxLayout, QGroupBox, QTextEdit, QDoubleSpinBox, QColor
00007 
00008 
00009 # generic helper to generate quickly QDoubleSpinBox
00010 def generate_q_double_spin_box(default_val, range_min, range_max, decimals, single_step):
00011     spin_box = QDoubleSpinBox()
00012     spin_box.setValue(default_val)
00013     spin_box.setRange(range_min, range_max)
00014     spin_box.setDecimals(decimals)
00015     spin_box.setSingleStep(single_step)
00016     #spin_box.valueChanged[unicode].connect(self.callback_spin_box)
00017     return spin_box
00018 
00019 
00020 # adds a layout with frame and text to parent widget
00021 def add_layout_with_frame(parent, layout, text = ""):
00022     box_layout = QHBoxLayout()
00023     box_layout.addLayout(layout)
00024 
00025     group_box = QGroupBox()
00026 
00027     group_box.setStyleSheet("QGroupBox { border: 1px solid gray; border-radius: 4px; margin-top: 0.5em; } QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; }")
00028     group_box.setTitle(text)
00029     group_box.setLayout(box_layout)
00030 
00031     parent.addWidget(group_box)
00032 
00033 
00034 # adds a widget with frame and text to parent widget
00035 def add_widget_with_frame(parent, widget, text = ""):
00036     box_layout = QHBoxLayout()
00037     box_layout.addWidget(widget)
00038 
00039     group_box = QGroupBox()
00040 
00041     group_box.setStyleSheet("QGroupBox { border: 1px solid gray; border-radius: 4px; margin-top: 0.5em; } QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; }")
00042     group_box.setTitle(text)
00043     group_box.setLayout(box_layout)
00044 
00045     parent.addWidget(group_box)
00046 
00047 
00048 # outputs message with given color at a QTextEdit
00049 def output_message(text_edit, msg, color):
00050     text_edit.setTextColor(color)
00051     text_edit.append(msg)
00052 
00053 
00054 # outputs error_status msg at QTextEdit field
00055 def output_status(text_edit, error_status):
00056     if error_status.error != 0:
00057         output_message(text_edit, error_status.error_msg, Qt.red)
00058 
00059     if error_status.warning != 0:
00060         output_message(text_edit, error_status.warning_msg, QColor(255, 165, 0))


vigir_footstep_planning_lib
Author(s): Alexander Stumpf
autogenerated on Sat Jul 15 2017 02:47:56