0

I am trying to work with xrc resource in wxpython. It is good but where is one big "no" - there is no autocomplete of wxFrame class loadet from xrc. And other loaded from xrc classes too.

Is this right or I'am doing somthing wgong?

here is the part of code for example:

import wx
from wx import xrc

class MyApp(wx.App):
    def OnInit(self):
        if os.path.exists("phc.xrc"):
            self.res = xrc.XmlResource("phc.xrc")

            self.frame = self.res.LoadFrame(None, 'MyFrame')
            self.list_box = xrc.XRCCTRL(self.frame, "list_box_1")
            self.notebook = xrc.XRCCTRL(self.frame, "Notebook")
            self.StatusBar= xrc.XRCCTRL(self.frame, "MFrame_statusbar")
            self.list_ctrl= xrc.XRCCTRL(self.frame, "list_ctr_1")
Viktor
  • 313
  • 2
  • 11

2 Answers2

0

Well, how good the autocomplete function is depends entirely on the editor/IDE that you are using. You didn't specify what you are using to write python scripts, but from personal experience I would say that it is probably true, that there is no autocomplete.

I've used Eclipse/PyDev, Spyder, SPE and PyCharm in the past and they all did not show an ability to autocomplete widgets created with XRC. You could still try to get the Emacs autocomplete for Python to work and try it there, but I doubt it'll work.

I did not find this a particular hindrance, but everyone's different, I guess. Hopefully, that answers your question.

Nebelhom
  • 3,783
  • 4
  • 21
  • 22
0

Yes autocomplete wouldn't work here since our code doesn't know what the xrc is going to return. Your code gets to know about the type of variable (in this case, frame) only during runtime.

And, unfortunately/fortunately, we cannot assign 'type' to a variable in Python for the autocompletion to work.

But in Eclipse + PyDev plugin

you can add this statement for autocomplete to work:

assert isinstance(self.frame, wx.Frame)

autocomplete works after this statement.