50 ToggleItem.__init__(self)
52 self.
id = self.
canvas.create_text(x, y, text=text)
75 ToggleItem.__init__(self)
103 def __init__(self, canvas, x, y, width, height, pitch):
104 ToggleItem.__init__(self)
121 circrange = range(
int(circnum))
124 x0 = self.
x - self.
pitch * i
125 y0 = self.
y - self.
pitch * i
126 x1 = self.
x + self.
pitch * i
127 y1 = self.
y + self.
pitch * i
132 id = self.
canvas.create_oval(x0, y0, x1, y1, fill=color,
149 def __init__(self, canvas, x0, y0, x1, y1, color, width):
150 ToggleItem.__init__(self)
182 self.
id = self.
canvas.create_oval(x-r, y-r, x+r, y+r, **key)
241 dx = (x1 - self.
x) - self.
coffx 242 dy = (y1 - self.
y) - self.
coffy 279 th = math.acos((x * 1.0) / (r * 1.0)) * 180.0 / math.pi
281 th = math.acos((x * 1.0) / (r * 1.0)) * -180.0 / math.pi
291 def __init__(self, r=10, width=300, height=300, master=None):
292 Frame.__init__(self, master)
363 self.
canvas.pack(side=LEFT)
374 text =
'x: %4d, y: %4d' % (0, 0)
379 text =
'r: %4.2f, th: NaN' % (0.0)
390 fill=
"#999999", width=1)
398 self.
frame.pack(side=LEFT, fill=Y, padx=3, pady=3)
406 f = Frame(frame, bd=2, relief=GROOVE)
407 dummy = Frame(f, width=self.
wd)
409 sl = Scale(f, from_=0, to=10, resolution=0.01,
410 label=
"Scale Factor", command=self.
on_scale,
411 variable=self.
scale_var, orient=HORIZONTAL)
412 bt = Button(f, text=
"Reset Scale", command=self.
reset_scale)
413 sl.pack(side=TOP, fill=X)
414 bt.pack(side=TOP, fill=X)
426 f = Frame(frame, bd=2, relief=GROOVE)
427 dummy = Frame(f, width=self.
wd)
429 vec = Checkbutton(f, text=
"Vector Line",
430 onvalue=
"on", offvalue=
"off",
431 justify=LEFT, anchor=W,
434 axis = Checkbutton(f, text=
"Axis",
435 onvalue=
"on", offvalue=
"off",
436 justify=LEFT, anchor=W,
439 circ = Checkbutton(f, text=
"Background",
440 onvalue=
"on", offvalue=
"off",
441 justify=LEFT, anchor=W,
444 xy = Checkbutton(f, text=
"X-Y position",
445 onvalue=
"on", offvalue=
"off",
446 justify=LEFT, anchor=W,
449 pol = Checkbutton(f, text=
"Polar postion",
450 onvalue=
"on", offvalue=
"off",
451 justify=LEFT, anchor=W,
454 for w
in [vec, axis, circ, xy, pol]:
455 w.pack(side=TOP, anchor=W, fill=X)
460 dummy = Frame(f, width=self.
wd)
462 xl = Label(f, text=
"x: ", width=3)
463 xe = Entry(f, width=7, textvariable=self.
xentry,
464 justify=RIGHT, relief=GROOVE)
465 yl = Label(f, text=
"y: ", width=3)
466 ye = Entry(f, width=7, textvariable=self.
yentry,
467 justify=RIGHT, relief=GROOVE)
469 for w
in [ye, yl, xe, xl]:
470 w.pack(side=RIGHT, fill=X)
474 f = Frame(frame, width=self.
wd)
475 dummy = Frame(f, width=self.
wd)
477 rl = Label(f, text=
"r: ", width=3)
478 re = Entry(f, width=7, textvariable=self.
rentry,
479 justify=RIGHT, relief=GROOVE)
480 thl = Label(f, text=
"th:", width=3)
481 the = Entry(f, width=7, textvariable=self.
thentry,
482 justify=RIGHT, relief=GROOVE)
483 for w
in [the, thl, re, rl]:
484 w.pack(side=RIGHT, fill=X)
501 xt =
'%4d' % (self.
pos_x)
502 yt =
'%4d' % (self.
pos_y)
503 rt =
'%5.2f' % (self.
pol_r)
504 if pol[1] > 360: tht =
'NaN' 505 else: tht =
'%5.2f' % self.
pol_th 512 text =
'x: %4d, y: %4d' % (pos[0], pos[1])
515 text =
'r: %5.2f, th: NaN' % (pol[0])
517 text =
'r: %5.2f, th: %5.2f' % (pol[0], pol[1])
539 if __name__ ==
'__main__':
test()
def set_on_update(self, func)
def on_pos_update(self, pos, pol)
def __init__(self, canvas, text, x, y)
def set_on_drag_end(self, func)
def create_xylabel(self, frame)
def __init__(self, canvas, x, y, width, height, pitch)
def create_scale(self, frame)
def set_on_drag_start(self, func)
def drag_start(self, event)
def create_checkbutton(self, frame)
def dragging(self, event)
def draw_line(self, x0, y0, x1, y1)
def drag_end(self, event)
def set_pitch(self, pitch)
def __init__(self, canvas, x0, y0, x1, y1, color, width)
def __init__(self, r=10, width=300, height=300, master=None)
def create_pollabel(self, frame)
def draw_text(self, x, y, text)
def __init__(self, canvas, width, height)
def __init__(self, canvas, x, y, r, key)
def set_on_dragging(self, func)
static int max(int a, int b)