[Pythonmac-SIG] Re: Pythonmac-SIG digest, Vol 1 #166 - 5 msgs

Samuel Smith smith@oe.fau.edu
Thu, 22 Apr 1999 09:42:48 -0400


Jack

>Samuel,
>you should probably also ask your non-mac-specific Tkinter questions in the
>general Python mailinglist/newsgroup, where you have a much better chance of
>an answer.
>
>I'll stick to answering the mac things I know about:
>
>> The python menubar gets replaced with a new menu bar who's menus apparently
>> do nothing.
>
>This is a Tk problem, and I think there's little I can do about it.
>

Are you the one who built the Python Mac Tk library?  I have about 4 years
experience programming the Mac toolbox. although it has been a few years
since I had done any mac development so I am pretty rusty. If someone can
point me in the right direction as to the process of porting Tk to python
maybe I can help.
It appears that Tk defaults to creating a menu bar etc.

There are some issues with the programming model. The python interpreter is
an application in its own right. If I run the tk gui should it be its own
application or should it live within the interpreters application.


>> I can't quit python once I close a Tkinter window (the Tkinter menu bar
>> stays on the screen) The only way I could figure out to quit python was to
>> do a sys.exit(). I bound sys.exit to my Tk quit button but that doesn't
>> work for the close box on the window title bar.
>
>There used to be a workaround for this, which re-installed the Python
>menubar.
>Unfortunately it stopped working some time in the past. I'll see whether I
>can
>do something about it.
>

great
>
>> Tk docs refer to a resource file. How is this supported on the Mac. (Other
>> platforms)
>
>Could you give me a pointer? I'm not familiar with what Tk calls resource
>files...
>

quote from Prac. Prog. in TCL/TK
" The resource database in maintained in main memory by the TK toolkit. On
UNIX the database is initialized from the RESOURCE_MANAGER property on the
root window or the .Xdefaults file in your home directory. On Windows and
Macintosh there are a few resources added by the tk.tcl library file.
Additional files can be explicitly loaded with the option readfile command
and individual database entries are added with the option add Tcl command.
"

Basically it enables you to specify attributes for widgets in a resource
file instead of hard coded.

I would think that this behavior could be replicated using the native
macintosh resource fork.  I could find no reference to a similar "option
readfile" command to get attributes from the resource database.

>This is an incompatability that is probably pretty difficult to fix. Both Tk
>and IDE fight over the eventloop, the menubar, window ownership and a few
>other things. It shouldn't crash your system, though, at most it should crash
>python

I get (paraphrased) a python error that says something like " menu Id 254
already in use. fatal python error" and I have to reboot my mac to recover.

Steven
>
>As noted in previous message: I've been using native Mac toolbox lately
>and haven't been using Tkinter on mac for a while, but I dug out some
>old Tkinter code and tried it.
>
>It looks like this behaviour may be due to the changes in Tk 8.0.x to
>support Mac style menu's. I don't think the earlier versions behaved
>like this.
>
>It looks like when you create a Tk root:
>	root = Tkinter.Tk()
>
>that Python's menu bar get's overwritten with Tk's menu default menu bar.
>If you look at the apple menu, just before that call, you have 'About
>Python', and right after, you have 'About Tcl & Tk' .

yes thats what I get.
>
>The Tk menus, however, won't do anything until you run the mainloop:
>	root.mainloop()
>
>Then, when you QUIT from the Tk menubar, the Python menubar reappears.
>However, the Python interpreter has terminated, so you can't type in
>the listener window, but you can QUIT the Python app, or select 'About
>Python' from the apple menu.
>
I can't quit from the tk menubar
>


Peter,


>A wild guess (don't have TK installed)
>
>That looks like similar problems I had when running
>another event loop under the IDE, How about storing
>and restoring the menubar ?
>
I will try it. I thought there was probably some way to override the
default menu bar creation. It just seemed that I should be able to run the
hello world demo without crashing my system


># store
>oldBar = Menu.GetMenuBar()
>
># run TK
>
># restore
>Menu.ClearMenuBar()
>Menu.SetMenuBar(oldBar)
>Menu.DrawMenuBar()
>
>-- Peter

**********************************

Samuel M. Smith Ph.D.
Associate Professor
Director Advanced Marine Systems Lab


**************(Dania Building)***********************

Institute for Ocean and Systems Engineering
Florida Atlantic University
Rm. 225 B, SeaTech Bldg.
101 North Beach Road,  Dania, FL 33004

(voice) 954-924-7232
(secretary Paula) 954-924-7230
(fax) 954-924-7233
(email) smith@oe.fau.edu
(web) http://www.oe.fau.edu

************** (Boca Raton Campus) *******************
Ocean Engineering Dept. Bldg. 36
Florida Atlantic University
777 Glades Rd, Boca Raton FL 33431

(voice) 561-297-3606
(reception) 561-297-3430
(fax) 561-297-3885
(email) smith@oe.fau.edu
(web) http://www.oe.fau.edu

***********************************