[color=red]问题]8.04 下面安装wxPython[/color]

Python/PHP/Perl 开发与设计
回复
头像
onedayoneday
帖子: 26
注册时间: 2008-04-24 17:02
送出感谢: 0
接收感谢: 0

[color=red]问题]8.04 下面安装wxPython[/color]

#1

帖子 onedayoneday » 2008-07-10 13:31

我参考http://linux.chinaunix.net/techdoc/system/2008/05/15/1003170.shtml
中的sudo apt-get install python-wxgtk2.8 python-wxtools python-wxaddons wx2.8-i18n
安装的
import wx 没问题
但用下面的代码时,发生了异常
#-*- coding: utf-8 -*-

import wx
class MyFrame(wx.Frame):

def init(self):
wx.Frame.init(self, None, -1, "My Frame", size=(300, 300))
panel = wx.Panel(self, -1)
panel.Bind(wx.EVT_MOTION, self.OnMove)
wx.StaticText(panel, -1, "Pos:", pos=(10, 12))
self.posCtrl = wx.TextCtrl(panel, -1, "", pos=(40, 10))

def OnMove(self, event):
pos = event.GetPosition()
self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))


if __name__ == "__main__":
app = wx.PySimpleApp()
frame = MyFrame()
frame.Show(True)
app.MainLoop()

######################################################

Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "copyright", "credits" or "license()" for more information.

****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************

IDLE 1.2.2 ==== No Subprocess ====
>>>
Traceback (most recent call last):
File "/home/l/文档/pythonSource/wx1.py", line 20, in <module>
frame = MyFrame()
File "/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_windows.py", line 493, in __init__
_windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
TypeError: new_Frame() takes at least 1 argument (0 given)
>>>

我将line 20 改为 frame = MyFrame(5)后,运行,界面一闪,idle也关了
等待高人解答 谢谢
vabc3
帖子: 94
注册时间: 2008-04-09 20:50
送出感谢: 0
接收感谢: 0
联系:

#2

帖子 vabc3 » 2008-07-15 0:16

init的地方 应该是__init__
papersnake
帖子: 35
注册时间: 2008-04-21 22:07
送出感谢: 0
接收感谢: 0

#3

帖子 papersnake » 2008-09-09 23:58

OnInit(self)
回复

回到 “Python/Php/Perl”