Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Dijkstra-Project/Shortest Path Algorithm.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
868 lines (751 sloc)
27.9 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as gui | |
############################################### | |
# GRAPH SETUP # | |
############################################### | |
global startNode, destNode | |
startNode = -1 | |
destNode = -1 | |
nodeNames = {0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G", | |
7:"H",8:"I",9:"J",10:"K",11:"L",12:"M",13:"N", | |
14:"O",15:"P",16:"Q",17:"R",18:"S",19:"T",20:"U",21:"V",22:"W"} | |
nodes = [{1:121,5:266}, #A = 0 | |
{0:121,2:144,6:300}, #B = 1 | |
{1:144,3:103,7:270}, #C = 2 | |
{2:103,8:240}, #D = 3 | |
{5:210,17:382}, #E = 4 | |
{0:266,4:210,6:105}, #F = 5 | |
{1:300,5:105,7:98}, #G = 6 | |
{2:270,6:98,8:88}, #H = 7 | |
{3:240,7:88,9:38,12:150}, #I = 8 | |
{8:38,10:612,11:67}, #J = 9 | |
{9:612,22:516}, #K = 10 | |
{9:67,15:277,16:323}, #L = 11 | |
{8:150,13:198}, #M = 12 | |
{12:198,14:81,19:141}, #N = 13 | |
{13:81,18:122}, #O = 14 | |
{11:277,16:101,20:99}, #P = 15 | |
{11:323,15:101,21:111}, #Q = 16 | |
{4:382,18:337}, #R = 17 | |
{14:122,17:337,19:60}, #S = 18 | |
{13:141,18:60,20:134}, #T = 19 | |
{15:99,19:134,21:128}, #U = 20 | |
{16:111,20:128,22:341}, #V = 21 | |
{21:341,10:516}, #W = 22 | |
] | |
""" | |
nodes = [{1:1,2:3,5:10}, #a | |
{0:1,2:1,3:7,4:5,6:2}, #b | |
{0:3,1:1,3:9,4:3}, #c | |
{1:7,2:9,4:2,5:1,6:12}, #d | |
{1:5,2:3,3:2,5:2}, #e | |
{4:2,3:1,0:10}, #f | |
{1:2,3:12} #g | |
] | |
""" | |
x = len(nodeNames) | |
#print(x) | |
############################################# | |
# TRAVEL TIMES SETUP # | |
############################################# | |
xyz = '' #couldnt think of a better name | |
WALK_SPEED = 2 #m/s | |
JOG_SPEED = 4 #m/s | |
RUN_SPEED = 6 #m/s | |
DRIVE_SPEED = 11 #m/s | |
global walk_time,jog_time,run_time,drive_time | |
walk_time = 0 | |
jog_time = 0 | |
run_time = 0 | |
drive_time = 0 | |
############################################# | |
# FUNCTIONS # | |
############################################# | |
def mapSwitch1(): | |
currentMap.configure(image=map1) | |
def mapSwitch2(): | |
currentMap.configure(image=map2) | |
def NodeInputA(): #Where node A is also 0 in the dictionary | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 0 | |
btnA.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 0: | |
pass | |
elif destNode == -1: | |
destNode = 0 | |
btnA.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputB(): #Where node B is also 1 in the dictionary | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 1 | |
btnB.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 1: | |
pass | |
elif destNode == -1: | |
destNode = 1 | |
btnB.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputC(): #Where node C is also 2 in the dictionary | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 2 | |
btnC.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 2: | |
pass | |
elif destNode == -1: | |
destNode = 2 | |
btnC.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputD(): #Where node D is also 3 in the dictionary | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 3 | |
btnD.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 3: | |
pass | |
elif destNode == -1: | |
destNode = 3 | |
btnD.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputE(): #Where node E is also 4 in the dictionary | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 4 | |
btnE.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 4: | |
pass | |
elif destNode == -1: | |
destNode = 4 | |
btnE.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputF(): #Where node F is also 5 in the dictionary | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 5 | |
btnF.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 5: | |
pass | |
elif destNode == -1: | |
destNode = 5 | |
btnF.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputG(): #Where node G is also 6 in the dictionary | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 6 | |
btnG.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 6: | |
pass | |
elif destNode == -1: | |
destNode = 6 | |
btnG.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputH(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 7 | |
btnH.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 7: | |
pass | |
elif destNode == -1: | |
destNode = 7 | |
btnH.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputI(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 8 | |
btnI.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 8: | |
pass | |
elif destNode == -1: | |
destNode = 8 | |
btnI.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputJ(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 9 | |
btnJ.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 9: | |
pass | |
elif destNode == -1: | |
destNode = 9 | |
btnJ.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputK(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 10 | |
btnK.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 10: | |
pass | |
elif destNode == -1: | |
destNode = 10 | |
btnK.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputL(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 11 | |
btnL.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 11: | |
pass | |
elif destNode == -1: | |
destNode = 11 | |
btnL.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputM(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 12 | |
btnM.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 12: | |
pass | |
elif destNode == -1: | |
destNode = 12 | |
btnM.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputN(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 13 | |
btnN.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 13: | |
pass | |
elif destNode == -1: | |
destNode = 13 | |
btnN.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputO(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 14 | |
btnO.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 14: | |
pass | |
elif destNode == -1: | |
destNode = 14 | |
btnO.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputP(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 15 | |
btnP.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 15: | |
pass | |
elif destNode == -1: | |
destNode = 15 | |
btnP.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputQ(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 16 | |
btnQ.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 16: | |
pass | |
elif destNode == -1: | |
destNode = 16 | |
btnQ.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputR(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 17 | |
btnR.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 17: | |
pass | |
elif destNode == -1: | |
destNode = 17 | |
btnR.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputS(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 18 | |
btnS.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 18: | |
pass | |
elif destNode == -1: | |
destNode = 18 | |
btnS.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputT(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 19 | |
btnT.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 19: | |
pass | |
elif destNode == -1: | |
destNode = 19 | |
btnT.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputU(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 20 | |
btnU.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 20: | |
pass | |
elif destNode == -1: | |
destNode = 20 | |
btnU.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputV(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 21 | |
btnV.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 21: | |
pass | |
elif destNode == -1: | |
destNode = 21 | |
btnV.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
def NodeInputW(): | |
global startNode, destNode | |
if startNode == -1: | |
startNode = 22 | |
btnW.configure(bg="light blue") | |
elif startNode != -1: | |
if startNode == 22: | |
pass | |
elif destNode == -1: | |
destNode = 22 | |
btnW.configure(bg="red") | |
print("") | |
print("Start Node:",startNode) | |
print("Destination Node",destNode) | |
sN = nodeNames.get(startNode) | |
dN = nodeNames.get(destNode) | |
selectedNodes = "Start:",sN,",Dest:",dN | |
currentSelectionLBL.configure(text=selectedNodes) | |
################################################################ | |
################################################################ | |
## ALGORITHM ## | |
################################################################ | |
################################################################ | |
def startAlgorithm(): | |
global status | |
def resetState(): | |
global status | |
for i in range(0,x): | |
status.append({"final":0,"temp":100000000,"visited":False}) | |
return status | |
def endCondition(): | |
global status | |
flag = True | |
for s in status: | |
if s["visited"] == False: | |
flag = False | |
return(flag) | |
def dijkstra(currentNode,destNode): | |
global status | |
#print("") | |
#print("") | |
#print("Current node",nodeNames[currentNode]) | |
d = nodes[currentNode] | |
#print(d) | |
#for key, value in d.items(): | |
#print(key,value) | |
minValue = 1000000 | |
minValueNode = '' | |
for key, value in d.items(): | |
#print("checking node",nodeNames[key]) | |
if status[key]["visited"] == False: | |
#print(status[currentNode]["final"],value,status[key]["temp"]) | |
if status[currentNode]["final"] + value < status[key]["temp"]: | |
status[key]["temp"] = status[currentNode]["final"] + value | |
status[key]["final"] = status[key]["temp"] | |
#print("setting node",nodeNames[key],"temp to",(status[currentNode]["final"] + value)) | |
if status[key]["temp"] < minValue and status[key]["visited"] == False: | |
minValue = status[key]["temp"] | |
minValueNode = key | |
status[currentNode]["visited"] = True | |
#print("Next node is",minValueNode) | |
#for s in status: | |
#print(s) | |
# Test for end condition | |
if minValueNode == '': | |
#if endCondition(): | |
return | |
else: | |
dijkstra(minValueNode,destNode) | |
status = [] | |
status = resetState() | |
#print(status) | |
#print(len(status)) | |
minDistance = dijkstra(startNode,destNode) | |
################################################# | |
# PATH CALCULATION # | |
################################################# | |
#print(""" | |
# | |
#""") | |
#print("PATH CALCULATION") | |
reverseCurrentNode = destNode | |
nextNode = '' | |
global path, pathDistance | |
path = [] | |
pathDistance = status[reverseCurrentNode]["final"] | |
path.append(reverseCurrentNode) | |
while reverseCurrentNode != startNode: | |
d = nodes[reverseCurrentNode] | |
for key, value in d.items(): | |
#print("checking node", nodeNames[key]) | |
if status[key]["final"] == (status[reverseCurrentNode]["final"]) - value: | |
nextNode = key | |
reverseCurrentNode = nextNode | |
path.append(reverseCurrentNode) | |
#print("PATH:",path[::-1],"\n","DISTANCE:",pathDistance) | |
path2 = [] | |
for i in path: | |
for key,value in nodeNames.items(): | |
if i == key: | |
path2.append(nodeNames[i]) | |
############################################################## | |
# TRAVEL TIME # | |
############################################################## | |
xyz = pathDistance | |
walk_time = float((xyz)/(WALK_SPEED)) | |
jog_time = float((xyz)/(JOG_SPEED)) | |
run_time = float((xyz)/(RUN_SPEED)) | |
drive_time = float((xyz)/(DRIVE_SPEED)) | |
walk_time = round(walk_time) | |
jog_time = round(jog_time) | |
run_time = round(run_time) | |
drive_time = round(drive_time) | |
Wtime = "Walk Time:",(walk_time),"seconds" | |
Jtime = "Jog Time:",(jog_time),"seconds" | |
Rtime = "Run Time:",(run_time),"seconds" | |
Dtime = "Drive Time:",(drive_time),"seconds" | |
walkInfoLBL.configure(text=Wtime) | |
jogInfoLBL.configure(text=Jtime) | |
runInfoLBL.configure(text=Rtime) | |
driveInfoLBL.configure(text=Dtime) | |
############################################################## | |
path2 = path2[::-1] | |
pathDistance = str(pathDistance),"metres" | |
pathLBL.configure(text=path2) | |
path2LBL.configure(text=pathDistance) | |
############################################################## | |
""" | |
def resetSelection(): # | |
startNode = -1 # | |
destNode = -1 # FIX THIS | |
#print(startNode,destNode) # | |
currentSelectionLBL.configure(text="") # | |
""" | |
############################################################## | |
# GUI # | |
############################################################## | |
def helpWindow(): | |
helpWindow = gui.Tk() | |
helpWindow.title("HELP") | |
#helpWindow.geometry("705x625+64+75") #PC Settings | |
helpWindow.geometry("705x625") #Laptop Settings | |
helpWindow.wm_iconbitmap('logo.ico') | |
helpWindow.configure(bg="Grey") | |
helpInformationTitleLBL = gui.Label(helpWindow, text="HELP WINDOW",height=2,width=100) | |
helpInformationLBL = gui.Label(helpWindow,text=""" | |
HELPFUL INFORMATION | |
~~~~~~~~~~~~~~~~~ | |
Q: What does this program do? | |
A: It finds the shortest path between two points. | |
Q: How do I start the program? | |
A: Select one start node and one destination node on the map and then press Start. | |
Q: What is Map 1 showing? | |
A: Map 1 is taken from Google Maps, and shows the area involved in the algorithm. | |
Q: What is Map 2 showing? | |
A: Map 2 is a graphical version of map 1. It simplifies the map to give a better understanding of how the algorithm sees the roads. | |
Q: What do the buttons on the map represent? | |
A: The buttons act as nodes, this is what the algorithm works from to find the shortest path. | |
Q: How do I decide which node to select as my start node? | |
A: You can base it off of which node you are nearest to. Or just from where you want to start the path from. | |
Q: What does the Path box show? | |
A: When the program has calculated the path, it will show here. | |
Q: How accurate is the time taken to travel the path? | |
A: The walk time: Based off of how long it takes to walk 1km | |
jog time: Based off of how long it takes to jog 1km | |
run time: Based off of how long it takes to run 1km | |
drive time: Based off of how long it takes to drive 1km | |
Q: Why are the nodes changing colour? | |
A: The first node (the start node) becomes blue, the second one (the destination node) turns red. | |
""") | |
helpInformationTitleLBL.place(x=0,y=0) | |
helpInformationLBL.place(x=10,y=45) | |
helpWindowExitBTN = gui.Button(helpWindow, text="EXIT") | |
helpWindowExitBTN.configure(command=helpWindow.destroy) | |
helpWindowExitBTN.place(x=352,y=590) | |
################################################# | |
# WINDOW # | |
################################################# | |
window = gui.Tk() | |
#window.geometry("1280x720+65+75") #PC Settings | |
window.geometry("1280x720") #Laptop Settings | |
window.title("Shortest Path Calculator") | |
window.wm_iconbitmap('logo.ico') | |
window.configure(bg="Grey") | |
map1 = gui.PhotoImage(file="map1.gif") | |
map2 = gui.PhotoImage(file="map2.gif") | |
m1buttonIMG = gui.PhotoImage(file="M1buttonNEW.gif") | |
m2buttonIMG = gui.PhotoImage(file="M2buttonNEW.gif") | |
mapTitle = gui.PhotoImage(file="mapTitleNEW.gif") | |
startIMG = gui.PhotoImage(file="startButtonNEW.gif") | |
helpIMG = gui.PhotoImage(file="helpButtonNEW.gif") | |
exitIMG = gui.PhotoImage(file="exitNEW.gif") | |
pathIMG = gui.PhotoImage(file="pathNEW.gif") | |
timesIMG = gui.PhotoImage(file="timesNEW.gif") | |
selectedIMG = gui.PhotoImage(file="selectedNEW.gif") | |
currentMap = gui.Label(window, image=map1,bd=0) | |
currentMap.place(x=0,y=0) | |
#global helpTitleIMG | |
#helpTitleIMG = gui.PhotoImage(file="helpTitleNEW.gif") | |
############################################## | |
# NODES # | |
############################################## | |
btnA = gui.Button(window,text="A",command=NodeInputA) | |
btnB = gui.Button(window,text="B",command=NodeInputB) | |
btnC = gui.Button(window,text="C",command=NodeInputC) | |
btnD = gui.Button(window,text="D",command=NodeInputD) | |
btnE = gui.Button(window,text="E",command=NodeInputE) | |
btnF = gui.Button(window,text="F",command=NodeInputF) | |
btnG = gui.Button(window,text="G",command=NodeInputG) | |
btnH = gui.Button(window,text="H",command=NodeInputH) | |
btnI = gui.Button(window,text="I",command=NodeInputI) | |
btnJ = gui.Button(window,text="J",command=NodeInputJ) | |
btnK = gui.Button(window,text="K",command=NodeInputK) | |
btnL = gui.Button(window,text="L",command=NodeInputL) | |
btnM = gui.Button(window,text="M",command=NodeInputM) | |
btnN = gui.Button(window,text="N",command=NodeInputN) | |
btnO = gui.Button(window,text="O",command=NodeInputO) | |
btnP = gui.Button(window,text="P",command=NodeInputP) | |
btnQ = gui.Button(window,text="Q",command=NodeInputQ) | |
btnR = gui.Button(window,text="R",command=NodeInputR) | |
btnS = gui.Button(window,text="S",command=NodeInputS) | |
btnT = gui.Button(window,text="T",command=NodeInputT) | |
btnU = gui.Button(window,text="U",command=NodeInputU) | |
btnV = gui.Button(window,text="V",command=NodeInputV) | |
btnW = gui.Button(window,text="W",command=NodeInputW) | |
##################################################### | |
btnA.place(x=91,y=68) | |
btnB.place(x=174,y=33) | |
btnC.place(x=275,y=45) | |
btnD.place(x=349,y=70) | |
btnE.place(x=23,y=277) | |
btnF.place(x=174,y=229) | |
btnG.place(x=252,y=216) | |
btnH.place(x=327,y=216) | |
btnI.place(x=399,y=210) | |
btnJ.place(x=436,y=210) | |
btnK.place(x=840,y=65) | |
btnL.place(x=474,y=226) | |
btnM.place(x=422,y=312) | |
btnN.place(x=415,y=400) | |
btnO.place(x=370,y=410) | |
btnP.place(x=531,y=412) | |
btnQ.place(x=606,y=400) | |
btnR.place(x=132,y=510) | |
btnS.place(x=394,y=490) | |
btnT.place(x=442,y=485) | |
btnU.place(x=540,y=479) | |
btnV.place(x=638,y=472) | |
btnW.place(x=879,y=390) | |
########### | |
# BUTTONS # | |
########### | |
mapLBL = gui.Label(window, text="MAPS", image=mapTitle, bd=0) | |
mapLBL.place(x=960,y=20) | |
pathTextLBL = gui.Label(window, text="PATH:", image=pathIMG, bd=0) | |
pathTextLBL.place(x=40,y=540) | |
pathLBL = gui.Label(window, text=" [PATH WILL APPEAR HERE] ", height=4, width=30) | |
pathLBL.place(x=152,y=542) | |
path2LBL = gui.Label(window, text=" [DISTANCE WILL APPEAR HERE] ",height=4, width=30) | |
path2LBL.place(x=372,y=542) | |
map1BTN = gui.Button(window, bd=0, command=mapSwitch1, image=m1buttonIMG) | |
map1BTN.place(x=990,y=80) | |
map2BTN = gui.Button(window, bd=0, command=mapSwitch2, image=m2buttonIMG) | |
map2BTN.place(x=1128,y=80) | |
startBTN = gui.Button(window, text="START", image=startIMG, bd=0, command=startAlgorithm) | |
startBTN.place(x=1035,y=185) | |
helpWindowBTN = gui.Button(window, text="HELP", image=helpIMG, bd=0, command=helpWindow) | |
helpWindowBTN.place(x=1035,y=330) | |
exitBTN = gui.Button(window, bd=0, image=exitIMG) | |
exitBTN.configure(command=window.destroy) | |
exitBTN.place(x=1025,y=500) | |
selectionLBL = gui.Label(window, text="SELECTION:", image=selectedIMG, bd=0) | |
selectionLBL.place(x=615,y=540) | |
currentSelectionLBL = gui.Label(window, height=2, width=20) | |
currentSelectionLBL.place(x=726,y=555) | |
timesTextLBL = gui.Label(window, text="PATH TIMES:", image=timesIMG, bd=0) | |
timesTextLBL.place(x=302,y=621) | |
walkInfoLBL = gui.Label(window, height=1, text=(xyz), width=25) | |
walkInfoLBL.place(x=452,y=618) | |
jogInfoLBL = gui.Label(window, height=1, text=(xyz), width=25) | |
jogInfoLBL.place(x=452,y=636) | |
runInfoLBL = gui.Label(window, height=1, text=(xyz), width=25) | |
runInfoLBL.place(x=452,y=654) | |
driveInfoLBL = gui.Label(window, height=1, text=(xyz), width=25) | |
driveInfoLBL.place(x=452,y=672) | |
#clearBTN = gui.Button(window, text="RESET", height=4, width=20, bd=0, command=resetSelection) | |
#clearBTN.place(x=750,y=621) | |
window.mainloop() | |
############################################################# | |