Scrollectext derived class and Notebook

atalon1
2007-09-13
2013-02-21
  • atalon1

    atalon1 - 2007-09-13

    Hi, I made a Scrolledtext derived class that I wanted to pack in one of the tab of a PMW NoteBook. It seems that the instance of my class is packed into the Tk window, bellow the NoteBook instead of being packed in the tab of the NoteBook. If I put directly a Scrollectext instead of my class instance, it works... What is the problem here?

    Thanks a lot.

    Here is the exemple code (adapted from the NoteBook example):

    title = 'Pmw.NoteBook demonstration'

    # Import Pmw from this directory tree.
    import sys
    sys.path[:0] = ['../../..']

    import Tkinter
    import Pmw
    from ScrolledText import *

    class Fenseq(ScrolledText):
      '''Fenêtre daffichage de la séquence'''
      def __init__(self, parent, lsize):
        ScrolledText.__init__(self, font = "courier")
        self.parent = parent
        self.lsize = lsize
        self.pack(expand =1, fill='both') 
        self.focus_set()
        ##self.pack Deux méthodes de placement, c'est pas bon, surtout si la dernière n'est pas bonne en syntaxe (Ici, il manque les "()")

    class Demo:
        def __init__(self, parent):
        # Create and pack the NoteBook.
             
            notebook = Pmw.NoteBook(parent)
            notebook.pack(fill = 'both', expand = 1, padx = 10, pady = 10)

            # Add the "Appearance" page to the notebook.
            page = notebook.add('Appearance')
            notebook.tab('Appearance').focus_set()

            # Create the "Toolbar" contents of the page.
            group = Pmw.Group(page, tag_text = 'Toolbar')
            group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
            b1 = Tkinter.Checkbutton(group.interior(), text = 'Show toolbar')
            b1.grid(row = 0, column = 0)
            b2 = Tkinter.Checkbutton(group.interior(), text = 'Toolbar tips')
            b2.grid(row = 0, column = 1)

            # Create the "Startup" contents of the page.
            group = Pmw.Group(page, tag_text = 'Startup')
            group.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
            home = Pmw.EntryField(group.interior(), labelpos = 'w',
                label_text = 'Home page location:')
            home.pack(fill = 'x', padx = 20, pady = 10)

            # Add two more empty pages.
            page = notebook.add('Helpers')
            text =  ScrolledText(page, width = 100)
            text.pack()
            page = notebook.add('Images')
            text =  Fenseq(page, 50)

            notebook.setnaturalsize()

    ######################################################################

    # Create demo in root window for testing.
    if __name__ == '__main__':
        root = Tkinter.Tk()
        Pmw.initialise(root)
        root.title(title)

        widget = Demo(root)
        exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
        exitButton.pack()
        root.mainloop()

     
    • atalon1

      atalon1 - 2007-09-14

      Sorry, I think I put this iin the wrong part of the forum

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks