-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInput.py
More file actions
22 lines (18 loc) · 870 Bytes
/
UserInput.py
File metadata and controls
22 lines (18 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class UserInput:
# initiation that takes graph argument and attaches this UserInput class to that specific graph
def __init__(self,graph,KMeans):
self.graph = graph
self.KMeans = KMeans
self.graph.connect_to_graph('button_press_event', self.on_mouse_click)
#Takes mouse click input and class to draw on graph and update the graph
def on_mouse_click(self, event):
self.graph.remove_old(self.KMeans.n)
self.KMeans.update_store_list([event.xdata, event.ydata])
self.graph.draw_new_store(event)
if self.KMeans.calculate_kmeans() != 0:
self.graph.recolor(self.KMeans.get_zipped(), self.KMeans.n)
calc = self.KMeans.calculate_kmeans()
self.graph.draw_new_centroids(calc)
else:
print("not ready for centroids")
self.graph.update_graph()