qt_helper.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 
5 from python_qt_binding.QtCore import Qt
6 from python_qt_binding.QtGui import QHBoxLayout, QGroupBox, QTextEdit, QDoubleSpinBox, QColor
7 
8 
9 # generic helper to generate quickly QDoubleSpinBox
10 def generate_q_double_spin_box(default_val, range_min, range_max, decimals, single_step):
11  spin_box = QDoubleSpinBox()
12  spin_box.setValue(default_val)
13  spin_box.setRange(range_min, range_max)
14  spin_box.setDecimals(decimals)
15  spin_box.setSingleStep(single_step)
16  #spin_box.valueChanged[unicode].connect(self.callback_spin_box)
17  return spin_box
18 
19 
20 # adds a layout with frame and text to parent widget
21 def add_layout_with_frame(parent, layout, text = ""):
22  box_layout = QHBoxLayout()
23  box_layout.addLayout(layout)
24 
25  group_box = QGroupBox()
26 
27  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; }")
28  group_box.setTitle(text)
29  group_box.setLayout(box_layout)
30 
31  parent.addWidget(group_box)
32 
33 
34 # adds a widget with frame and text to parent widget
35 def add_widget_with_frame(parent, widget, text = ""):
36  box_layout = QHBoxLayout()
37  box_layout.addWidget(widget)
38 
39  group_box = QGroupBox()
40 
41  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; }")
42  group_box.setTitle(text)
43  group_box.setLayout(box_layout)
44 
45  parent.addWidget(group_box)
46 
47 
48 # outputs message with given color at a QTextEdit
49 def output_message(text_edit, msg, color):
50  text_edit.setTextColor(color)
51  text_edit.append(msg)
52 
53 
54 # outputs error_status msg at QTextEdit field
55 def output_status(text_edit, error_status):
56  if error_status.error != 0:
57  output_message(text_edit, error_status.error_msg, Qt.red)
58 
59  if error_status.warning != 0:
60  output_message(text_edit, error_status.warning_msg, QColor(255, 165, 0))
def generate_q_double_spin_box(default_val, range_min, range_max, decimals, single_step)
Definition: qt_helper.py:10
def output_message(text_edit, msg, color)
Definition: qt_helper.py:49
def add_widget_with_frame(parent, widget, text="")
Definition: qt_helper.py:35
def output_status(text_edit, error_status)
Definition: qt_helper.py:55
def add_layout_with_frame(parent, layout, text="")
Definition: qt_helper.py:21


vigir_footstep_planning_lib
Author(s): Alexander Stumpf
autogenerated on Mon Jun 10 2019 15:47:33