Newbie: Tkinter and macPython

Discussion in 'Python' started by gt, Jun 29, 2003.

  1. gt

    gt Guest

    I'm waffling between Ruby, and Python as a programming
    language.
    I borrowed a friends book on Ruby, and have played with
    it a bit.
    I went by the library to check out 'Learning Python'
    but i was too late, the library had closed already...

    Anyway, to the point.
    I downloaded macPython for OSX, and was trying to get
    a simpe Tkinter example to work form Lundh's tutorial,
    I think it was.
    Bu I get an error...

    # File: hello1.py

    from Tkinter import *

    root = Tk()
    w = Label(root, text="Hello, world!")
    w.pack()

    root.mainloop()


    error is:
    'Tk' is not defined

    and in the IDLE:

    Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/codeop.py",
    line 140, in __call__
    codeob = compile(source, filename, symbol, self.flags, 1)
    File "<input>", line 1
    root = Tk()
    ^
    SyntaxError: invalid syntax
    gt, Jun 29, 2003
    #1
    1. Advertising

  2. gt

    gt Guest

    "Russell E. Owen" <> wrote in message news:<bdq5nv$2bdo$>...
    > In article <>,
    > (gt) wrote:
    >
    > >I'm waffling between Ruby, and Python as a programming
    > >language.
    > >I borrowed a friends book on Ruby, and have played with
    > >it a bit.
    > >I went by the library to check out 'Learning Python'
    > >but i was too late, the library had closed already...
    > >
    > >Anyway, to the point.
    > >I downloaded macPython for OSX, and was trying to get
    > >a simpe Tkinter example to work form Lundh's tutorial,
    > >I think it was.
    > >Bu I get an error...
    > >
    > ># File: hello1.py

    >
    > You have hit MacPython at a slightly awkward time. MacPython (through
    > version 2.2.x) runs as a carbon application on MacOS X and the Tk
    > interface was never "carbonized" (I think because the underlying Tk was
    > never carbonized, but whatever the reason, the fact is it will not
    > work). (MacPython can also be configured as a classic app, simply by
    > double clicking the suitable application in the installation, in which
    > case Tkinter runs just fine at least if you boot into MacOS 9, I'm not
    > sure if it runs in Classic emulation mode.)
    >
    > If you want to run Python 2.2.x/Tkinter on MacOS X you can do it as
    > follows:
    >
    > Download and install aqua tcl/tk. Version 8.4.1 is the latest that will
    > work with Python 2.2.x. A binary distribution is available from
    > <http://www.maths.mq.edu.au/~steffen/tcltk/TclTkAqua/>; there are three
    > flavors available; I recommend TclTkAqua (having "wish" around is nice.
    > I'm not sure the full "BI" version adds anything you'll find useful.
    >
    > Download and install Python. For Python 2.2.x I suggest using Bob
    > Ippolito's binary installer <http://redivi.com/~bob/>, since it includes
    > Tkinter and some other useful stuff already built. Note that it also
    > includes wxPython, an alternate GUI that you may wish to look at.
    >
    > If you prefer to install thiss stuff from source, my home page
    > <http://www.astro.washington.edu/owen/> has a suitable link. Installing
    > from source is not for the faint of heart (though it'll be easier for
    > Python 2.3).
    >
    > Warning: unix Python 2.2.2 requires \n line endings for files, which is
    > not the Mac norm. Any decent text editor (e.g. BBEdit or Pepper) *can*
    > save files with \n, but you have to configure it to do it. This problem
    > will go away with Python 2.3.
    >
    >
    > Python 2.3 will be the first version that unifies "MacPython" and unix
    > Python (thanks to hard work by Jack Jansen and others). Python 2.3b1 is
    > available now from Jack's MacPython site
    > <http://homepages.cwi.nl/~jack/macpython.html>. Install aqua Tk/tcl as
    > above, then install the 2.3b1 binary installer. You have to do a bit
    > more work to get Tkinter installed -- I think MacPython 2.3b1 comes with
    > a package manager that will do the job, but I've not yet tried it.
    >
    > I personally use both 2.3b1 and have had no problems with it. (I
    > actually have a dual installation; 2.3b1 with aqua Tk and 2.2.2 with
    > unix style x-windowing Tk; both work well.)
    >
    > In conclusion, life will be grand when Python 2.3 is released. Meanwhile
    > it's a bit of work, but not too bad.
    >
    >
    > I hope this helps.
    >
    > -- Russell


    Wow.
    I never expected anything this thourough for a response.
    Thanks Russell.
    I have actually installed MacPython 2.3b1.
    I tried the package manager, but at the time it wouldnt connect to
    the 'database' (if I remember correctly)
    At any rate, it looks like I need aqua Tk.
    It would seem that I should un-install 2.3b1, install
    aqua Tk, then reinstall 2.3b1 and implement the package manager.
    Thanks again.

    -- Greg
    gt, Jul 1, 2003
    #2
    1. Advertising

  3. In article <>,
    (gt) wrote:

    >Wow.
    >I never expected anything this thourough for a response.
    >Thanks Russell.
    >I have actually installed MacPython 2.3b1.
    >I tried the package manager, but at the time it wouldnt connect to
    >the 'database' (if I remember correctly)
    >At any rate, it looks like I need aqua Tk.
    >It would seem that I should un-install 2.3b1, install
    >aqua Tk, then reinstall 2.3b1 and implement the package manager.
    >Thanks again.


    Sorry to hear that. The package manager in 2.3b1 had some bugs that are
    probably fixed in 2.3b2, but it's so new that I don't think there's a
    binary installer for MacOS X yet.

    I doubt you need to uninstall your Python.

    Installing Tk in advance is important if you buld Python from source
    (because the make script automatically builds Tkinter for you if it can
    find Tcl/Tk). I don't think it matters when installing from binary.

    Unfortunately, I do not know how to add Tkinter to the binary installed
    version of Python 2.3 (given that you are having trouble with the
    package manager). I'm sure somebody does know. Try posting to the
    MacPython mailing list.

    Two other options are:
    - Build Python from source (e.g. see link below). A bit slow but it
    certainly does work.
    - Use Bob Ippolito's binary installer for Python 2.2.2, which includes
    lots of extras.

    I've put what I know about building Python for MacOS X at
    <http://www.astro.washington.edu/owen/PythonOnMacOSX.html>. Probably not
    much there I didn't already post, but at least now it's in one place and
    can be updated. I'm hoping Python 2.3 final will be so easy to install
    that extra information is redundant.

    -- Russell
    Russell E. Owen, Jul 1, 2003
    #3
  4. >>>>> (gt) (GT) wrote:

    GT> I'm waffling between Ruby, and Python as a programming
    GT> language.
    GT> I borrowed a friends book on Ruby, and have played with
    GT> it a bit.
    GT> I went by the library to check out 'Learning Python'
    GT> but i was too late, the library had closed already...

    GT> Anyway, to the point.
    GT> I downloaded macPython for OSX, and was trying to get
    GT> a simpe Tkinter example to work form Lundh's tutorial,
    GT> I think it was.
    GT> Bu I get an error...

    I guess you have downloaded a Python installation with proper Tkinter
    support. I had that also a few weeks ago. I installed the new 2.3b2 from
    source and it works.
    --
    Piet van Oostrum <>
    URL: http://www.cs.uu.nl/~piet [PGP]
    Private email:
    Piet van Oostrum, Jul 5, 2003
    #4
  5. >>>>> Piet van Oostrum <> (PvO) wrote:

    PvO> I guess you have downloaded a Python installation with proper Tkinter

    of course that should have been ... without ...
    --
    Piet van Oostrum <>
    URL: http://www.cs.uu.nl/~piet [PGP]
    Private email:
    Piet van Oostrum, Jul 5, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    289
    Michael S. Jessop
    Jul 14, 2003
  2. Chris Fonnesbeck

    scrollback in macpython

    Chris Fonnesbeck, Jul 17, 2003, in forum: Python
    Replies:
    1
    Views:
    292
    Skip Montanaro
    Jul 17, 2003
  3. Charles Starrett

    Subject: MacPython-OS9 2.2.3 & Tkinter

    Charles Starrett, Aug 5, 2003, in forum: Python
    Replies:
    0
    Views:
    311
    Charles Starrett
    Aug 5, 2003
  4. Leo
    Replies:
    4
    Views:
    348
    Skip Montanaro
    Oct 14, 2003
  5. Gregor
    Replies:
    0
    Views:
    268
    Gregor
    Oct 17, 2003
Loading...

Share This Page