51 ToggleItem.__init__(self)
53 self.
id = self.
canvas.create_text(x, y, text=text)
76 ToggleItem.__init__(self)
104 def __init__(self, canvas, x, y, width, height, pitch):
105 ToggleItem.__init__(self)
122 circrange = range(circnum)
125 x0 = self.
x - self.
pitch * i
126 y0 = self.
y - self.
pitch * i
127 x1 = self.
x + self.
pitch * i
128 y1 = self.
y + self.
pitch * i
133 id = self.
canvas.create_oval(x0, y0, x1, y1, fill=color,
150 def __init__(self, canvas, x0, y0, x1, y1, color, width):
151 ToggleItem.__init__(self)
183 self.
id = self.
canvas.create_oval(x-r, y-r, x+r, y+r, **key)
243 dx = (x1 - self.
x) - self.
coffx 244 dy = (y1 - self.
y) - self.
coffy 281 th = math.acos((x * 1.0) / (r * 1.0)) * 180.0 / math.pi
283 th = math.acos((x * 1.0) / (r * 1.0)) * -180.0 / math.pi
293 def __init__(self, r=10, width=300, height=300, master=None):
294 Frame.__init__(self, master)
365 self.
canvas.pack(side=LEFT)
376 text =
'x: %4d, y: %4d' % (0, 0)
381 text =
'r: %4.2f, th: NaN' % (0.0)
392 fill=
"#999999", width=1)
400 self.
frame.pack(side=LEFT, fill=Y, padx=3, pady=3)
408 f = Frame(frame, bd=2, relief=GROOVE)
409 dummy = Frame(f, width=self.
wd)
411 sl = Scale(f, from_=0, to=10, resolution=0.01,
412 label=
"Scale Factor", command=self.
on_scale,
413 variable=self.
scale_var, orient=HORIZONTAL)
414 bt = Button(f, text=
"Reset Scale", command=self.
reset_scale)
415 sl.pack(side=TOP, fill=X)
416 bt.pack(side=TOP, fill=X)
428 f = Frame(frame, bd=2, relief=GROOVE)
429 dummy = Frame(f, width=self.
wd)
431 vec = Checkbutton(f, text=
"Vector Line",
432 onvalue=
"on", offvalue=
"off",
433 justify=LEFT, anchor=W,
436 axis = Checkbutton(f, text=
"Axis",
437 onvalue=
"on", offvalue=
"off",
438 justify=LEFT, anchor=W,
441 circ = Checkbutton(f, text=
"Background",
442 onvalue=
"on", offvalue=
"off",
443 justify=LEFT, anchor=W,
446 xy = Checkbutton(f, text=
"X-Y position",
447 onvalue=
"on", offvalue=
"off",
448 justify=LEFT, anchor=W,
451 pol = Checkbutton(f, text=
"Polar postion",
452 onvalue=
"on", offvalue=
"off",
453 justify=LEFT, anchor=W,
456 for w
in [vec, axis, circ, xy, pol]:
457 w.pack(side=TOP, anchor=W, fill=X)
462 dummy = Frame(f, width=self.
wd)
464 xl = Label(f, text=
"x: ", width=3)
466 justify=RIGHT, relief=GROOVE)
467 yl = Label(f, text=
"y: ", width=3)
469 justify=RIGHT, relief=GROOVE)
471 for w
in [ye, yl, xe, xl]:
472 w.pack(side=RIGHT, fill=X)
476 f = Frame(frame, width=self.
wd)
477 dummy = Frame(f, width=self.
wd)
479 rl = Label(f, text=
"r: ", width=3)
481 justify=RIGHT, relief=GROOVE)
482 thl = Label(f, text=
"th:", width=3)
484 justify=RIGHT, relief=GROOVE)
485 for w
in [the, thl, re, rl]:
486 w.pack(side=RIGHT, fill=X)
503 xt =
'%4d' % (self.
pos_x)
504 yt =
'%4d' % (self.
pos_y)
505 rt =
'%5.2f' % (self.
pol_r)
506 if pol[1] > 360: tht =
'NaN' 507 else: tht =
'%5.2f' % self.
pol_th 514 text =
'x: %4d, y: %4d' % (pos[0], pos[1])
517 text =
'r: %5.2f, th: NaN' % (pol[0])
519 text =
'r: %5.2f, th: %5.2f' % (pol[0], pol[1])
541 if __name__ ==
'__main__':
test()
def __init__(self, canvas, x0, y0, x1, y1, color, width)
def on_pos_update(self, pos, pol)
def dragging(self, event)
def __init__(self, canvas, width, height)
def create_pollabel(self, frame)
def set_on_drag_start(self, func)
def drag_start(self, event)
def set_pitch(self, pitch)
def create_checkbutton(self, frame)
def __init__(self, canvas, x, y, width, height, pitch)
def set_on_dragging(self, func)
def __init__(self, canvas, x, y, r, key)
def set_on_update(self, func)
def create_xylabel(self, frame)
def __init__(self, canvas, text, x, y)
def __init__(self, r=10, width=300, height=300, master=None)
def set_on_drag_end(self, func)
def create_scale(self, frame)
def draw_text(self, x, y, text)
def draw_line(self, x0, y0, x1, y1)
def drag_end(self, event)