Example #1
0
#!/usr/bin/env python
# as planet1.py, but here we add functionality for dragging the
# planets around in the canvas

import Tkinter, Pmw
import math, copy, time
from scitools.CanvasCoords import CanvasCoords

C = CanvasCoords()  # transformation object
# default values
C.set_coordinate_system(400, 800, 200, 200)

from model1 import *


class Planet:
    def __init__(self, x, y, radius=10, color='red', canvas=None):
        self.x = x
        self.y = y
        # current physical center coordinates
        self.rc = radius
        # radius in canvas coords
        self.r = float(radius / C.xy_scale)
        # radius in physical coords
        self.color = color
        self.id = 0
        # ID as returned from create_oval
        if canvas is not None:
            self.draw(canvas)

    def draw(self, canvas):