PDA

View Full Version : Non-modal panel for python?



clintonman
03-01-2013, 12:00 AM
Does anyone know how to make a non-modal panel in python? All the examples I can find use "lwsdk.PANF_BLOCKING" which creates a modal dialog.

clintonman
03-01-2013, 12:58 AM
I figured it out(for the most part). I thought the handle function had to be used in some kind of loop, but it looks like you just use it and return. I assume that the python interface is taking care of any cleanup in the background. All the modal samples used a destroy function, but I don't see how to capture the button press for ok or cancel to do it non-modally. I also found that handle function returns -1 when the panel is closed and returns random(?) positive values while it is open. If lwsdk.EVNT_BLOCKING is passed to handle it seems to behave modally. Still not sure what's going on, but I know enough to get by now. Here is the code.


class test_panels_edit(lwsdk.IGeneric):
def __init__(self, context):
super(test_panels_edit, self).__init__()

# Callbacks --------------------------------------
def edit_event(self, control, userdata):
#if control == self._c1:
# print 'Something happened...'
if self._c1.get_str() != self._c1_val:
print 'You typed: %s' % self._c1.get_str()
self._c1_val = self._c1.get_str()


# LWGeneric -------------------------------------------
def process(self, generic_access):
i = 0
ui = lwsdk.LWPanels()
panel = ui.create('Test Edit')

self._c1 = panel.str_ctl('Edit',44)
self._c1.set_str('default')
self._c1_val = 'default'

self._c1.set_event(self.edit_event)

panel.open(lwsdk.PANF_CANCEL)

panel.handle(lwsdk.EVNT_ALL)

return lwsdk.AFUNC_OK