I have a standalone application on my desktop written in Python. I am using modules like Tkinter, cv2, numpy in my application. My Tkinter renders my GUI (which has a button and an image). Now my issue is that I want to make it a web application. For this purpose, I am using Django framework which asks to segregate Model ,View and Template(MTV) . How do I render the same GUI with the same buttons and images using HTML. (My GUI having buttons and image should be in the Template while my business logic should be in View.) This is the piece of code which I want to convert to MTV Form. I want the Upload button to be in the Template(HTML). Onclick of the Upload button the program should go to the View(Logic).How do I segregate the logic and the HTML? (Is it even necessary? Can i convert the entire thing to Django framework without segregating) Please Help.
def upload():
global original_img,img,img2,img3,image_path,old_label_image,photo,label,image_path,image,ax,fig
print "upload"
image_path=tkFileDialog.askopenfilename()
image = Image.open(image_path)
original_img= image.copy()
image.thumbnail((1000,625))
photo = ImageTk.PhotoImage(image)
label = Label(image=photo)
label.image = photo
if old_label_image is not None:
old_label_image.destroy()
old_label_image = label
#label.update()
label.pack()
root = Tk.Tk() # creating an instance of Tk class
print "main"
old_label_image = None
frame = Frame(root) #creates a new window (given by the pathName argument) and makes it into a frame widget.The frame command returns the path name of the new window.
frame.pack() #The Pack geometry manager packs widgets in rows or columns
bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )
UploadButton = Button(frame, text="Upload", command= upload)
UploadButton.pack( side = LEFT)
root.mainloop()