Bonjour, j'ai dérivé une classe depuis la classe Scrolledtext. J'ai ensuite pris l'exemple de Notebook donné dans les demo de PMW. Si je met un Scrolledtext dans l'un des onglets, pas de problème il est bien intégré à l'onglet ("helpers"). Si je tente de mettre une instance de ma classe dérivée du Scrolledtext, cette instance est ajoutée "en bas du Notebook", donc en dehors de mon onglet "images" même si j'ai spécifié de le mettre dans cet onglet.
Pouvez vous m'aider à intégrer mon instance de classe dans l'onglet. Merci d'avance.

Code de l'exemple:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 d'affichage 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
 
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()