gtk python expanding content to fit window
Question: I have this program and, as much as I try I can not make the elements expand
to occupy the area defined for the tire size of the application.

Code:

    
    
    import smtpClass
    import xmlHostes
    import pygtk
    pygtk.require('2.0')
    import gtk
    
    
    
    class Base:
    
    def get_main_menu(self, window):
        accel_group = gtk.AccelGroup()
        item_factory = gtk.ItemFactory(gtk.MenuBar, "<main>", accel_group)
        item_factory.create_items(self.menu_items)
        window.add_accel_group(accel_group)
        self.item_factory = item_factory
        return item_factory.get_widget("<main>")
    
    def __init__(self):
    
        ## MENU CONTENT
        self.menu_items = (#  MENU TREE      # CONTROL KEY   # FUNCTION
                           ( "/_File",          None,         None,             0,  "<Branch>" ),
                           ( "/File/_Setings",  "<control>S", None,             0,  None ),
                           ( "/File/Quit",      "<control>Q", gtk.main_quit,    0,  None ),
                           ( "/_Help",          None,         None,             0,  "<LastBranch>" ),
                           ( "/_Help/About",    None,         None,             0,  None ),
                           )
    
    
        # WINDOW WIDGET
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("pyAnonMail")
        self.window.set_size_request(500, 500)
    
        # CONTEINER DATA
        main_vbox = gtk.VBox(False, 5)
        #main_vbox.set_border_width(1)
        self.window.add(main_vbox)
        main_vbox.show()
    
        self.contentTable = gtk.Table(1, 3, True)
        main_vbox.pack_start(self.contentTable, True, True, 10)
    
        # ADD MENU TO CONTEINER
        self.menubar = self.get_main_menu(self.window)
        main_vbox.add(self.menubar)
        self.menubar.show()
    
        # FRAME 1 ##########################################################
        self.frame1 = gtk.Frame()
        self.contentTable.attach(self.frame1, 0, 1, 0, 1,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        self.frame1.set_label_align(0.0, 0.0)
        self.frame1.set_label("Enter message data")
        self.frame1.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        self.frame1.show()
    
    
        # DATA TABLE
    
        dataTable = gtk.Table(2, 6, False)
        self.frame1.add(dataTable)
        dataTable.show()
    
        senderNameFrame = gtk.Label("Sender Name:")
        dataTable.attach(senderNameFrame, 0, 1, 0, 1,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        senderNameFrame.show()
        senderNameEntry = gtk.Entry()
        dataTable.attach(senderNameEntry, 0, 1, 1, 2,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        senderNameEntry.show()
    
        senderEmailFrame = gtk.Label("Sender Email:")
        dataTable.attach(senderEmailFrame, 1, 2, 0, 1,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        senderEmailFrame.show()
        senderEmailEntry = gtk.Entry()
        dataTable.attach(senderEmailEntry, 1, 2, 1, 2,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        senderEmailEntry.show()
    
        recipientNameFrame = gtk.Label("Recipient Name:")
        dataTable.attach(recipientNameFrame, 0, 1, 2, 3,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        recipientNameFrame.show()
        recipientNameEntry = gtk.Entry()
        dataTable.attach(recipientNameEntry, 0, 1, 3, 4,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        recipientNameEntry.show()
    
        recipientEmailFrame = gtk.Label("Recipient Email:")
        dataTable.attach(recipientEmailFrame, 1, 2, 2, 3,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        recipientEmailFrame.show()
        recipientEmailEntry = gtk.Entry()
        dataTable.attach(recipientEmailEntry, 1, 2, 3, 4,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        recipientEmailEntry.show()
    
        dataAndTimeFrame = gtk.Label("Data and Time:")
        dataTable.attach(dataAndTimeFrame, 0, 1, 4, 5,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        dataAndTimeFrame.show()
        dataAndTimeEntry = gtk.Entry()
        dataTable.attach(dataAndTimeEntry, 1, 2, 4, 5,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        dataAndTimeEntry.show()
    
        subjectFrame = gtk.Label("Subject:")
        dataTable.attach(subjectFrame, 0, 1, 5, 6,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        subjectFrame.show()
        subjectEntry = gtk.Entry()
        dataTable.attach(subjectEntry, 1, 2, 5, 6,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        subjectEntry.show()
    
        ####################################################################
    
        # FRAME 2 ##########################################################
        self.frame2 = gtk.Frame()
        self.contentTable.attach(self.frame2,0,1,1,2,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        self.frame2.set_label_align(0.0, 0.0)
        self.frame2.set_label("Enter message body")
        self.frame2.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        self.frame2.show()
    
        table = gtk.ScrolledWindow()
        table.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        text = gtk.TextView()
        text.set_editable(True)
        textbuffer = text.get_buffer()
        self.frame2.add(table)
        table.show()
        table.add(text)
        text.show()
    
    
    
        ####################################################################
    
        # FRAME 3 ##########################################################
        self.frame3 = gtk.Frame()
        self.contentTable.attach(self.frame3,0,1,2,3,
            gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        self.frame3.set_label_align(0.0, 0.0)
        self.frame3.set_label("Select attached files")
        self.frame3.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        self.frame3.show()
    
        ####################################################################
    
        self.contentTable.show()
    
        self.window.show()
    
    def main(self):
        gtk.main()
    
    def destroy(self, widget, data=None):
        gtk.main_quit()
    

I thought the problem was in the gtk.box parameters, or the parameters of
gtk.tables. I've tried everything and nothing changes. In the examples I find
on the net about gtk and python, everything is as I have but the result is
always different from mine.


Answer: You have to add gtk.EXPAND to the xoptions parameter when calling
[**contentTable.attach**](http://www.pygtk.org/docs/pygtk/class-
gtktable.html#method-gtktable--attach):

    
    
    # FRAME 1 ##########################################################
    self.frame1 = gtk.Frame()
    self.contentTable.attach(self.frame1, 0, 1, 0, 1,
    gtk.FILL | gtk.EXPAND, gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
    

