2005年11月18日 星期五 11:40
加了几行后,我想第二次点鼠标时出现另一条线, 怎么不行呢? from Tkinter import * def drawline1(event): canvas.create_line(100, 0, 100, 200, arrow=FIRST,fill="green") def drawline2(event): canvas.create_line(100, 50, 60, 300, arrow=FIRST,fill="purple") tk = Tk() canvas = Canvas(tk, bg="white", bd=0, highlightthickness=0) canvas.pack(fill=BOTH, expand=YES) canvas.create_line(100, 200, 350, 200, arrow=LAST,fill='red') canvas.bind("<1>", drawline1) canvas.bind("<1>", drawline2) tk.mainloop() On 11/17/05, wangzhe <wangzhe at eastcom.com> wrote: > from Tkinter import * > > def drawline(event): > canvas.create_line(100, 0, 100, 200, arrow=FIRST,fill="green") > > tk = Tk() > canvas = Canvas(tk, bg="white", bd=0, highlightthickness=0) > canvas.pack(fill=BOTH, expand=YES) > canvas.create_line(100, 200, 350, 200, arrow=LAST,fill='red') > canvas.bind("<1>", drawline) > tk.mainloop() > > 鼠标点击画线 > ======= 2005-11-18 09:07:34 您在来信中写道:======= > > >如果我希望下面的绿线比红线迟出现, > >应该怎么做,能用按回车键控制吗? > >多谢了!!! > > > >from Tkinter import * > >tk = Tk() > >canvas = Canvas(tk, bg="white", bd=0, highlightthickness=0) > >canvas.pack(fill=BOTH, expand=YES) > >canvas.create_line(100, 200, 350, 200, arrow=LAST,fill='red') > >canvas.create_line(100, 0, 100, 200, arrow=FIRST,fill="green") > >tk.mainloop() > > = = = = = = = = = = = = = = = = = = = = > > > 致 > 礼! > > > wangzhe > wangzhe at eastcom.com > 2005-11-18 > > >
2005年11月18日 星期五 12:02
Shi Mu wrote: > 加了几行后,我想第二次点鼠标时出现另一条线, > 怎么不行呢? > from Tkinter import * > > def drawline1(event): > canvas.create_line(100, 0, 100, 200, arrow=FIRST,fill="green") > def drawline2(event): > canvas.create_line(100, 50, 60, 300, arrow=FIRST,fill="purple") > tk = Tk() > canvas = Canvas(tk, bg="white", bd=0, highlightthickness=0) > canvas.pack(fill=BOTH, expand=YES) > canvas.create_line(100, 200, 350, 200, arrow=LAST,fill='red') > canvas.bind("<1>", drawline1) > canvas.bind("<1>", drawline2) 这个bind把前一个bind覆盖了,点鼠标的时候只运行drawline2。 > tk.mainloop() -- Qiangning Hong, Registered Linux User #396996 My Blog: http://www.hn.org/hongqn RSS: http://feeds.feedburner.com/hongqn
Zeuux © 2025
京ICP备05028076号