-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
75 lines (64 loc) · 2.4 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
"""
Interface graphique pour utilser algo PRIM dans le cadre du probleme du voyageur de commerce
"""
from tkinter import * # GUI module
from threading import Thread # Permet de faire tourner des fonctions en meme temps (async)
# Frames individuelles
from mapFrame import MapFrame
__AUTHORS__ = 'Raphaël, Elisa and Grégoire'
__VERSION__ = '1.2'
X = 700
Y = 700
class TopLevel(Tk):
"""
Représente le client (l'interface)
"""
def __init__(self, x=X, y=Y) -> None:
super().__init__()
self.version = __VERSION__
self.authors = __AUTHORS__
self.iconphoto(True, PhotoImage(file="assets/logo.png"))
self.title(
f"Voyageur v{__VERSION__}")
self.geometry("{}x{}".format(x, y))
self.size = (x, y)
self.villes = (
"clermond ferrand", "bordeaux", "bayonne", "toulouse", "marseille", "nice", "nantes",
"rennes", "paris", "lille", "dijon", "valences", "aurillac", "orleans", "reims", "starsbourg",
"limoges", "troyes", "le havre", "cherbourg", "brest", "niort"
)
self.__setup_frames()
def __setup_frames(self):
"""
Place les Frames dans la grille
"""
def motion(event):
if event.widget.__dict__['master'] == self.mapFrame and not event.widget['text'] in self.villes: # the map is focused
x, y = event.x, event.y
self.mapFrame.show_selection(x, y)
self.mapFrame = MapFrame(self)
update_map = Thread(target=self.mapFrame.resize_map) # resize image thread
update_map.setDaemon(True) # will be closed when the main thread is closed
update_map.start()
self.bind('<Motion>', motion)
@property
def size(self):
return self._size
@size.setter
def size(self, value = None):
if value:
self._size = value
else:
(x, y) = (self.winfo_width(), self.winfo_height())
self._size = (x, y)
def main():
print("===============================================================")
print(f"Voyageur v{__VERSION__}")
print(f"Made by {__AUTHORS__}")
print("Source : https://github.com/Ilade-s/Voyageur-tk")
print("Assets : https://feathericons.com/")
print("===============================================================")
client = TopLevel()
client.mainloop()
if __name__ == '__main__':
main()