Ok, first off, yes I'm trying to implement a ribbon-like interface,
Microsoft can sue me. :P

Anyway, I am wondering if there is any way to put a toolbar inside a
notebook. I have tried it with my code, but the toolbars don't seem to
show, making me wonder if I am doing something wrong. Perhaps someone
could look at it and see what I did wrong, or tell me if it is
possible at all? I could find absolutely no documentation on this,
meaning its either really simple or impossible.

Thanks to whomever helps,
Smartboy
#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk

class MainWindow(object):
    def delete_event(self, widget, event, data=None):
        return False


    def destroy(self, widget, data=None):
        gtk.main_quit()


    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_border_width(0)
        self.window.set_resizable(True)
        self.window.set_default_size(300, 250)
        self.window.set_title('SmartTE, Smartboy\'s Text Editor')
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)

        newButton = gtk.ToolButton(gtk.STOCK_NEW)
        #newButton.connect('clicked', self.new)
        openButton = gtk.ToolButton(gtk.STOCK_OPEN)
        #openButton.connect('clicked', self.open)
        saveButton = gtk.ToolButton(gtk.STOCK_SAVE)
        #saveButton.connect('clicked', self.save)
        saveAsButton = gtk.ToolButton(gtk.STOCK_SAVE_AS)
        #saveAsButton.connect('clicked', self.save_as)
        quitButton = gtk.ToolButton(gtk.STOCK_QUIT)
        #quitButton.connect('clicked', self.quit)
        filebar = gtk.Toolbar()
        filebar.set_style(gtk.TOOLBAR_ICONS)
        filebar.insert(newButton, 0)
        filebar.insert(openButton, 1)
        filebar.insert(saveButton, 2)
        filebar.insert(saveAsButton, 3)
        filebar.insert(quitButton, 4)
        fileLabel = gtk.Label('File')

        boldButton = gtk.ToolButton(gtk.STOCK_BOLD)
        #boldButton.connect('clicked', self.bold)
        italicizeButton = gtk.ToolButton(gtk.STOCK_ITALIC)
        #openButton.connect('clicked', self.italicize)
        underlineButton = gtk.ToolButton(gtk.STOCK_UNDERLINE)
        #saveButton.connect('clicked', self.underline)
        sep1 = gtk.SeparatorToolItem()
        justLeftButton = gtk.ToolButton(gtk.STOCK_JUSTIFY_LEFT)
        #justLeftButton.connect('clicked', self.just_left)
        justCenterButton = gtk.ToolButton(gtk.STOCK_JUSTIFY_CENTER)
        #justCenterButton.connect('clicked', self.just_center)
        justRightButton = gtk.ToolButton(gtk.STOCK_JUSTIFY_RIGHT)
        #justRightButton.connect('clicked', self.just_right)
        justFillButton = gtk.ToolButton(gtk.STOCK_JUSTIFY_RIGHT)
        #justFillButton.connect('clicked', self.just_fill)
        formbar = gtk.Toolbar()
        formbar.set_style(gtk.TOOLBAR_ICONS)
        formbar.insert(boldButton, 0)
        formbar.insert(italicizeButton, 1)
        formbar.insert(underlineButton, 2)
        formbar.insert(sep1, 3)
        formbar.insert(justLeftButton, 4)
        formbar.insert(justCenterButton, 5)
        formbar.insert(justRightButton, 6)
        formbar.insert(justFillButton, 7)
        formLabel = gtk.Label('Format')

        notebook = gtk.Notebook()
        notebook.set_tab_pos(gtk.POS_TOP)
        notebook.append_page(filebar, fileLabel)
        notebook.append_page(formbar, formLabel)

        textView = gtk.TextView()
        textBuffer = textView.get_buffer()

        statusbar = gtk.Statusbar()

        vbox = gtk.VBox()
        vbox.pack_start(notebook, False)
        vbox.pack_start(textView, True)
        vbox.pack_start(statusbar, False)
        filebar.show()
        formbar.show()
        notebook.show()
        textView.show()
        statusbar.show()
        vbox.show()

        self.window.add(vbox)
        self.window.show()


    def main(self):
        gtk.main()

startup = MainWindow()
startup.main()
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to