maliang.core.virtual¶
字数 1209 个 代码 268 行 阅读时间 7 分钟 访问量
All virtual classes.
The virtual.Widget
consists of five parts, which are Shape
, Text
, Image
, Style
and Feature
. In addition, they can be nested within each other.
Where Feature
is the function of widgets, Style
control the color of the widget, and each widget can be bound to up to one Feature
and one Style
, but in terms of appearance, there is no limit to the number of Shape
, Text
, and Image
.
Shape
, Text
, and Image
are all appearance elements that inherit from abstract base class Elements
.
🟢Element
¶
class
public
| ABC
virtual.Widget
. widget
: parent widgetposition
: position relative to its widgetssize
: size of elementname
: name of elementgradient_animation
: Wether use animation to change colorkwargs
: extra parameters for CanvasItem
🟡center
¶
method
public
Element
. 🟡configure
¶
method
public
Element
and update them immediately. style
: style datagradient_animation
: whether use gradient animation
🟡coords
¶
method
public
Element
. size
: new size of the elementposition
: new position of the element
🟡destroy
¶
method
public
Element
. 🟡detect
¶
method
public
Element
. x
: x-coordinate of the location to be detectedy
: y-coordinate of the location to be detected
🟡display
¶
method
public
Element
on a Canvas
. 🟡forget
¶
method
public
value
: whether to forgetgradient_animation
: whether use gradient animation
🟡move
¶
method
public
Element
. dx
: x-coordinate offsetdy
: y-coordinate offset
🟡moveto
¶
method
public
Element
to a certain position. x
: x-coordinate of the target locationy
: y-coordinate of the target location
🟡region
¶
method
public
Element
. 🟡update
¶
method
public
Element
to the corresponding state. state
: the state of theElement
gradient_animation
: whether use gradient animation
🟡zoom
¶
method
public
Element
. ratios
: ratios of zoomingzoom_position
: whether or not to zoom the location of the elementzoom_size
: whether or not to zoom the size of the element
🟢Feature
¶
class
public
| object
Widget
. widget
: parent widget
🟡_parse_method_name
¶
method
protected
name
: original name
Example:
"<Ctrl-C>"
->"_ctrl_c"
"<MouseWheel>"
->"_mouse_wheel"
🟡get_method
¶
method
public
name
: name of the method
🟢Image
¶
class
public
| Element
Widget
. widget
: parent widgetrelative_position
: position relative to its widgetssize
: size of elementimage
: image object of the elementname
: name of elementgradient_animation
: Wether use animation to change colorkwargs
: extra parameters for CanvasItem
🟡region
¶
method
public
Image
. 🟡zoom
¶
method
public
ratios
: ratios of zoomingzoom_position
: whether or not to zoom the location of the imagezoom_size
: whether or not to zoom the size of the image
🟢Shape
¶
class
public
| Element
🟡zoom
¶
method
public
ratios
: ratios of zoomingzoom_position
: whether or not to zoom the location of the shapezoom_size
: whether or not to zoom the size of the shape
🟢Style
¶
class
public
| object
Widget
. widget
: parent widgetauto_update
: whether the theme manager update it automatically
🟡__getitem__
¶
method
special
🟡_get_key
¶
method
protected
key
: the object related to the key
🟡_set
¶
method
protected
theme
: the theme name, None indicates bothdata
: data of colorkwargs
: { arg name: element key or element keys tuple }
🟡_wrap_arg
¶
method
protected
arg
: argument
🟡get
¶
method
public
theme
: the theme of the widget, None indicates the current theme
🟡get_disabled_style
¶
method
public
element
: element that style to be calculated
🟡init
¶
method
public
name
: the key of the elementtheme
: the theme name, None indicates both
🟡reset
¶
method
public
theme
: the theme to be reset, None indicates both
🟡set
¶
method
public
🟢Text
¶
class
public
| Element
Widget
. widget
: parent widgetrelative_position
: position relative to its widgetssize
: size of elementtext
: text valuefamily
: font familyfontsize
: font sizeweight
: weight of the fontslant
: slant of the fontunderline
: wether text is underlineoverstrike
: wether text is overstrikelimit
: limit on the number of charactersshow
: display a value that obscures the original contentplaceholder
: a placeholder for the promptname
: name of elementgradient_animation
: Wether use animation to change colorkwargs
: extra parameters for CanvasItem
🟡region
¶
method
public
Text
. 🟡zoom
¶
method
public
ratios
: ratios of zoomingzoom_position
: whether or not to zoom the location of the textzoom_size
: whether or not to zoom the size of the text
🟢Widget
¶
class
public
| object
Widget
= Element
+ Style
+ Feature
master
: parent canvasposition
: position of the widgetsize
: size of the widgetanchor
: layout anchor of the widgetcapture_events
: wether detect another widget under the widgetgradient_animation
: wether enable animationauto_update
: whether the theme manager update it automaticallystyle
: style of the widget
🟡bind
¶
method
public
sequence
: event namecommand
: callback functionadd
: if True, original callback function will not be overwritten
🟡bind_on_update
¶
method
public
This extra function has two positional arguments, both of which are arguments to the method update
. And this extra function will be called when the widget is updated (whether it’s automatically updated or manually updated).
command
: the extra function that is bound
🟡deregister_elements
¶
method
public
elements
: elements to be deregistered
🟡destroy
¶
method
public
🟡detect
¶
method
public
Widget
. x
: x-coordinate of the location to be detectedy
: y-coordinate of the location to be detected
🟡disable
¶
method
public
value
: whether to disable
🟡forget
¶
method
public
value
: whether to forget the widget
🟡generate_event
¶
method
public
sequence
: event nameevent
: eventkwargs
: attr of event
🟡move
¶
method
public
dx
: x-coordinate offsetdy
: y-coordinate offset
🟡moveto
¶
method
public
x
: x-coordinate of the target locationy
: y-coordinate of the target location
🟡register_elements
¶
method
public
elements
: elements to be registered
🟡unbind
¶
method
public
sequence
: event namecommand
: callback function
🟡unbind_on_update
¶
method
public
command
: the extra function that is bound
🟡update
¶
method
public
state
: state of the widgetgradient_animation
: whether use gradient animationnested
: whether nested
🟡zoom
¶
method
public
ratios
: ratios of zoomingzoom_position
: whether or not to zoom the location of the widgetzoom_size
: whether or not to zoom the size of the widget