> In my past world a combobox would work as you suggested. But this is
> wxPython
> and it just does not follow my old world of thinking. So!
>
>
I extended the dComboBox class to add a ValueMode of user.
It works fine when you hit enter on it, but if you just go off of the
control, it doesn't call the OnTextBox event.
I tried to add an OnLostFocus event that would call the
dComboBox.__onTextBox event, but I couldn't figure it out at the moment.
If anyone could help me out I'd appreciate it.
The code is below:
import dabo, dabo.ui
from dabo.dLocalize import _
import dabo.dEvents as dEvents
from dabo.ui import makeDynamicProperty
import wx
class dComboBox2(dabo.ui.dComboBox):
def __init__(self, parent, properties=None, attProperties=None,
*args, **kwargs):
dabo.ui.dComboBox.__init__(self, parent, *args, **kwargs)
def _initEvents(self):
super(dComboBox2, self)._initEvents()
self.bindEvent(dEvents.LostFocus, self.onLostFocus)
def onLostFocus(self,evt):
pass
#self.raiseEvent(wx.EVT_COMBOBOX,evt)
def _getValueMode(self):
try:
vm = {"p": "position", "s": "string", "k": "key", "u":
"user"}[self._valueMode]
except AttributeError:
vm = self._valueMode = "string"
return vm
def _setValueMode(self, val):
val = str(val).lower()[0]
if val in ("p", "s", "k","u"):
self._valueMode = val
def _getValue(self):
# print "getvalue"
if self.ValueMode == "position":
ret = self.PositionValue
elif self.ValueMode == "key":
ret = self.KeyValue
elif self.ValueMode =="user":
ret=self.UserValue
if ret=="":
ret=None
else:
ret = self.StringValue
return ret
def _setValue(self, value):
# print "value=%s"%value
if not value:
value=""
if self.ValueMode == "position":
self.PositionValue = value
elif self.ValueMode == "key":
self.KeyValue = value
elif self.ValueMode == "user":
self.UserValue = value
else:
self.StringValue = value
Value = property(_getValue, _setValue, None,
_("""Specifies which item is currently selected in the list.
-> Type can vary. Read-write at runtime.
Value refers to one of the following, depending on the
setting of ValueMode:
+ ValueMode="Position" : the index of the selected
item(s) (integer)
+ ValueMode="String" : the displayed string of the
selected item(s) (string)
+ ValueMode="Key" : the key of the selected item(s)
(can vary)""") )
ValueMode = property(_getValueMode, _setValueMode, None,
_("""Specifies the information that the Value property
refers to.
-> String. Read-write at runtime.
'Position' : Value refers to the position in the choices
(integer).
'String' : Value refers to the displayed string for the
selection (default) (string).
'Key' : Value refers to a separate key, set using the
Keys property (can vary).""") )
DynamicValue = makeDynamicProperty(Value)
DynamicValueMode = makeDynamicProperty(ValueMode)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]