-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.py
More file actions
150 lines (102 loc) · 4.25 KB
/
GUI.py
File metadata and controls
150 lines (102 loc) · 4.25 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
from tkinter import *
from tkinter import filedialog
from tkinter import ttk # Normal Tkinter.* widgets are not themed!
from ttkthemes import ThemedTk
import shutil
import imgurpush
import os
import pathlib
import tkinter as tk
import tkinter.font as font
from PIL import Image, ImageTk
from imgurpush import license_plate_number as license_plate_number
license_image = None
filename = ""
image_path = None
# window = tk.ThemedTk()
# window.get_themes()
# window.set_theme("plastik")
window = Tk()
def center_window(w=500, h=400):
global window
# get screen width and height
ws = window.winfo_screenwidth()
hs = window.winfo_screenheight()
# calculate position x, y
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
window.geometry('%dx%d+%d+%d' % (w, h, x, y))
window['bg']='black'
window.title('AutoLicense')
center_window(500, 400)
def browseFiles():
global filename
filename = filedialog.askopenfilename(initialdir = "/",
title = "Select a File",
filetypes = (("JPEG",
"*.jpg*"),
("PNG",
"*.png"),
("all files",
"*.*")))
file_location.configure(text="File Opened: "+ os.path.basename(filename) )
path = filename
def copyToProject(path):
# print('Path: {}\nNew path: {}\n'.format( path, os.path.join(pathlib.Path().absolute(), "plate_copies") ))
# print('END PATH: {}'.format('./' + os.path.join(os.path.basename(path), '')))
shutil.copy(path, 'plate_copies')
return os.path.basename(path)
def sendPlate(filename):
global image_path
global license_plate_number
copyToProject(filename)
path = copyToProject(filename)
image_path = path
imgurpush.pushImage(path)
license_plate_number_label.config(text=license_plate_number)
def refresh(self):
self.destroy()
self.__init__()
# def viewImage():
# global license_image
# license_image = ImageTk.PhotoImage((Image.open(f'.\plate_copies\{image_path}')))
# picture_preview.configure(image=license_image)
# picture_preview.image = license_image
image = Image.open('background.png')
photo_image = ImageTk.PhotoImage(image)
plus_image = ImageTk.PhotoImage(Image.open('plus.png'))
window.columnconfigure(0, weight=1) # Set weight to row and
window.rowconfigure(0, weight=1)
# T1 = tk.Text(window)
# T1.tag_configure("center", justify='center')
# T1.insert("1.0", "text")
# T1.tag_add("center", "1.0", "end")
# T1.pack()
# container = Frame(window, bg='black') # bg color to show extent
# container.pack()
myFont = font.Font(size=30)
background_label = Label(window, image=photo_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
#File Explorer
file_location = Label(window,
text = "Look up license picture!",
fg = "blue",
anchor = CENTER, highlightbackground = "white", bg='black', foreground='white', font='myFont', padx=10, pady=20)
button_explore = Button(window,
text = "Browse Files",
command= browseFiles,
anchor = CENTER, highlightbackground = "white", bg='black', foreground='white', font='myFont')
button_sendPlate = Button(window,
text = "Send",
command=lambda :sendPlate(filename),
anchor = CENTER, highlightbackground = "white", bg='black', foreground='white', font='myFont')
license_plate_number_label = Label(window,
text="",
foreground='white',
bg='black',
font='myFont'
)
file_location.place(x=120, y=135)
button_explore.place(x=320, y=144)
button_sendPlate.place(x=258, y=210)
window.mainloop()