microGUI.Widgets.Widget ======================= .. py:module:: microGUI.Widgets.Widget Classes ------- .. autoapisummary:: microGUI.Widgets.Widget.Widget Module Contents --------------- .. py:class:: Widget(*args, **kwargs) Widget is the fundamental superclass. All widgets belong to a subclass of Widget. .. seealso:: dynamic_widget_caste() .. py:property:: AllowDrop Gets or sets a value indicating whether the widget can accept data that the user drags onto it. .. seealso:: - DragEventArgs - DragOver - DragDrop - DragEnter - DragLeave - DoDragDrop :getter: Return ``true`` if drag-and-drop operations are allowed in the widget; otherwise, ``false``. The default is ``false``. :setter: Sets AllowDrop property :raise TypeError: When not set AllowDrop with a bool type or None :type: bool .. py:property:: Anchor Gets or sets a value indicating whether the widget can accept data that the user drags onto it. Exemple ======= .. code-block:: python :emphasize-lines: 2 widget = Widget() widget.Anchor = ( Widgets.AnchorStyles.Bottom | Widgets.AnchorStyles.Right ) .. attention:: Use the Widget.Anchor property to define how a widget is automatically resized as its parent widget is resized. Anchoring a widget to its parent widget ensures that the anchored edges remain in the same position relative to the edges of the parent widget when the parent widget is resized. You can anchor a widget to one or more edges of its container. For example, if you have a Container with a Button whose microGUI.Widgets.Button.Anchor property value is set to microGUI.Widgets.AnchorStyles.Top and :py:class:`microGUI.Widgets.AnchorStyles.Bottom`, the microGUI.Widgets.Button is stretched to maintain the anchored distance to the top and bottom edges of the :py:class:`~microGUI.Widgets.Container.Container` as the Height of the :py:class:`~microGUI.Widgets.Container.Container` is increased. .. seealso:: - :py:class:`microGUI.Widgets.AnchorStyles` - Dock - Layout :getter: Return ``True`` if drag-and-drop operations are allowed in the widget; otherwise, ``False``. The default is ``False``. :setter: Sets :py:attr:`~microGUI.Widgets.Widget.Widget.Anchor` property :raise TypeError: When not set AllowDrop with a bool type or None :type: A bitwise combination of the Flags :py:class:`microGUI.Widgets.AnchorStyles` values. .. py:property:: BevelWidth :type: int Gets or sets the bevel width of the widget. .. attention:: The width of the widget's bevel if the widget is highlighted and is to draw a bevel. .. seealso:: - :py:class:`microGUI.Widgets.Widget.ThisFlagsHighlighted` - :py:class:`microGUI.Widgets.Basic.ThisFlags.Basic` :getter: The bevel width of the widget in chars. :setter: Sets :py:attr:`~microGUI.Widgets.Widget.Widget.BevelWidth` property :raise TypeError: When :py:attr:`~microGUI.Widgets.Widget.Widget.BevelWidth` property value is not set with an :py:obj:`int` or :py:obj:`None` :type: int .. py:property:: Bottom :type: int Gets the distance, in chars, between the bottom edge of the widget and the top edge of its container's client area. .. attention:: The value of this property is equal to the sum of the :py:attr:`~microGUI.Widgets.Widget.Widget.Top` property value, and the :py:attr:`~microGUI.Widgets.Widget.Widget.Height` property value. The :py:attr:`~microGUI.Widgets.Widget.Widget.Bottom` property is a read-only property. You can manipulate this property value by changing the value of the :py:attr:`~microGUI.Widgets.Widget.Widget.Top` or :py:attr:`~microGUI.Widgets.Widget.Widget.Height` properties or calling the :py:func:`~microGUI.Widgets.Widget.Widget.SetBounds` methods. .. seealso:: - :py:attr:`microGUI.Widgets.Widget.Top` - :py:attr:`microGUI.Widgets.Widget.Height` :getter: An int representing the distance, in chars, between the bottom edge of the widget and the top edge of its container's client area. :type: int .. py:property:: Bounds :type: microGUI.Types.Area.AreaType Gets or sets the size and location of the widget including its nonclient elements, in pixels, relative to the parent widget. **Examples:** .. code-block:: python # Create the widget widget = Widget() # Set value directly from the widget default Bounds property widget.Bounds.pos = PointType(20, 48) widget.Bounds.size = DimType(12, 20) .. code-block:: python # Create the widget widget = Widget() # Replace the default Bounds object by a AreaType class widget.Bounds = AreaType( PointType(20, 48), DimType(12, 20), ) .. seealso:: - :py:attr:`~microGUI.Widgets.Widget.Top` - :py:attr:`~microGUI.Widgets.Widget.Left` - :py:attr:`~microGUI.Widgets.Widget.Left` - :py:attr:`~microGUI.Widgets.Widget.Width` :setter: Set a :py:class:`~microGUI.Types.Area.AreaType` in pixels/chars relative to the parent widget that represents the size and location of the widget including its nonclient elements. :getter: Return :py:attr:`~microGUI.Widgets.Widget.Widget.Bounds` property :rtype: AreaType :raise TypeError: When :py:attr:`~microGUI.Widgets.Widget.Widget.Bounds` property value is not set with an :py:class:`~microGUI.Types.Area.AreaType` instance or :py:obj:`None` .. py:property:: CanFocus :type: bool Gets a value indicating whether the widget can receive focus. .. attention:: In order for a widget to receive input focus, the :py:class:`microGUI.Widgets.Widget.widget` must be assigned, and the :py:attr:`~microGUI.Widgets.Widget.Widget.Visible` and :py:attr:`~microGUI.Widgets.Widget.Widget.Enabled` properties must both be set to :py:obj:`True` for both the widget and all its parent widgets, and the widget must be a :py:class:`microGUI.Widgets.Window.Window` or the widget's outermost parent must be a :py:class:`microGUI.Widgets.Window.Window`. .. seealso:: - :py:attr:`~microGUI.Widgets.Widget.Enabled` - :py:attr:`~microGUI.Widgets.Widget.Visible` - :py:func:`~microGUI.Widgets.Widget.Focus()` - :py:attr:`~microGUI.Widgets.Widget.Focused` - :py:attr:`~microGUI.Widgets.Widget.CanSelect` :getter: :py:obj:`True` if the widget can receive focus; otherwise, :py:obj:`False`. :rtype: bool .. py:property:: CanSelect .. py:method:: get() Returns the stored pointer. :return: self from widget point of view :rtype: Widget