GladeGen and initializing widgets at startup

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aengys

    #1

    GladeGen and initializing widgets at startup

    Hi all,

    Being struck by article 7421 of the linux journal
    (http://www.linuxjournal.com/article/7421), I'll tried to give it a go.
    Mainly because I have done some experiments with Glade and found that
    it is really easy to create good looking GUIs. On the other end, there
    is the GladeGen tool which helps you in building a skeleton in Python
    such that you only have to code the events. But being a newbie with
    Python as well as Glade I'm heavily dependent on documentation (mainly
    online a big part being usenet). There I found that almost nobody
    seems to use it, or they don't have any problems with it. In this group
    there is only thread that has a reference to it!

    So my questions:

    Does anybody use GladeGen? If not, why?

    For those that do use it, where do I write the code which has to be
    executed when a window loads? The thing is pretty basic here. I have a
    window with a treeview, and I simply want that treeview filled up when
    opening the window.

    Hoping for some echos...

    Aengys

  • David Reed

    #2
    Re: GladeGen and initializing widgets at startup


    On May 6, 2006, at 4:39 PM, Aengys wrote:
    [color=blue]
    > Hi all,
    >
    > Being struck by article 7421 of the linux journal
    > (http://www.linuxjournal.com/article/7421), I'll tried to give it a
    > go.
    > Mainly because I have done some experiments with Glade and found that
    > it is really easy to create good looking GUIs. On the other end, there
    > is the GladeGen tool which helps you in building a skeleton in Python
    > such that you only have to code the events. But being a newbie with
    > Python as well as Glade I'm heavily dependent on documentation (mainly
    > online a big part being usenet). There I found that almost nobody
    > seems to use it, or they don't have any problems with it. In this
    > group
    > there is only thread that has a reference to it!
    >
    > So my questions:
    >
    > Does anybody use GladeGen? If not, why?
    >
    > For those that do use it, where do I write the code which has to be
    > executed when a window loads? The thing is pretty basic here. I
    > have a
    > window with a treeview, and I simply want that treeview filled up when
    > opening the window.
    >
    > Hoping for some echos...
    >
    > Aengys
    >[/color]


    I'm the author of it - I got a number (20-30 I think) of responses
    from people using it and a few quick questions. I emailed the gnome-
    python maintainer to see if they were interested in including it or
    taking it over, but never heard back. If anyone wants to take it over
    and extend it, you're welcome to. I believe Linux Journal maintained
    copyright ownership for a few months after the publication but then
    it reverts back to the author so I'll happily release it under the
    GPL for anyone to extend. To answer your question, you can put your
    code in the init method after the call to: GladeWindow.__i nit__ or
    you can override the GladeWindow's show method in your class if you
    want it to be called every time the window is shown. I often wrote a
    method named "populate" to file in data in widgets and then called it
    from the show method.

    Dave

    Comment

    • Aengys

      #3
      Re: GladeGen and initializing widgets at startup

      Thank you for your reply!

      I finally managed to do what I wanted. Maybe a little side-remark here.
      In the article you have said that all changes to the init-method are
      lost once you regenerate the file. I have tried it, and indeed all my
      changes were lost (which I had backed up before). So I've created a
      method which do the initialization and I call this method from the
      init-method. Maybe it would be a nice extention to include such a
      method by default; a method you can fill with all the code that needs
      to be done when initializing the window.... I'm not yet so familiar
      with the whole process, but I might have a look at it in the future.
      I'll keep you updated on that if it happens.

      Regarding the extension of the show method: how do I do that? And what
      benefit does it have to the solution mentioned above?

      Aengys

      Comment

      • David Reed

        #4
        Re: GladeGen and initializing widgets at startup


        On May 7, 2006, at 4:24 AM, Aengys wrote:
        [color=blue]
        > Thank you for your reply!
        >
        > I finally managed to do what I wanted. Maybe a little side-remark
        > here.
        > In the article you have said that all changes to the init-method are
        > lost once you regenerate the file. I have tried it, and indeed all my
        > changes were lost (which I had backed up before). So I've created a
        > method which do the initialization and I call this method from the
        > init-method. Maybe it would be a nice extention to include such a
        > method by default; a method you can fill with all the code that needs
        > to be done when initializing the window.... I'm not yet so familiar
        > with the whole process, but I might have a look at it in the future.
        > I'll keep you updated on that if it happens.
        >[/color]

        It's been a while since I've looked at it or used it (haven't been
        doing an GUI programming recently). I should have said to put your
        code in the __init__ method after the call to init since the init
        method is regenerated each time.

        [color=blue]
        > Regarding the extension of the show method: how do I do that? And what
        > benefit does it have to the solution mentioned above?[/color]


        You mentioned you were new to Python - you really need to learn more
        (specifically about inheritance) before you can fully understand
        this. The GladeWindow provides a show method but you can write your
        own show method that would get called instead of it. If you want the
        code to just be called once, using the __init__ method is appropriate
        but if your window is repeatedly shown/hidden and you want the code
        executed each time the window is shown.

        Dave

        Comment

        Working...