M
Mudcat
I have an image that displays on a canvas that works unless I put the
same code in a class. I can't figure that out. Here's what works:
def uts5100(self):
self.screen = Toplevel( self.master )
self.screen.geometry("+100+50")
self.screen.grab_set()
self.screen.focus_set()
self.screenType = "uts5100"
self.canvas = Canvas(self.screen)
self.canvas.create_image(20, 20, image = self.empty5100,
anchor=NW, tags = "chasis" )
self.canvas.pack()
The image is opened in another function:
def openImages(self):
self.empty5100 = ImageTk.PhotoImage( Image.open("Images/" +
"5100empty.bmp") )
However if I do the same thing, but in it's own class, the image does
not appear:
def uts5100(self):
sys5100 = UTS5100( self.master )
class UTS5100:
def __init__(self, master):
self.master = master
self.openImages()
self.draw()
def openImages(self):
self.empty5100 = ImageTk.PhotoImage( Image.open("Images/" +
"5100empty.bmp") )
def draw(self):
self.screen = Toplevel( self.master )
self.screen.geometry("+100+50")
self.screen.grab_set()
self.screen.focus_set()
self.screenType = "uts5100"
self.canvas = Canvas(self.screen)
self.image = self.canvas.create_image(20, 20, image =
self.empty5100, anchor=NW, tags = "chasis" )
self.canvas.pack()
They are called from a button that when pressed creates the window
where the image is supposed to appear. Obviously there is something
that I am missing when putting this window into it's own class, but I
can't figure it out.
Anyone got an idea why this is happening?
Thanks
same code in a class. I can't figure that out. Here's what works:
def uts5100(self):
self.screen = Toplevel( self.master )
self.screen.geometry("+100+50")
self.screen.grab_set()
self.screen.focus_set()
self.screenType = "uts5100"
self.canvas = Canvas(self.screen)
self.canvas.create_image(20, 20, image = self.empty5100,
anchor=NW, tags = "chasis" )
self.canvas.pack()
The image is opened in another function:
def openImages(self):
self.empty5100 = ImageTk.PhotoImage( Image.open("Images/" +
"5100empty.bmp") )
However if I do the same thing, but in it's own class, the image does
not appear:
def uts5100(self):
sys5100 = UTS5100( self.master )
class UTS5100:
def __init__(self, master):
self.master = master
self.openImages()
self.draw()
def openImages(self):
self.empty5100 = ImageTk.PhotoImage( Image.open("Images/" +
"5100empty.bmp") )
def draw(self):
self.screen = Toplevel( self.master )
self.screen.geometry("+100+50")
self.screen.grab_set()
self.screen.focus_set()
self.screenType = "uts5100"
self.canvas = Canvas(self.screen)
self.image = self.canvas.create_image(20, 20, image =
self.empty5100, anchor=NW, tags = "chasis" )
self.canvas.pack()
They are called from a button that when pressed creates the window
where the image is supposed to appear. Obviously there is something
that I am missing when putting this window into it's own class, but I
can't figure it out.
Anyone got an idea why this is happening?
Thanks