Skip to content

Commit 32779af

Browse files
authored
Update ui.py
1 parent eff3b27 commit 32779af

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

ui.py

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
11
# -*- coding: utf-8 -*-
22
"""
33
Created on Tue Dec 31 17:27:12 2019
4-
54
@author: Lenovo
65
"""
76

8-
from tkinter import *
7+
import tkinter as tk
98
from tkinter.ttk import *
109
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()
1117

1218
def face():
13-
subprocess.call(["python", "face-try.py"])
14-
19+
run_script("face-try.py")
20+
1521
def blink():
16-
subprocess.call(["python", "blinkDetect.py"])
17-
22+
run_script("blinkDetect.py")
23+
1824
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')
2330
root.title('Drowsiness Detection System')
2431

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)
2734

35+
# Buttons
36+
btn1 = Button(root, text='Face Detection', command=face)
37+
btn1.pack(pady=40)
2838

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)
3241

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)
3644

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)
4347

44-
45-
root.mainloop()
48+
root.mainloop()

0 commit comments

Comments
 (0)