[Tkinter-discuss] Tkinter, toplevel and images

Reson reson5 at cox.net
Wed Sep 3 02:16:20 CEST 2008


Hi!
changing extension to pyw (in windows) can help ;)
Reson


ptg wrote:
> 
> 
> Hi 
>  I'm trying to build a small application that can display some images 
>  in a toplevel window. I have this code: 
>  def Results(master): 
>      from Tkinter import Toplevel, Button, Label 
>      from PIL import ImageTk 
>      figures = ['first.png', 'second.png'] 
>      ResultsWindow = Toplevel(master) 
>      ResultsWindow.title('Results') 
>      picts = [ImageTk.PhotoImage(file = x) for x in figures] 
>      butRW = Button(ResultsWindow, text = 'CLOSE', command = 
>  ResultsWindow.destroy) 
>      butRW.pack() 
>      height = sum([x.height() for x in picts]) 
>      width = picts[0].width() 
>      y = 0 
>      for pict in picts: 
>          label =
> Label(ResultsWindow,image=pict).pack() 
>          y += pict.height() 
>  from Tkinter import Tk 
>  root = Tk() 
>  Results(root) 
>  root.mainloop() 
>  and I just can see a grey window with a "close" button... However, 
>  when I try the same code with the root I can see both images... Can 
>  anyone give me a tip? 
>  Thanks! :)  
> 
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
> 
> 

-- 
View this message in context: http://www.nabble.com/Tkinter%2C-toplevel-and-images-tp19112323p19280820.html
Sent from the Python - tkinter-discuss mailing list archive at Nabble.com.



More information about the Tkinter-discuss mailing list