Re: Frame not found by LoadFrame

Carsten Grohmann <[email protected]>
Newsgroups gmane.comp.python.wxglade
Message-ID <[email protected]>
Hi Fabrizio,

Am 05.03.2015 18:34 schrieb Fabrizio Pollastri:
> xml_resource = xrc.XmlResource('test.wxg')

The wxGlade design files (*.wxg) aren't XRC compatible. Thereby you've to convert the wxGlade design into an XRC file first. You can use the GUI to create a XRC file or use wxglade on command line:

# ./wxglade -g XRC -o test.xrc test.wxg

In next step, you've to load the XRC file e.g. using this example code:

#!/usr/bin/env python2

import wx
from wx import xrc

GUI_FILENAME = "test.xrc"
GUI_MAINFRAME_NAME = "frame_1"

class MyApp(wx.App):
    def OnInit(self):
        self.res = xrc.XmlResource(GUI_FILENAME)
        self.frame = self.res.LoadFrame(None, GUI_MAINFRAME_NAME)
        self.frame.Show()
        return True

if __name__ == "__main__":
    app = MyApp()
    app.MainLoop()

That's all and it works fine.

HTH,
Carsten

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.