Miro’s widget frontend is split between portable code and platform-specific code.
The portable code is located in portable/frontends/widgets/ and is in the miro.frontends.widgets package space.
See the chapter on platform-specific widget frontend modules for platform-specific details.
FIXME - need explanation here and probably a drawing of the architecture
``miro.frontends.widgets.application – The application module holds Application and the portable code to handle the high level running of the Miro application.
It also holds:
This class holds the portable application code. Each platform extends this class with a platform-specific version.
Ask the user to enter a url in a TextEntry box.
If the URL the user enters is invalid, she will be asked to re-enter it again. This process repeats until the user enters a valid URL, or clicks Cancel.
The initial text for the TextEntry will be the clipboard contents (if it is a valid URL).
Override this to provide platform-specific Main Window dimensions.
Must return a Rect.
Track channel/item updates from the backend.
To track item updates, use add_item_callback(). To track tab updates, connect to one of the signals below.
Signals:
Tracks the list of callbacks for InfoUpdater.
Adds the callback to the list for type_ id_.
| Parameters: |
|
|---|
Get the list of callbacks for type_, id_.
| Parameters: |
|
|---|
Removes the callback from the list for type_ id_.
| Parameters: |
|
|---|
Handles frontend messages.
There’s a method to handle each frontend message type. See miro.messages (portable/messages.py) and miro.messagehandler (portable/messagehandler.py) for more details.
miro.frontends.widgets.cellpack – Code to layout CustomTableCells.
We use the hbox/vbox model to lay things out with a couple changes. The main difference here is that layouts are one-shot. We don’t keep state around inside the cell renderers, so we just set up the objects at the start, then use them to calculate info.
Box is the base class for VBox and HBox. Box objects lay out children linearly either left to right or top to bottom.
Add a new child to the box. The child will be placed after all the children packed before with pack_start.
| Parameters: |
|
|---|
Add a new child to the end box. The child will be placed before all the children packed before with pack_end.
| Parameters: |
|
|---|
Helper object used to calculate margins.
Base class packing objects. Packer objects work similarly to widgets, but they only used in custom cell renderers so there’s a couple differences. The main difference is that cell renderers don’t keep state around. Therefore Packers just get set up, used, then discarded. Also Packers can’t receive events directly, so they have a different system to figure out where mouse clicks happened (the Hotspot class).
Find the hotspot at (x, y). width and height are the size of the cell this Packer is rendering.
If a hotspot is found, return the tuple (name, x, y, width, height) where name is the name of the hotspot, x, y is the position relative to the top-left of the hotspot area and width, height are the dimensions of the hotspot.
If no Hotspot is found return None.
Get the minimum size required to hold the Packer at this point
Call this method if you are going to change the packer after the call, for example if you have more children to pack into a box. get_size() saves caches it’s result which is can mess things up.
miro.frontends.widgets.dialogs – Dialog boxes for the Widget frontend.
The difference between this module and rundialog.py is that rundialog handles dialog boxes that are coming from the backend code. This model handles dialogs that we create from the frontend
One big difference is that we don’t have to be as general about dialogs, so they can present a somewhat nicer API. One important difference is that all of the dialogs run modally.
Ask the user to enter a string in a TextEntry box.
description - textual description with newlines initial_text - None, string or callable to pre-populate the entry box
Returns the value entered, or None if the user clicked cancel
Sets a Dialog object to be transient for the main window if possible.
If the main window has not been created yet, this is a no-op.
miro.frontends.widgets.imagepool – Get Image objects for image filenames.
imagepool handles creating Image and ImageSurface objects for image filenames. It remembers images that have been created, and doesn’t create duplicate Image/ImageSurface objects for a single path.
Lazily loaded ImageSurface.
LazySurface objects only create ImageSurfaces as needed. If multiple LazySurface objects are created for the same path, then they will share the underlying ImageSurface object.
Returns an Image for path.
| Parameters: |
|
|---|
Returns an ImageSurface for path.
| Parameters: |
|
|---|
Takes an image which has a width and a height and a size tuple that specifies the space available and returns the new width and height that allows the image to fit into the sized space at the correct height/width ratio.
| Parameters: |
|
|---|
miro.frontends.widgets.util – Utility functions.
Create a path using a rounded rectangle. xradius and yradius specifies how far away from the normal rectangle corner the rounded edge will start.
yradius defaults to xradius.
miro.frontends.widgets.widgetconst – Constants for the widgets frontend.
miro.frontends.widgets.widgetutil – Utility functions.
Creates a widget that can be hidden and shown.
Example:
>>> lab = Label(_("Error!"))
>>> hidden_lab = HideableWidget(lab)
Then when we want to hide it, we do:
>>> hidden_lab.hide()
and when we want to show it again, we do:
>>> hidden_lab.show()
Takes a left, center and right image and draws them to an arbitrary width. If the width is greater than the combined width of the 3 images, then the center image will be tiled to compensate.
Example:
>>> timelinebar = ThreeImageSurface("timelinebar")
This creates a ThreeImageSurface using the images images/timelinebar_left.png, images/timelinebar_center.png, and images/timelinebar_right.png.
Example:
>>> timelinebar = ThreeImageSurface()
>>> img_left = make_surface("timelinebar_left")
>>> img_center = make_surface("timelinebar_center")
>>> img_right = make_surface("timelinebar_right")
>>> timelinebar.set_images(img_left, img_center, img_right)
This does the same thing, but allows you to explicitly set which images get used.
Draw an icon with the corners rounded.
x, y, width, height define where the box is.
inset creates a margin between where the images is drawn and (x, y, width, height)
Specifies path of a rectangle with rounded corners.
This specifies the rectangle in a counter-clockwise fashion.