I should be the one to apologize; I included code that is required for packages
created by pyinstaller, which is a tool that will take a Python script and turn
it into a self-contained executable. Let me try again:
import Tkinter as tk
import ttk
photo = tk.PhotoImage(file='myImageFile.gif'))
myLabel = ttk.Label(self.myFrame, image=self.photo)
myLabel.grid()
This is just the Tkinter code. I have "tk.PhotoImage()" instead of just
"PhotoImage()" because of the way I imported Tkinter. Most examples will
probably show this:
from Tkinter import *
so you would not need the "tk." prefix. I prefer to keep the namespaces
separate.
I use "ttk.Label()" instead of "tk.Label()" because I like the newer ttk
widgets better.
On Oct 4, 2012, at 11:59 AM, Matthew Ngaha <[email protected]> wrote:
> On Thu, Oct 4, 2012 at 7:23 PM, Lynn Oliver <[email protected]> wrote:
>> I know this isn't exactly what you asked, but I am displaying an image in a
>> label in a --onefile distribution, and this code works both while debugging
>> and while running the packaged application:
>>
>> if getattr(sys, 'frozen', None):
>> basedir = sys._MEIPASS
>> else:
>> basedir = os.path.dirname(__file__)
>> self.photo = tk.PhotoImage(file=os.path.join(basedir,
>> 'myImage.gif'))
>> self.myLabel = ttk.Label(self.myFrame, image=self.photo)
>> self.myLabel.grid()
>>
>> Lynn
>
> i am very new to programming and all that code is confusing me:( sorry:)
>
>> Hi Matthew,
>>
>> Your first line should in fact be:
>>
>> from PIL import Image
>>
>> ...then your line:
>>
>> my_image = Image.open("imagepath.jpg")
>>
>> Mick
>
> it gave me an ImportError saying no module named PIL
> _______________________________________________
> Tkinter-discuss mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/tkinter-discuss
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss