forked from siracoj/QuickHull
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
100 lines (73 loc) · 2.45 KB
/
main.py
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
"""
QuickHull Animation
This is a program that takes a set of points choosen by the user
and ether animates the QuickHull process or the user can click through it step by step
Author: Jared Siraco
"""
#imports
from tkinter import ttk,Tk,Frame,Menu,Canvas
from tkinter.ttk import *
import threading
#Custom imports
from window import Window
import Triangles
from QuickHull import QuickHull
#==========================================GUI=======================================
def startWindow():
points = []
Panel = Tk()
mainWindow = Window(Panel)
mainWindow.config(title = "QuickHull Menu",h=150,w=200)
mainWindow.positionWindow(mainWindow.TOPLEFT)
#start adding points
def start(points = []):
mainWindow.onExit()
QuickHull(points) #Start QuickHull process
mainWindow.mainloop();
def exportData():
return
#Export points to csv
def getFile():
AskFile = Tk()
fileWindow = Window(AskFile)
fileWindow.config(title="Import...", w=200, h=100)
fileWindow.positionWindow(fileWindow.TOPLEFT)
ask = Label(AskFile, text = "What file would you like to import? ")
ask.place(x=10,y=25)
style = Style()
style.configure("BW.TEntry", foreground="black", background="white")
text = Entry(AskFile,width=29,style="BW.TEntry") #Create Text Box
text.place(x=10,y=45)
text.focus_set()
def readin(): #Call back to get text, open the file, and close the window
try:
print ("Loading file...")
filename = text.get()
if(filename==""):
filename = "test.txt" #uses test as default entry
data = open(filename)
points = [[int(x) for x in line.split()] for line in data] # takes a each point in as: x y
fileWindow.onExit()
except IOError:
print ("Could not read the specified file")
finally:
print("Closing Import...")
start(points) #Start QuickHull process
ok = Button(AskFile,width=10, text="OK", command=readin)
ok.place(x=70,y=70)
fileWindow.startLoop()
menubar = Menu(Panel)
Panel.config(menu=menubar)
fileMenu = Menu(menubar)
#fileMenu.add_command(label="Start", command = start)
fileMenu.add_command(label="Import...", command = getFile)
fileMenu.add_command(label="Exit", command = mainWindow.onExit)
menubar.add_cascade(label="File",menu=fileMenu)
SButton = Button(Panel, text = "Start", command = start)
SButton.pack()
mainWindow.startLoop()
#===================================Main===========================================
def main():
print ("Starting Application...")
startWindow()
main()