[pygtk] help with two main windows in pygtk

Edward Stow ed.stow at gmail.com
Fri Feb 22 07:02:55 WST 2008


On Fri, Feb 22, 2008 at 3:28 AM, Prashant Shah <elite.mumbai at gmail.com> wrote:
> >  self.new_comp_glade = self.mwglade.get_widget("new_company")
>  >  self.vbox_main = self.mwglade.get_widget("vbox_main")
>  >
>  >  child = self.new_comp_glade.get_child()
>  >  if child:
>  >     # remove the child from the top window
>  >     self.new_comp_glade.remove(child)
>  >     self.vbox_main.add(child)
>
>  Cool !! It works :) Thanks a lot !!!
>
>  I am making a small financial app in pygtk (gpl)
>
>  glade file :
>  http://rapidshare.com/files/93713518/main.glade.html
>
>  I have a =MainWindow= window (hbox: menubar, statusbar, a central main
>  area where all the stuff is displayed) with a menu item called create
>  company. On clicking create company - it has to open the
>  =CreateCompany= window in the central main area.
>
>  I have made different windows for vouchers/reports. For every action
>  it will load the windows in the central main area.
>
>  I dont know whether this is the rightway - I just took a guess.
>
>  Also should I use seperate python files for each gtk window or how is it done ??

I use one glade file that contains many top level windows - each top
window contains a child container that is reparented as needed.  Each
of these containers is represented by a View class (a python class,)
each View subclass knows how to initialise the view, populate widgets
with model data, and respond to events.

I keep each view class in a separate *.py file.

Whether this the 'python way' I don't know.

Suggest you read up on Model View Controller / Model View Presenter patterns.

Martin Fowler is a starting point


More information about the pygtk mailing list