Package random_text :: Module generator_GUI :: Class GeneratorGUI
[hide private]
[frames] | no frames]

Class GeneratorGUI

object --+
         |
        GeneratorGUI

This class represents the user interface of the Random Text Generator program.

Instance Methods [hide private]
 
__init__(self)
Creates a new Random Text Generator GUI.
 
button_pressed(self)
Event handler method: reacts to clicks of the "Randomize!" button by generating random text based on the text file indicated by what the user has written in the input text field (either the name of a local text file or the address of a file on the net).

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

 

Creates a new Random Text Generator GUI. The constructor needs to create the following GUI components and make them visible onscreen:

  • An application window with an initial size of 800 by 600 pixels, and the title "Random Text Generator". The window contains all the other GUI components described below. This initializer registers the new GeneratorGUI object as an event listener of the application frame, enabling it to react to button presses.
  • A label "Source text:" at row 0, column 0 (Label).
  • An input text field at row 0, column 1. In this text field the user can enter the name or URL of the source text file that serves as the basis for random text generation (Entry).
  • A button labeled "Randomize!" at row 0, column 2. Clicking the button will generate random text from the text file indicated.
  • An output text area spanning row 1 columns 0 to 2. Generated random text is placed here. This text area is not editable by the user (Message).

Store each widget to an object variable. Testing requires this.

Overrides: object.__init__

button_pressed(self)

 

Event handler method: reacts to clicks of the "Randomize!" button by generating random text based on the text file indicated by what the user has written in the input text field (either the name of a local text file or the address of a file on the net). I.e., when the user clicks the button, this method makes use of the randomize method of a Generator object.

The resulting random text is placed in the output text area. It replaces any text that was previously there.

See Also: Generator