Python论坛  - 讨论区

标题:[python-chinese] Re: 线的顺序

2005年11月18日 星期五 11:40

Shi Mu samrobertsmith at gmail.com
Fri Nov 18 11:40:57 HKT 2005

加了几行后,我想第二次点鼠标时出现另一条线,
怎么不行呢?
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
>
>
>

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年11月18日 星期五 12:02

Qiangning Hong hongqn at gmail.com
Fri Nov 18 12:02:57 HKT 2005

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


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号