Catching events from an xmlResource & other questions

Hi,

First off, big thanks to everyone who's contributed to wxPython, it's so
much more than I expected. I'm new to GUIs, but not to programming.

I'm developing a simple database form type app, though it will save as
XML, to be imported into a database on the server. To keep it simple I'm
planning on doing most of the interface as an XML resource, but is this
a good idea? I'm also a bit concerned that I'm nesting sizers too much -
is five levels too many?

What I can't figure how to do is get at the XMLresouce elements, like
how to get the text out of a text box? Also I figured out how to catch
some events, EVT_BUTTON works fine, but to get the "got focus" event
I've tried using EVT_COMMAND_SET_FOCUS but it just doesn't catch
anything.

Thanks,

Paul

Here's the code I've been using:

#!c:/python/python

from wxPython.wx import *
from wxPython.xrc import *

class paj(wxFrame):
  def __init__(self):
    wxFrame.__init__(self, None, -1, "paj")

    res = wxXmlResource('client.xrc')
    panel = res.LoadPanel(self, "PANEL2")

    #EVT_BUTTON(self, 123, self.silly)
    EVT_COMMAND_SET_FOCUS(self, 123, self.silly)

  def silly(self, event):
    print "hello"

app = wxPySimpleApp()
paj().Show()
app.MainLoop()

Paul Johnston wrote:

Hi,

First off, big thanks to everyone who's contributed to wxPython, it's so
much more than I expected.

You're welcome.

I'm developing a simple database form type app, though it will save as
XML, to be imported into a database on the server. To keep it simple I'm
planning on doing most of the interface as an XML resource, but is this
a good idea? I'm also a bit concerned that I'm nesting sizers too much -
is five levels too many?

No.

What I can't figure how to do is get at the XMLresouce elements, like
how to get the text out of a text box?

You can get a reference to the widgets defined in the xrc by name. For example:

  textctl = XRCCTRL("MyTextbox")
  val = textbox.GetValue()

Also I figured out how to catch
some events, EVT_BUTTON works fine, but to get the "got focus" event
I've tried using EVT_COMMAND_SET_FOCUS but it just doesn't catch
anything.

As you've found command events will travel up to the containing window and can be caught there. Other event types have to be caught at the window where they happen so you can get a reference to the window by name as above and then use it with the EVT_* function to bind the event to a handler.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!