[Pythonmac-SIG] Targeting Object Instances from a menu?

Bob Ippolito bob at redivi.com
Tue Oct 26 00:44:56 CEST 2004


On Oct 25, 2004, at 18:22, Jerry LeVan wrote:

> On Oct 25, 2004, at 5:32 PM, Bob Ippolito wrote:
>
>> On Oct 25, 2004, at 17:22, Jerry LeVan wrote:
>>
>>> As a learning project I am creating a class PGBrowser. Creating
>>> an instance of a PGBrowser will bring up a gui with an editor,
>>> status area and a table area connected to a user specified
>>> Postgresql database.
>>>
>>> The basic functionality is in place, I can connect to my postgresql
>>> databases and execute sql commands against the database and
>>> get the results displayed nicely in the table area.
>>>
>>> I am getting ready to add "enhancements" via a menu and it just
>>> occurred to me that if I have more than one instance of a PGBrowser,
>>> how can I target the appropriate one.
>>>
>>> "Regular" mac applications target the "First Responder" chain, in
>>> this case it is generally the frontmost window...
>>>
>>> So if I have two browser instances, can I identify the "frontmost"?
>>>
>>> If this  is not possible, then it appears that I might have to use
>>> a row of button menus set in each browser window... not a very
>>> mac like solution.
>>>
>>> Any suggestions?
>>
>> This is totally different depending on which GUI framework you are 
>> using.  You didn't bother to mention that :)
>>
> Tkinter based on Aqua Tcl/Tk BI, sorry about that :)

Well, however you find out what the front window is in Tk.  I have no 
idea, I avoid Tk, it doesn't look very good on the Mac.

I find that PyObjC requires a whole lot less code, especially for 
something like this where you could use NSTableView, etc.  These sorts 
of issues are handled in a sane way with Cocoa because it was designed 
for the GUI you're using.  The responder chain is a native concept in 
Cocoa.

-bob



More information about the Pythonmac-SIG mailing list