Skip to content

Commit bf3bb16

Browse files
committed
added gui
0 parents  commit bf3bb16

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

dijkstra.py

Whitespace-only changes.

pathfinding.py

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import pygame
2+
import sys
3+
from tkinter import messagebox, Tk
4+
5+
6+
7+
window_width = 500
8+
window_height = 500
9+
10+
# initializing display of required width and height
11+
window = pygame.display.set_mode((window_width, window_height))
12+
13+
14+
coloumn = 25
15+
row = 25
16+
17+
box_width = window_width // coloumn
18+
box_height = window_height // row
19+
20+
grid = []
21+
22+
class Box:
23+
def __init__(self ,i,j): # init used as constructor self used as instance i and j is row and coloumn
24+
self.x = i
25+
self.y = j
26+
# draw used to draw little boxes in canvas
27+
def draw(self, win , color):
28+
pygame.draw.rect(win,color,(self.x*box_width, self.y*box_height, box_width-2, box_height-2))
29+
30+
#create grid
31+
for i in range(coloumn):
32+
arr = []
33+
for j in range(row):
34+
arr.append(Box(i,j))
35+
grid.append(arr)
36+
37+
38+
def main():
39+
while True:
40+
for event in pygame.event.get():
41+
#quit window
42+
if event.type == pygame.QUIT:
43+
pygame.quit()
44+
sys.exit()
45+
46+
window.fill((0,0,0))
47+
48+
for i in range(coloumn):
49+
for j in range(row):
50+
box = grid[i][j]
51+
box.draw(window, (255,255,255))
52+
53+
pygame.display.flip()
54+
55+
56+
main()

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pygame
2+
tkinter
3+
dijkstra algorithm

0 commit comments

Comments
 (0)