|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | """ |
3 | 3 | Created on Tue Dec 31 17:27:12 2019 |
4 | | -
|
5 | 4 | @author: Lenovo |
6 | 5 | """ |
7 | 6 |
|
8 | | -from tkinter import * |
| 7 | +import tkinter as tk |
9 | 8 | from tkinter.ttk import * |
10 | 9 | import subprocess |
| 10 | +import sys |
| 11 | +from threading import Thread |
| 12 | + |
| 13 | +def run_script(script_name): |
| 14 | + def target(): |
| 15 | + subprocess.call([sys.executable, script_name]) |
| 16 | + Thread(target=target).start() |
11 | 17 |
|
12 | 18 | def face(): |
13 | | - subprocess.call(["python", "face-try.py"]) |
14 | | - |
| 19 | + run_script("face-try.py") |
| 20 | + |
15 | 21 | def blink(): |
16 | | - subprocess.call(["python", "blinkDetect.py"]) |
17 | | - |
| 22 | + run_script("blinkDetect.py") |
| 23 | + |
18 | 24 | def lane(): |
19 | | - subprocess.call(["python", "lanedetection.py"]) |
20 | | - |
21 | | -root = Tk() |
22 | | -root.geometry('300x550') |
| 25 | + run_script("lanedetection.py") |
| 26 | + |
| 27 | +# GUI setup |
| 28 | +root = tk.Tk() |
| 29 | +root.geometry('300x550') |
23 | 30 | root.title('Drowsiness Detection System') |
24 | 31 |
|
25 | | -style = Style() |
26 | | -style.configure('TButton', font =('calibri', 20, 'bold'), borderwidth = '2') |
| 32 | +style = Style() |
| 33 | +style.configure('TButton', font=('calibri', 16, 'bold'), borderwidth='2', padding=10) |
27 | 34 |
|
| 35 | +# Buttons |
| 36 | +btn1 = Button(root, text='Face Detection', command=face) |
| 37 | +btn1.pack(pady=40) |
28 | 38 |
|
29 | | -# button 1 |
30 | | -btn1 = Button(root, text = 'Face Detection', command = face) |
31 | | -btn1.grid(row =10, column = 0, padx = 30,pady=70) |
| 39 | +btn2 = Button(root, text='Blink Detection', command=blink) |
| 40 | +btn2.pack(pady=20) |
32 | 41 |
|
33 | | -# button 2 |
34 | | -btn2 = Button(root, text = 'Blink Detection', command = blink) |
35 | | -btn2.grid(row = 13, column = 0, padx = 65) |
| 42 | +btn4 = Button(root, text='Lane Detection', command=lane) |
| 43 | +btn4.pack(pady=30) |
36 | 44 |
|
37 | | -# button 2 |
38 | | -btn4 = Button(root, text = 'Lane Detection', command = lane) |
39 | | -btn4.grid(row = 16, column = 0, padx = 75,pady=70) |
40 | | -#button 3 |
41 | | -btn3 = Button(root, text = 'Quit', command = root.destroy) |
42 | | -btn3.grid(row = 20, column = 0, padx = 45) |
| 45 | +btn3 = Button(root, text='Quit', command=root.destroy) |
| 46 | +btn3.pack(pady=30) |
43 | 47 |
|
44 | | - |
45 | | -root.mainloop() |
| 48 | +root.mainloop() |
0 commit comments