[Glade-users] [pygtk] how to add window as a page to a notebook



hi Andi,
I tried your second solution.But it is giving the error:'glade.XML' object
has no attribute 'get_child'
for your reference i am sending my whole folder as tar.gz.Please refer it .
Thanks for your help.

Njoy the share of Freedom,
Anusha

On Sat, Jan 10, 2009 at 1:11 PM, Andi Albrecht <albrecht.andi at googlemail.com
wrote:

Hi Anusha,

I think there are two problems here: First you have to reparent the
widget you want to add to the notebook and then you can't add toplevel
windows to notebooks.

I could not test it, but IMO show_newOrganisation() should look
something like this (where NAME_OF_THE_WIDGET is the name of the first
child widget in your second glade file):

def show_newOrganisation(self,widget):
      new_org.org()
      self.gladefile_newOrg = "new_org.glade"
       widget = gtk.glade.XML(self.gladefile_newOrg, 'NAME_OF_THE_WIDGET')
      self.page=self.notebook.insert_page(widget    , None, 0)
       self.notebook.set_current_page(self.page)

FWIW, if you need to toplevel window from the second glade file too
you can do something like this:

def show_newOrganisation(self,widget):
      new_org.org()
      self.gladefile_newOrg = "new_org.glade"
      self.wTreenewOrg = gtk.glade.XML(self.gladefile_newOrg)
       self.page = self.wTreenewOrg.get_child()
      self.page.reparent(self.notebook)
      self.page.set_tab_label_text(self.page, 'some tab label')

Regards,

Andi

On Sat, Jan 10, 2009 at 7:54 AM, anusha k <anuhacks at gmail.com> wrote:
hi,

I am using glade and pygtk to develop an accounting software.In that we
have
two glade files .first glade file contain the main window and the note
book
and the second glade contains the another window .I want to add the
second
glade-window as a page to first glade-window.how to do this
I have the code as below.but it is giving the warning and the window is
not
shown up .warnings are :
How to solve the warnings.Is there any other way to solve this

Warnings:****************************************************************************

self.wTree = gtk.glade.XML(self.gladefile)
main.py:47: GtkWarning: gtk_notebook_set_tab_label: assertion
`GTK_IS_WIDGET
(child)' failed
  self.wTree = gtk.glade.XML(self.gladefile)
main.py:20: GtkWarning: Can't set a parent on a toplevel widget



self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget("window_new_org")
, None, 0)
main.py:20: GtkWarning: gtk_widget_set_child_visible: assertion
`!GTK_WIDGET_TOPLEVEL (widget)' failed


self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget("window_new_org")
, None, 0)

***************************************************************************
Code:

import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade
import new_org
class mainmenu:
    def show_newOrganisation(self,widget):
        new_org.org()
        self.gladefile_newOrg = "new_org.glade"
        self.wTreenewOrg = gtk.glade.XML(self.gladefile_newOrg)


self.page=self.notebook.insert_page(self.wTreenewOrg.get_widget("window_new_org")
, None, 0)
        self.notebook.set_current_page(self.page)

    def dialogQuit(self,widget):
        self.dialog_quit = self.wTree.get_widget("dialog_quit")
        self.dialog_quit.show()
        self.response = self.dialog_quit.run()
        if self.response == 'gtk.RESPONSE_QUIT':
            gtk.main_quit()
            self.window.destroy()
        self.dialog_quit.destroy()


    def on_button_quit_clicked(*args):
        gtk.main_quit()

    def on_button_cancel_clicked(*args):
        self.dialog_quit.destroy()

    #To quit the main window
    def on_Mainwindow_destroy(self):
        gtk.main_quit()


    def __init__(self):
        #set the glade file
        self.gladefile = "gnukhata.glade"
        self.wTree = gtk.glade.XML(self.gladefile)

        #get the Main Window and connect the Destroy event
        self.window = self.wTree.get_widget("MainWindow")
        self.window.show()
        self.window.connect('destroy',gtk.main_quit)
        self.notebook = self.wTree.get_widget("notebook_main")
        self.notebook.show()

        self.menuitem_quit = self.wTree.get_widget("menuitem_quit")
        self.menuitem_quit.connect('activate',self.dialogQuit)

        self.menuitem_newOrg =
self.wTree.get_widget("menuitem_new_organisation")

self.menuitem_newOrg.connect('activate',self.show_newOrganisation)
if __name__ == "__main__":
    mm=mainmenu()
    gtk.main()

Thanks in advance

Njoy the share of Freedom,
Anusha

_______________________________________________
pygtk mailing list   pygtk at daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

_______________________________________________
pygtk mailing list   pygtk at daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20090110/1eef6406/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnukhata919.tar.gz
Type: application/x-gzip
Size: 5658 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/glade-users/attachments/20090110/1eef6406/attachment-0001.gz 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]