Window Objects Module¶
Summary¶
Functions
createRoundedButton ([w, h, text, action, ...]) |
Function that creates a rounded button. |
createPanelButton (panel, x, y, w, h, text, tag) |
Creates a button to add to a panel. |
createPanelHeader (panel, x, y, text[, ...]) |
Creates a header to add to a panel. |
createButton (width, height, action, text[, ...]) |
Creates a ButtonP object. |
createHeader (text[, textColor, fS]) |
Creates a general text objects with settings appropriate for a header. |
adminPanel (foo) |
Enables an admin panel? |
Layouts
Layout () |
Base class meant to help organize buttons and other interface objects. |
HorizontalLayout () |
Layout meant to organize objects horizontally. |
VerticalLayout () |
Layout meant to organize objects vertically. |
ScrolledLayout ([width, height]) |
Layout that allows scrolling in different directions. |
Window Items
ButtonBase () |
A base object for all buttons. |
ButtonP (point1, point2, rad[, xMargin, yMargin]) |
Old style button that directly extends the shape of the button itself. |
RoundedButton (point1, point2, rad) |
Creates a rounded, clickable button. |
DragAndDropButton (p1, p2) |
Class for drag-and-drop buttons. |
TextP (point1, text) |
Text object with different default values. |
EntryBox (p1, p2) |
Entry box that allows the user to insert text. |
Panel (point1, point2) |
Panel object to draw buttons and other items to. |
Windows
WindowBase ([name, width, height, ...]) |
|
WindowLRC (title, width, height[, tag, ...]) |
|
MenuWindow ([parent, name, header, ...]) |
Other
statObject (name, score, elapseTime, win, ...) |
|
GameData (ver) |
|
BackgroundWrapper (window) |
|
TimeoutEvent (iterations, action) |
Functions¶
-
createRoundedButton
(w=250, h=40, text=' ', action=None, desc=' ', window=None, fontSize=24)[source]¶ Function that creates a rounded button.
-
createPanelButton
(panel, x, y, w, h, text, tag, avatar=None, buttonColor=color, textColor=color, fS=18)[source]¶ Creates a button to add to a panel.
-
createPanelHeader
(panel, x, y, text, textColor=color, fS=30)[source]¶ Creates a header to add to a panel.
-
createButton
(width, height, action, text, fillColor=color, textColor=color, fontSize=18, desc='', avatar=None, radius=5)[source]¶ Creates a ButtonP object.
Should probably be deprecated.
Layouts¶
-
class
Layout
[source]¶ Base class meant to help organize buttons and other interface objects.
-
add
(shape, clickable=True)[source]¶ Adds a shape to this layout.
Parameters: - shape (
Shape
) – The shape to add to the layout. - clickable (bool) – If true, this shape can be returned when picked.
- shape (
-
draw
(window)[source]¶ Draws the layout to a window.
Parameters: window ( Window
) – The window to draw to.
-
hit
(x, y)[source]¶ Indicates whether the queried position hits this layout.
Because the basic layout has no bounding box, this function will always return true.
Parameters: - x (float) – The x coordinate of the point to be queried.
- y (float) – The y coordinate of the point to be queried.
Returns: Always returns True.
-
moveTo
(x, y)[source]¶ Moves this frame to the indicated coordinates.
Parameters: - x (float) – The new x coordinate of the layout.
- y (float) – The new y coordinate of the layout.
-
pick
(x, y)[source]¶ Returns the clickable shape at a queried position.
Pick is generally used for on click events, adn will thus ignore all shapes that are not clickable.
Parameters: - x (float) – The x coordinate of the point to be queried.
- y (float) – The y coordinate of the point to be queried.
Returns: The clickable shape at the queried location, or None if there was no clickable shape a the queried location.
-
reset
()[source]¶ Resets the width an height of the layout object.
The basic layout object does not have any other attributes, but objects that extend the basic layout object may have a more involved reset.
-
resetSizeAndPosition
()[source]¶ Resets this size and position of this layout.
In contrast to reset, also resets all clickable shapes, as well as its parents.
-
setWindow
(window)[source]¶ Sets the window for this layout, and all child layouts.
The main purpose of this function is to allow you to add any number of layouts to this layout before drawing it to the window, and still ensure that all child layouts have a valid reference to the main window.
Parameters: window ( Window
) – The window to set for this layout.
-
-
class
HorizontalLayout
[source]¶ Layout meant to organize objects horizontally.
-
hit
(x, y)[source]¶ Indicates whether this layout was hit.
The HorizontalLayout has a width, height and origin, and this function simply checks whether the indicated coordinate lies within this bounding bos.
Parameters: - x (float) – The x coordinate of the point to be queried.
- y (float) – The y coordinate of the point to be queried.
Returns: True if the coordinate (x,y) lies within the bounding-box of this layout, False otherwise.
-
-
class
VerticalLayout
[source]¶ Layout meant to organize objects vertically.
-
hit
(x, y)[source]¶ Indicates whether this layout was hit.
The VerticalLayout has a width, height and origin, and this function simply checks whether the indicated coordinate lies within this bounding bos.
Parameters: - x (float) – The x coordinate of the point to be queried.
- y (float) – The y coordinate of the point to be queried.
Returns: True if the coordinate (x,y) lies within the bounding-box of this layout, False otherwise.
-
-
class
ScrolledLayout
(width=500, height=500)[source]¶ Layout that allows scrolling in different directions.
-
__init__
(width=500, height=500)[source]¶ Constructs a ScrolledLayout object.
Parameters: - width (float) – The width of the scrolled layout.
- height (float) – The height of the scrolled layout.
-
add
(shape)[source]¶ Adds a shape to this layout.
Overwrites the basic
Layout
because objects need to be added to the innerFrame, rather than to the outer frame.Parameters: shape ( Shape
) – The shape to add to the layout.
-
hit
(x, y)[source]¶ Indicates whether this layout was hit.
The ScrolledLayout is drawn on a
Rectangle
, and this function simply checks whether that rectangle was hit.Parameters: - x (float) – The x coordinate of the point to be queried.
- y (float) – The y coordinate of the point to be queried.
Returns: True if the coordinate (x,y) lies within the bounding-box of this layout, False otherwise.
-
moveTo
(x, y)[source]¶ Moves this frame to the indicated coordinates.
Overwrite of the basic
Layout
class because the scrolled layout is drawn on aRectangle
, rather than aframe
, yet we want its behavior to match that of a frame.Parameters: - x (float) – The new x coordinate of the layout.
- y (float) – The new y coordinate of the layout.
-
Window Items¶
-
class
ButtonBase
[source]¶ A base object for all buttons.
Designed to be extended so the button will actually have some body.
-
applyColor
()[source]¶ Applies a color to this button, depending on whether it is enabled or highlighted.
-
copyAttributes
(other)[source]¶ Copies all attributes of the other button to this button.
Parameters: other ( ButtonBase
) – Button to copy attributes from.
-
mouseDown
(win, event)[source]¶ Callback for if this button is clicked on.
Parameters: - win (
Window
) – Reference to the Calico window object. - event (
Event
) – The event triggering this callback.
- win (
-
mouseDownAlt
(win, event)[source]¶ Callback for mouse down events.
In contrast to
mouseDown()
, this function first checks if this button was actually clicked on, meaning it can be used without aLayout
.Parameters: - win (
Window
) – Reference to the Calico window object. - event (
Event
) – The event triggering this callback.
- win (
-
onMouseEnter
(win, event)[source]¶ Callback for mouse enter which highlights this button.
Parameters: - win (
Window
) – Reference to the Calico window object. - event (
Event
) – The event triggering this callback.
- win (
-
onMouseLeave
(win, event)[source]¶ Callback for the mouse leave which removes the highlight.
Parameters: - win (
Window
) – Reference to the Calico window object. - event (
Event
) – The event triggering this callback.
- win (
-
-
class
ButtonP
(point1, point2, rad, xMargin=5, yMargin=5)[source]¶ Old style button that directly extends the shape of the button itself.
Should probably be deprecated.
-
class
RoundedButton
(point1, point2, rad)[source]¶ Creates a rounded, clickable button.
-
__init__
(point1, point2, rad)[source]¶ Constructs a rounded button.
Parameters: - point1 (tuple) – The top left corner of the button.
- point2 (tuple) – The bottom right corner of the button.
- ra (float) – The radius of the rounded corners of the button.
-
copyAttributes
(other)[source]¶ Copies all attributes of the other button to this button.
Parameters: other ( RoundedButton
) – Button to copy attributes from.
-
setup
(text, desc=' ', fontSize=24)[source]¶ Performs a setup on the RoundedButton.
Because the rounded button extend a Calico shape, we can not change the constructor. As such the setup function is effectively a secondary constructor.
Parameters: - text (str) – The text to be shown on the button.
- desc (str) – The description that should be shown on mouse-over.
- fonstSize (int) – The font size of the text on the button.
-
-
class
DragAndDropButton
(p1, p2)[source]¶ Class for drag-and-drop buttons.
Probably a bit too specialized to the drag-and-drop control activity.
-
__init__
(p1, p2)[source]¶ Constructs a drag-and-drop button.
Parameters: - point1 (tuple) – The top left corner of the button.
- point2 (tuple) – The bottom right corner of the button.
-
copyAttributes
(other)[source]¶ Copies all attributes of the other button to this button.
Parameters: other ( RoundedButton
) – Button to copy attributes from.
-
getEntryValues
()[source]¶ Retrieves the EntryBox values of this button.
Returns: List containing the values of each EntryBox.
-
hitEntry
(testX, testY)[source]¶ Tests whether the provided coordinates hits one of the entry boxes.
Parameters: - textX (float) – The x coordinate.
- textY (float) – The y coordinate.
Returns: True if an EntryBox is at the indicated position, False otherwise.
-
setup
(dictionaryData, fontSize=24)[source]¶ Performs a setup on the DragAndDropButton.
Because the drag-and-drop button extends a Calico shape, we can not change the constructor. As such the setup function is effectively a secondary constructor.
Parameters: - dictionaryData (dict) – Dictionary with data.
- fonstSize (int) – The font size of the text on the button.
-
-
class
TextP
(point1, text)[source]¶ Text object with different default values.
We should probably use the makeText function instead, because TextP does not seem to have any attributes that would require a separate class.
-
class
EntryBox
(p1, p2)[source]¶ Entry box that allows the user to insert text.
-
__init__
(p1, p2)[source]¶ Constructs an EntryBox.
Parameters: - p1 (tuple) – Top left corner of the box.
- p2 (tuple) – Bottom right corner of the box.
-
keyPress
(win, event)[source]¶ Keypress callback event that be directly registered to a window to make this EntryBox functional.
Parameters: - win (
Window
) – Reference to the Calico window object. - event (
Event
) – The event triggering this callback.
- win (
-
mouseDown
(win, event)[source]¶ Mousedown callback event that enables the focus of this entry-box.
Parameters: - win (
Window
) – Reference to the Calico window object. - event (
Event
) – The event triggering this callback.
- win (
-
mouseUp
(win, event)[source]¶ Mouseup callback event for this entry-box.
Currently not used.
Parameters: - win (
Window
) – Reference to the Calico window object. - event (
Event
) – The event triggering this callback.
- win (
-
setEditable
(editable=True)[source]¶ Sets whether this EntryBox is currently editable.
Parameters: focus (bool) – Whether to set (True), or unset (False) the editable.
-
setFocus
(focus=True)[source]¶ Sets the focus of this EntryBox.
Parameters: focus (bool) – Whether to set (True), or unset (False) the focus.
-
setText
(text)[source]¶ Sets the text of this entry box, which doubles as its current value.
Parameters: text (str) – The text to be set to this EntryBox.
-
setup
(win, editable=True, visible=True)[source]¶ Performs the setup of this EntryBox.
Because the EntryBox extends a Calico shape, the constructor can not be normally changed. Thus, this setup function effectively functions as a secondary constructor.
Parameters: - win (
Window
) – Reference to the Calico object this EntryBox is drawn to. - editable (bool) – Indicates whether this EntryBox should startout editable.
- visible (bool) – Indicates whether this EntryBox should startout visible.
- win (
-
Windows¶
-
class
MenuWindow
(parent=None, name='', header='', reuseWindow=False, options=True)[source]¶ -
-
afterShow
()[source]¶ Called right after the window is revealed.
This is a good place to start animations that should be shown once the window is opened.
-
beforeShow
()[source]¶ Called right before the window is revealed.
This is a good place to painting of the window and other updates that you don’t want the user to see.
-
burnEvidence
()[source]¶ Method for clearing the output and history. Useful when someone enters a password and you want to clear you’re tracks.
-