SourceForge has been redesigned. Learn more.

#35 Customisation through subclasses

to discuss

I don't like editing generated code if I can avoid it!

So I'd hoped to have wxGlade generate classes, but be able to specify a sub-class for instantiation - which I would write myself, importing it through 'extracode'.

That way the generated event methods would be abstract templates, overridden in the hand-written sub-class.

As stands, I can set the base class, name the generated class, but can't set the instantiated class to be a sub-class. So to get my event methods to run, I create a custom base class, generate the code, and delete the template event methods by hand so they no longer mask the real ones.

A related problem: My 'main' script calls the generated GUI. But I can only pass data to it through global variables. I know I'm being fussy, globals do the job just fine, and I'm never likely to instantiate two app instancess ... but globals are ugly!


  • Dietmar Schwertberger

    Not sure whether I got that right.
    If you have a sub-class, then you have overwritten the handlers.
    So actually, you want to avoid that a handler method is created by wxglade. It should be bound, but no name generated in order not to overwrite.
    I'm not sure whether this is the way to go. As of now, it's best to implement the main application yourself and make it import a module where you derive from the generated window class.
    For small glue code, it may just be fine to edit the handler in the generated file and to de-select "overwrite existing sources". This way it won't be overwritten.
    Some better documentation is required. There's an old wiki page on this, but it's way too complicated.

  • Dietmar Schwertberger

    • status: open --> closed
    • assigned_to: Dietmar Schwertberger
    • Group: --> to discuss

Log in to post a comment.