[PMW 1.2] Dialog controls vanish upon editing

F

F. GEIGER

Hi all,

I use PMW 1.2 on Python 2.3.0 on Win2k.

I've created a dialog that looks like so:

+----------------------+
Name | |
+----------------------+
+----------------------+
Caption text head | |
+----------------------+
+----------------------+
# Digits w/o sign | |
+----------------------+
+----------------------+
Caption text tail | |
+----------------------+
+--+
Is editable | |
+--+
+--------------------+-+
Parameter name | |V| Drop-down.
+--------------------+-+


I pull down the drop-down control, select an item, the drop-down closes
and - vanishes. All controls have vanished. After half a second or so the
first one reappears, but w/o its label 'Name'.

The other ones reapper if I click onto the pane where they are supposed to
be. They also reapper if I change to an other app and then come back again.
I guess this is because a window update is issued by the OS.

What do I miss?


Many thanks in advance and kind regards
Franz GEIGER


Code:

class QCWidgetNumberEditor(_Editor):
'''
+----------------------+
Name | |
+----------------------+
+----------------------+
Caption text head | |
+----------------------+
+----------------------+
# Digits w/o sign | |
+----------------------+
+----------------------+
Caption text tail | |
+----------------------+
+--+
Is editable | |
+--+
+--------------------+-+ Drop-down. Offers only
existing
Parameter name | |V| parameters, i.e. you have to
first
+--------------------+-+ create at least one parameter.
'''

def __init__(self, parent, x, y, traits=None):
_Editor.__init__(self, parent)
self._pos = (x, y)
self._traits = traits
self._isEditable = Tkinter.IntVar(0)
self._createAndPackEntryFields_()
return

def traits(self):
return self._traits

def _createAndPackEntryFields_(self):

w = Tkinter.Label(self.interior(),
pady = 20
)
w.pack(expand = 1, fill = 'both', padx = 4, pady = 4)

parent = w

# Create and pack the EntryFields.
nameId = ''
if self._traits:
nameId = self._traits.name()
self._tkwNameId = Pmw.EntryField(parent,
labelpos = 'w',
value = nameId,
label_text = 'Name of number
control:',
validate = self._validateNameId_,
modifiedcommand =
self._onChangedNameId_,
command = self._onNameId_
)
textDisplayed = ''
if self._traits:
textDisplayed = self._traits.textHead()
self._tkwTextDisplayedHead = Pmw.EntryField(parent,
labelpos = 'w',
value = textDisplayed,
label_text = 'Caption text
head:',
# validate = {'validator' :
'real',
# 'min' : 10,
'max' : 99, 'minstrict' : 0
# },
modifiedcommand =
self._onChangedTextDisplayedHead_
)
textDisplayed = '1'
if self._traits:
textDisplayed = str(self._traits.numDigitsExclSign())
self._tkwNumDigitsExclSign = Pmw.EntryField(parent,
labelpos = 'w',
value = textDisplayed,
label_text = '# Digits w/o
sign:',
validate = {'validator' :
'integer',
'min' : 1,
'max' : 5, # 'minstrict' : 0
},
modifiedcommand =
self._onChangedNumDigits_
)
textDisplayed = ''
if self._traits:
textDisplayed = self._traits.textTail()
self._tkwTextDisplayedTail = Pmw.EntryField(parent,
labelpos = 'w',
value = textDisplayed,
label_text = 'Caption text
tail:',
modifiedcommand =
self._onChangedTextDisplayedTail_
)

if self._traits:
self._isEditable.set(self._traits.isEditable())
else:
self._isEditable.set(0)
tkwIsEditable = Tkinter.Checkbutton(parent,
variable=self._isEditable,
text='Editable on target',
command=self._onToggleIsEditable_
)

paramNames = Proxy.DataProxy().parameterNames()
self._tkwParamName = Pmw.ComboBox(parent,
labelpos = 'nw',
scrolledlist_items=paramNames,
label_text="Parameter name"
)
i = 0
if self._traits:
paramName = self._traits.parameterName()
try: i = paramNames.index(paramName)
except ValueError:
pass

try:
self._tkwParamName.selectitem(Proxy.DataProxy().parameterNames())
except IndexError: pass

entries = (self._tkwNameId,
self._tkwTextDisplayedHead,
self._tkwNumDigitsExclSign,
self._tkwTextDisplayedTail,
tkwIsEditable,
self._tkwParamName
)

for entry in entries:
entry.pack(fill='x', expand=1, padx=10, pady=5)
Pmw.alignlabels(entries)

self._tkwNameId.component('entry').focus_set()

return

def _execute_(self, event):
if event == 'OK':
nameId = self._tkwNameId.getvalue()
textDisplayedHead = self._tkwTextDisplayedHead.getvalue()
numDigits = int(self._tkwNumDigitsExclSign.getvalue())
textDisplayedTail = self._tkwTextDisplayedTail.getvalue()
isEditable = self._isEditable.get()
paramName = self._tkwParamName.get()
if nameId and numDigits > 0 and paramName:
param = Proxy.DataProxy().parameters(paramName)
self._traits = QCWidgetTraits.QCWidgetNumberTraits(nameId,
self._pos[0],
self._pos[1],

textDisplayedHead,
numDigits,

textDisplayedTail,
isEditable,
paramName
)

self.deactivate()
return

def _onChangedTextDisplayedHead_(self):
text = self._tkwTextDisplayedHead.getvalue()
return

def _onChangedNameId_(self):
return

def _onChangedNumDigits_(self):
text = self._tkwNumDigitsExclSign.getvalue()
return

def _onChangedTextDisplayedTail_(self):
text = self._tkwTextDisplayedTail.getvalue()
return

def _onToggleIsEditable_(self):
return

def _onNameId_(self):
return

def _validateFunName_(self, text):
return 1 # 2DO

def _validateNameId_(self, text):
if Proxy.DataProxy().parameterExists(text):
return -1
return 1
 
P

Peter Otten

F. GEIGER said:
Hi all,

I use PMW 1.2 on Python 2.3.0 on Win2k.

I've created a dialog that looks like so:

+----------------------+
Name | |
+----------------------+
+----------------------+
Caption text head | |
+----------------------+
+----------------------+
# Digits w/o sign | |
+----------------------+
+----------------------+
Caption text tail | |
+----------------------+
+--+
Is editable | |
+--+
+--------------------+-+
Parameter name | |V| Drop-down.
+--------------------+-+


I pull down the drop-down control, select an item, the drop-down closes
and - vanishes. All controls have vanished. After half a second or so the
first one reappears, but w/o its label 'Name'.

The other ones reapper if I click onto the pane where they are supposed to
be. They also reapper if I change to an other app and then come back
again. I guess this is because a window update is issued by the OS.

What do I miss?

I would guess that
def _validateNameId_(self, text):
if Proxy.DataProxy().parameterExists(text):
return -1
return 1

is either awfully slow and/or throws an exception.

You could easily verify this assumption with

(a)
def _validateNameId_(self, text):
return 1

and
(b)
def _validateNameId_(self, text):
try:
if Proxy.DataProxy().parameterExists(text):
return -1
return 1
except: # generally a bad idea
print >> sys.stderr, "something went wrong"
return 1


Peter
 
F

F. GEIGER

Thanks Peter,

but this method doesn't seem to be the reason. I placed a "return 1" as the
first statement in its body. No change for the better.

Kind regards
Franz GEIGER
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top