memory (params), tools (xml_tools), plugins, frontends: add "int" parameter type with "min" and "max" attributes
This commit is contained in:
parent
20c94f1fbc
commit
ac59d061f4
3 changed files with 80 additions and 11 deletions
|
|
@ -155,6 +155,24 @@ class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents):
|
|||
return "true" if self.get_state() else "false"
|
||||
|
||||
|
||||
class PrimitivusIntWidget(xmlui.IntWidget, sat_widgets.AdvancedEdit, PrimitivusEvents):
|
||||
|
||||
def __init__(self, _xmlui_parent, value, read_only=False):
|
||||
sat_widgets.AdvancedEdit.__init__(self, edit_text=value)
|
||||
self.read_only = read_only
|
||||
|
||||
def selectable(self):
|
||||
if self.read_only:
|
||||
return False
|
||||
return super(PrimitivusIntWidget, self).selectable()
|
||||
|
||||
def _xmluiSetValue(self, value):
|
||||
self.set_edit_text(value)
|
||||
|
||||
def _xmluiGetValue(self):
|
||||
return self.get_edit_text()
|
||||
|
||||
|
||||
class PrimitivusButtonWidget(xmlui.ButtonWidget, sat_widgets.CustomButton, PrimitivusEvents):
|
||||
|
||||
def __init__(self, _xmlui_parent, value, click_callback):
|
||||
|
|
|
|||
|
|
@ -101,6 +101,10 @@ class BoolWidget(Widget):
|
|||
"""
|
||||
|
||||
|
||||
class IntWidget(Widget):
|
||||
"""Input widget with require an integer"""
|
||||
|
||||
|
||||
class ButtonWidget(Widget):
|
||||
"""A clickable widget"""
|
||||
|
||||
|
|
@ -388,6 +392,9 @@ class XMLUIPanel(XMLUIBase):
|
|||
elif type_=="bool":
|
||||
ctrl = self.widget_factory.createBoolWidget(_xmlui_parent, value==C.BOOL_TRUE, self._isAttrSet("read_only", node))
|
||||
self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
|
||||
elif type_ == "int":
|
||||
ctrl = self.widget_factory.createIntWidget(_xmlui_parent, value, self._isAttrSet("read_only", node))
|
||||
self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
|
||||
elif type_ == "list":
|
||||
style = [] if node.getAttribute("multi") == 'yes' else ['single']
|
||||
_options = [(option.getAttribute("value"), option.getAttribute("label")) for option in node.getElementsByTagName("option")]
|
||||
|
|
|
|||
|
|
@ -127,6 +127,16 @@ class BoolWidget(EventWidget, ValueWidget, xmlui.BoolWidget, wx.CheckBox):
|
|||
return "true" if self.GetValue() else "false"
|
||||
|
||||
|
||||
# TODO: use wx.SpinCtrl instead of wx.TextCtrl
|
||||
class IntWidget(EventWidget, ValueWidget, xmlui.IntWidget, wx.TextCtrl):
|
||||
_xmlui_change_event = wx.EVT_TEXT
|
||||
|
||||
def __init__(self, _xmlui_parent, value, read_only=False):
|
||||
style = wx.TE_READONLY if read_only else 0
|
||||
wx.TextCtrl.__init__(self, _xmlui_parent, -1, value, style=style)
|
||||
self._xmlui_proportion = 1
|
||||
|
||||
|
||||
class ButtonWidget(EventWidget, WixWidget, xmlui.ButtonWidget, wx.Button):
|
||||
_xmlui_change_event = wx.EVT_BUTTON
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue