| 1 | # A Dialog with a ScrolledText widget. |
| 2 | |
| 3 | import Pmw |
| 4 | |
| 5 | class TextDialog(Pmw.Dialog): |
| 6 | def __init__(self, parent = None, **kw): |
| 7 | # Define the megawidget options. |
| 8 | INITOPT = Pmw.INITOPT |
| 9 | optiondefs = ( |
| 10 | ('borderx', 10, INITOPT), |
| 11 | ('bordery', 10, INITOPT), |
| 12 | ) |
| 13 | self.defineoptions(kw, optiondefs) |
| 14 | |
| 15 | # Initialise the base class (after defining the options). |
| 16 | Pmw.Dialog.__init__(self, parent) |
| 17 | |
| 18 | # Create the components. |
| 19 | interior = self.interior() |
| 20 | aliases = ( |
| 21 | ('text', 'scrolledtext_text'), |
| 22 | ('label', 'scrolledtext_label'), |
| 23 | ) |
| 24 | self._text = self.createcomponent('scrolledtext', |
| 25 | aliases, None, |
| 26 | Pmw.ScrolledText, (interior,)) |
| 27 | self._text.pack(side='top', expand=1, fill='both', |
| 28 | padx = self['borderx'], pady = self['bordery']) |
| 29 | |
| 30 | # Check keywords and initialise options. |
| 31 | self.initialiseoptions() |
| 32 | |
| 33 | # Need to explicitly forward this to override the stupid |
| 34 | # (grid_)bbox method inherited from Tkinter.Toplevel.Grid. |
| 35 | def bbox(self, index): |
| 36 | return self._text.bbox(index) |
| 37 | |
| 38 | Pmw.forwardmethods(TextDialog, Pmw.ScrolledText, '_text') |