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.geo metry("+100+50" )
self.screen.gra b_set()
self.screen.foc us_set()
self.screenType = "uts5100"
self.canvas = Canvas(self.scr een)
self.canvas.cre ate_image(20, 20, image = self.empty5100,
anchor=NW, tags = "chasis" )
self.canvas.pac k()
The image is opened in another function:
def openImages(self ):
self.empty5100 = ImageTk.PhotoIm age( Image.open("Ima ges/" +
"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.PhotoIm age( Image.open("Ima ges/" +
"5100empty.bmp" ) )
def draw(self):
self.screen = Toplevel( self.master )
self.screen.geo metry("+100+50" )
self.screen.gra b_set()
self.screen.foc us_set()
self.screenType = "uts5100"
self.canvas = Canvas(self.scr een)
self.image = self.canvas.cre ate_image(20, 20, image =
self.empty5100, anchor=NW, tags = "chasis" )
self.canvas.pac k()
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.geo metry("+100+50" )
self.screen.gra b_set()
self.screen.foc us_set()
self.screenType = "uts5100"
self.canvas = Canvas(self.scr een)
self.canvas.cre ate_image(20, 20, image = self.empty5100,
anchor=NW, tags = "chasis" )
self.canvas.pac k()
The image is opened in another function:
def openImages(self ):
self.empty5100 = ImageTk.PhotoIm age( Image.open("Ima ges/" +
"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.PhotoIm age( Image.open("Ima ges/" +
"5100empty.bmp" ) )
def draw(self):
self.screen = Toplevel( self.master )
self.screen.geo metry("+100+50" )
self.screen.gra b_set()
self.screen.foc us_set()
self.screenType = "uts5100"
self.canvas = Canvas(self.scr een)
self.image = self.canvas.cre ate_image(20, 20, image =
self.empty5100, anchor=NW, tags = "chasis" )
self.canvas.pac k()
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
Comment