tymber — GUI toolkit¶
Binaries: https://github.com/thomasfuhringer/tymber/bin
Source code: https://github.com/thomasfuhringer/tymber
Hello World¶
This simple program displays a window with a button that has a callback to close it.
import tymber as ty
def button__on_click(button):
button.parent.close()
app = ty.Application(ty.Window("Tymber", width=360, height=280))
label = ty.Label(app.window, "label", 20, 60, -20, 22, "Hello World!")
label.align_h = ty.Align.center
button = ty.Button(app.window, "button", -70, -40, 50, 20, "Close")
button.on_click = button__on_click
app.run()
Module Functions and Constants¶
-
tymber.message(message[, title])¶ Shows a message box displaying the string message, using the string title as window title.
-
tymber.set_setting(key1, key2, subkey, value)¶ Stores the byte object value as a configuration setting.
-
tymber.get_setting(key1, key2, subkey)¶ Retrieves the object stored using set_setting.
-
tymber.play_sound([filename])¶ Plays the .wav file in filename or the default chime.
-
tymber.joystick_status([stick_no])¶ Gets the status of joystick stick_no and returns a tuple (xpos, ypos, zpos, rpos, upos, button1, button2, button3, button4).
-
tymber.app¶ Singleton instance of Application class.
-
tymber.default_coordinate¶ Value to assign to
toporleftcoordinate ofWindowto show it using MS Windows’ default positioning.
-
tymber.version_info¶ The version number as a tuple of integers.
-
tymber.copyright¶ Copyright notice.
Enumerations¶
-
tymber.Align¶ Enumfor alignment of text in widgets, possible values: left, right, center, top, bottom, block
-
tymber.StockIcon¶ Enumicons included: file_open, file_new, save, ok, no, window, find
-
tymber.Key¶ Enumkeyboad keys: enter, tab, escape, delete, space, left, right, up, down, f1
Classes¶
Application¶
Window¶
-
class
tymber.Window([caption, left, top, width, height, visible])¶ -
top¶ Distance from top edge of desktop, if negative from bottom
-
width¶ Width or, if zero or negative, distance of right edge from right edge of desktop
-
height¶ - Height or, if zero or negative, distance of bottom edge from bottom edge of desktop
-
visible¶ By default
True.
-
children¶ A
Dictof Widgets contained.
-
position¶ A tuple with the (x, y) position of the widget on the screen.
-
size¶ A tuple with the (width, height) of the widget on the screen.
-
before_close¶ Callback. If it returns False the window will stay open.
-
on_close¶ Callback when closing.
-
focus¶ Widget holding the focus.
-
on_focus_change¶ Callback when focus was moved to new widget.
-
-
min_width¶ Minimum width
-
min_height¶ - Minimum height
-
run()¶ Show as dialog (modal).
-
close()¶ Hide the window and, if run modal, return from run. (Does not destroy it).
-
set_timer(callback[, interval, wait])¶ Sets a timer to fire after wait seconds every interval seconds.
-
del_timer()¶ Deletes the timer.
-
key_pressed(key)¶ Returns True if key is pressed.
-
-
Widget¶
-
class
tymber.Widget(parent, key[, left, top, width, height, caption, data_type, format, visible])¶ Widget is the base class from which all data aware widgets that can be displayed on a
Windoware derived.The construtor parameters are also available as attributes:
-
key¶ The string that is used to reference the widget in the parent’s children dict.
-
left¶ Distance from left edge of parent, if negative from right.
-
top¶ Distance from top edge of parent, if negative from bottom
-
width¶ Width or, if zero or negative, distance of right edge from right edge of parent
-
height¶ Height or, if zero or negative, distance of bottom edge from bottom edge of parent
-
data_type¶ The Python data type the widget can hold.
-
format¶ The Python format string in the
str.format()syntax that is used to render the data.
-
visible¶ By default
True
-
enabled¶ If
Falsewidget is grayed.
-
Label¶
Entry¶
-
class
tymber.Entry¶ Single line data entry. After leaving the widget, the entered text is parsed and converted into a value of
data_typeand available asdata.Attributes and methods
-
data¶ The value the Entry holds.
-
read_only¶ Editing not possible.
-
password¶ Characters are not legible.
-
input_data¶ The currently entered input converted to the Entry’s data type, but not yet committed to
data, for validation purposes.
-
input_string¶ The currently entered input string, but not yet committed to
data, for validation purposes.
-
align_horiz¶ Horizontal alignment. By default tymber.Align.left for data type str and tymber.Align.right for numeric data types
-
on_key¶ Callback when key is pressed
-
on_leave¶ Callback, return True if ready for focus to move on.
-
multiline¶ Characters are not legible.
-
ComboBox¶
Button¶
TabPage¶
Box¶
Splitter¶
Canvas¶
-
class
tymber.Canvas¶ A widget for basic drawing. It sports two buffers (index 0 and 1). By default buffer 0 is active and live.
-
set_pen([red, green, blue, alpha, width])¶ Color and thickness to be used for drawing and filling. Default: (0, 0, 0, 255, 1)
-
point(x, y)¶ Draws a point at the given coordinates.
-
line(x1, y1, x2, y2)¶ Draws a line from x1, y1 to x2, y2
-
rectangle(x, y, width, height[, fill])¶ Draws a rectangle.
-
polygon(points[, fill])¶ Draws a polygon from list of [x,y] coordinates in points.
-
ellipse(x, y, width, height[, fill])¶ Draws an ellipse.
-
text(x, y, x2, y2, string)¶ Writes string into the given rectangle.
-
image(x, y, data[, width, height])¶ Puts an image at the given position. If width or height is given, the image will be scaled retaining aspect ratio. data is to be either a ‘str’ holding file name or ‘bytes’ holding the data in memory.
-
resize_buffer([index, width, height, x, y])¶ Changes the size of the buffer. If index is not given active_buffer will be used. If width and height are not given the canvas’ are applied. If given the current content will be moved to x and y.
-
copy_buffer(index1, index1)¶ Copy the content of buffer 1 to 2.
-
clear_buffer([index])¶ Clears the buffer. If index is not given, the active_buffer will be used.
-
renew_buffer([index, width, height])¶ Creates a new buffer. If index is not given active_buffer will be used. If width and height are not given the canvas’ are applied.
-
refresh()¶ Triggers the paint process.
-
on_resize¶ Callback when the widget gets resized. Parameters: widget
-
active_buffer¶ Index of the buffer to be used for drawing operations. Default: 0
-
live_buffer¶ Index of the buffer to be displayed when the OS refreshes the screen. Default: 0
-
on_mouse_move¶ Callback when the mouse is moved. Parameters: widget, x, y
-
on_mouse_wheel¶ Callback when the left mouse wheel was turned. Parameters: widget, delta, x, y
Callback when the left mouse button is pressed. Parameters: widget, x, y
Callback when the left mouse button is released. Parameters: widget, x, y
-
anti_alias¶ Drawing operations should be done in a callback which is assigned here.
-
ToolBar¶
Icon¶
StatusBar¶
ImageView¶
-
class
tymber.ImageView¶ Displays a bitmap.
datamust be a ‘str’ of the file name or ‘bytes’ holding the data. Ifstretchis True it will be stretched keeping aspect ratio.
ListView¶
-
class
tymber.ListView¶ Displays a list of data in a table.
-
data¶ List that holds the data
-
columns¶ List of Lists that define the columns. Format: [caption, data_type, width, data_format] if width is None the the column is hidden.
-
row¶ Index of row currently selected, or None.
-
on_selection_changed¶ Callback when a row was selected. Parameters: widget
-
on_double_click¶ Callback when a row was double clicked. Parameters: widget, index
-
add_row(data[, index])¶ Adds a row with data after index . If index is not given
rowwill be used. In caserowis None the new row will be appended.
-
delete_row(index)¶ Removes the row at index.
-