tkinter virus

Solutions on MaxInterview for tkinter virus by the best coders in the world

showing results for - "tkinter virus"
Gwenaëlle
07 Aug 2020
1def _create_circle(self, x, y, r, **kwargs):
2    """Create a circle
3
4    x the abscissa of centre
5    y the ordinate of centre
6    r the radius of circle
7    **kwargs optional arguments
8    return the drawing of a circle
9    """
10    return self.create_oval(x-r, y-r, x+r, y+r, **kwargs)
11tk.Canvas.create_circle = _create_circle
12
13def _coords_circle(self, target, x, y, r, **kwargs):
14    """Define a circle
15
16    target the circle object
17    x the abscissa of centre
18    y the ordinate of centre
19    r the radius of circle
20    **kwargs optional arguments
21    return the circle drawing with updated coordinates
22    """
23    return self.coords(target, x-r, y-r, x+r, y+r, **kwargs)
24tk.Canvas.coords_circle = _coords_circle
25
26def create(balls, canvas):
27    """Create a drawing item for each solver.Ball object
28
29    balls the list of solver.Ball objects
30    canvas the Tkinter.Canvas oject
31    return a dictionary with solver.Ball objects as keys and their circle drawings as items
32    """
33    return {ball: canvas.create_circle(ball.position[0], ball.position[1], ball.radius, fill="white") for ball in balls}
34
35def update(drawing, canvas, step, size):
36    """Update the drawing items for a time step
37
38    drawing the dictionary of drawing items
39    canvas the Tkinter.Canvas oject
40    step the time step
41    size the medium size
42    """
43    balls = drawing.keys()
44    solver.solve_step(balls, step, size)
45    for ball in balls:
46        canvas.coords_circle(drawing[ball], ball.position[0], ball.position[1], ball.radius)
47    canvas.update()
queries leading to this page
tkinker virustkinter virus