XMLUI

Hi all,

  I'm happy to announce the first release of XMLUI: My

quicker-and-dirty implementation of xrc.

  The idea is you create structure in an XML file, then overlay

that structure on an already-created wx.Frame or wx.Dialog
instance.

Here’s the xml for a login frame that’s provided with the repo:

Test Frame &Username test &Password &Age 18 &Height (in metres) 1.5 Rating 3 Agree

Here’s the Python code that drives it:

“”“Show a frame generated from an XML file.”""

  import wx
  from xmlui.wx import WXXMLParser

  class MyXMLParser(WXXMLParser):
      """Add event handlers."""

      def on_paste(self, event):
          """Pop up an alert."""
          return wx.MessageBox('You shouldn\'t copy and paste

passwords.’)

      def on_copy(self, event):
          """Pop up an alert."""
          return wx.MessageBox(
              'You probably won\'t get any useful text that way.'
          )

      def on_login(self, event):
          frame = event.GetEventObject().GetParent().GetParent()
          username = frame.username.GetValue()
          password = frame.password.GetValue()
          return wx.MessageBox(
              'You clicked the Login button.\n\n'
              f'Username: {username}\n'
              f'Password: {password}'
          )

      def close(self, event):
          event.GetEventObject().GetParent().GetParent().Close(True)

  if __name__ == '__main__':
      a = wx.App()
      f = wx.Frame(None)
      xml.populate_from_file('frame.xml', f, None)
      f.Show(True)
      f.Maximize()
      a.MainLoop()

  As you can see, you can bind multiple events for each control.

Also, anything in there (apart from the root tag - which can be
anything), with a name attribute will be added to the frame with
that name.

Todo:

Currently there is no work around for lines like:

frame.Bind(wx.EVT_MENU, handler, menu_item)

  There is currently no documentation beyond docstrings. I'll add

that at some point in the hopefully-not-too-distant future
(hopefully tomorrow).

  If I (or someone else) wants that functionality I could add it

easily enough.

  If anyone has any suggestions or whatever, please feel free to

message me.

Github: Link

PyPi: Link

Complaints: Link