vetiarvind
Prince
What I am trying to achieve is a system where the user clicks a button in a python screen that opens a popup. I then get the user input text from the popup and call the dll with this value.
I used the event system to do this and the popup opening worked fine, but now it no longer does after I added a second event following the patter below. I don't know if it's because I don't get the event routing system, but if there's a simpler way of getting user input in text and calling the dll with it from python do let me know. (so far documentation on event routing and popups are few and far between)
So here is what I did:
I created a custom event in CvUtil.py:
In my python click event handler, I trigger the event:
In CvEventManager.py:
I added the following property to self.Events for the event routing system:
which declare the callback and start methods for the corresponding event respectively. These are supposed to be called automatically from the CvEventManager.py class when I called the "beginEvent" method (see above). The actual content of these two methods look like:
I have checked\rechecked the code a few times, so now I'm wondering if using the CvEventInterface like this is good practice or not. (I read on sourceforge that you're not supposed to import any *Interface modules directly) so maybe that's the reason why I'm getting inconsistent results.
I used the event system to do this and the popup opening worked fine, but now it no longer does after I added a second event following the patter below. I don't know if it's because I don't get the event routing system, but if there's a simpler way of getting user input in text and calling the dll with it from python do let me know. (so far documentation on event routing and popups are few and far between)
So here is what I did:
I created a custom event in CvUtil.py:
Code:
MyEvent = 8888
Code:
CvEventInterface.beginEvent(CvUtil.MyEvent)
I added the following property to self.Events for the event routing system:
Code:
CvUtil.MyEvent: ('MyEventName', self.doMyEventApply, self.doMyEventBegin),
which declare the callback and start methods for the corresponding event respectively. These are supposed to be called automatically from the CvEventManager.py class when I called the "beginEvent" method (see above). The actual content of these two methods look like:
Code:
#this creates a popup
def doSaveTradeGroupsBegin(self, argslist):
popup = CyPopup(CvUtil.MyEvent, EventContextTypes.EVENTCONTEXT_ALL, True)
popup.setHeaderString("hello".upper(), CvUtil.FONT_LEFT_JUSTIFY)
popup.createEditBox ("txtUserInput", 1)
popup.launch(true, PopupStates.POPUPSTATE_IMMEDIATE)
# do something on callback with popupReturn object's user entered values
def doMyEventApply(self, playerID, userData, popupReturn):