Python论坛  - 讨论区

标题:[python-chinese] Tkinter

2005年11月07日 星期一 13:13

wangzhe wangzhe at eastcom.com
Mon Nov 7 13:13:01 HKT 2005

from Tkinter import *
from math import sqrt

canvas = Canvas(bg="white", bd=0)
canvas.pack(fill=BOTH, expand=YES)

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.draw(x, y)
        
    def draw(self, x=None, y=None):
        canvas.create_line(self.x, self.y, self.x, self.y, width=1)
        
class Line:
    def __init__(self, head, tail):
        self.head = head
        self.tail = tail
        dx = self.head.x - self.tail.x
        dy = self.head.y - self.tail.y
        self.length = sqrt(dx*dx + dy*dy)
        self.draw()
        
    def draw(self):
        canvas.create_line(self.head.x, self.head.y,
                           self.tail.x, self.tail.y, width=1)
        
class Polygon:
    def __init__(self,lines):
        self.lines = lines
        self.__perimeter = None
        self.draw()
        
    def draw(self):
        for line in self.lines:
            line.draw()

    def perimeter(self):
        if not self.__perimeter:
            self.__perimeter = 0
            for line in self.lines:
                self.__perimeter += line.length
                if self.lines[0] != self.lines[-1]:
                    p2 = self.lines[0].head
                    p1 = self.lines[-1].tail
                    dx = p2.x - p1.x
                    dy = p2.y - p1.y
                    self.__perimeter += sqrt(dx*dx + dy*dy)
        return self.__perimeter
    
class Route:
    def __init__(self, legs):
        self.legs = legs
        d = 0
        for leg in self.legs:
            d += leg.length
            self.distance = d
            
    def draw(self):
        for leg in self.legs:
            leg.draw()
            
class Map:
    def __init__(self, objects):
        self.objects = objects
        self.draw()
        
    def draw(self):
        for object in self.objects:
            object.draw()

            
p1 = Point(20,30)
p2 = Point(50,50)
p3 = Point(69,105)
p4 = Point(26,64)
line1 = Line(p1,p2)
line2 = Line(p2,p3)
line3 = Line(p3,p1)
line4 = Line(p1,p3)
poly1 = Polygon([line1,line2,line3])
route1 = Route([line2,line2,line3,line4])
map = Map([p1,p2,p3,line1,line2,poly1])

大致是这样,用Canvas画。
======= 2005-11-07 06:56:01 您在来信中写道:=======

>下面的代码可以运行,并且在CONSOLE上出现结果,
>请问如何
>在Tkinter里实现?
>多谢了!
>from math import sqrt
>class Point:
>    def __init__(self,x,y):
>        self.x = x
>        self.y = y
>    def draw(self):
>        print 'point at (%d,%d)'%(self.x,self.y)
>class Line:
>    def __init__(self,head,tail):
>        self.head = head
>        self.tail = tail
>        dx = self.head.x - self.tail.x
>        dy = self.head.y - self.tail.y
>        self.length = sqrt(dx*dx + dy*dy)
>    def draw(self):
>        print 'dawing line'
>        print 'line starts at: '
>        self.head.draw()
>        print 'line ends at: '
>        self.tail.draw()
>class Polygon:
>    def __init__(self,lines):
>        self.lines = lines
>        self.__perimeter = None
>    def draw(self):
>        print 'drawing polygon'
>        print 'poly has %d lines'%len(self.lines)
>        for line in self.lines:
>            line.draw()
>            print 'polygon done'
>    def perimeter(self):
>        if not self.__perimeter:
>            self.__perimeter = 0
>            for line in self.lines:
>                self.__perimeter += line.length
>                if self.lines[0] != self.lines[-1]:
>                    p2 = self.lines[0].head
>                    p1 = self.lines[-1].tail
>                    dx = p2.x - p1.x
>                    dy = p2.y - p1.y
>                    self.__perimeter += sqrt(dx*dx + dy*dy)
>        return self.__perimeter
>class Route:
>    def __init__(self,legs):
>        self.legs = legs
>        d = 0
>        for leg in self.legs:
>            d += leg.length
>            self.distance = d
>    def draw(self):
>        print 'drawing route'
>        for leg in self.legs:
>            leg.draw()
>class Map:
>    def __init__(self,objects):
>        self.objects = objects
>        self.draw()
>    def draw(self):
>        for object in self.objects:
>            object.draw()
>p1 = Point(1,2)
>p2 = Point(3,4)
>p3 = Point(7,8)
>p4 = Point(12,1)
>line1 = Line(p1,p2)
>line2 = Line(p2,p3)
>line3 = Line(p3,p1)
>line4 = Line(p1,p3)
>poly1 = Polygon([line1,line2,line3])
>route1 = Route([line2,line2,line3,line4])
>map = Map([p1,p2,p3,line1,line2,poly1])
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>

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

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


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

2005年11月07日 星期一 14:00

Shi Mu samrobertsmith at gmail.com
Mon Nov 7 14:00:10 HKT 2005

我只能用python -i 的方式看到CANVAS上的图,如果不用-i,程序运行了,可是看不到结果.怎么理解?

On 11/6/05, wangzhe <wangzhe at eastcom.com> wrote:
> from Tkinter import *
> from math import sqrt
>
> canvas = Canvas(bg="white", bd=0)
> canvas.pack(fill=BOTH, expand=YES)
>
> class Point:
>    def __init__(self, x, y):
>        self.x = x
>        self.y = y
>        self.draw(x, y)
>
>    def draw(self, x=None, y=None):
>        canvas.create_line(self.x, self.y, self.x, self.y, width=1)
>
> class Line:
>    def __init__(self, head, tail):
>        self.head = head
>        self.tail = tail
>        dx = self.head.x - self.tail.x
>        dy = self.head.y - self.tail.y
>        self.length = sqrt(dx*dx + dy*dy)
>        self.draw()
>
>    def draw(self):
>        canvas.create_line(self.head.x, self.head.y,
>                           self.tail.x, self.tail.y, width=1)
>
> class Polygon:
>    def __init__(self,lines):
>        self.lines = lines
>        self.__perimeter = None
>        self.draw()
>
>    def draw(self):
>        for line in self.lines:
>            line.draw()
>
>    def perimeter(self):
>        if not self.__perimeter:
>            self.__perimeter = 0
>            for line in self.lines:
>                self.__perimeter += line.length
>                if self.lines[0] != self.lines[-1]:
>                    p2 = self.lines[0].head
>                    p1 = self.lines[-1].tail
>                    dx = p2.x - p1.x
>                    dy = p2.y - p1.y
>                    self.__perimeter += sqrt(dx*dx + dy*dy)
>        return self.__perimeter
>
> class Route:
>    def __init__(self, legs):
>        self.legs = legs
>        d = 0
>        for leg in self.legs:
>            d += leg.length
>            self.distance = d
>
>    def draw(self):
>        for leg in self.legs:
>            leg.draw()
>
> class Map:
>    def __init__(self, objects):
>        self.objects = objects
>        self.draw()
>
>    def draw(self):
>        for object in self.objects:
>            object.draw()
>
>
> p1 = Point(20,30)
> p2 = Point(50,50)
> p3 = Point(69,105)
> p4 = Point(26,64)
> line1 = Line(p1,p2)
> line2 = Line(p2,p3)
> line3 = Line(p3,p1)
> line4 = Line(p1,p3)
> poly1 = Polygon([line1,line2,line3])
> route1 = Route([line2,line2,line3,line4])
> map = Map([p1,p2,p3,line1,line2,poly1])
>
> 大致是这样,用Canvas画。
> ======= 2005-11-07 06:56:01 您在来信中写道:=======
>
> >下面的代码可以运行,并且在CONSOLE上出现结果,
> >请问如何
> >在Tkinter里实现?
> >多谢了!
> >from math import sqrt
> >class Point:
> >    def __init__(self,x,y):
> >        self.x = x
> >        self.y = y
> >    def draw(self):
> >        print 'point at (%d,%d)'%(self.x,self.y)
> >class Line:
> >    def __init__(self,head,tail):
> >        self.head = head
> >        self.tail = tail
> >        dx = self.head.x - self.tail.x
> >        dy = self.head.y - self.tail.y
> >        self.length = sqrt(dx*dx + dy*dy)
> >    def draw(self):
> >        print 'dawing line'
> >        print 'line starts at: '
> >        self.head.draw()
> >        print 'line ends at: '
> >        self.tail.draw()
> >class Polygon:
> >    def __init__(self,lines):
> >        self.lines = lines
> >        self.__perimeter = None
> >    def draw(self):
> >        print 'drawing polygon'
> >        print 'poly has %d lines'%len(self.lines)
> >        for line in self.lines:
> >            line.draw()
> >            print 'polygon done'
> >    def perimeter(self):
> >        if not self.__perimeter:
> >            self.__perimeter = 0
> >            for line in self.lines:
> >                self.__perimeter += line.length
> >                if self.lines[0] != self.lines[-1]:
> >                    p2 = self.lines[0].head
> >                    p1 = self.lines[-1].tail
> >                    dx = p2.x - p1.x
> >                    dy = p2.y - p1.y
> >                    self.__perimeter += sqrt(dx*dx + dy*dy)
> >        return self.__perimeter
> >class Route:
> >    def __init__(self,legs):
> >        self.legs = legs
> >        d = 0
> >        for leg in self.legs:
> >            d += leg.length
> >            self.distance = d
> >    def draw(self):
> >        print 'drawing route'
> >        for leg in self.legs:
> >            leg.draw()
> >class Map:
> >    def __init__(self,objects):
> >        self.objects = objects
> >        self.draw()
> >    def draw(self):
> >        for object in self.objects:
> >            object.draw()
> >p1 = Point(1,2)
> >p2 = Point(3,4)
> >p3 = Point(7,8)
> >p4 = Point(12,1)
> >line1 = Line(p1,p2)
> >line2 = Line(p2,p3)
> >line3 = Line(p3,p1)
> >line4 = Line(p1,p3)
> >poly1 = Polygon([line1,line2,line3])
> >route1 = Route([line2,line2,line3,line4])
> >map = Map([p1,p2,p3,line1,line2,poly1])
> >_______________________________________________
> >python-chinese list
> >python-chinese at lists.python.cn
> >http://python.cn/mailman/listinfo/python-chinese
> >
>
> = = = = = = = = = = = = = = = = = = = =
>
>
>> 礼!
>
>
> wangzhe
>         wangzhe at eastcom.com
> 2005-11-07
>
>
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
>
>
>

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

2005年11月07日 星期一 17:01

li rings ringsli at gmail.com
Mon Nov 7 17:01:37 HKT 2005

没有了消息循环..最后增加canvas.mainloop() 就可以了..


在 05-11-7,Shi Mu<samrobertsmith at gmail.com> 写道:
> 我只能用python -i 的方式看到CANVAS上的图,如果不用-i,程序运行了,可是看不到结果.怎么理解?
>
> On 11/6/05, wangzhe <wangzhe at eastcom.com> wrote:
> > from Tkinter import *
> > from math import sqrt
> >
> > canvas = Canvas(bg="white", bd=0)
> > canvas.pack(fill=BOTH, expand=YES)
> >
> > class Point:
> >    def __init__(self, x, y):
> >        self.x = x
> >        self.y = y
> >        self.draw(x, y)
> >
> >    def draw(self, x=None, y=None):
> >        canvas.create_line(self.x, self.y, self.x, self.y, width=1)
> >
> > class Line:
> >    def __init__(self, head, tail):
> >        self.head = head
> >        self.tail = tail
> >        dx = self.head.x - self.tail.x
> >        dy = self.head.y - self.tail.y
> >        self.length = sqrt(dx*dx + dy*dy)
> >        self.draw()
> >
> >    def draw(self):
> >        canvas.create_line(self.head.x, self.head.y,
> >                           self.tail.x, self.tail.y, width=1)
> >
> > class Polygon:
> >    def __init__(self,lines):
> >        self.lines = lines
> >        self.__perimeter = None
> >        self.draw()
> >
> >    def draw(self):
> >        for line in self.lines:
> >            line.draw()
> >
> >    def perimeter(self):
> >        if not self.__perimeter:
> >            self.__perimeter = 0
> >            for line in self.lines:
> >                self.__perimeter += line.length
> >                if self.lines[0] != self.lines[-1]:
> >                    p2 = self.lines[0].head
> >                    p1 = self.lines[-1].tail
> >                    dx = p2.x - p1.x
> >                    dy = p2.y - p1.y
> >                    self.__perimeter += sqrt(dx*dx + dy*dy)
> >        return self.__perimeter
> >
> > class Route:
> >    def __init__(self, legs):
> >        self.legs = legs
> >        d = 0
> >        for leg in self.legs:
> >            d += leg.length
> >            self.distance = d
> >
> >    def draw(self):
> >        for leg in self.legs:
> >            leg.draw()
> >
> > class Map:
> >    def __init__(self, objects):
> >        self.objects = objects
> >        self.draw()
> >
> >    def draw(self):
> >        for object in self.objects:
> >            object.draw()
> >
> >
> > p1 = Point(20,30)
> > p2 = Point(50,50)
> > p3 = Point(69,105)
> > p4 = Point(26,64)
> > line1 = Line(p1,p2)
> > line2 = Line(p2,p3)
> > line3 = Line(p3,p1)
> > line4 = Line(p1,p3)
> > poly1 = Polygon([line1,line2,line3])
> > route1 = Route([line2,line2,line3,line4])
> > map = Map([p1,p2,p3,line1,line2,poly1])
> >
> > 大致是这样,用Canvas画。
> > ======= 2005-11-07 06:56:01 您在来信中写道:=======
> >
> > >下面的代码可以运行,并且在CONSOLE上出现结果,
> > >请问如何
> > >在Tkinter里实现?
> > >多谢了!
> > >from math import sqrt
> > >class Point:
> > >    def __init__(self,x,y):
> > >        self.x = x
> > >        self.y = y
> > >    def draw(self):
> > >        print 'point at (%d,%d)'%(self.x,self.y)
> > >class Line:
> > >    def __init__(self,head,tail):
> > >        self.head = head
> > >        self.tail = tail
> > >        dx = self.head.x - self.tail.x
> > >        dy = self.head.y - self.tail.y
> > >        self.length = sqrt(dx*dx + dy*dy)
> > >    def draw(self):
> > >        print 'dawing line'
> > >        print 'line starts at: '
> > >        self.head.draw()
> > >        print 'line ends at: '
> > >        self.tail.draw()
> > >class Polygon:
> > >    def __init__(self,lines):
> > >        self.lines = lines
> > >        self.__perimeter = None
> > >    def draw(self):
> > >        print 'drawing polygon'
> > >        print 'poly has %d lines'%len(self.lines)
> > >        for line in self.lines:
> > >            line.draw()
> > >            print 'polygon done'
> > >    def perimeter(self):
> > >        if not self.__perimeter:
> > >            self.__perimeter = 0
> > >            for line in self.lines:
> > >                self.__perimeter += line.length
> > >                if self.lines[0] != self.lines[-1]:
> > >                    p2 = self.lines[0].head
> > >                    p1 = self.lines[-1].tail
> > >                    dx = p2.x - p1.x
> > >                    dy = p2.y - p1.y
> > >                    self.__perimeter += sqrt(dx*dx + dy*dy)
> > >        return self.__perimeter
> > >class Route:
> > >    def __init__(self,legs):
> > >        self.legs = legs
> > >        d = 0
> > >        for leg in self.legs:
> > >            d += leg.length
> > >            self.distance = d
> > >    def draw(self):
> > >        print 'drawing route'
> > >        for leg in self.legs:
> > >            leg.draw()
> > >class Map:
> > >    def __init__(self,objects):
> > >        self.objects = objects
> > >        self.draw()
> > >    def draw(self):
> > >        for object in self.objects:
> > >            object.draw()
> > >p1 = Point(1,2)
> > >p2 = Point(3,4)
> > >p3 = Point(7,8)
> > >p4 = Point(12,1)
> > >line1 = Line(p1,p2)
> > >line2 = Line(p2,p3)
> > >line3 = Line(p3,p1)
> > >line4 = Line(p1,p3)
> > >poly1 = Polygon([line1,line2,line3])
> > >route1 = Route([line2,line2,line3,line4])
> > >map = Map([p1,p2,p3,line1,line2,poly1])
> > >_______________________________________________
> > >python-chinese list
> > >python-chinese at lists.python.cn
> > >http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> > = = = = = = = = = = = = = = = = = = = =
> >
> >
> > 致
> > 礼!
> >
> >
> > wangzhe
> > wangzhe at eastcom.com
> > 2005-11-07
> >
> >
> > _______________________________________________
> > python-chinese list
> > python-chinese at lists.python.cn
> > http://python.cn/mailman/listinfo/python-chinese
> >
> >
> >
>
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
>
>
>

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

2005年11月07日 星期一 17:01

li rings ringsli at gmail.com
Mon Nov 7 17:01:54 HKT 2005

在 05-11-7,li rings<ringsli at gmail.com> 写道:
> 没有了消息循环..最后增加canvas.mainloop() 就可以了..
>
>
> 在 05-11-7,Shi Mu<samrobertsmith at gmail.com> 写道:
> > 我只能用python -i 的方式看到CANVAS上的图,如果不用-i,程序运行了,可是看不到结果.怎么理解?
> >
> > On 11/6/05, wangzhe <wangzhe at eastcom.com> wrote:
> > > from Tkinter import *
> > > from math import sqrt
> > >
> > > canvas = Canvas(bg="white", bd=0)
> > > canvas.pack(fill=BOTH, expand=YES)
> > >
> > > class Point:
> > >    def __init__(self, x, y):
> > >        self.x = x
> > >        self.y = y
> > >        self.draw(x, y)
> > >
> > >    def draw(self, x=None, y=None):
> > >        canvas.create_line(self.x, self.y, self.x, self.y, width=1)
> > >
> > > class Line:
> > >    def __init__(self, head, tail):
> > >        self.head = head
> > >        self.tail = tail
> > >        dx = self.head.x - self.tail.x
> > >        dy = self.head.y - self.tail.y
> > >        self.length = sqrt(dx*dx + dy*dy)
> > >        self.draw()
> > >
> > >    def draw(self):
> > >        canvas.create_line(self.head.x, self.head.y,
> > >                           self.tail.x, self.tail.y, width=1)
> > >
> > > class Polygon:
> > >    def __init__(self,lines):
> > >        self.lines = lines
> > >        self.__perimeter = None
> > >        self.draw()
> > >
> > >    def draw(self):
> > >        for line in self.lines:
> > >            line.draw()
> > >
> > >    def perimeter(self):
> > >        if not self.__perimeter:
> > >            self.__perimeter = 0
> > >            for line in self.lines:
> > >                self.__perimeter += line.length
> > >                if self.lines[0] != self.lines[-1]:
> > >                    p2 = self.lines[0].head
> > >                    p1 = self.lines[-1].tail
> > >                    dx = p2.x - p1.x
> > >                    dy = p2.y - p1.y
> > >                    self.__perimeter += sqrt(dx*dx + dy*dy)
> > >        return self.__perimeter
> > >
> > > class Route:
> > >    def __init__(self, legs):
> > >        self.legs = legs
> > >        d = 0
> > >        for leg in self.legs:
> > >            d += leg.length
> > >            self.distance = d
> > >
> > >    def draw(self):
> > >        for leg in self.legs:
> > >            leg.draw()
> > >
> > > class Map:
> > >    def __init__(self, objects):
> > >        self.objects = objects
> > >        self.draw()
> > >
> > >    def draw(self):
> > >        for object in self.objects:
> > >            object.draw()
> > >
> > >
> > > p1 = Point(20,30)
> > > p2 = Point(50,50)
> > > p3 = Point(69,105)
> > > p4 = Point(26,64)
> > > line1 = Line(p1,p2)
> > > line2 = Line(p2,p3)
> > > line3 = Line(p3,p1)
> > > line4 = Line(p1,p3)
> > > poly1 = Polygon([line1,line2,line3])
> > > route1 = Route([line2,line2,line3,line4])
> > > map = Map([p1,p2,p3,line1,line2,poly1])
> > >
> > > 大致是这样,用Canvas画。
> > > ======= 2005-11-07 06:56:01 您在来信中写道:=======
> > >
> > > >下面的代码可以运行,并且在CONSOLE上出现结果,
> > > >请问如何
> > > >在Tkinter里实现?
> > > >多谢了!
> > > >from math import sqrt
> > > >class Point:
> > > >    def __init__(self,x,y):
> > > >        self.x = x
> > > >        self.y = y
> > > >    def draw(self):
> > > >        print 'point at (%d,%d)'%(self.x,self.y)
> > > >class Line:
> > > >    def __init__(self,head,tail):
> > > >        self.head = head
> > > >        self.tail = tail
> > > >        dx = self.head.x - self.tail.x
> > > >        dy = self.head.y - self.tail.y
> > > >        self.length = sqrt(dx*dx + dy*dy)
> > > >    def draw(self):
> > > >        print 'dawing line'
> > > >        print 'line starts at: '
> > > >        self.head.draw()
> > > >        print 'line ends at: '
> > > >        self.tail.draw()
> > > >class Polygon:
> > > >    def __init__(self,lines):
> > > >        self.lines = lines
> > > >        self.__perimeter = None
> > > >    def draw(self):
> > > >        print 'drawing polygon'
> > > >        print 'poly has %d lines'%len(self.lines)
> > > >        for line in self.lines:
> > > >            line.draw()
> > > >            print 'polygon done'
> > > >    def perimeter(self):
> > > >        if not self.__perimeter:
> > > >            self.__perimeter = 0
> > > >            for line in self.lines:
> > > >                self.__perimeter += line.length
> > > >                if self.lines[0] != self.lines[-1]:
> > > >                    p2 = self.lines[0].head
> > > >                    p1 = self.lines[-1].tail
> > > >                    dx = p2.x - p1.x
> > > >                    dy = p2.y - p1.y
> > > >                    self.__perimeter += sqrt(dx*dx + dy*dy)
> > > >        return self.__perimeter
> > > >class Route:
> > > >    def __init__(self,legs):
> > > >        self.legs = legs
> > > >        d = 0
> > > >        for leg in self.legs:
> > > >            d += leg.length
> > > >            self.distance = d
> > > >    def draw(self):
> > > >        print 'drawing route'
> > > >        for leg in self.legs:
> > > >            leg.draw()
> > > >class Map:
> > > >    def __init__(self,objects):
> > > >        self.objects = objects
> > > >        self.draw()
> > > >    def draw(self):
> > > >        for object in self.objects:
> > > >            object.draw()
> > > >p1 = Point(1,2)
> > > >p2 = Point(3,4)
> > > >p3 = Point(7,8)
> > > >p4 = Point(12,1)
> > > >line1 = Line(p1,p2)
> > > >line2 = Line(p2,p3)
> > > >line3 = Line(p3,p1)
> > > >line4 = Line(p1,p3)
> > > >poly1 = Polygon([line1,line2,line3])
> > > >route1 = Route([line2,line2,line3,line4])
> > > >map = Map([p1,p2,p3,line1,line2,poly1])
> > > >_______________________________________________
> > > >python-chinese list
> > > >python-chinese at lists.python.cn
> > > >http://python.cn/mailman/listinfo/python-chinese
> > > >
> > >
> > > = = = = = = = = = = = = = = = = = = = =
> > >
> > >
> > > 致
> > > 礼!
> > >
> > >
> > > wangzhe
> > > wangzhe at eastcom.com
> > > 2005-11-07
> > >
> > >
> > > _______________________________________________
> > > python-chinese list
> > > python-chinese at lists.python.cn
> > > http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> > >
> >
> > _______________________________________________
> > python-chinese list
> > python-chinese at lists.python.cn
> > http://python.cn/mailman/listinfo/python-chinese
> >
> >
> >
>

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

2005年11月14日 星期一 18:44

Shi Mu samrobertsmith at gmail.com
Mon Nov 14 18:44:13 HKT 2005

请问如何用python和Tkinter实现以下步骤:
有两条线段(假设是2x+y-1=0 并且两端点坐标是 (1,-1) 和(-1,3);
x+y+6=0 并且两端点坐标是 (-3,-3) 和(-4,-2);).
在这两条线段延伸并且互相碰到之后,延伸停止,
如何用python和Tkinter实现这两条线的这个最后状态.

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

2005年11月14日 星期一 19:29

Jacob Fan jacob at exoweb.net
Mon Nov 14 19:29:16 HKT 2005

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实现这两条线的这个最后状态.
解这两个方程式,算出交点.后面的步骤就很简单了


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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号