| 1 | |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta name="description" content="Pmw - a toolkit for building high-level compound widgets in Python"> |
| 5 | <meta name="content" content="python, megawidget, mega widget, compound widget, gui, tkinter"> |
| 6 | <title>Pmw.ScrolledField reference manual</title> |
| 7 | </head> |
| 8 | |
| 9 | <body bgcolor="#ffffff" text="#000000" link="#0000ee" |
| 10 | vlink="551a8b" alink="ff0000"> |
| 11 | |
| 12 | <h1 ALIGN="CENTER">Pmw.ScrolledField</h1> |
| 13 | |
| 14 | <center><IMG SRC=ScrolledField.gif ALT="" WIDTH=268 HEIGHT=37></center> |
| 15 | <dl> |
| 16 | <dt> <h3>Name</h3></dt><dd> |
| 17 | <p>Pmw.ScrolledField() - |
| 18 | single line scrollable output field |
| 19 | </p> |
| 20 | |
| 21 | |
| 22 | </dd> |
| 23 | <dt> <h3>Inherits</h3></dt><dd> |
| 24 | <a href="MegaWidget.html">Pmw.MegaWidget</a><br> |
| 25 | </dd> |
| 26 | <dt> <h3>Description</h3></dt><dd> |
| 27 | <p> |
| 28 | A scrolled field displays a single line of text. If the text is |
| 29 | too wide to display in the megawidget it can be scrolled to the |
| 30 | left and right by the user by dragging with the middle mouse |
| 31 | button. The text is also selectable by clicking or dragging with |
| 32 | the left mouse button.</p> |
| 33 | |
| 34 | <p> It can be used instead of a Tkinter.Label widget when displaying |
| 35 | text of unknown width such as application status messages.</p> |
| 36 | |
| 37 | <p></p> |
| 38 | |
| 39 | |
| 40 | </dd> |
| 41 | <dt> <h3>Options</h3></dt><dd> |
| 42 | Options for this megawidget and its base |
| 43 | classes are described below.<p></p> |
| 44 | <a name=option.labelmargin></a> |
| 45 | <dl><dt> <strong>labelmargin |
| 46 | </strong></dt><dd> |
| 47 | Initialisation option. If the <strong>labelpos</strong> option is not <strong>None</strong>, this specifies the |
| 48 | distance between the <strong>label</strong> component and the rest of the |
| 49 | megawidget. The default is <strong>0</strong>.</p> |
| 50 | |
| 51 | |
| 52 | </dd></dl> |
| 53 | <a name=option.labelpos></a> |
| 54 | <dl><dt> <strong>labelpos |
| 55 | </strong></dt><dd> |
| 56 | Initialisation option. Specifies where to place the <strong>label</strong> component. If not |
| 57 | <strong>None</strong>, it should be a concatenation of one or two of the |
| 58 | letters <strong>'n'</strong>, <strong>'s'</strong>, <strong>'e'</strong> and <strong>'w'</strong>. The first letter |
| 59 | specifies on which side of the megawidget to place the label. |
| 60 | If a second letter is specified, it indicates where on that |
| 61 | side to place the label. For example, if <strong>labelpos</strong> is <strong>'w'</strong>, |
| 62 | the label is placed in the center of the left hand side; if |
| 63 | it is <strong>'wn'</strong>, the label is placed at the top of the left |
| 64 | hand side; if it is <strong>'ws'</strong>, the label is placed at the |
| 65 | bottom of the left hand side.</p> |
| 66 | <p> If <strong>None</strong>, a label component is not created. The default is <strong>None</strong>.</p> |
| 67 | |
| 68 | |
| 69 | |
| 70 | </dd></dl> |
| 71 | <a name=option.sticky></a> |
| 72 | <dl><dt> <strong>sticky |
| 73 | </strong></dt><dd> |
| 74 | Initialisation option. The default is <strong>'ew'</strong>.</p> |
| 75 | |
| 76 | |
| 77 | </dd></dl> |
| 78 | <a name=option.text></a> |
| 79 | <dl><dt> <strong>text |
| 80 | </strong></dt><dd> |
| 81 | Specifies the text to display in the scrolled field. The default is <strong>''</strong>.</p> |
| 82 | |
| 83 | |
| 84 | </dd></dl> |
| 85 | </dd> |
| 86 | <dt> <h3>Components</h3></dt><dd> |
| 87 | Components created by this megawidget and its base |
| 88 | classes are described below.<p></p> |
| 89 | <a name=component.entry></a> |
| 90 | <dl><dt> <strong>entry |
| 91 | </strong></dt><dd> |
| 92 | This is used to display the text and allows the user to scroll and |
| 93 | select the text. The <strong>state</strong> of this component is set to |
| 94 | <strong>'readonly'</strong> (or <strong>'disabled'</strong> in earlier versions of Tcl/Tk which do |
| 95 | not support <strong>'readonly'</strong>), so that the user is unable to modify the text. By default, this component is a Tkinter.Entry.</p> |
| 96 | |
| 97 | |
| 98 | </dd></dl> |
| 99 | <a name=component.hull></a> |
| 100 | <dl><dt> <strong>hull |
| 101 | </strong></dt><dd> |
| 102 | This acts as the body for the entire megawidget. Other components |
| 103 | are created as children of the hull to further specialise this |
| 104 | class. By default, this component is a Tkinter.Frame.</p> |
| 105 | |
| 106 | |
| 107 | </dd></dl> |
| 108 | <a name=component.label></a> |
| 109 | <dl><dt> <strong>label |
| 110 | </strong></dt><dd> |
| 111 | If the <strong>labelpos</strong> option is not <strong>None</strong>, this component is |
| 112 | created as a text label for the megawidget. See the |
| 113 | <strong>labelpos</strong> option for details. Note that to set, for example, |
| 114 | the <strong>text</strong> option of the label, you need to use the <strong>label_text</strong> |
| 115 | component option. By default, this component is a Tkinter.Label.</p> |
| 116 | |
| 117 | |
| 118 | </dd></dl> |
| 119 | </dd> |
| 120 | <a name=methods></a> |
| 121 | <dt> <h3>Methods</h3></dt><dd> |
| 122 | This megawidget has no methods of its own. |
| 123 | For a description of its inherited methods, see the |
| 124 | manual for its base class |
| 125 | <strong><a href="MegaWidget.html#methods">Pmw.MegaWidget</a></strong>. |
| 126 | In addition, methods from the |
| 127 | <strong>Tkinter.Entry</strong> class |
| 128 | are forwarded by this megawidget to the |
| 129 | <strong>entry</strong> component. |
| 130 | <p></p> |
| 131 | </dd> |
| 132 | <dt> <h3>Example</h3></dt><dd> |
| 133 | The image at the top of this manual is a snapshot |
| 134 | of the window (or part of the window) produced |
| 135 | by the following code.<p></p> |
| 136 | <pre> |
| 137 | class Demo: |
| 138 | def __init__(self, parent): |
| 139 | # Create and pack the ScrolledField. |
| 140 | self._field = Pmw.ScrolledField(parent, entry_width = 30, |
| 141 | entry_relief='groove', labelpos = 'n', |
| 142 | label_text = 'Scroll the field using the\nmiddle mouse button') |
| 143 | self._field.pack(fill = 'x', expand = 1, padx = 10, pady = 10) |
| 144 | |
| 145 | # Create and pack a button to change the ScrolledField. |
| 146 | self._button = Tkinter.Button(parent, text = 'Change field', |
| 147 | command = self.execute) |
| 148 | self._button.pack(padx = 10, pady = 10) |
| 149 | |
| 150 | self._index = 0 |
| 151 | self.execute() |
| 152 | |
| 153 | def execute(self): |
| 154 | self._field.configure(text = lines[self._index % len(lines)]) |
| 155 | self._index = self._index + 1 |
| 156 | |
| 157 | lines = ( |
| 158 | 'Alice was beginning to get very tired of sitting by her sister', |
| 159 | 'on the bank, and of having nothing to do: once or twice she had', |
| 160 | 'peeped into the book her sister was reading, but it had no', |
| 161 | 'pictures or conversations in it, "and what is the use of a book,"', |
| 162 | 'thought Alice "without pictures or conversation?"', |
| 163 | 'Alice\'s Adventures in Wonderland', |
| 164 | 'Lewis Carroll', |
| 165 | ) |
| 166 | |
| 167 | </pre> |
| 168 | </dd> |
| 169 | </dl> |
| 170 | |
| 171 | <center><P ALIGN="CENTER"> |
| 172 | <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5> |
| 173 | </p></center> |
| 174 | |
| 175 | |
| 176 | <font size=-1> |
| 177 | <center><P ALIGN="CENTER"> |
| 178 | Pmw 1.2 - |
| 179 | 5 Aug 2003 |
| 180 | - <a href="index.html">Home</a> |
| 181 | <br>Manual page last reviewed: 23 August 1998 |
| 182 | </p></center> |
| 183 | </font> |
| 184 | |
| 185 | </body> |
| 186 | </html> |
| 187 | |