GraphicsWindow Class Reference

« | ReferenceGuide | GraphicsCanvas »

This class defines a basic top level window that can be opened on the desktop and used to produce simple graphical drawings. It contains a canvas on which geometric shapes can be drawn and manipulated.

Public Methods

GraphicsWindow()
Creates a new graphics window with a canvas that has a default size.
GraphicsWindow(width, height)
Creates a new graphics window with a canvas of the given size.
alertDialog(message)
Displays a note or information type message in a basic dialog box.
alertDialog(message, msgType)
Displays one of several types of messages within a basic dialog box.
alertDialog(message, msgType, title)
Displays one of several types of messages within a basic dialog box.
canvas()
Returns a reference to the canvas contained within the window.
clearEvents(event1, event2, ...)
Clears or deactivates one or more window events that were set using the enableEvents() method.
clearTimer()
Clears the timer before it expires.
close()
Closes and destroys the window.
colorDialog()
colorDialog(initColor)
configStatus(options)
Modifies one or more configuration options of the status bar.
confirmDialog(title, message)
<figure img=“yesnodlg.
confirmDialog(title, message, cancel)
enableEvents(event1, event2, ...)
Enables one or more action events on the window.
getKey()
Gets and returns the next key pressed by the user.
getMouse()
Gets and returns the position at which the next mouse button is clicked.
hide()
Hides or iconifies the top level window.
hideMenu()
Hides the menu bar and removes it from the window.
hideStatus()
Hides the status bar by removing it from the bottom of the window.
inputDialog(title, prompt)
inputDialog(title, prompt, initValue)
isValid()
Returns a Boolean indicating whether the window associated with the object exist and is valid.
menu()
Returns a reference to the menu bar associated with the window.
openfileDialog()
openfileDialog(fileTypes)
openfileDialog(fileTypes, initDir)
pause(msTime)
Pauses the program for a given amount of time.
quit()
Terminates the GUI application.
savefileDialog()
savefileDialog(fileTypes)
savefileDialog(fileTypes, initDir)
setEventHander(handler)
Sets the event handler to a user-defined function or object.
setStatus(text)
Sets the text message displayed in the message bar.
setStatus()
Clears the text message and sets it to the empty string.
setTimer(msTime)
Sets a timer that triggers an alarm after it expires.
setTitle(title)
Sets the title of the window.
show()
Shows or deiconifies a previously hidden top level window.
showMenu()
Displays the menu bar at the top of the window.
showStatus()
Displays a status bar at the bottom of the window that can be used to display text messages.
wait()
Starts the event loop that processes various window events.

Detailed Description

GraphicsWindow()
Creates a new graphics window with a canvas that has a default size. The canvas contained in the window is initially empty with a white background. It is created with a default size of 400 x 400.
GraphicsWindow(width, height)
Creates a new graphics window with a canvas of the given size. The canvas contained in the window is initially empty with a white background. The size of the canvas will be set to the size specified by width and height.
Parameters:
width
The horizontal size of the canvas in pixels.
height
The vertical size of the canvas in pixels.
canvas()
Returns a reference to the canvas contained within the window. The canvas can be used to draw and manipulate geometric shapes and text.
Returns:
A reference to the GraphicsCanvas contained in the window.
wait()
Starts the event loop that processes various window events. This causes the sequential execution of the program to stop and wait for the user to click the close button on the main window or to call the quit() method on any window. This method should only be called on the main window.
setTitle(title)
Sets the title of the window. The title is displayed in the title bar of the top-level window. By default, the window has no title.
Parameters:
title
A text string to which the title of the window is set. To remove the title, pass an empty string to the method.
getMouse()
v2.0
Gets and returns the position at which the next mouse button is clicked. The program pauses and waits until the user clicks a mouse button within the canvas area. Other events continue to be processed using the regular event handlers.
Returns:
A 2-tuple (x, y) that contains the canvas coordinates of the mouse pointer when the mouse button was clicked.
getKey()
v2.0
Gets and returns the next key pressed by the user. The program pauses and waits for the user to press any key within the window. Other events continue to be processed using the regular event handlers.
Returns:
A string indicating which key was pressed. See the list of KeySymbols for a complete list of possible return values.
pause(msTime)
v2.0
Pauses the program for a given amount of time. This method only pauses the sequential flow of execution for a specified amount of time. The events (window, mouse, key, etc) continue to be processed in the background.
Parameters:
msTime
The amount of time to pause given in milliseconds.
isValid()
Returns a Boolean indicating whether the window associated with the object exist and is valid. The object of an invalid window, which normally results from being closed, can not be used.
Returns:
True if the window is valid or False otherwise.
quit()
Terminates the GUI application. The program continues execution immediately after the call to the wait() method, but none of the Ez Graphics tools can be used.
close()
Closes and destroys the window. The window object still exist, but the window is not valid and can not be used. If the main window is closed, the event loop will be terminated.
hide()
Hides or iconifies the top level window. The window still exists and can be displayed again using the show() method.
See Also:
show()
show()
Shows or deiconifies a previously hidden top level window.
See Also:
hide()
menu()
v2.0
Returns a reference to the menu bar associated with the window. A menu bar will be displayed after this method is called the first time and the menu has been configured.
Returns:
A reference to a GraphicsMenu object.
showMenu()
v2.0
Displays the menu bar at the top of the window. The menu() method is used to access the menu for configuration.
See Also:
hideMenu()
hideMenu()
v2.0
Hides the menu bar and removes it from the window. The menu still exists and can be displayed again and/or configured further.
See Also:
hideMenu()
showStatus()
v2.0
Displays a status bar at the bottom of the window that can be used to display text messages.
See Also:
hideStatus(), setStatus()
hideStatus()
v2.0
Hides the status bar by removing it from the bottom of the window. Hiding the bar does not destroy it or the text contained within the bar.
See Also:
showStatus(), setStatus()
setStatus(text)
v2.0
Sets the text message displayed in the message bar. By default, the message is aligned to the left side of the bar.
Parameters:
text
The text string to be displayed in the status bar.
See Also:
showStatus()
setStatus()
v2.0
Clears the text message and sets it to the empty string.
See Also:
showStatus()
configStatus(options)
v2.0
Modifies one or more configuration options of the status bar. The options and settings are specified as named parameters.
Parameters:
options
One or more named parameters that specify the individual option to be configured and its corresponding value. The options that can be configured include the following:
enableEvents(event1, event2, ...)
v2.0
Enables one or more action events on the window.
Parameters:
event1, event2, ...
The window event(s) that are to be detected in order to take some action via an event handler or callback function. The events are specified as one or more strings from among the following :
ValueDescription
"KeyPress"Detects when a key is pressed.
"MouseDown"Detects when a mouse button is pressed.
"MouseUp"Detects when a mouse button is released.
"MouseMove"Detects when the mouse pointer is moved.
See Also:
clearEvents()
clearEvents(event1, event2, ...)
v2.0
Clears or deactivates one or more window events that were set using the enableEvents() method.
Parameters:
event1, event2, ...
The window event(s) that are to be cleared. The events are specified as one or more strings from among the following :
ValueDescription
"KeyPress"Detects when a key is pressed.
"MouseDown"Detects when a mouse button is pressed.
"MouseUp"Detects when a mouse button is released.
"MouseMove"Detects when the mouse pointer is moved.
See Also:
enableEvents()
setEventHander(handler)
v2.0
Sets the event handler to a user-defined function or object. By default, the callback methods of the GraphicsWindow class are called and thus must be overridden in a derived class.
Parameters:
handler
A reference to a user-defined function or an object.
setTimer(msTime)
v2.0
Sets a timer that triggers an alarm after it expires. When the alarm is triggered, an Alarm event occurs and the appropriate event handler is called.
Parameters:
time
The amount of time given in milliseconds before the alarm is triggered.
clearTimer()
v2.0
Clears the timer before it expires.
See Also:
setTimer()
alertDialog(message)
Displays a note or information type message in a basic dialog box.
Parameters:
message
The text message to be displayed in the dialog box.
alertDialog(message, msgType)
Displays one of several types of messages within a basic dialog box. There are three types of alert messages: Informational, Warning, and Error.
Parameters:
message
The text message to be displayed in the dialog box.
msgType
A string indicating the type of message to display. It can be one of the following:
ValueDescription
"info"note message
"warn"warning message
"error"error message
alertDialog(message, msgType, title)
Displays one of several types of messages within a basic dialog box. The dialog box has a user-specified title. There are three types of alert messages: Informational, Warning, and Error.
Parameters:
message
The text message to be displayed in the dialog box.
msgType
A string indicating the type of message to display. It can be one of the following:
ValueDescription
"info"note message
"warn"warning message
"error"error message
title
The title of the dialog box, which replaces the standard title.
confirmDialog(title, message)
confirmDialog(title, message, cancel)
inputDialog(title, prompt)
inputDialog(title, prompt, initValue)
colorDialog()
colorDialog(initColor)
openfileDialog()
openfileDialog(fileTypes)
openfileDialog(fileTypes, initDir)
savefileDialog()
savefileDialog(fileTypes)
savefileDialog(fileTypes, initDir)


« | ReferenceGuide | GraphicsCanvas »

Last modified: March 18, 2018, at 04:06 PM.