ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pythoncard
pythoncard
RE: [Pythoncard-users] what is the syntax for posting an event?
by Kevin Altis other posts by this author
Apr 21 2002 2:17PM messages near this date
[Pythoncard-users] what is the syntax for posting an event? | [Pythoncard-users] small doodle bug
>  From: David Primmer
> 
>  This has been covered before but it wasn't spelled out clearly enough
>  for me. What do I need to do to post an event? How would I simulate
>  someone selecting a checkable menu item?

If you want to actually post an event with the existing framework, you must
create a valid wxPython event object and then use wxPython's wxPostEvent or
ProcessEvent. That isn't necessary for your needs as I'll show below.

Since event handlers like your on_menuViewPreviewBrowser_select are just
methods, you can always call them directly, but that is not the same as
posting an event that goes into the queue and if you call a method that way,
you won't have a valid event argument, so it is important that you not try
and use the event attributes. The dbBrowser, saveClipboardBitmap,
radioclient, resourceEditor, and textEditor use this technique. For example,
in saveClipboardBitmap, the openBackground handler calls the file save as
event handler; note that the event is None.

        self.on_menuFileSaveAs_select(None)

It won't work for your example below because you don't want to actually do
everything that is in on_menuViewPreviewBrowser_select.

>  I have a child window whose visibility is controlled by the menu item
>  and I want to toggle the menu check when the use closes the child
>  window.

You mean hides the child window; that's what the code does that you
supplied.

>  So here's my menu handler:
> 
>      def on_menuViewPreviewBrowser_select(self, event):
>          state = self.menuBar.getChecked('menuViewPreviewBrowser')
>          #show or hid the browser child'
>          self.iechild.Show(state)
>          self.configState['browserpreview.visible'] = state
> 
> 
>  and here's the child PreviewBrowser window's close methods:
> 
>      def doExit(self):
>          pass
>          ##here's where I'd like to set the state
> 
>      # we don't have window events hooked up yet to our own event model
>  yet
>      def OnCloseWindow(self, event):
>          self.doExit()
>          self.Show(0)

You need a reference to the parent window. If you don't already have that
reference, then use GetParent().

    def doExit(self):
        parent = self.GetParent()
        parent.menuBar.setChecked('menuViewPreviewBrowser', 0)
        parent.configState['browserpreview.visible'] = 0

ka


_______________________________________________
Pythoncard-users mailing list
Pythoncard-users@[...].net
https://lists.sourceforge.net/lists/listinfo/pythoncard-users
Thread:
David Primmer
Kevin Altis

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved