[Tkinter-discuss] Opening a .py that uses Tkinter on OS X pops open a console window

Kevin Walzer kw at codebykevin.com
Tue Mar 18 19:38:59 CET 2008


Jonathan Frankel wrote:
> I'm on 10.4.11, and I just updated python to the most recent version,
> with the Tkinter that came with it.
> 
> When I do this:
> 
> 
> class App(Tk):
> 
>     def __init__(self, parent):
> 
>         Tk.__init__(self, parent)
> 
>         try:
>             self.tk.call('console','hide')
>         except TclError:
>             pass
> 
> I get another error when I run it:
> 
> 
> ...., line 19, in __init__
>     Tk.__init__(self, parent)
>   File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py",
> line 1636, in __init__
>     self.tk = _tkinter.create(screenName, baseName, className,
> interactive, wantobjects, useTk, sync, use)
> TypeError: create() argument 1 must be string or None, not instance
> 
> 
> Is this related to how I'm instantiating my App object (app=App(root))
> in the first place?
> 

Not sure.

This works for me:

from Tkinter import *

class App(Tk):

     def __init__(self, parent):

         Tk.__init__(self, parent)

         try:
             self.tk.call('console','hide')
         except TclError, msg:
             print msg

if __name__ == '__main__':
     app = App(None)
     app.mainloop()




-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com


More information about the Tkinter-discuss mailing list