David Cortesi | 4 Aug 2010 07:26
Picon

python 3.1 - tkinter 8.4 - no tile?

Hello. I'm beginning to explore Python 3 and tkinter (using Mac OSX 10.6).
Following the directions in (http://wiki.python.org/moin/TkInter) I verified that
>>> import tkinter
>>> tkinter._test()
does indeed open a little window as expected. So there is SOME fashion of tkinter and TCL/TK installed on this machine.

Next I attempt to run the "First (Real) Example" in (http://www.tkdocs.com/tutorial/firstexample.html), but get the error,

    File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/tkinter/ttk.py", line 47, in _load_tile  master.tk.eval('package require tile')

Looking at the ttk.py file I find it checks tkinter.TkVersion < 8.5, and in fact tkinter.TkVersion yields 8.4.

Performing the following google search,

     site:mail.python.org 'package require tile'

I observe that this same error has been mentioned 66 times over the last few years and with several versions of Python and different platforms. (It seems odd, when this problem has been arising since 2004, the latest version 3.1.2 of Python is still distributed with tkinter 8.4 and yet no tile package. But I digress.)

The usual advice is to install the tile package from sourceforge. So I tried to do this but encountered several problems, beginning with, where, ie what folder? Doesn't really matter, as I find that its ./configure script looks for a C compiler -- and the Apple Developer package is not installed on this system. I looked around in /bin and /usr but there doesn't seem to even be a lowly cc anywhere.

I'd appreciate any suggestions to get past this stone wall.

Thanks,

Dave Cortesi

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Kevin Walzer | 4 Aug 2010 13:53
Favicon

Re: python 3.1 - tkinter 8.4 - no tile?

You're correct that ttk didn't come built-in to Tk until 8.5--hence the 
need for the Tile package with 8.4. I believe the most recent Tile 
package is 0.8 or 0.8.2, at the site you referenced.

As for a compiler, install Apple's developer tools (Xcode and friends) 
and you'll have a working gcc. The dev tools are an optional install on 
the DVD, or can be downloaded from Apple.

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
David Cortesi | 4 Aug 2010 17:13
Picon

Re: python 3.1 - tkinter 8.4 - no tile?


On Wed, Aug 4, 2010 at 4:53 AM, Kevin Walzer <kw <at> codebykevin.com> wrote:
You're correct that ttk didn't come built-in to Tk until 8.5--hence the need for the Tile package with 8.4. I believe the most recent Tile package is 0.8 or 0.8.2, at the site you referenced.

As for a compiler, install Apple's developer tools (Xcode and friends) and you'll have a working gcc. The dev tools are an optional install on the DVD, or can be downloaded from Apple.

Kevin, thanks for taking the time to reply.

I have Xcode installed on one of my macs, but not on the laptop where I meant to experiment with Py 3 and Tk.

I had hoped, since Tk is the default, expected, distributed-with-python GUI framework (so says the python wiki) that it would "just work." On the contrary, it appears that to make it work, I will have to install Xcode, and figure out how to do an install of this package. And there are several unknowns in that install, for OS X, beginning with, where in /Library to put it, or if not in /Library, where? Wherever, I also have to edit my .login to set PYTHONPATH appropriately so it can be found.

It seems to me this all amounts to quite a steep barrier for someone to climb, just in order to try out the supposed default GUI.

To me, the really puzzling question is, since this has been the case for several years (based on the history of the same error being encountered repeatedly), why is the very latest Python apparently being distributed with tkinter 8.4 but without tile?

Dave Cortesi
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Kevin Walzer | 4 Aug 2010 23:23
Favicon

Re: python 3.1 - tkinter 8.4 - no tile?

On 8/4/10 11:13 AM, David Cortesi wrote:

> I have Xcode installed on one of my macs, but not on the laptop where I
> meant to experiment with Py 3 and Tk.
>
> I had hoped, since Tk is the default, expected, distributed-with-python
> GUI framework (so says the python wiki) that it would "just work." On
> the contrary, it appears that to make it work, I will have to install
> Xcode, and figure out how to do an install of this package. And there
> are several unknowns in that install, for OS X, beginning with, where in
> /Library to put it, or if not in /Library, where? Wherever, I also have
> to edit my .login to set PYTHONPATH appropriately so it can be found.
>
> It seems to me this all amounts to quite a steep barrier for someone to
> climb, just in order to try out the supposed default GUI.

I believe that the system build of Python 2.6 on Snow Leopard (the one 
installed by Apple) is linked against Tk 8.5, which includes the ttk 
widgets. You'd still need to install the Python ttk wrapper module from 
http://code.google.com/p/python-ttk/, but that's easier than building 
the Tile module from scratch. Just download the code, and run "sudo 
/usr/bin/python setup.py install" and you should be in business.

>
> To me, the really puzzling question is, since this has been the case for
> several years (based on the history of the same error being encountered
> repeatedly), why is the very latest Python apparently being distributed
> with tkinter 8.4 but without tile?

The maintainers of the Mac build of Python from Python.org (not the same 
as the system install of Python included by Apple) decided to keep their 
build of Python linked to 8.4 for backward compatibility--that build of 
Python has to support several versions of OS X. While they do distribute 
Tkinter, they don't include the Tcl/Tk libraries that Tkinter depends 
on--those are installed by Apple. Apple's installation of Tcl/Tk 8.4 
doesn't include Tile for whatever reason, hence, Python's ttk module 
won't work.

--Kevin

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
diskhub | 11 Aug 2010 16:33
Picon
Favicon
Gravatar

Tkinter GUI change background image on button pressed?


How do i make my tkinter gui change background image on button pressed?
Can someone guide me?
--

-- 
View this message in context: http://old.nabble.com/Tkinter-GUI-change-background-image-on-button-pressed--tp29408957p29408957.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
David Hutto | 12 Aug 2010 01:54
Picon

Re: Tkinter GUI change background image on button pressed?

On Wed, Aug 11, 2010 at 10:33 AM, diskhub <hyperila <at> hotmail.com> wrote:
>
> How do i make my tkinter gui change background image on button pressed?
> Can someone guide me?
> --
> View this message in context: http://old.nabble.com/Tkinter-GUI-change-background-image-on-button-pressed--tp29408957p29408957.html
> Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss <at> python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>

try background ='red' in the ()'s
Chris Chia | 12 Aug 2010 01:48
Picon

Python Tkinter Simple Qn

Hi i have the following problem with Python Tkinter.
I switch to switch the image background (which i used Tkinter.Label with image arg to display on the GUI).

How can I do that? the callback function which i have created doesn't seem to work...
some advice?

below is my code:


import Tkinter as tk
from PIL import Image, ImageTk

root = tk.Tk()

# having problem with switching the image
def callback(event):
    global root
    root.panel1.pack_forget()
    root.panel1.image = image2
    root.panel1.pack()

   
def app():
   
    root.title('FIT 2022 Assignment 1')
     
    # pick an image file you have .bmp .jpg .gif. .png
    # load the file and covert it to a Tkinter image object
    imageFile = "c:\\test1.jpg"
    image1 = ImageTk.PhotoImage(Image.open(imageFile))
    imageFile2 = "c:\\test2.jpg"
    image2 = ImageTk.PhotoImage(Image.open(imageFile2))


    # get the image size
    w = image1.width()
    h = image1.height()

     
    # position coordinates of root 'upper left corner'
    x = 0
    y = 0

     
    # make the root window the size of the image
    root.geometry("%dx%d+%d+%d" % (w, h, x, y))

     
    # root has no image argument, so use a label as a panel
    panel1 = tk.Label(root, image=image1)
    panel1.pack(side='top', fill='both', expand='yes')
    panel1.image = image1
    panel1.bind("<Button-1>", callback)


    panel1.pack()
    root.mainloop()


app()




--
Regards,
Chris

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Firat Ozgul | 12 Aug 2010 08:15
Picon

Re: Python Tkinter Simple Qn

Hello,

I posted the code in here:

http://paste-it.net/public/y1ba880/

Firat

2010/8/12 Chris Chia <chrischia82 <at> gmail.com>
Hi i have the following problem with Python Tkinter.
I switch to switch the image background (which i used Tkinter.Label with image arg to display on the GUI).

How can I do that? the callback function which i have created doesn't seem to work...
some advice?

below is my code:


import Tkinter as tk
from PIL import Image, ImageTk

root = tk.Tk()

# having problem with switching the image
def callback(event):
    global root
    root.panel1.pack_forget()
    root.panel1.image = image2
    root.panel1.pack()

   
def app():
   
    root.title('FIT 2022 Assignment 1')
     
    # pick an image file you have .bmp .jpg .gif. .png
    # load the file and covert it to a Tkinter image object
    imageFile = "c:\\test1.jpg"
    image1 = ImageTk.PhotoImage(Image.open(imageFile))
    imageFile2 = "c:\\test2.jpg"
    image2 = ImageTk.PhotoImage(Image.open(imageFile2))


    # get the image size
    w = image1.width()
    h = image1.height()

     
    # position coordinates of root 'upper left corner'
    x = 0
    y = 0

     
    # make the root window the size of the image
    root.geometry("%dx%d+%d+%d" % (w, h, x, y))

     
    # root has no image argument, so use a label as a panel
    panel1 = tk.Label(root, image=image1)
    panel1.pack(side='top', fill='both', expand='yes')
    panel1.image = image1
    panel1.bind("<Button-1>", callback)


    panel1.pack()
    root.mainloop()


app()




--
Regards,
Chris

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Firat Ozgul | 12 Aug 2010 14:55
Picon

Re: Python Tkinter Simple Qn

My previous code was erroneous. Therefore I edited it.

http://paste-it.net/public/u46e119/

2010/8/12 Chris Chia <chrischia82 <at> gmail.com>
Hi i have the following problem with Python Tkinter.
I switch to switch the image background (which i used Tkinter.Label with image arg to display on the GUI).

How can I do that? the callback function which i have created doesn't seem to work...
some advice?

below is my code:


import Tkinter as tk
from PIL import Image, ImageTk

root = tk.Tk()

# having problem with switching the image
def callback(event):
    global root
    root.panel1.pack_forget()
    root.panel1.image = image2
    root.panel1.pack()

   
def app():
   
    root.title('FIT 2022 Assignment 1')
     
    # pick an image file you have .bmp .jpg .gif. .png
    # load the file and covert it to a Tkinter image object
    imageFile = "c:\\test1.jpg"
    image1 = ImageTk.PhotoImage(Image.open(imageFile))
    imageFile2 = "c:\\test2.jpg"
    image2 = ImageTk.PhotoImage(Image.open(imageFile2))


    # get the image size
    w = image1.width()
    h = image1.height()

     
    # position coordinates of root 'upper left corner'
    x = 0
    y = 0

     
    # make the root window the size of the image
    root.geometry("%dx%d+%d+%d" % (w, h, x, y))

     
    # root has no image argument, so use a label as a panel
    panel1 = tk.Label(root, image=image1)
    panel1.pack(side='top', fill='both', expand='yes')
    panel1.image = image1
    panel1.bind("<Button-1>", callback)


    panel1.pack()
    root.mainloop()


app()




--
Regards,
Chris

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
chris chia | 13 Aug 2010 12:19
Picon
Favicon
Gravatar

Continued: force the GUI to switch image instead of relying on the <button-1> event

I wish to do a multi threading program such that user can still use the console to control this GUI.
Can I ask u how can i write a command to force the GUI to switch image instead of relying on the <button-1> event.

thanks to Firat,

his code is as the following:
import sys
import Tkinter as tk
from PIL import Image, ImageTk

class ImageViewer(object):
def __init__(self):
self.imagelist = [image1, image2]
self.create_widgets()
self.ind = 0

def create_widgets(self):
self.label = tk.Label(image = self.imagelist[0])
self.label.pack()
self.label.bind("<Button-1>", self.change_image)

def change_image(self, event):
self.ind += 1
self.label.update()
try:
self.label["image"] = self.imagelist[self.ind]
except IndexError:
pass


root = tk.Tk()

image1 = ImageTk.PhotoImage(file = "test1.jpg")
image2 = ImageTk.PhotoImage(file = "test2.jpg")


w = image1.width()
h = image1.height()

x = 0
y = 0

root.geometry("%dx%d+%d+%d" % (w, h, x, y))
app = ImageViewer()

root.mainloop()


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Gmane