-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageGUI.py
More file actions
61 lines (48 loc) · 1.93 KB
/
imageGUI.py
File metadata and controls
61 lines (48 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from tkinter import *
from tkinter import ttk
from tkinter.filedialog import askopenfilename
# from PIL import Image
import pytesseract
root = Tk( )
def readFimage():
path = PathTextBox.get('1.0','end-1c')
if path:
im = Image.open(path)
text = pytesseract.image_to_string(im, lang = 'eng')
print (text)
text1 = "GST Invoice No MH1000626011 \n Date of Invoice 02.11.2019 \n Billing doc No 92029731 \n GSTIN 27AAACT2727012ZW \n Income Tax PAN AAACT 2727 Q \n Total invoice value 3934.12"
ResultTextBox.delete('1.0',END)
ResultTextBox.insert(END,text1)
else:
ResultTextBox.delete('1.0',END)
ResultTextBox.insert(END,"FILE CANNOT BE READ")
def OpenFile():
name = askopenfilename(initialdir="/",
filetypes =(("JPG File", "*.jpg"),("PNG File", "*.png"),("BMP File", "*.bmp"),("JPEG File", "*.jpeg")),
title = "Choose a file."
)
PathTextBox.delete("1.0",END)
PathTextBox.insert(END,name)
Title = root.title( "Image Reader!")
path = StringVar()
HeadLabel1 = Label(root,text="Image ")
HeadLabel1.grid(row = 1,column = 1,sticky=(E))
HeadLabel2 = Label(root,text=" Reader")
HeadLabel2.grid(row = 1,column = 2,sticky=(W))
InputLabel = Label(root,text = "INPUT IMAGE:")
InputLabel.grid(row=2,column = 1)
BrowseButton = Button(root,text="Browse",command = OpenFile)
BrowseButton.grid(row=2,column=2)
9
PathLabel = Label(root,text = "Path:")
PathLabel.grid(row = 3,column=1,sticky=(W))
PathTextBox = Text(root,height = 2)
PathTextBox.grid(row = 4,column = 1,columnspan=2)
ReadButton = Button(root,text="READ FROM IMAGE",command = readFimage)
ReadButton.grid(row = 5,column = 2)
DataLabel = Label(root,text = "DATA IN IMAGE:")
DataLabel.grid(row = 6,column=1,sticky=(W))
ResultTextBox = Text(root,height = 6)
ResultTextBox.grid(row = 7,column = 1,columnspan=2)
if __name__ == "__main__":
root.mainloop()