wxPython之XRC加载流水账
按图索骥一番,用以下代码测试一下:
#!/usr/bin/python
#-*- coding: utf-8 -*-
import wx
import wx.xrc as xrc
class XML(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
res = xrc.XmlResource('cr01.xrc')
res.LoadFrame(self, 'MyFrame2')
self.Center()
self.Show(True)
def OnClose(self, event):
self.Close()
app = wx.App()
XML(None, -1, 'xml resource test')
app.MainLoop()
cr01.xrc里定义了数个组件,发现载入进来的只是一个空框架。
参考文件 :http://privacybrowse.info/index.php?hl=f5&q=uggc%3A%2F%2Fzejyjna.jbeqcerff.pbz%2F2008%2F05%2F03%2Fjkclguba%25RS%25OP%259Nkep%2F
#!/usr/bin/python
#-*- coding: utf-8 -*-
import wx
import wx.xrc as xrc
class XML(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
res = xrc.XmlResource('cr01.xrc')
res.LoadFrame(self, 'MyFrame2')
self.Center()
self.Show(True)
def OnClose(self, event):
self.Close()
app = wx.App()
XML(None, -1, 'xml resource test')
app.MainLoop()
cr01.xrc里定义了数个组件,发现载入进来的只是一个空框架。
参考文件 :http://privacybrowse.info/index.php?hl=f5&q=uggc%3A%2F%2Fzejyjna.jbeqcerff.pbz%2F2008%2F05%2F03%2Fjkclguba%25RS%25OP%259Nkep%2F

1 条评论:
虽然加载了res,但什么也没做呀,实际上你使用了wx.Frame.__init__
于是就创建了空frame了。继承xrc中的类,建议由xrced自动生成代码,继承代码中的xrcframe类,比较简单,而且不会出错。
发表评论
<< 主页