Skip to content

Adding Tkinter GUI #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 20, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor Fix and Options added
  • Loading branch information
apb7 committed Dec 16, 2017
commit 442765b2a47779b5ee6823ee24ab10873e41afde
80 changes: 52 additions & 28 deletions gui/romania_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@

root = None
city_coord = {}
height = 0
romania_problem = GraphProblem('Arad', 'Bucharest', romania_map)
algo=None
start=None
goal=None


def create_map(root):
'''
This function draws out the required map.
'''
romania_problem = GraphProblem('Arad', 'Bucharest', romania_map)
global romania_problem
romania_locations = romania_map.locations
global height
width = 700
height = 800
width = 750
height = 670
margin = 5
city_map = Canvas(root, width=width, height=height)
city_map.pack()
Expand All @@ -33,7 +35,7 @@ def create_map(root):
romania_locations['Sibiu'][0],
height -
romania_locations['Sibiu'][1],
140)
romania_map.get('Arad', 'Sibiu'))
make_line(
city_map,
romania_locations['Arad'][0],
Expand All @@ -42,7 +44,7 @@ def create_map(root):
romania_locations['Zerind'][0],
height -
romania_locations['Zerind'][1],
75)
romania_map.get('Arad', 'Zerind'))
make_line(
city_map,
romania_locations['Arad'][0],
Expand All @@ -51,7 +53,7 @@ def create_map(root):
romania_locations['Timisoara'][0],
height -
romania_locations['Timisoara'][1],
118)
romania_map.get('Arad', 'Timisoara'))
make_line(
city_map,
romania_locations['Oradea'][0],
Expand All @@ -60,7 +62,7 @@ def create_map(root):
romania_locations['Zerind'][0],
height -
romania_locations['Zerind'][1],
71)
romania_map.get('Oradea', 'Zerind'))
make_line(
city_map,
romania_locations['Oradea'][0],
Expand All @@ -69,7 +71,7 @@ def create_map(root):
romania_locations['Sibiu'][0],
height -
romania_locations['Sibiu'][1],
151)
romania_map.get('Oradea', 'Sibiu'))
make_line(
city_map,
romania_locations['Lugoj'][0],
Expand All @@ -78,7 +80,7 @@ def create_map(root):
romania_locations['Timisoara'][0],
height -
romania_locations['Timisoara'][1],
111)
romania_map.get('Lugoj', 'Timisoara'))
make_line(
city_map,
romania_locations['Lugoj'][0],
Expand All @@ -87,7 +89,7 @@ def create_map(root):
romania_locations['Mehadia'][0],
height -
romania_locations['Mehadia'][1],
70)
romania_map.get('Lugoj', 'Mehandia'))
make_line(
city_map,
romania_locations['Drobeta'][0],
Expand All @@ -96,7 +98,7 @@ def create_map(root):
romania_locations['Mehadia'][0],
height -
romania_locations['Mehadia'][1],
75)
romania_map.get('Drobeta', 'Mehandia'))
make_line(
city_map,
romania_locations['Drobeta'][0],
Expand All @@ -105,7 +107,7 @@ def create_map(root):
romania_locations['Craiova'][0],
height -
romania_locations['Craiova'][1],
120)
romania_map.get('Drobeta', 'Craiova'))
make_line(
city_map,
romania_locations['Pitesti'][0],
Expand All @@ -114,7 +116,7 @@ def create_map(root):
romania_locations['Craiova'][0],
height -
romania_locations['Craiova'][1],
138)
romania_map.get('Pitesti', 'Craiova'))
make_line(
city_map,
romania_locations['Rimnicu'][0],
Expand All @@ -123,7 +125,7 @@ def create_map(root):
romania_locations['Craiova'][0],
height -
romania_locations['Craiova'][1],
146)
romania_map.get('Rimnicu', 'Craiova'))
make_line(
city_map,
romania_locations['Rimnicu'][0],
Expand All @@ -132,7 +134,7 @@ def create_map(root):
romania_locations['Sibiu'][0],
height -
romania_locations['Sibiu'][1],
80)
romania_map.get('Rimnicu', 'Sibiu'))
make_line(
city_map,
romania_locations['Rimnicu'][0],
Expand All @@ -141,7 +143,7 @@ def create_map(root):
romania_locations['Pitesti'][0],
height -
romania_locations['Pitesti'][1],
97)
romania_map.get('Rimnicu', 'Pitesti'))
make_line(
city_map,
romania_locations['Fagaras'][0],
Expand All @@ -150,7 +152,7 @@ def create_map(root):
romania_locations['Sibiu'][0],
height -
romania_locations['Sibiu'][1],
99)
romania_map.get('Fagaras', 'Sibiu'))
make_line(
city_map,
romania_locations['Fagaras'][0],
Expand All @@ -159,7 +161,7 @@ def create_map(root):
romania_locations['Bucharest'][0],
height -
romania_locations['Bucharest'][1],
211)
romania_map.get('Fagaras', 'Bucharest'))
make_line(
city_map,
romania_locations['Giurgiu'][0],
Expand All @@ -168,7 +170,7 @@ def create_map(root):
romania_locations['Bucharest'][0],
height -
romania_locations['Bucharest'][1],
90)
romania_map.get('Giurgiu', 'Bucharest'))
make_line(
city_map,
romania_locations['Urziceni'][0],
Expand All @@ -177,7 +179,7 @@ def create_map(root):
romania_locations['Bucharest'][0],
height -
romania_locations['Bucharest'][1],
85)
romania_map.get('Urziceni', 'Bucharest'))
make_line(
city_map,
romania_locations['Urziceni'][0],
Expand All @@ -186,7 +188,7 @@ def create_map(root):
romania_locations['Hirsova'][0],
height -
romania_locations['Hirsova'][1],
98)
romania_map.get('Urziceni', 'Hirsova'))
make_line(
city_map,
romania_locations['Eforie'][0],
Expand All @@ -195,7 +197,7 @@ def create_map(root):
romania_locations['Hirsova'][0],
height -
romania_locations['Hirsova'][1],
86)
romania_map.get('Eforie', 'Hirsova'))
make_line(
city_map,
romania_locations['Urziceni'][0],
Expand All @@ -204,7 +206,7 @@ def create_map(root):
romania_locations['Vaslui'][0],
height -
romania_locations['Vaslui'][1],
142)
romania_map.get('Urziceni', 'Vaslui'))
make_line(
city_map,
romania_locations['Iasi'][0],
Expand All @@ -213,7 +215,7 @@ def create_map(root):
romania_locations['Vaslui'][0],
height -
romania_locations['Vaslui'][1],
92)
romania_map.get('Iasi', 'Vaslui'))
make_line(
city_map,
romania_locations['Iasi'][0],
Expand All @@ -222,7 +224,7 @@ def create_map(root):
romania_locations['Neamt'][0],
height -
romania_locations['Neamt'][1],
87)
romania_map.get('Iasi', 'Neamt'))

for city in romania_locations.keys():
make_rectangle(
Expand Down Expand Up @@ -262,6 +264,7 @@ def make_rectangle(map, x0, y0, margin, city_name):
city_coord.update({city_name: rect})

def make_legend(map):

rect1=map.create_rectangle(600,100,610,110,fill="white")
text1 = map.create_text(615, 105,anchor=W,text="Un-explored")

Expand All @@ -276,10 +279,31 @@ def make_legend(map):

rect5=map.create_rectangle(600,160,610,170,fill="dark green")
text5 = map.create_text(615, 165, anchor=W, text="Final Solution")

def main():
global algo,start,goal
root = Tk()
root.title("Road Map of Romania")
root.geometry("950x1150")
algo=StringVar(root)
start = StringVar(root)
goal = StringVar(root)
algo.set("Breadth First Tree Search")
start.set('Arad')
goal.set('Bucharest')
cities=list(romania_map.locations.keys())
cities.sort()
algorithm_menu=OptionMenu(root,algo,"Breadth-First Tree Search","Depth-First Tree Search")
Label(root,text="\n Search Algorithm").pack()
algorithm_menu.pack()
Label(root,text="\n Start City").pack()
start_menu = OptionMenu(root,start,*cities)
start_menu.pack()
Label(root, text="\n Goal City").pack()
goal_menu = OptionMenu(root,goal,*cities)
goal_menu.pack()
next_button = Button(root, width=6, height=2, text="Next", command=None,padx=2,pady=2,relief=GROOVE)
next_button.pack(side=BOTTOM)
create_map(root)
root.mainloop()

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy