Python论坛  - 讨论区

标题:[python-chinese] 使用Tkinter的一个问题

2006年02月26日 星期日 12:07

Gu Yingbo tensiongyb at gmail.com
Sun Feb 26 12:07:11 HKT 2006

这个程序执行不了,在mainloop()那一行会出错,把类Gui里面的内容放到外面就可以。
但我看python核心编程里就有同样的写法,难道是因为原来的版本太旧了?
刚开始用Tkinter,还请指点一下。

from Tkinter import *
class Gui:
    def __init__(self):
        self.root = Tk()
        self.a = Button(self.root, text='aaa', command=self.click)
        self.a.pack()
    def click(self):
        print 'aaa'
        self.root.quit()

def main():
    x = Gui
    mainloop()

if __name__ == '__main__':
    main()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060226/4eaf6d91/attachment.html

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

2006年02月26日 星期日 13:34

helium helium.sun at gmail.com
Sun Feb 26 13:34:52 HKT 2006

def main():
    x = Gui()
    mainloop()

在06-2-26,Gu Yingbo <tensiongyb at gmail.com> 写道:
>
> 这个程序执行不了,在mainloop()那一行会出错,把类Gui里面的内容放到外面就可以。
> 但我看python核心编程里就有同样的写法,难道是因为原来的版本太旧了?
> 刚开始用Tkinter,还请指点一下。
>
> from Tkinter import *
> class Gui:
>     def __init__(self):
>         self.root = Tk()
>         self.a = Button(self.root, text='aaa', command=self.click)
>         self.a.pack()
>     def click(self):
>         print 'aaa'
>         self.root.quit()
>
> def main():
>     x = Gui
>     mainloop()
>
> if __name__ == '__main__':
>     main()
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060226/4e30f5c9/attachment.htm

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

2006年02月26日 星期日 14:28

Gu Yingbo tensiongyb at gmail.com
Sun Feb 26 14:28:53 HKT 2006

哦,低级错误啊!
On 2/26/06, helium <helium.sun at gmail.com> wrote:
>
> def main():
>     x = Gui()
>     mainloop()
>
> 在06-2-26,Gu Yingbo <tensiongyb at gmail.com> 写道:
> >
> > 这个程序执行不了,在mainloop()那一行会出错,把类Gui里面的内容放到外面就可以。
> > 但我看python核心编程里就有同样的写法,难道是因为原来的版本太旧了?
> > 刚开始用Tkinter,还请指点一下。
> >
> > from Tkinter import *
> > class Gui:
> >     def __init__(self):
> >         self.root = Tk()
> >         self.a = Button(self.root, text='aaa', command=self.click)
> >         self.a.pack()
> >     def click(self):
> >         print 'aaa'
> >         self.root.quit()
> >
> > def main():
> >     x = Gui
> >     mainloop()
> >
> > if __name__ == '__main__':
> >     main()
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> >
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060226/6ed5ed6d/attachment.html

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号