Advertisement
Guest User

tkinter

a guest
Jul 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter as tk
  3. from PIL import ImageTk, Image
  4. import tkinter.filedialog as filedialog
  5. from model_recognition import main
  6.  
  7.  
  8. def LoadFile(ev):
  9.     global filename
  10.     filename = filedialog.askopenfilename(initialdir="./", title="Select file",
  11.                                                filetypes=(("jpeg files", "*.jpg"), ("png files", "*.png")))
  12.     print(filename)
  13.  
  14.  
  15. def ShowImg():
  16.     img_label = Label(root)
  17.     img_label.image = ImageTk.PhotoImage(Image.open('./test.jpg'))
  18.     img_label.pack()
  19.  
  20.  
  21. root = Tk()
  22. filename = ''
  23. panelFrame = Frame(root, height=60, bg='gray')
  24. textFrame = Frame(root, height=340, width=600)
  25.  
  26. panelFrame.pack(side='top', fill='x')
  27. textFrame.pack(side='bottom', fill='both', expand=1)
  28.  
  29. textbox = Text(textFrame, font='Arial 14', wrap='word')
  30. textbox.pack(side='left', fill='both', expand=1)
  31.  
  32. loadBtn = Button(panelFrame, text='Load')
  33. loadBtn.bind("<Button-1>", LoadFile)
  34. loadBtn.place(x=10, y=10, width=40, height=40)
  35. #
  36. # showBtn = Button(panelFrame, text='Show')
  37. # showBtn.bind("<Button-2>", ShowImg)
  38. # showBtn.place(x=50, y=10, width=40, height=40)
  39.  
  40. ShowImg()
  41. root.mainloop(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement