| |
- __builtin__.object
-
- BarChartUserInterface
- Event
- HouseMarketUserInterface
- LifeUserInterface
- OthelloReplayUserInterface
- SnakeUserInterface
- StockMarketUserInterface
class BarChartUserInterface(__builtin__.object) |
| |
Methods defined here:
- __init__(self, bar_count)
- This class starts the BarChartUserInterface.
Constants: (none)
Parameters for the class:
- bar_count: at least 1
Optional parameters: (none)
- close(self)
- Closes the display and stops your program.
- raise_bar(self, bar_index)
- Increment the given bar_index by 1.
- set_bar_name(self, bar_index, text)
- Set a name, provided by 'text', to a given bar_index.
Note: this function's effects are visible without calling show.
- show(self)
- Show the changes made to the display (i.e. after calling raise_bar).
- show_names(self, value)
- Whether or not to show the names of the bars.
Value given must be a boolean.
Default at start is False.
- show_values(self, value)
- Whether or not to show the values of the bars.
Value given must be a boolean.
Default at start is True.
- stay_open(self)
- Force the window to remain open.
Only has effect on Mac OS to prevent the window from closing after the execution finishes.
Make sure that this is the last statement you call when including it because the code does NOT continue after this.
- wait(self, ms)
- Let your program wait for an amount of milliseconds.
This function only guarantees that it will wait at least this amount of time.
If the system, i.e., is too busy, then this time might increase.
- Python time module.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Event(__builtin__.object) |
| |
Methods defined here:
- __init__(self, name, data)
- This class holds the name and data for each event in their respective variables.
Variables:
- name
- data
Example to access with SnakeUserInterface:
ui = SnakeUserInterface(5,5) # 5 by 5 grid for testing purposes
your_variable = ui.get_event() # code will block untill an event comes
# your_variable now points to an event
print your_variable.name, your_variable.data
List of events:
- name: mouseover
data: x and y coordinates (as integers), separated by a space
generated when mouse goes over a coordinate on the window
- name: mouseexit
data: x and y coordinates (as integers), separated by a space
generated when mouse exits a coordinate on the window
- name: click
data: x and y coordinates (as integers), separated by a space
generated when the user clicks on a coordinate on the window
- name: alarm
data: refresh
generated as often per second as the user set the animation speed to; note that the data is exactly as it says: "refresh"
- name: letter
data: the letter that got pressed
generated when the user presses on a letter (A to Z; can be lowercase or uppercase depending on shift/caps lock)
- name: number
data: the number (as a string) that got pressed
generated when the user presses on a number (0 to 9)
- name: alt_number
data: the number (as a string) that got pressed
generated when the user presses on a number (0 to 9) while at the same time pressing the Alt key
- name: arrow
data: the arrow key that got pressed, given by a single letter
generated when the user presses on an arrow key, data is then one of: l, r, u, d
- name: other
data: data depends on key pressed
generated when the user pressed a different key than those described above
possible data:
- caps_lock
- num_lock
- alt
- control
- shift
more data can exist and are recorded (read: they generate events), but not documented
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class HouseMarketUserInterface(__builtin__.object) |
| |
Methods defined here:
- __init__(self)
- plot_dot(self, x, y, color, **kwargs)
- Plot the point (x,y) in the ui. With the color specified by the string 'color'.
Possible colors: 'b', 'g', 'r'
Arguments:
x: float
y: float
Advanced functionality: a list of floats may be supplied to both x and y to draw many points in one step.
- plot_line(self, *args, **kwargs)
- Plot the polynomial represented by the coefficients provided.
E.g. plot_line(2,1) would plot the function '2 + 1 * x'
plot_line(3,4,5) plots '5*x^2 + 4*x + 3'
- show(self)
- Draw the current state of the ui.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class LifeUserInterface(__builtin__.object) |
| |
Methods defined here:
- __init__(self, width, height, scale=1.0)
- This class starts the LifeUserInterface.
Constants:
- DEAD
- ALIVE
Parameters for the class:
- width: at least 1
- height: at least 1
Optional parameters:
- scale: 0.25 to 1.0
- clear(self)
- Clears the display.
Note: this does not clear the text area!
- clear_text(self)
- Clears the text area on the display.
- close(self)
- Closes the display and stops your program.
- get_event(self)
- Returns an event generated from the display.
The returned object has 2 properties:
- name: holds the group which the event belongs to.
- data: holds useful information for the user.
- place(self, x, y, color)
- Place a Life piece (defined by 'color') on the given X and Y coordinates.
- print_(self, text)
- Print text to the text area on the display.
This function does not add a trailing newline by itself.
- random(self, maximum)
- Picks a random integer ranging from 0 <= x < maximum
Minimum for maximum is 1
- set_animation_speed(self, fps)
- Set an event to repeat 'fps' times per second.
If the value is set to 0 or less, the repeating will halt.
In theory the maximum value is 1000, but this depends on activity of the system.
The generated events (available by using get_event) have these properties:
- name: 'alarm'.
- data: 'refresh'.
- show(self)
- Show the changes made to the display (i.e. after calling place or clear)
- stay_open(self)
- Force the window to remain open.
Only has effect on Mac OS to prevent the window from closing after the execution finishes.
Make sure that this is the last statement you call when including it because the code does NOT continue after this.
- wait(self, ms)
- Let your program wait for an amount of milliseconds.
This function only guarantees that it will wait at least this amount of time.
If the system, i.e., is too busy, then this time might increase.
- Python time module.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class OthelloReplayUserInterface(__builtin__.object) |
| |
Methods defined here:
- __init__(self, scale=1.0)
- This class starts the OthelloReplayUserInterface.
Constants:
- NUMBER_OF_ROWS
- NUMBER_OF_COLUMNS
- EMPTY
- WHITE
- BLACK
Parameters for the class: (none)
Optional parameters:
- scale: 0.25 to 1.0
- clear(self)
- Clears the display.
Note: this does not clear the text area!
- clear_text(self)
- Clears the text area on the display.
- close(self)
- Closes the display and stops your program.
- place(self, x, y, color)
- Place an Othello piece (defined by 'color') on the given X and Y coordinates.
- place_transparent(self, x, y, color)
- Place a semi-transparent Othello piece (defined by 'color') on the given X and Y coordinates.
- print_(self, text)
- Print text to the text area on the display.
This function does not add a trailing newline by itself.
- show(self)
- Show the changes made to the display (i.e. after calling place or clear).
- stay_open(self)
- Force the window to remain open.
Only has effect on Mac OS to prevent the window from closing after the execution finishes.
Make sure that this is the last statement you call when including it because the code does NOT continue after this.
- wait(self, ms)
- Let your program wait for an amount of milliseconds.
This function only guarantees that it will wait at least this amount of time.
If the system, i.e., is too busy, then this time might increase.
- Python time module.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class SnakeUserInterface(__builtin__.object) |
| |
Methods defined here:
- __init__(self, width, height, scale=1.0)
- This class starts the SnakeUserInterface.
Constants:
- EMPTY
- FOOD
- SNAKE
- WALL
Parameters for the class:
- width: at least 1
- height: at least 1
Optional parameters:
- scale: 0.25 to 1.0
- clear(self)
- Clears the display.
Note: this does not clear the text area!
- clear_text(self)
- Clears the text area on the display.
- close(self)
- Closes the display and stops your program.
- get_event(self)
- Returns an event generated from the display.
The returned object has 2 properties:
- name: holds the group which the event belongs to.
- data: holds useful information for the user.
- place(self, x, y, color)
- Place a Snake piece (defined by 'color') on the given X and Y coordinates.
- place_transparent(self, x, y, color)
- Place a semi-transparent Snake piece (defined by 'color') on the given X and Y coordinates.
- print_(self, text)
- Print text to the text area on the display.
This function does not add a trailing newline by itself.
- random(self, maximum)
- Picks a random integer ranging from 0 <= x < maximum
Minimum for maximum is 1
- set_animation_speed(self, fps)
- Set an event to repeat 'fps' times per second.
If the value is set to 0 or less, the repeating will halt.
In theory the maximum value is 1000, but this depends on activity of the system.
The generated events (available by using get_event) have these properties:
- name: 'alarm'.
- data: 'refresh'.
- show(self)
- Show the changes made to the display (i.e. after calling place or clear)
- stay_open(self)
- Force the window to remain open.
Only has effect on Mac OS to prevent the window from closing after the execution finishes.
Make sure that this is the last statement you call when including it because the code does NOT continue after this.
- wait(self, ms)
- Let your program wait for an amount of milliseconds.
This function only guarantees that it will wait at least this amount of time.
If the system, i.e., is too busy, then this time might increase.
- Python time module.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class StockMarketUserInterface(__builtin__.object) |
| |
Methods defined here:
- __init__(self, enable_cache=False)
- User interface for the stocks assigment.
Variables:
enable_cache: if set to True retrieved data will be cached.
- get_stock_quotes(self, symbol, start, end)
- Returns a list of dictionaries containing Yahoo historical stock quotes for variable 'symbol'.
Variables:
- symbol: (stock symbol e.g. AAPL, IBM, MSFT)
- start: start date of historical interval. Format: yyyy-mm-dd
- end: end date of historical interval. Format: yyyy-mm-dd
The Yahoo API supports a max time interval of 365 day, thus an exception is raised if
the interval between start and end > 365 days.
- plot(self, prices, color, **kwargs)
- Plots the list of prices. With the color specified by the string 'color'.
Possible colors: 'b', 'g', 'r'
Use show() to display the plotted data.
Variables:
prices: list of floats with prices to be plotted.
**kwargs: (optional) additional kwargs.
- show(self)
- Draw the current state of the ui.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |