Hello everybody!!
I would like some help with the following problem:
I have the following piece of code: -
-
from Tkinter import *
-
root = Tk()
-
menuframe=Frame(root,height="1c",width="30c",bg="#d5ab6c",bd=2,relief=RAISED)
-
menuframe.pack(expand=NO,side=TOP,fill=BOTH)
-
mainframe=Frame(root,height="19.8c",width="30c",bg="#d5ab3c",bd=2,relief=RAISED)
-
mainframe.pack()#expand=NO,side=TOP,fill=BOTH)
-
CN=Canvas(mainframe,height="19.8c",width="30c",bg="#d5ab3c")
-
images="C:/Python25/pic.GIF"
-
photo1=PhotoImage(file=images)
-
CN.create_image("15c","9.9c",image=photo1)
-
CN.pack()
-
-
mBar = Frame(menuframe, relief=RAISED, borderwidth=2)
-
mBar.pack(fill=X,side=LEFT)
-
-
ArxBtn = makeArxiaMenu()
-
KinBtn = makeKiniseisMenu()
-
EktBtn = makeEktyposeisMenu()
-
VoiBtn = makeVoithitikaMenu()
-
RytBtn = makeRythmiseisMenu()
-
EpiBtn = makeEpikoinoniesMenu()
-
mBar.tk_menuBar(ArxBtn,KinBtn,EktBtn,VoiBtn,RytBtn,EpiBtn)
-
-
-
root.title('Window App by Elias')
-
root.geometry("1142x800")
-
root.mainloop()
-
-
Then , from the buttons of the menu , i can "destroy" the mainframe and recreate it as it should be for the coresponding function.
Here is an example for the code i use in one of the functions: -
-
def Polites():
-
global mainframe
-
mainframe.destroy()
-
mainframe=Frame(root,height="19.8c",width="30c",bd=4,relief=RAISED)
-
mainframe.pack(anchor=SW)
-
-
Pict=Canvas(mainframe,height="19.8c",width="30c",bg="#d5ab3c")
-
images="C:/Python25/maria.GIF"
-
photo1=PhotoImage(file=images)
-
Pict.create_image("15c","9.9c",image=photo1)
-
Pict.grid()
-
-
The problem is that the program "refuses" to display any image in the child
widgets of mainframe ( i tried through Canvas and Label ).
The strange things are :
1)All works fine in the initial mainframe ( the picture is displayed ) but in the
next mainframe construction ...no Images.
2) the space of the widget is actually there , and the widgets are responsive for text inserts etc... BUT , no Images.
I am working on Windows Vista , Pyhton 2.5
I would be gratefull for any help on this....
Thank you all in advance...
Elias
4 2429
Right off the bat, I notice that you use different geometry managers.
widget.grid() and widget.pack() are not equivalent. NOTE: The geometry managers may not be mixed in a single frame.
If I get some time later, I'll try running you program on my system.
In case you haven't found the Tkinter docs yet: An Introduction to Tkinter.
You'll notice that they are quite old. Generally, Tkinter is not getting much support these days.
Hope that helps,
Barton
Dear Bartonc ,
I thank you for your quick reply to my question.
I know that mixing the layout managers is messy , but i dont think the
problem is there. Here is a simpler example of code i tried which again ,
refuses to draw the images.... -
-
from Tkinter import *
-
-
-
def f1():
-
mainframe=Frame(root)
-
mainframe.pack()
-
CN=Canvas(mainframe,height="9.8c",width="15c",bg="#d5ab3c")
-
images="C:/Python25/Bother/3.GIF"
-
photo1=PhotoImage(file=images)
-
CN.create_image("7.55c","4.9c",image=photo1)
-
CN.pack()
-
-
-
def f2():
-
mainframe2=Frame(root)
-
mainframe2.pack()
-
CN=Canvas(mainframe2,height="9.8c",width="15c",bg="#d5ab3c")
-
images="C:/Python25/GIFS/5bl.103b.GIF"
-
photo1=PhotoImage(file=images)
-
CN.create_image("7.5c","4.9c",image=photo1)
-
CN.pack()
-
-
root=Tk()
-
f1()
-
f2()
-
root.mainloop()
-
-
It seems like i am missing something basic here.....
Thanks again for your time... :)
Elias
Dear Bartonc ,
I thank you for your quick reply to my question.
I know that mixing the layout managers is messy , but i dont think the
problem is there.
Thanks again for your time... :)
Elias
I wasn't suggesting that mixing GMs was the problem, simply warning you about the conflict. What I suggest is that this: -
-
def Polites():
-
global mainframe
-
mainframe.destroy()
-
mainframe=Frame(root,height="19.8c",width="30c",bd=4,relief=RAISED)
-
mainframe.pack(anchor=SW)
-
-
Pict=Canvas(mainframe,height="19.8c",width="30c",bg="#d5ab3c")
-
images="C:/Python25/maria.GIF"
-
photo1=PhotoImage(file=images)
-
Pict.create_image("15c","9.9c",image=photo1)
-
Pict.grid()
-
-
(as you said) works because it uses widget.grid() instead of .pack().
Just to close this thread ( in case anyone wondered what was the problem..):
The absense of the picture was due to a bug in PIL , which is fixed
if you append your images to a list, so the program "keeps them in mind",
else , they get forgoten , and blank space appears in their place.
Au revoir!!!
Elias
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Josh |
last post by:
Caution, newbie approaching...
I'm trying to come up with a very simple Tkinter test application that
consists of a window with a drop-down menu bar at the top and a grid
of colored rectangles...
|
by: Frank Stajano |
last post by:
The compact form of pack behaves differently (and I believe incorrectly)
compared to the long form. The following two scripts demonstrate it, at
least on this interpreter:
Python 2.3.2 (#1, Oct 9...
|
by: midtoad |
last post by:
I'm trying to display a GIF image in a label as the central area to a
Tkinter GUI. The image does not appear, though a space is made for it.
Why is this so?
I notice that I can display a GIF...
|
by: Terry Carroll |
last post by:
I've got a small batch image-processing program (it adds the time a
digital photo was taken to the lower right of the image), and as a
feature, I wanted to show a thumbnail of each image it was...
|
by: Michael Yanowitz |
last post by:
Hello:
Below I have included a stripped down version of the GUI I am working on.
It contains 2 dialog boxes - one main and one settings. It has the following
problems, probably all related, that...
|
by: sj |
last post by:
I am just learning to use Tkinter and am having problems displaying image
files. I am able to display an image using tutorials (such as
http://www.daniweb.com/code/snippet296.html) But when I try...
|
by: Andrew |
last post by:
Hello Ive been messing around with a simple raw image viewer using Pil
and Tkinter
However I am running into problems displaying the images they appear to
be not correct I believe it is cause of...
|
by: nish88 |
last post by:
hi to all...
i'm working on an animation where i have to make the picture background.gif transparent.
l'm not able to do it.can you please help me or tell me what codes i should add to make the...
|
by: execrable |
last post by:
I am writing a simple (maybe a bit conveluded, but I just started
learning Tkinter) program that uses a 'notebook' code snippet from a
python cookbook. It creates a customizable frame and radio...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |