Add TextType to ease gui generation
TextType is intended for formatted text (multiple lines), whereas StringType is intended for a single line of text (without '\n') Change-Id: Ibce29ae6b4e426bd8685f2cf7ff6966d81b0c6aa Reviewed-on: https://forge.frm2.tum.de/review/20951 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
@ -24,9 +24,10 @@
|
||||
from __future__ import division, print_function
|
||||
|
||||
from secop.datatypes import ArrayOf, BLOBType, BoolType, EnumType, \
|
||||
FloatRange, IntRange, StringType, StructOf, TupleOf
|
||||
FloatRange, IntRange, StringType, StructOf, TupleOf, TextType
|
||||
from secop.gui.qt import QCheckBox, QComboBox, QDialog, QDoubleSpinBox, \
|
||||
QFrame, QGridLayout, QGroupBox, QLabel, QLineEdit, QSpinBox, QVBoxLayout
|
||||
QFrame, QGridLayout, QGroupBox, QLabel, QLineEdit, QSpinBox, QVBoxLayout, \
|
||||
QTextEdit
|
||||
from secop.gui.util import loadUi
|
||||
|
||||
# XXX: implement live validators !!!!
|
||||
@ -46,10 +47,26 @@ class StringWidget(QLineEdit):
|
||||
self.setText(value)
|
||||
|
||||
|
||||
class TextWidget(QTextEdit):
|
||||
def __init__(self, datatype, readonly=False, parent=None):
|
||||
super(TextWidget, self).__init__(parent)
|
||||
self.datatype = datatype
|
||||
if readonly:
|
||||
self.setEnabled(False)
|
||||
|
||||
def get_value(self):
|
||||
res = self.text()
|
||||
return self.datatype(res)
|
||||
|
||||
def set_value(self, value):
|
||||
self.setText(value)
|
||||
|
||||
|
||||
class BlobWidget(StringWidget):
|
||||
# XXX: make an editable hex-table ?
|
||||
pass
|
||||
|
||||
|
||||
# or derive from widget and switch between combobox and radiobuttons?
|
||||
class EnumWidget(QComboBox):
|
||||
def __init__(self, datatype, readonly=False, parent=None):
|
||||
@ -202,6 +219,7 @@ def get_widget(datatype, readonly=False, parent=None):
|
||||
return {FloatRange: FloatWidget,
|
||||
IntRange: IntWidget,
|
||||
StringType: StringWidget,
|
||||
TextType: TextWidget,
|
||||
BLOBType: BlobWidget,
|
||||
EnumType: EnumWidget,
|
||||
BoolType: BoolWidget,
|
||||
|
Reference in New Issue
Block a user