[pygtk] help with two main windows in pygtk

Edward Stow ed.stow at gmail.com
Thu Feb 21 10:42:56 WST 2008


Prashant:

On Thu, Feb 21, 2008 at 4:44 AM, Prashant Shah <elite.mumbai at gmail.com> wrote:
> I am making a PyGTK Application.
>
>  I am using glade. I have made two Windows (main_window, new_company)
>  and saved them within the same galde file and loading them using
>  libglade (?)
>
>  I have a button in the main_window which when clicked should show the
>  new_comany window (within a vbox in the main window).
>
>  I am not sure how to implement this using pygtk.
>
>  Should I make a different class and different file for each Window ?
>  This is going to be fairly big application.
>
>  And how to load the the new_company window within a vbox in the main_window.
>
>  This is the signal handler for the button click in the main
>  window(mwglade). vbox_main is the vbox. new_comp_glade is the window
>  for the new company.
>
>  def new_file(self,widget,data=None):
>                 """New data file"""
>                 self.new_comp_glade = self.mwglade.get_widget("new_company")
>                 self.vbox_main = self.mwglade.get_widget("vbox_main")
>                 self.vbox_main.add(self.new_comp_glade)


I'm not sure what you are trying to do  exactly but adding a
gtk.Window to a widget is not going to work.  Consider adding the
container (VBox, or HBox ) that is the child of the window

And I know that you cannot add a widget that already has a parent.

So consider unparent() 'ing the widget that you are adding to the vbox.

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)

>  This gives seg fault.
>
>  Am I doing something wrong here since this is not making sense. I know
>  I have messed up somewhere.
>  _______________________________________________
>  pygtk mailing list   pygtk at daa.com.au
>  http://www.daa.com.au/mailman/listinfo/pygtk
>  Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>



-- 

Edward Stow


More information about the pygtk mailing list