Skip to content

Commit

Permalink
gui
Browse files Browse the repository at this point in the history
  • Loading branch information
Debson committed Nov 18, 2020
1 parent 1bcb42e commit d70a0b5
Showing 1 changed file with 44 additions and 18 deletions.
62 changes: 44 additions & 18 deletions ChaosMosaicGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,61 @@ def __init__(self, root):
self._root.title("Texture Synthesis Chaos Mosaic")
self._root.resizable(width=True, height=True)

Frame.__init__(self, root)
self.grid(row=0, column=0, sticky=tk.E+tk.W+tk.N+tk.S)

self._root.rowconfigure(0, weight=1)
self._root.columnconfigure(0, weight=1)


# Left side panel - options go here
self._optionsFrame = Frame(self._root)
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)

self._leftPanel = Frame(self)
self._leftPanel.grid(row=0, column=0, sticky=tk.N + tk.S + tk.E)



# Right panel configuration
self.rowconfigure(0, weight=1)
self.columnconfigure(1, weight=1)

self._rightPanel = Frame(self)
self._rightPanel.grid(row=0, column=1, sticky=tk.N + tk.S + tk.E)

self._rightPanel.rowconfigure(1, weight=1)
self._rightPanel.columnconfigure(0, weight=1)

self._outputInfoPanel = Frame(self._rightPanel)
self._outputInfoPanel.grid(row=0, column=0, sticky=tk.N + tk.S)

self._outputImageLabel = Label(self._outputInfoPanel, text="Synthesized Texture")
self._outputImageLabel.grid(row=0, column=0, sticky=tk.E+tk.W+tk.N+tk.S)

# Output image file panel
self._outputImageFrame = Frame(self._root)
self._outputImageFrame.grid(row=0, column=0, sticky=tk.E+tk.W+tk.N+tk.S)
self._outputImagePanel = Frame(self._rightPanel)
self._outputImagePanel.grid(row=1, column=0, sticky=tk.N + tk.S + tk.E)

self._outputImageFrame.rowconfigure(0, weight=1)
self._outputImageFrame.columnconfigure(0, weight=1)
self._outputImagePanel.rowconfigure(0, weight=1)
self._outputImagePanel.columnconfigure(0, weight=1)

self._original = Image.open("out/out.jpg")
self._image = ImageTk.PhotoImage(self._original )
self._display = Canvas(self._outputImageFrame, bd=0, highlightthickness=0)
self._display.create_image(0, 0, image=self._image, anchor=tk.NW, tags="IMG")
self._outputImage = Image.open("out/out.jpg")
self._outputImageTk = ImageTk.PhotoImage(self._outputImage)
self._outputImageCanvas = Canvas(self._outputImagePanel, bd=0, highlightthickness=0)
self._outputImageCanvas.create_image(0, 0, image=self._outputImageTk, anchor=tk.NW, tags="IMG")
self._outputImageCanvas.grid(row=0, column=0, sticky=tk.E + tk.W + tk.N + tk.S)

self._display.grid(row=0, column=0, sticky=tk.E+tk.W+tk.N+tk.S)
self._outputImageFrame.pack(fill=tk.BOTH, expand=1)
self.pack(fill=tk.BOTH, expand=1)

self._display.bind("<Configure>", self.resize)
self._rightPanel.bind("<Configure>", self.resize2)

def resize(self, event):
def resize2(self, event):
size = (event.width, event.height)

resized = self._original.resize(size, Image.ANTIALIAS)
self._image = ImageTk.PhotoImage(resized)
self._display.delete("IMG")
self._display.create_image(0, 0, image=self._image, anchor=tk.NW, tags="IMG")
resized = self._outputImage.resize(size, Image.ANTIALIAS)
self._outputImageTk = ImageTk.PhotoImage(resized)
self._outputImageCanvas.delete("IMG")
self._outputImageCanvas.create_image(0, 0, image=self._outputImageTk, anchor=tk.NW, tags="IMG")

def _uploadImage(self):
# choose image from file selector and upload to input label
Expand Down

0 comments on commit d70a0b5

Please sign in to comment.