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.

createHeader(text, textColor=color, fS=30)[source]

Creates a general text objects with settings appropriate for a header.

adminPanel(foo)[source]

Enables an admin panel?

Layouts

class Layout[source]

Base class meant to help organize buttons and other interface objects.

__init__()[source]

Constructs a layout object.

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.
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.
updateSizeAndPosition(shape)[source]

Updates the size and position of the indicated shape.

Does nothing in the basic layout.

Parameters:shape – The shape to update.
class HorizontalLayout[source]

Layout meant to organize objects horizontally.

__init__()[source]

Constructs a HorizontalLayout object.

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.

reset()[source]

Resets this layout.

For the HorizontalLayout this simply means that the x position, used to position all objects, is reset to 0.

updateSizeAndPosition(shape)[source]

Updates the size and position of the indicated shape.

Positions the shape right next to the other shapes.

Parameters:shape (Shape or Layout) – The object to update.
class VerticalLayout[source]

Layout meant to organize objects vertically.

__init__()[source]

Constructs a VerticalLayout object.

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.

reset()[source]

Resets this layout.

For the VerticalLayout this simply means that the y position, used to position all objects, is reset to 0.

updateSizeAndPosition(shape)[source]

Updates the size and position of the indicated shape.

Positions the shape right below the other shapes.

Parameters:shape (Shape or Layout) – The object to update.
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 a Rectangle, rather than a frame, 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.
scrollBack()[source]

Scrolls a descrete distance backward in the horizontal direction.

scrollBackStep()[source]

Callback for scrolling in the horizontal direction.

scrollNext()[source]

Scrolls a descrete distance forward in the horizontal direction.

scrollX(distance)[source]

Scroll the indicated distance in the horizontal direction.

Parameters:distance (float) – The distance to scroll.
scrollY(distance)[source]

Scroll the indicated distance in the vertical direction.

Parameters:distance (float) – The distance to scroll.

Window Items

class ButtonBase[source]

A base object for all buttons.

Designed to be extended so the button will actually have some body.

__init__()[source]
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.
disable()[source]

Disable this button.

enable()[source]

Enable this button.

highlight()[source]

Highlight this button.

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.
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 a Layout.

Parameters:
  • win (Window) – Reference to the Calico window object.
  • event (Event) – The event triggering this callback.
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.
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.
setWindowWrapper(windowWrapper)[source]

Sets the window-wrapper of this button.

The window wrapper has a similar role as the Calico main window, but allows us to register mouse enter, and mouse leave events.

Parameters:windowWrapper (Someting) – The window-wrapper to set.
unhighlight()[source]

Return to default color after highlight.

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.

__init__(point1, point2, rad, xMargin=5, yMargin=5)[source]
init(centerText=False, text=None)[source]

Draws all elements of the button to the button.

Because this object inherets from a C# object, it can not take extra parameters to its constructor. Thus, this object now effectively has two constructors: the real constructor, and this constructor.

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.

makeEditable()[source]

Makes all EntryBoxes on this button editable.

setDefaultValue()[source]

Sets all default values.

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.

__init__(point1, text)[source]
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.

Callback that enables the cursor to blink.

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.
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.
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.
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.

Registers a callback that causes the cursor of this EntryBox to blink.

class Panel(point1, point2)[source]

Panel object to draw buttons and other items to.

Maybe conflicts with the idea of layouts.

__init__(point1, point2)[source]

Windows

class WindowBase(name='', width=800, height=800, reuseWindow=False, parent=None)[source]
__init__(name='', width=800, height=800, reuseWindow=False, parent=None)[source]
class WindowLRC(title, width, height, tag=' ', reuseWindow=False)[source]
__init__(title, width, height, tag=' ', reuseWindow=False)[source]
class MenuWindow(parent=None, name='', header='', reuseWindow=False, options=True)[source]
__init__(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.

outputPrint(message, tagNo=0)[source]

Method for printing colored text to the output.

Parameters:
  • message – String containing the message to be displayed.
  • tagNo – Integer indicating in which of the predetermined colors the text will be printed.
update()[source]

Function should update the window to reflect the current state of the window.

Should be called whenever the window needs redrawing. By default it is called on beforeShow().

Other

class statObject(name, score, elapseTime, win, winTime, lose, restart)[source]
__init__(name, score, elapseTime, win, winTime, lose, restart)[source]
class GameData(ver)[source]
__init__(ver)[source]
class BackgroundWrapper(window)[source]
__init__(window)[source]
class TimeoutEvent(iterations, action)[source]
__init__(iterations, action)[source]