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.t itle('Results')
picts = [ImageTk.PhotoIm age(file = x) for x in figures]
butRW = Button(ResultsW indow, text = 'CLOSE', command =
ResultsWindow.d estroy)
butRW.pack()
height = sum([x.height() for x in picts])
width = picts[0].width()
y = 0
for pict in picts:
label = Label(ResultsWi ndow,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! :) 2 5544
On Aug 22, 9:17 am, Pedro <Pedro.Tarr...@ gmail.comwrote:
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.t itle('Results')
picts = [ImageTk.PhotoIm age(file = x) for x in figures]
butRW = Button(ResultsW indow, text = 'CLOSE', command =
ResultsWindow.d estroy)
butRW.pack()
height = sum([x.height() for x in picts])
width = picts[0].width()
y = 0
for pict in picts:
label = Label(ResultsWi ndow,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! :)
You can try making a class for the Tkinter.Topleve l window. I don't
have PIL, but I know if you query for a widget's value when the window
is not yet displayed, it will give a nearly 0-by-0 size result.
You can also try to set a size for the Toplevel window and see if the
images display.
I have not encountered this before, but I only know what I have read
from books (like Programming Python by O'Reilly) and have assumed.
Good luck.
Pedro wrote:
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?
this was cross-posted to the tkinter mailing list; in case someone
stumbles upon this via a search engine, here's a link that explains why
this happens: http://effbot.org/tkinterbook/photoimage.htm#note
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fuzzyman |
last post by:
I'm working on a presentation program that needs to produce 'full
screen' images.
The effect will be something like a powerpoint presentation.
In actual fact it's a song database with lyrics - and each 'screen'
will need a widget for next verse, previous verse, chorus etc..... so
what I'd really like is a Tk text widget that is full screen sized.
(For the moment I'll just use a large window - most of the work will
be in building the...
|
by: Michael Zhang |
last post by:
My project uses Python-2.3.4 + Tkinter + PIL-1.1.4 to retrieve images
from server and display those images.
I created a thread (also a separate toplevel window) for displaying
images and another thread for recording the frame rates (using a
progress bar for visulization). The whole application worked very well
once it received image data from the socket.
The problem is when I tried to close that display window (click on the
standard...
|
by: max(01)* |
last post by:
hi people.
when i create a widget, such as a toplevel window, and then i destroy
it, how can i test that it has been destroyed? the problem is that even
after it has been destroyed, the instance still exists and has a tkinter
name, so testing for None is not feasible:
>>> import Tkinter
>>> fin = None
>>> fin1 = Tkinter.Toplevel()
|
by: Stewart Midwinter |
last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item
that does nothing more than fetch a directory listing and display it
in a Toplevel window (I'd use a tkMessageBox showinfo widget, but for
some reason the text is invisible on cygwin).
After I close the Toplevel widget, all of the menus in my app behave
as though they have no contents to them, i..e I can press on the File
menu button, and see it depress, but the Exit...
|
by: yvesd |
last post by:
hello i want to intercept tkinter python system events like
wm_delete_window
and if possible for any window, but the newest code I've produced give
me
an error :
Traceback (most recent call last):
File "C:\Documents and Settings\yvesd\Bureau\protowin.py", line 36,
in ?
b1 = Tkinter.Button (win1)
| |
by: aldonnelley |
last post by:
Hi all.
Just having a weird problem with tkinter. I'm trying to make a gui that
shows results from an image search, with a "forward" and "back" button
so the user can compare results from different pages. All that's
working fine...
The problem I'm having is that the images don't show onscreen the first
time the "first page" of results shows up. When I click the "search
again" button, and have more than the original results page to...
|
by: Gigs_ |
last post by:
class MenuDemo(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.createWidgets()
def createWidgets(self):
self.makeMenuBar()
self.makeToolBar()
L = Label(self, text='Menu and Toolbar demo')
|
by: Chris |
last post by:
Hi,
If a user resizes a Toplevel window, or I set a Toplevel's geometry
using the geometry() method*, is there any way to have the geometry
reset to that required for all the widgets?
I think I found what I'm looking for in tk itself:
"""
13.3. How can I clear the geometry settings for a toplevel?
If you want to have Tk resize your toplevel to what the toplevel
|
by: J-Burns |
last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in
programming itself... :P. Need some help here.
Problem 1:
How do I make something appear on 2 separate windows using Tkinter? By
this I mean that the format would be something like this:
You have Page1 : This has 2-3 buttons on it.
Clicking on each button opens up a new window respectively having
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |