View¶
- class pyto_ui.View¶
An object that manages the content for a rectangular area on the screen.
- add_gesture_recognizer(gesture_recognizer: GestureRecognizer)¶
Adds a gesture recognizer.
- Parameters:
gesture_recognizer – The gesture recognizer to be added.
- add_subview(view: View)¶
Adds the given view to the receiver’s hierarchy.
- Parameters:
view – The view to add.
- property alpha: float¶
The opacity of the view.
- Return type:
float
- property appearance: Appearance¶
The appearance of the view. See
Appearanceconstants for possible values.- Return type:
Appearance
- become_first_responder() bool¶
Becomes the first responder. On
TextViewandTextFieldobjects, the keyboard will be shown. Returns a boolean indicating the success.- Return type:
bool
- property border_width: float¶
The width of the view’s border.
- Return type:
float
- property center: Point¶
The center point of the view’s frame rectangle. Setting this value updates
frameproperty appropiately. This value is a tuple with X and Y coordinates.- Return type:
Point
- property center_x: float¶
The center x-coordinate of the view’s frame rectangle. Setting this value updates
frameproperty appropiately.- Return type:
float
- property center_y: float¶
The center y-coordinate of the view’s frame rectangle. Setting this value updates
frameproperty appropiately.- Return type:
float
- property clips_to_bounds: bool¶
A boolean value that determines whether subviews are confined to the bounds of the view.
- Return type:
bool
- close()¶
Closes the view, if the receiver object is the root view presented to the user.
- property content_mode: ContentMode¶
A flag used to determine how a view lays out its content when its bounds change. See Content Mode:py:class: <~pyto_ui.ContentMode>` constants for possible values.
- Return type:
ContentMode
- property corner_radius: float¶
The radius to use when drawing rounded corners for the view’s background.
- Return type:
float
- property did_appear: callable¶
A function called when the view appears on screen. This function is called only if for the presented view and not its subviews.
- Return type:
callable
- property did_disappear: callable¶
A function called when the view stops being visible on screen. This function is called only if for the presented view and not its subviews.
- Return type:
callable
- property first_responder: bool¶
(Read Only) A boolean indicating the view is first responder.
UIKitdispatches some types of events, such as motion events, to the first responder initially.- Return type:
bool
- property flex: AutoResizing¶
A list that determines how the receiver resizes itself when its superview’s bounds change. See
Auto Resizingconstants for possible values.- Return type:
list of
Auto Resizing
- property frame: Rect¶
The frame rectangle, which describes the view’s location and size in its superview’s coordinate system. This value is a tuple with X, Y, Width and Height values.
- Return type:
Rect
- property gesture_recognizers: list[GestureRecognizer]¶
(Read Only) Returns all gesture recognizers.
- Return type:
list[GestureRecognizer]
- property height: float¶
The height of the view.
- Return type:
float
A boolean indicating whether the view is visible or not.
- Return type:
bool
- ib_init()¶
This method is called when the view was initialized from the interface builder. PytoUI doesn’t call ‘__init__’ when a view is created from the interface builder.
- insert_subview(view: View, index: int)¶
Inserts the given view to the receiver’s hierarchy at the given index.
- Parameters:
view – The view to insert.
index – The index where the view should be inserted.
- insert_subview_above(view: View, above_view: View)¶
Inserts the given view to the receiver’s hierarchy above another given view.
- Parameters:
view – The view to insert.
above_view – The view below the inserted view.
- insert_subview_below(view: View, below_view: View)¶
Inserts the given view to the receiver’s hierarchy bellow another given view.
- Parameters:
view – The view to insert.
below_view – The view above the inserted view.
- property key_press_began: callable¶
Called when a physical keyboard key is pressed. The view needs to be the first responder to listen to this event. Call
become_first_responder()if needed.- Return type:
callable
- property key_press_ended: callable¶
Called after a physical keyboard key is pressed. The view needs to be the first responder to listen to this event. Call
become_first_responder()if needed.- Return type:
callable
- property layout: callable¶
A function called when the view is resized. Takes the view as parameter.
- Return type:
callable
- property left_button_items: tuple[ButtonItem]¶
A tuple of
ButtonItemobjects to be displayed on the left of the top bar if the view is in a navigation view.- Return type:
list[ButtonItem]
A context menu to be displayed when long pressing the view.
- Return type:
Menu
- property name: str¶
The name identifying the view. To access a subview with its name, you can use the
subview_with_name()function.Viewis also subscriptable, so you can do something like that:import pyto_ui as ui button = ui.Button() button.name = "Button" view = ui.View() view.add_subview(button) view["Button"] # -> Button object
- Return type:
str
Returns the
NavigationViewcontaining the receiver view if it exists.- Return type:
NavigationView
- property opaque: bool¶
A boolean indicating whether the view is opaque or not. Setting to
Trueshould prevent the view from having a transparent background.- Return type:
bool
- property origin: Point¶
A point that specifies the coordinates of the view’s rectangle’s origin. This value is a tuple with X and Y coordinates.
- Return type:
Point
- remove_from_superview()¶
Removes the view from the parent’s hierarchy.
- remove_gesture_recognizer(gesture_recognizer: GestureRecognizer)¶
Removes a gesture recognizer.
- Parameters:
gesture_recognizer – The gesture recognizer to be removed.
- resign_first_responder() bool¶
Stops being the first responder. On
TextViewandTextFieldobjects, the keyboard will be hidden. Returns a boolean indicating the success.- Return type:
bool
- property right_button_items: tuple[ButtonItem]¶
A tuple of
ButtonItemobjects to be displayed on the right of the top bar if the view is in a navigation view.- Return type:
list[ButtonItem]
- property size: Size¶
A size that specifies the height and width of the rectangle. This value is a tuple with height and width values.
- Return type:
Size
- size_to_fit()¶
Sizes the view to fit its content.
- subview_with_name(name) View¶
Returns the subview with the given name. This function search through all of the subviews recursively.
Raises
NameErrorif no view is found.- Return type:
View
- property subviews: tuple[View]¶
(Read Only) A tuple of the view’s children.
See also
add_subview().- Return type:
tuple[View]
- property tint_color: Color¶
The tint color of the view. If set to
None, the tint color will be inherited from the superview. The tint color affects some views likeButtonfor title color,TextViewfor cursor color, etc.- Return type:
pyto_ui.Color
- property title: str¶
If this view is directly presented, the top bar will show this view’s title.
- Return type:
str
- property user_interaction_enabled: bool¶
A boolean indicating whether the view responds to touches.
- Return type:
bool
- property width: float¶
The width of the view.
- Return type:
float
- property x: float¶
The x-coordinate of the view.
- Return type:
float
- property y: float¶
The y-coordinate of the point.
- Return type:
float