Skip to content

Instantly share code, notes, and snippets.

@RicherMans
Last active August 29, 2015 14:19
Show Gist options
  • Save RicherMans/bf0b619a70a139923573 to your computer and use it in GitHub Desktop.
Save RicherMans/bf0b619a70a139923573 to your computer and use it in GitHub Desktop.
Billy's fix
from Tkinter import *
from PIL import ImageTk, Image
class App(Frame):
im = None
grayIm = None
def openFile(self, file_path):
self.im = Image.open(file_path)
def displayImage(self, panelImg, im, r, c):
img = ImageTk.PhotoImage(im)
panel = Label(panelImg, padx=10, pady=10, image=img)
panel.img = img
panel.grid(column=c, row=r)
def openNewWindow(self, event):
winf = Toplevel()
Wind(winf, self.im)
winf.mainloop()
def __init__(self, parent):
Frame.__init__(self, parent)
self.grid()
self.mainCont = Frame(root)
self.btn = Button(
root, text="New window", command=lambda: self.openNewWindow(0))
self.openFile('Lenna.jpg')
self.displayImage(root, self.im, 0, 0)
self.btn.grid(row=1, column=0)
class Wind(Frame):
def displayImage(self, panelImg, im, r, c):
img = ImageTk.PhotoImage(im)
panel = Label(panelImg, padx=10, pady=10, image=img)
panel.img = img
panel.grid(column=c, row=r)
def __init__(self, parent, im):
Frame.__init__(self, parent)
self.im = im
self.displayImage(parent, self.im, 0, 0)
if __name__ == "__main__":
root = Tk()
root.title('Image Processing')
app = App(root)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment