Python论坛  - 讨论区

标题:[python-chinese] Tkinter

2005年11月15日 星期二 09:38

wangzhe wangzhe at eastcom.com
Tue Nov 15 09:38:34 HKT 2005

重定向了坐标到(100, 200)以便画图。
from Tkinter import *

def lineA(x):
    return (x+100, 1-2*x+200)

def lineB(x):
    return (x+100, -(x+6)+200)

#(100, 200)start

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)
canvas.create_line(100, 0, 100, 200, arrow=FIRST)
x = -40

def drawlines():
    global x, l1, l2, go
    x1, y1 = lineA(x)
    x2, y2 = lineB(x)
    l1 = canvas.create_line(60, 281, x1, y1, fill="blue")
    l2 = canvas.create_line(60, 234, x2, y2, fill="blue")
    x += 1
    if x1 == x2 and y1 == y2:
        canvas.create_text(x1+20, y1-10, text="("+`x1-100`+", "+`y1-200`+")",
                           fill="red")
        return
    loop()

def loop():
    tk.after(100, drawlines)
loop()
tk.mainloop()
    
活做的糙了点,不知到是不是这个意思。
>On 一, 2005-11-14 at 02:44 -0800, Shi Mu wrote:
>> 请问如何用python和Tkinter实现以下步骤:
>> 有两条线段(假设是2x+y-1=0 并且两端点坐标是 (1,-1) 和(-1,3);
>> x+y+6=0 并且两端点坐标是 (-3,-3) 和(-4,-2);).
>> 在这两条线段延伸并且互相碰到之后,延伸停止,
>> 如何用python和Tkinter实现这两条线的这个最后状态.
>解这两个方程式,算出交点.后面的步骤就很简单了
>
>_______________________________________________
>Python
> python-chinese at lists.python.cn
> subscribe  python-chinese-request at lists.python.cn
> unsubscribe   python-chinese-request at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        wangzhe
        wangzhe at eastcom.com
          2005-11-15

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wangzhe.VCF
Type: application/octet-stream
Size: 304 bytes
Desc: not available
Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20051115/ae6e5fa5/wangzhe-0001.obj

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

2005年11月15日 星期二 13:17

Shi Mu samrobertsmith at gmail.com
Tue Nov 15 13:17:02 HKT 2005

多谢了!

On 11/14/05, wangzhe <wangzhe at eastcom.com> wrote:
> 重定向了坐标到(100, 200)以便画图。
> from Tkinter import *
>
> def lineA(x):
>    return (x+100, 1-2*x+200)
>
> def lineB(x):
>    return (x+100, -(x+6)+200)
>
> #(100, 200)start
>
> 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)
> canvas.create_line(100, 0, 100, 200, arrow=FIRST)
> x = -40
>
> def drawlines():
>    global x, l1, l2, go
>    x1, y1 = lineA(x)
>    x2, y2 = lineB(x)
>    l1 = canvas.create_line(60, 281, x1, y1, fill="blue")
>    l2 = canvas.create_line(60, 234, x2, y2, fill="blue")
>    x += 1
>    if x1 == x2 and y1 == y2:
>        canvas.create_text(x1+20, y1-10, text="("+`x1-100`+", "+`y1-200`+")",
>                           fill="red")
>        return
>    loop()
>
> def loop():
>    tk.after(100, drawlines)
> loop()
> tk.mainloop()
>
> 活做的糙了点,不知到是不是这个意思。
> >On 一, 2005-11-14 at 02:44 -0800, Shi Mu wrote:
> >> 请问如何用python和Tkinter实现以下步骤:
> >> 有两条线段(假设是2x+y-1=0 并且两端点坐标是 (1,-1) 和(-1,3);
> >> x+y+6=0 并且两端点坐标是 (-3,-3) 和(-4,-2);).
> >> 在这两条线段延伸并且互相碰到之后,延伸停止,
> >> 如何用python和Tkinter实现这两条线的这个最后状态.
> >解这两个方程式,算出交点.后面的步骤就很简单了
> >
> >_______________________________________________
> >Python
> > python-chinese at lists.python.cn
> > subscribe  python-chinese-request at lists.python.cn
> > unsubscribe   python-chinese-request at lists.python.cn
> > http://python.cn/mailman/listinfo/python-chinese
>
> = = = = = = = = = = = = = = = = = = = =
>
>
>> 礼!
>
>
> wangzhe
> wangzhe at eastcom.com
> 2005-11-15
>
>
> _______________________________________________
> Python中文技术讨论邮件列表
> 发言: 发邮件到 python-chinese at lists.python.cn
> 订阅: 发送 subscribe 到 python-chinese-request at lists.python.cn
> 退订: 发送 unsubscribe 到  python-chinese-request at lists.python.cn
> 详细说明: http://python.cn/mailman/listinfo/python-chinese
>
>
>

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

2005年11月15日 星期二 19:33

Shi Mu samrobertsmith at gmail.com
Tue Nov 15 19:33:25 HKT 2005

return (x+100, 1-2*x+200)是什么意思?

On 11/14/05, wangzhe <wangzhe at eastcom.com> wrote:
> 重定向了坐标到(100, 200)以便画图。
> from Tkinter import *
>
> def lineA(x):
>    return (x+100, 1-2*x+200)
>
> def lineB(x):
>    return (x+100, -(x+6)+200)
>
> #(100, 200)start
>
> 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)
> canvas.create_line(100, 0, 100, 200, arrow=FIRST)
> x = -40
>
> def drawlines():
>    global x, l1, l2, go
>    x1, y1 = lineA(x)
>    x2, y2 = lineB(x)
>    l1 = canvas.create_line(60, 281, x1, y1, fill="blue")
>    l2 = canvas.create_line(60, 234, x2, y2, fill="blue")
>    x += 1
>    if x1 == x2 and y1 == y2:
>        canvas.create_text(x1+20, y1-10, text="("+`x1-100`+", "+`y1-200`+")",
>                           fill="red")
>        return
>    loop()
>
> def loop():
>    tk.after(100, drawlines)
> loop()
> tk.mainloop()
>
> 活做的糙了点,不知到是不是这个意思。
> >On 一, 2005-11-14 at 02:44 -0800, Shi Mu wrote:
> >> 请问如何用python和Tkinter实现以下步骤:
> >> 有两条线段(假设是2x+y-1=0 并且两端点坐标是 (1,-1) 和(-1,3);
> >> x+y+6=0 并且两端点坐标是 (-3,-3) 和(-4,-2);).
> >> 在这两条线段延伸并且互相碰到之后,延伸停止,
> >> 如何用python和Tkinter实现这两条线的这个最后状态.
> >解这两个方程式,算出交点.后面的步骤就很简单了
> >
> >_______________________________________________
> >Python
> > python-chinese at lists.python.cn
> > subscribe  python-chinese-request at lists.python.cn
> > unsubscribe   python-chinese-request at lists.python.cn
> > http://python.cn/mailman/listinfo/python-chinese
>
> = = = = = = = = = = = = = = = = = = = =
>
>
>> 礼!
>
>
> wangzhe
> wangzhe at eastcom.com
> 2005-11-15
>
>
> _______________________________________________
> Python中文技术讨论邮件列表
> 发言: 发邮件到 python-chinese at lists.python.cn
> 订阅: 发送 subscribe 到 python-chinese-request at lists.python.cn
> 退订: 发送 unsubscribe 到  python-chinese-request at lists.python.cn
> 详细说明: http://python.cn/mailman/listinfo/python-chinese
>
>
>

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

2005年11月15日 星期二 20:37

limodou limodou at gmail.com
Tue Nov 15 20:37:38 HKT 2005

在 05-11-15,Shi Mu<samrobertsmith at gmail.com> 写道:
> return (x+100, 1-2*x+200)是什么意思?

返回值是一个tuple
--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号