diff --git a/packages/flet/lib/src/controls/animated_switcher.dart b/packages/flet/lib/src/controls/animated_switcher.dart index af6d909644..a93060072b 100644 --- a/packages/flet/lib/src/controls/animated_switcher.dart +++ b/packages/flet/lib/src/controls/animated_switcher.dart @@ -47,6 +47,6 @@ class AnimatedSwitcherControl extends StatelessWidget { }, child: content, ); - return ConstrainedControl(control: control, child: animatedSwitcher); + return LayoutControl(control: control, child: animatedSwitcher); } } diff --git a/packages/flet/lib/src/controls/base_controls.dart b/packages/flet/lib/src/controls/base_controls.dart index 1b1f06426d..ee1b74fc04 100644 --- a/packages/flet/lib/src/controls/base_controls.dart +++ b/packages/flet/lib/src/controls/base_controls.dart @@ -29,11 +29,20 @@ class BaseControl extends StatelessWidget { } } -class ConstrainedControl extends StatelessWidget { +// TODO - remove when extensions migrated to LayoutControl +class ConstrainedControl extends LayoutControl { + const ConstrainedControl({ + super.key, + required super.control, + required super.child, + }); +} + +class LayoutControl extends StatelessWidget { final Control control; final Widget child; - const ConstrainedControl({ + const LayoutControl({ super.key, required this.control, required this.child, diff --git a/packages/flet/lib/src/controls/bottom_app_bar.dart b/packages/flet/lib/src/controls/bottom_app_bar.dart index 3d89264e91..0753b2e8e7 100644 --- a/packages/flet/lib/src/controls/bottom_app_bar.dart +++ b/packages/flet/lib/src/controls/bottom_app_bar.dart @@ -22,6 +22,6 @@ class BottomAppBarControl extends StatelessWidget { child: control.buildWidget("content"), ); - return ConstrainedControl(control: control, child: bottomAppBar); + return LayoutControl(control: control, child: bottomAppBar); } } diff --git a/packages/flet/lib/src/controls/button.dart b/packages/flet/lib/src/controls/button.dart index d3577aec58..aac90d0531 100644 --- a/packages/flet/lib/src/controls/button.dart +++ b/packages/flet/lib/src/controls/button.dart @@ -218,6 +218,6 @@ class _ButtonControlState extends State with FletStoreMixin { } } - return ConstrainedControl(control: widget.control, child: button); + return LayoutControl(control: widget.control, child: button); } } diff --git a/packages/flet/lib/src/controls/canvas.dart b/packages/flet/lib/src/controls/canvas.dart index b29071ac95..5d703202a4 100644 --- a/packages/flet/lib/src/controls/canvas.dart +++ b/packages/flet/lib/src/controls/canvas.dart @@ -167,7 +167,7 @@ class _CanvasControlState extends State { child: widget.control.buildWidget("content"), ); - return ConstrainedControl(control: widget.control, child: paint); + return LayoutControl(control: widget.control, child: paint); } } diff --git a/packages/flet/lib/src/controls/card.dart b/packages/flet/lib/src/controls/card.dart index a3b8963b10..233ba2ad9f 100644 --- a/packages/flet/lib/src/controls/card.dart +++ b/packages/flet/lib/src/controls/card.dart @@ -77,6 +77,6 @@ class CardControl extends StatelessWidget { child: contentWidget); } - return ConstrainedControl(control: control, child: card); + return LayoutControl(control: control, child: card); } } diff --git a/packages/flet/lib/src/controls/checkbox.dart b/packages/flet/lib/src/controls/checkbox.dart index 3f42d9a2ea..12a9420688 100644 --- a/packages/flet/lib/src/controls/checkbox.dart +++ b/packages/flet/lib/src/controls/checkbox.dart @@ -136,6 +136,6 @@ class _CheckboxControlState extends State { child: FittedBox(fit: BoxFit.fill, child: result)); } - return ConstrainedControl(control: widget.control, child: result); + return LayoutControl(control: widget.control, child: result); } } diff --git a/packages/flet/lib/src/controls/chip.dart b/packages/flet/lib/src/controls/chip.dart index 9ac5814d46..b460cb731c 100644 --- a/packages/flet/lib/src/controls/chip.dart +++ b/packages/flet/lib/src/controls/chip.dart @@ -136,6 +136,6 @@ class _ChipControlState extends State { : null, ); - return ConstrainedControl(control: widget.control, child: chip); + return LayoutControl(control: widget.control, child: chip); } } diff --git a/packages/flet/lib/src/controls/circle_avatar.dart b/packages/flet/lib/src/controls/circle_avatar.dart index d99e63c953..d02452c611 100644 --- a/packages/flet/lib/src/controls/circle_avatar.dart +++ b/packages/flet/lib/src/controls/circle_avatar.dart @@ -72,6 +72,6 @@ class CircleAvatarControl extends StatelessWidget { : null, child: content); - return ConstrainedControl(control: control, child: avatar); + return LayoutControl(control: control, child: avatar); } } diff --git a/packages/flet/lib/src/controls/column.dart b/packages/flet/lib/src/controls/column.dart index 2ba1a4deee..b2323c247f 100644 --- a/packages/flet/lib/src/controls/column.dart +++ b/packages/flet/lib/src/controls/column.dart @@ -59,6 +59,6 @@ class ColumnControl extends StatelessWidget { child = ScrollNotificationControl(control: control, child: child); } - return ConstrainedControl(control: control, child: child); + return LayoutControl(control: control, child: child); } } diff --git a/packages/flet/lib/src/controls/container.dart b/packages/flet/lib/src/controls/container.dart index f55ae026da..124564cfea 100644 --- a/packages/flet/lib/src/controls/container.dart +++ b/packages/flet/lib/src/controls/container.dart @@ -199,6 +199,6 @@ class ContainerControl extends StatelessWidget with FletStoreMixin { container = IgnorePointer(child: container); } - return ConstrainedControl(control: control, child: container); + return LayoutControl(control: control, child: container); } } diff --git a/packages/flet/lib/src/controls/cupertino_action_sheet.dart b/packages/flet/lib/src/controls/cupertino_action_sheet.dart index 7b38c5222b..0a26320c3f 100644 --- a/packages/flet/lib/src/controls/cupertino_action_sheet.dart +++ b/packages/flet/lib/src/controls/cupertino_action_sheet.dart @@ -20,6 +20,6 @@ class CupertinoActionSheetControl extends StatelessWidget { actions: control.buildWidgets("actions"), ); - return ConstrainedControl(control: control, child: sheet); + return LayoutControl(control: control, child: sheet); } } diff --git a/packages/flet/lib/src/controls/cupertino_action_sheet_action.dart b/packages/flet/lib/src/controls/cupertino_action_sheet_action.dart index fae8aa58d6..131756545b 100644 --- a/packages/flet/lib/src/controls/cupertino_action_sheet_action.dart +++ b/packages/flet/lib/src/controls/cupertino_action_sheet_action.dart @@ -34,6 +34,6 @@ class CupertinoActionSheetActionControl extends StatelessWidget { child: content, ); - return ConstrainedControl(control: control, child: actionSheet); + return LayoutControl(control: control, child: actionSheet); } } diff --git a/packages/flet/lib/src/controls/cupertino_activity_indicator.dart b/packages/flet/lib/src/controls/cupertino_activity_indicator.dart index 0c024f616a..8e467a7b0e 100644 --- a/packages/flet/lib/src/controls/cupertino_activity_indicator.dart +++ b/packages/flet/lib/src/controls/cupertino_activity_indicator.dart @@ -21,6 +21,6 @@ class CupertinoActivityIndicatorControl extends StatelessWidget { animating: control.getBool("animating", true)!, color: control.getColor("color", context), ); - return ConstrainedControl(control: control, child: activityIndicator); + return LayoutControl(control: control, child: activityIndicator); } } diff --git a/packages/flet/lib/src/controls/cupertino_button.dart b/packages/flet/lib/src/controls/cupertino_button.dart index b874ec6297..c10679850a 100644 --- a/packages/flet/lib/src/controls/cupertino_button.dart +++ b/packages/flet/lib/src/controls/cupertino_button.dart @@ -68,7 +68,7 @@ class _CupertinoButtonControlState extends State { if (icon != null) { if (content != null) { child = Row( - mainAxisSize: MainAxisSize.min, + mainAxisSize: MainAxisSize.min, children: [icon, const SizedBox(width: 8), content]); } else { child = icon; @@ -208,6 +208,6 @@ class _CupertinoButtonControlState extends State { ); } - return ConstrainedControl(control: widget.control, child: button); + return LayoutControl(control: widget.control, child: button); } } diff --git a/packages/flet/lib/src/controls/cupertino_checkbox.dart b/packages/flet/lib/src/controls/cupertino_checkbox.dart index 89a79e0d7f..3589ddcebd 100644 --- a/packages/flet/lib/src/controls/cupertino_checkbox.dart +++ b/packages/flet/lib/src/controls/cupertino_checkbox.dart @@ -130,6 +130,6 @@ class _CheckboxControlState extends State { child: FittedBox(fit: BoxFit.fill, child: result)); } - return ConstrainedControl(control: widget.control, child: result); + return LayoutControl(control: widget.control, child: result); } } diff --git a/packages/flet/lib/src/controls/cupertino_date_picker.dart b/packages/flet/lib/src/controls/cupertino_date_picker.dart index 060e5dece3..978c80e1a0 100644 --- a/packages/flet/lib/src/controls/cupertino_date_picker.dart +++ b/packages/flet/lib/src/controls/cupertino_date_picker.dart @@ -49,6 +49,6 @@ class _CupertinoDatePickerControlState return ErrorControl("CupertinoDatePicker Error: ${e.toString()}"); } - return ConstrainedControl(control: widget.control, child: dialog); + return LayoutControl(control: widget.control, child: dialog); } } diff --git a/packages/flet/lib/src/controls/cupertino_list_tile.dart b/packages/flet/lib/src/controls/cupertino_list_tile.dart index 73979ea158..c2f6d24756 100644 --- a/packages/flet/lib/src/controls/cupertino_list_tile.dart +++ b/packages/flet/lib/src/controls/cupertino_list_tile.dart @@ -88,6 +88,6 @@ class CupertinoListTileControl extends StatelessWidget { tile = ListTileClicks(notifier: _clickNotifier, child: tile); } - return ConstrainedControl(control: control, child: tile); + return LayoutControl(control: control, child: tile); } } diff --git a/packages/flet/lib/src/controls/cupertino_navigation_bar.dart b/packages/flet/lib/src/controls/cupertino_navigation_bar.dart index 54053079fb..f3f549c83a 100644 --- a/packages/flet/lib/src/controls/cupertino_navigation_bar.dart +++ b/packages/flet/lib/src/controls/cupertino_navigation_bar.dart @@ -59,6 +59,6 @@ class _CupertinoNavigationBarControlState label: dest.getString("label", "")!); }).toList()); - return ConstrainedControl(control: widget.control, child: navBar); + return LayoutControl(control: widget.control, child: navBar); } } diff --git a/packages/flet/lib/src/controls/cupertino_picker.dart b/packages/flet/lib/src/controls/cupertino_picker.dart index 517e8223a6..d4f7ea1de8 100644 --- a/packages/flet/lib/src/controls/cupertino_picker.dart +++ b/packages/flet/lib/src/controls/cupertino_picker.dart @@ -63,6 +63,6 @@ class _CupertinoPickerControlState extends State { }).toList(), ); - return ConstrainedControl(control: widget.control, child: picker); + return LayoutControl(control: widget.control, child: picker); } } diff --git a/packages/flet/lib/src/controls/cupertino_radio.dart b/packages/flet/lib/src/controls/cupertino_radio.dart index f242ab1a4b..0970fb8107 100644 --- a/packages/flet/lib/src/controls/cupertino_radio.dart +++ b/packages/flet/lib/src/controls/cupertino_radio.dart @@ -110,6 +110,6 @@ class _CupertinoRadioControlState extends State : Row(children: [labelWidget, cupertinoRadio]))); } - return ConstrainedControl(control: widget.control, child: result); + return LayoutControl(control: widget.control, child: result); } } diff --git a/packages/flet/lib/src/controls/cupertino_segmented_button.dart b/packages/flet/lib/src/controls/cupertino_segmented_button.dart index ad9be2b4f4..1bd1c9b086 100644 --- a/packages/flet/lib/src/controls/cupertino_segmented_button.dart +++ b/packages/flet/lib/src/controls/cupertino_segmented_button.dart @@ -55,6 +55,6 @@ class _CupertinoSegmentedButtonControlState }, ); - return ConstrainedControl(control: widget.control, child: segmnetedButton); + return LayoutControl(control: widget.control, child: segmnetedButton); } } diff --git a/packages/flet/lib/src/controls/cupertino_slider.dart b/packages/flet/lib/src/controls/cupertino_slider.dart index 8a6dfe700f..8da3545680 100644 --- a/packages/flet/lib/src/controls/cupertino_slider.dart +++ b/packages/flet/lib/src/controls/cupertino_slider.dart @@ -72,6 +72,6 @@ class _CupertinoSliderControlState extends State { } : null); - return ConstrainedControl(control: widget.control, child: cupertinoSlider); + return LayoutControl(control: widget.control, child: cupertinoSlider); } } diff --git a/packages/flet/lib/src/controls/cupertino_sliding_segmented_button.dart b/packages/flet/lib/src/controls/cupertino_sliding_segmented_button.dart index 9567b9d537..61ea3c5dc3 100644 --- a/packages/flet/lib/src/controls/cupertino_sliding_segmented_button.dart +++ b/packages/flet/lib/src/controls/cupertino_sliding_segmented_button.dart @@ -49,6 +49,6 @@ class CupertinoSlidingSegmentedButtonControl extends StatelessWidget { }, ); - return ConstrainedControl(control: control, child: button); + return LayoutControl(control: control, child: button); } } diff --git a/packages/flet/lib/src/controls/cupertino_switch.dart b/packages/flet/lib/src/controls/cupertino_switch.dart index b3a5881672..ecb065b855 100644 --- a/packages/flet/lib/src/controls/cupertino_switch.dart +++ b/packages/flet/lib/src/controls/cupertino_switch.dart @@ -136,7 +136,7 @@ class _CupertinoSwitchControlState extends State { : Row(children: [labelWidget, swtch]))); } - return ConstrainedControl(control: widget.control, child: result); + return LayoutControl(control: widget.control, child: result); //}); } } diff --git a/packages/flet/lib/src/controls/cupertino_textfield.dart b/packages/flet/lib/src/controls/cupertino_textfield.dart index a7a4e91f9d..b5d2a12b06 100644 --- a/packages/flet/lib/src/controls/cupertino_textfield.dart +++ b/packages/flet/lib/src/controls/cupertino_textfield.dart @@ -314,11 +314,11 @@ class _CupertinoTextFieldControlState extends State { } if (widget.control.getExpand("expand", 0)! > 0) { - return ConstrainedControl(control: widget.control, child: textField); + return LayoutControl(control: widget.control, child: textField); } else { double? width = widget.control.getDouble("width"); - return ConstrainedControl( + return LayoutControl( control: widget.control, child: width == null ? ConstrainedBox( diff --git a/packages/flet/lib/src/controls/cupertino_timer_picker.dart b/packages/flet/lib/src/controls/cupertino_timer_picker.dart index fa58e50739..5d877f7026 100644 --- a/packages/flet/lib/src/controls/cupertino_timer_picker.dart +++ b/packages/flet/lib/src/controls/cupertino_timer_picker.dart @@ -43,6 +43,6 @@ class _CupertinoTimerPickerControlState }, ); - return ConstrainedControl(control: widget.control, child: picker); + return LayoutControl(control: widget.control, child: picker); } } diff --git a/packages/flet/lib/src/controls/datatable.dart b/packages/flet/lib/src/controls/datatable.dart index bbce9084a7..01601bbd70 100644 --- a/packages/flet/lib/src/controls/datatable.dart +++ b/packages/flet/lib/src/controls/datatable.dart @@ -127,6 +127,6 @@ class DataTableControl extends StatelessWidget { }).toList(), ); - return ConstrainedControl(control: control, child: datatable); + return LayoutControl(control: control, child: datatable); } } diff --git a/packages/flet/lib/src/controls/dismissible.dart b/packages/flet/lib/src/controls/dismissible.dart index f6b8123444..9d0192bb0d 100644 --- a/packages/flet/lib/src/controls/dismissible.dart +++ b/packages/flet/lib/src/controls/dismissible.dart @@ -102,7 +102,7 @@ class _DismissibleControlState extends State { .getDismissThresholds("dismiss_thresholds", const {})!, child: content); - return ConstrainedControl(control: widget.control, child: dismissible); + return LayoutControl(control: widget.control, child: dismissible); } } diff --git a/packages/flet/lib/src/controls/dropdown.dart b/packages/flet/lib/src/controls/dropdown.dart index 037807893f..e215a4e5cd 100644 --- a/packages/flet/lib/src/controls/dropdown.dart +++ b/packages/flet/lib/src/controls/dropdown.dart @@ -238,6 +238,6 @@ class _DropdownControlState extends State { }); } - return ConstrainedControl(control: widget.control, child: dropDown); + return LayoutControl(control: widget.control, child: dropDown); } } diff --git a/packages/flet/lib/src/controls/dropdownm2.dart b/packages/flet/lib/src/controls/dropdownm2.dart index b5b381fe42..a07e5dc6b7 100644 --- a/packages/flet/lib/src/controls/dropdownm2.dart +++ b/packages/flet/lib/src/controls/dropdownm2.dart @@ -148,7 +148,7 @@ class _DropdownM2ControlState extends State { ); if (widget.control.getExpand("expand", 0)! > 0) { - return ConstrainedControl(control: widget.control, child: dropDown); + return LayoutControl(control: widget.control, child: dropDown); } else { return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { @@ -159,7 +159,7 @@ class _DropdownM2ControlState extends State { child: dropDown); } - return ConstrainedControl(control: widget.control, child: dropDown); + return LayoutControl(control: widget.control, child: dropDown); }, ); } diff --git a/packages/flet/lib/src/controls/expansion_panel.dart b/packages/flet/lib/src/controls/expansion_panel.dart index 35d53b65df..5f7bb50183 100644 --- a/packages/flet/lib/src/controls/expansion_panel.dart +++ b/packages/flet/lib/src/controls/expansion_panel.dart @@ -55,6 +55,6 @@ class ExpansionPanelListControl extends StatelessWidget { ); }).toList()); - return ConstrainedControl(control: control, child: panelList); + return LayoutControl(control: control, child: panelList); } } diff --git a/packages/flet/lib/src/controls/expansion_tile.dart b/packages/flet/lib/src/controls/expansion_tile.dart index c31fc4f8a4..05344976a2 100644 --- a/packages/flet/lib/src/controls/expansion_tile.dart +++ b/packages/flet/lib/src/controls/expansion_tile.dart @@ -103,6 +103,6 @@ class ExpansionTileControl extends StatelessWidget { children: controls, ); - return ConstrainedControl(control: control, child: tile); + return LayoutControl(control: control, child: tile); } } diff --git a/packages/flet/lib/src/controls/flet_app_control.dart b/packages/flet/lib/src/controls/flet_app_control.dart index bef0a65584..1bbe226a3b 100644 --- a/packages/flet/lib/src/controls/flet_app_control.dart +++ b/packages/flet/lib/src/controls/flet_app_control.dart @@ -32,7 +32,7 @@ class _FletAppControlState extends State { var appStartupScreenMessage = widget.control.getString("app_startup_screen_message"); - return ConstrainedControl( + return LayoutControl( control: widget.control, child: FletApp( controlId: widget.control.id, diff --git a/packages/flet/lib/src/controls/floating_action_button.dart b/packages/flet/lib/src/controls/floating_action_button.dart index 185058a9d8..3a8eabbae1 100644 --- a/packages/flet/lib/src/controls/floating_action_button.dart +++ b/packages/flet/lib/src/controls/floating_action_button.dart @@ -112,6 +112,6 @@ class FloatingActionButtonControl extends StatelessWidget { "FloatingActionButton has nothing to display. Provide at minimum icon or content."); } - return ConstrainedControl(control: control, child: button); + return LayoutControl(control: control, child: button); } } diff --git a/packages/flet/lib/src/controls/gesture_detector.dart b/packages/flet/lib/src/controls/gesture_detector.dart index 4fb3371f84..0752cc8040 100644 --- a/packages/flet/lib/src/controls/gesture_detector.dart +++ b/packages/flet/lib/src/controls/gesture_detector.dart @@ -436,6 +436,6 @@ class _GestureDetectorControlState extends State { "GestureDetector should have at least one event handler defined"); } - return ConstrainedControl(control: widget.control, child: result); + return LayoutControl(control: widget.control, child: result); } } diff --git a/packages/flet/lib/src/controls/grid_view.dart b/packages/flet/lib/src/controls/grid_view.dart index 2ccd491bf8..85f67791f1 100644 --- a/packages/flet/lib/src/controls/grid_view.dart +++ b/packages/flet/lib/src/controls/grid_view.dart @@ -134,6 +134,6 @@ class _GridViewControlState extends State { }, ); - return ConstrainedControl(control: widget.control, child: gridView); + return LayoutControl(control: widget.control, child: gridView); } } diff --git a/packages/flet/lib/src/controls/icon.dart b/packages/flet/lib/src/controls/icon.dart index 03c76263da..6a29dcce9f 100644 --- a/packages/flet/lib/src/controls/icon.dart +++ b/packages/flet/lib/src/controls/icon.dart @@ -17,7 +17,7 @@ class IconControl extends StatelessWidget { Widget build(BuildContext context) { debugPrint("Icon build: ${control.id}"); - return ConstrainedControl( + return LayoutControl( control: control, child: Icon( control.getIconData("icon"), diff --git a/packages/flet/lib/src/controls/icon_button.dart b/packages/flet/lib/src/controls/icon_button.dart index e82041b082..4295649945 100644 --- a/packages/flet/lib/src/controls/icon_button.dart +++ b/packages/flet/lib/src/controls/icon_button.dart @@ -237,7 +237,7 @@ class _IconButtonControlState extends State onPressed: onPressed); } - return ConstrainedControl(control: widget.control, child: button); + return LayoutControl(control: widget.control, child: button); }); } } diff --git a/packages/flet/lib/src/controls/image.dart b/packages/flet/lib/src/controls/image.dart index 4b6d6666f7..176ba364e7 100644 --- a/packages/flet/lib/src/controls/image.dart +++ b/packages/flet/lib/src/controls/image.dart @@ -57,7 +57,7 @@ class ImageControl extends StatelessWidget { disabled: control.disabled, errorCtrl: errorContent, ); - return ConstrainedControl( + return LayoutControl( control: control, child: _clipCorners(image, control.getBorderRadius("border_radius"))); } diff --git a/packages/flet/lib/src/controls/interactive_viewer.dart b/packages/flet/lib/src/controls/interactive_viewer.dart index 15c22cde29..658e20b964 100644 --- a/packages/flet/lib/src/controls/interactive_viewer.dart +++ b/packages/flet/lib/src/controls/interactive_viewer.dart @@ -147,7 +147,6 @@ class _InteractiveViewerControlState extends State "InteractiveViewer.content must be provided and visible"), ); - return ConstrainedControl( - control: widget.control, child: interactiveViewer); + return LayoutControl(control: widget.control, child: interactiveViewer); } } diff --git a/packages/flet/lib/src/controls/list_tile.dart b/packages/flet/lib/src/controls/list_tile.dart index db0e568873..bea5172e4e 100644 --- a/packages/flet/lib/src/controls/list_tile.dart +++ b/packages/flet/lib/src/controls/list_tile.dart @@ -119,7 +119,7 @@ class ListTileControl extends StatelessWidget with FletStoreMixin { tile = Material(type: MaterialType.transparency, child: tile); - return ConstrainedControl(control: control, child: tile); + return LayoutControl(control: control, child: tile); } } diff --git a/packages/flet/lib/src/controls/list_view.dart b/packages/flet/lib/src/controls/list_view.dart index 7cc7a69d82..4fed71b539 100644 --- a/packages/flet/lib/src/controls/list_view.dart +++ b/packages/flet/lib/src/controls/list_view.dart @@ -149,6 +149,6 @@ class _ListViewControlState extends State { }, ); - return ConstrainedControl(control: widget.control, child: listView); + return LayoutControl(control: widget.control, child: listView); } } diff --git a/packages/flet/lib/src/controls/markdown.dart b/packages/flet/lib/src/controls/markdown.dart index beecb7adfe..876cdd8f04 100644 --- a/packages/flet/lib/src/controls/markdown.dart +++ b/packages/flet/lib/src/controls/markdown.dart @@ -100,7 +100,7 @@ class MarkdownControl extends StatelessWidget { control.triggerEvent("tap_link", href); }); - return ConstrainedControl(control: control, child: markdown); + return LayoutControl(control: control, child: markdown); } } diff --git a/packages/flet/lib/src/controls/menu_bar.dart b/packages/flet/lib/src/controls/menu_bar.dart index bf669bed94..99a64c701d 100644 --- a/packages/flet/lib/src/controls/menu_bar.dart +++ b/packages/flet/lib/src/controls/menu_bar.dart @@ -27,6 +27,6 @@ class _MenuBarControlState extends State { widget.control.getClipBehavior("clip_behavior", Clip.none)!, children: controls); - return ConstrainedControl(control: widget.control, child: menuBar); + return LayoutControl(control: widget.control, child: menuBar); } } diff --git a/packages/flet/lib/src/controls/menu_item_button.dart b/packages/flet/lib/src/controls/menu_item_button.dart index ed7608d417..15892640ac 100644 --- a/packages/flet/lib/src/controls/menu_item_button.dart +++ b/packages/flet/lib/src/controls/menu_item_button.dart @@ -86,6 +86,6 @@ class _MenuItemButtonControlState extends State { _focusNode.requestFocus(); } - return ConstrainedControl(control: widget.control, child: menuItem); + return LayoutControl(control: widget.control, child: menuItem); } } diff --git a/packages/flet/lib/src/controls/merge_semantics.dart b/packages/flet/lib/src/controls/merge_semantics.dart index c9aa6f569f..21acc3614a 100644 --- a/packages/flet/lib/src/controls/merge_semantics.dart +++ b/packages/flet/lib/src/controls/merge_semantics.dart @@ -13,7 +13,7 @@ class MergeSemanticsControl extends StatelessWidget { Widget build(BuildContext context) { debugPrint("MergeSemantics build: ${control.id}"); - return ConstrainedControl( + return LayoutControl( control: control, child: MergeSemantics(child: control.buildWidget("content"))); } diff --git a/packages/flet/lib/src/controls/navigation_bar.dart b/packages/flet/lib/src/controls/navigation_bar.dart index 5066d62ca4..5f88bee561 100644 --- a/packages/flet/lib/src/controls/navigation_bar.dart +++ b/packages/flet/lib/src/controls/navigation_bar.dart @@ -68,7 +68,7 @@ class _NavigationBarControlState extends State widget.control.disabled ? null : _destinationChanged, destinations: widget.control.buildWidgets("destinations")); - return ConstrainedControl(control: widget.control, child: navBar); + return LayoutControl(control: widget.control, child: navBar); }); } } diff --git a/packages/flet/lib/src/controls/navigation_rail.dart b/packages/flet/lib/src/controls/navigation_rail.dart index 6474969221..945de9adb2 100644 --- a/packages/flet/lib/src/controls/navigation_rail.dart +++ b/packages/flet/lib/src/controls/navigation_rail.dart @@ -114,6 +114,6 @@ class _NavigationRailControlState extends State }, ); - return ConstrainedControl(control: widget.control, child: rail); + return LayoutControl(control: widget.control, child: rail); } } diff --git a/packages/flet/lib/src/controls/pagelet.dart b/packages/flet/lib/src/controls/pagelet.dart index d2e4ec5bf1..c161abc86f 100644 --- a/packages/flet/lib/src/controls/pagelet.dart +++ b/packages/flet/lib/src/controls/pagelet.dart @@ -159,6 +159,6 @@ class _PageletControlState extends State { child: scaffold); } - return ConstrainedControl(control: widget.control, child: scaffold); + return LayoutControl(control: widget.control, child: scaffold); } } diff --git a/packages/flet/lib/src/controls/placeholder.dart b/packages/flet/lib/src/controls/placeholder.dart index c655045a2e..c5c9e8e528 100644 --- a/packages/flet/lib/src/controls/placeholder.dart +++ b/packages/flet/lib/src/controls/placeholder.dart @@ -22,6 +22,6 @@ class PlaceholderControl extends StatelessWidget { strokeWidth: control.getDouble("stroke_width", 2.0)!, child: control.buildWidget("content")); - return ConstrainedControl(control: control, child: placeholder); + return LayoutControl(control: control, child: placeholder); } } diff --git a/packages/flet/lib/src/controls/popup_menu_button.dart b/packages/flet/lib/src/controls/popup_menu_button.dart index fa62e4162d..4936326ab1 100644 --- a/packages/flet/lib/src/controls/popup_menu_button.dart +++ b/packages/flet/lib/src/controls/popup_menu_button.dart @@ -107,7 +107,7 @@ class PopupMenuButtonControl extends StatelessWidget { }).toList(), child: content); - return ConstrainedControl( + return LayoutControl( control: control, child: TooltipVisibility( visible: control.getString("tooltip") == null, diff --git a/packages/flet/lib/src/controls/progress_bar.dart b/packages/flet/lib/src/controls/progress_bar.dart index 9400f973eb..7278d97c7d 100644 --- a/packages/flet/lib/src/controls/progress_bar.dart +++ b/packages/flet/lib/src/controls/progress_bar.dart @@ -31,6 +31,6 @@ class ProgressBarControl extends StatelessWidget { year2023: control.getBool( "year_2023"), // todo: deprecated and to be removed in future versions ); - return ConstrainedControl(control: control, child: indicator); + return LayoutControl(control: control, child: indicator); } } diff --git a/packages/flet/lib/src/controls/progress_ring.dart b/packages/flet/lib/src/controls/progress_ring.dart index 3ecfcf05e0..2b8242455a 100644 --- a/packages/flet/lib/src/controls/progress_ring.dart +++ b/packages/flet/lib/src/controls/progress_ring.dart @@ -34,6 +34,6 @@ class ProgressRingControl extends StatelessWidget { year2023: control.getBool( "year2023"), // todo: deprecated and to be removed in future versions ); - return ConstrainedControl(control: control, child: indicator); + return LayoutControl(control: control, child: indicator); } } diff --git a/packages/flet/lib/src/controls/radio.dart b/packages/flet/lib/src/controls/radio.dart index 87c2aedc4e..3c571fa566 100644 --- a/packages/flet/lib/src/controls/radio.dart +++ b/packages/flet/lib/src/controls/radio.dart @@ -116,6 +116,6 @@ class _RadioControlState extends State { : Row(children: [labelWidget, radio]))); } - return ConstrainedControl(control: widget.control, child: result); + return LayoutControl(control: widget.control, child: result); } } diff --git a/packages/flet/lib/src/controls/range_slider.dart b/packages/flet/lib/src/controls/range_slider.dart index 6c1c4dbe4e..8fdf6f94dc 100644 --- a/packages/flet/lib/src/controls/range_slider.dart +++ b/packages/flet/lib/src/controls/range_slider.dart @@ -77,6 +77,6 @@ class _SliderControlState extends State { } : null); - return ConstrainedControl(control: widget.control, child: rangeSlider); + return LayoutControl(control: widget.control, child: rangeSlider); } } diff --git a/packages/flet/lib/src/controls/reorderable_list_view.dart b/packages/flet/lib/src/controls/reorderable_list_view.dart index e65bb20e0f..24ac158c1d 100644 --- a/packages/flet/lib/src/controls/reorderable_list_view.dart +++ b/packages/flet/lib/src/controls/reorderable_list_view.dart @@ -162,6 +162,6 @@ class _ListViewControlState extends State { }, ); - return ConstrainedControl(control: widget.control, child: result); + return LayoutControl(control: widget.control, child: result); } } diff --git a/packages/flet/lib/src/controls/responsive_row.dart b/packages/flet/lib/src/controls/responsive_row.dart index 4fa77a362b..e4fd0f15cb 100644 --- a/packages/flet/lib/src/controls/responsive_row.dart +++ b/packages/flet/lib/src/controls/responsive_row.dart @@ -89,7 +89,7 @@ class ResponsiveRowControl extends StatelessWidget with FletStoreMixin { } }); - return ConstrainedControl(control: control, child: result); + return LayoutControl(control: control, child: result); }); } } diff --git a/packages/flet/lib/src/controls/row.dart b/packages/flet/lib/src/controls/row.dart index 42b2ccde5d..d53891b9cf 100644 --- a/packages/flet/lib/src/controls/row.dart +++ b/packages/flet/lib/src/controls/row.dart @@ -56,6 +56,6 @@ class RowControl extends StatelessWidget { child = ScrollNotificationControl(control: control, child: child); } - return ConstrainedControl(control: control, child: child); + return LayoutControl(control: control, child: child); } } diff --git a/packages/flet/lib/src/controls/safe_area.dart b/packages/flet/lib/src/controls/safe_area.dart index f2fe1ddc5d..f42127477a 100644 --- a/packages/flet/lib/src/controls/safe_area.dart +++ b/packages/flet/lib/src/controls/safe_area.dart @@ -28,6 +28,6 @@ class SafeAreaControl extends StatelessWidget { const ErrorControl( "SafeArea.content must be provided and visible")); - return ConstrainedControl(control: control, child: safeArea); + return LayoutControl(control: control, child: safeArea); } } diff --git a/packages/flet/lib/src/controls/search_bar.dart b/packages/flet/lib/src/controls/search_bar.dart index d9bffb1132..398882cbd5 100644 --- a/packages/flet/lib/src/controls/search_bar.dart +++ b/packages/flet/lib/src/controls/search_bar.dart @@ -253,6 +253,6 @@ class _SearchBarControlState extends State { return widget.control.buildWidgets("controls"); }); - return ConstrainedControl(control: widget.control, child: anchor); + return LayoutControl(control: widget.control, child: anchor); } } diff --git a/packages/flet/lib/src/controls/segmented_button.dart b/packages/flet/lib/src/controls/segmented_button.dart index b3ece2e7c2..b995698e09 100644 --- a/packages/flet/lib/src/controls/segmented_button.dart +++ b/packages/flet/lib/src/controls/segmented_button.dart @@ -99,6 +99,6 @@ class _SegmentedButtonControlState extends State label: segment.buildTextOrWidget("label")); }).toList()); - return ConstrainedControl(control: widget.control, child: segmentedButton); + return LayoutControl(control: widget.control, child: segmentedButton); } } diff --git a/packages/flet/lib/src/controls/semantics.dart b/packages/flet/lib/src/controls/semantics.dart index 021af7b6a5..42803ad604 100644 --- a/packages/flet/lib/src/controls/semantics.dart +++ b/packages/flet/lib/src/controls/semantics.dart @@ -104,6 +104,6 @@ class SemanticsControl extends StatelessWidget { : null, ); - return ConstrainedControl(control: control, child: semantics); + return LayoutControl(control: control, child: semantics); } } diff --git a/packages/flet/lib/src/controls/shader_mask.dart b/packages/flet/lib/src/controls/shader_mask.dart index 8c9373f94f..7854f65b0a 100644 --- a/packages/flet/lib/src/controls/shader_mask.dart +++ b/packages/flet/lib/src/controls/shader_mask.dart @@ -24,7 +24,7 @@ class ShaderMaskControl extends StatelessWidget { shaderCallback: (bounds) => gradient.createShader(bounds), blendMode: control.getBlendMode("blend_mode", BlendMode.modulate)!, child: control.buildWidget("content")); - return ConstrainedControl( + return LayoutControl( control: control, child: _clipCorners(shaderMask, borderRadius: control.getBorderRadius("border_radius"))); diff --git a/packages/flet/lib/src/controls/slider.dart b/packages/flet/lib/src/controls/slider.dart index 511459e6c5..6a774736d1 100644 --- a/packages/flet/lib/src/controls/slider.dart +++ b/packages/flet/lib/src/controls/slider.dart @@ -105,6 +105,6 @@ class _SliderControlState extends State { } : null); - return ConstrainedControl(control: widget.control, child: slider); + return LayoutControl(control: widget.control, child: slider); } } diff --git a/packages/flet/lib/src/controls/stack.dart b/packages/flet/lib/src/controls/stack.dart index 99a68bb70a..aa5c845077 100644 --- a/packages/flet/lib/src/controls/stack.dart +++ b/packages/flet/lib/src/controls/stack.dart @@ -26,6 +26,6 @@ class StackControl extends StatelessWidget { control.getAlignment("alignment") ?? AlignmentDirectional.topStart, children: control.buildWidgets("controls"), ); - return ConstrainedControl(control: control, child: stack); + return LayoutControl(control: control, child: stack); } } diff --git a/packages/flet/lib/src/controls/submenu_button.dart b/packages/flet/lib/src/controls/submenu_button.dart index 9cf17d74b9..58ff77d05f 100644 --- a/packages/flet/lib/src/controls/submenu_button.dart +++ b/packages/flet/lib/src/controls/submenu_button.dart @@ -91,6 +91,6 @@ class _SubmenuButtonControlState extends State { _focusNode.requestFocus(); } - return ConstrainedControl(control: widget.control, child: subMenuButton); + return LayoutControl(control: widget.control, child: subMenuButton); } } diff --git a/packages/flet/lib/src/controls/switch.dart b/packages/flet/lib/src/controls/switch.dart index 0204517679..2e29b5eedc 100644 --- a/packages/flet/lib/src/controls/switch.dart +++ b/packages/flet/lib/src/controls/switch.dart @@ -152,7 +152,7 @@ class _SwitchControlState extends State { ); } - return ConstrainedControl(control: widget.control, child: result); + return LayoutControl(control: widget.control, child: result); // }); } } diff --git a/packages/flet/lib/src/controls/tabs.dart b/packages/flet/lib/src/controls/tabs.dart index 5904f73b3b..31c9191fa3 100644 --- a/packages/flet/lib/src/controls/tabs.dart +++ b/packages/flet/lib/src/controls/tabs.dart @@ -142,7 +142,7 @@ class _TabsControlState extends State return const ErrorControl("Tabs.content must be provided and visible"); } - return ConstrainedControl(control: widget.control, child: content); + return LayoutControl(control: widget.control, child: content); } } @@ -164,8 +164,8 @@ class TabBarViewControl extends StatelessWidget { final tabController = tabsState._tabController; - Widget buildConstrainedTabView() { - return ConstrainedControl( + Widget buildLayoutTabView() { + return LayoutControl( control: control, child: TabBarView( controller: tabController, @@ -179,7 +179,7 @@ class TabBarViewControl extends StatelessWidget { // If expand property was set, we return the result directly. // Because having Expanded as direct child of LayoutBuilder is not allowed. if (control.getExpand("expand", 0)! > 0) { - return buildConstrainedTabView(); + return buildLayoutTabView(); } return LayoutBuilder( @@ -196,7 +196,7 @@ class TabBarViewControl extends StatelessWidget { ); } - return buildConstrainedTabView(); + return buildLayoutTabView(); }, ); } diff --git a/packages/flet/lib/src/controls/text.dart b/packages/flet/lib/src/controls/text.dart index 59eb32ba24..1945380a83 100644 --- a/packages/flet/lib/src/controls/text.dart +++ b/packages/flet/lib/src/controls/text.dart @@ -146,6 +146,6 @@ class TextControl extends StatelessWidget { overflow: overflow, ); - return ConstrainedControl(control: control, child: textWidget); + return LayoutControl(control: control, child: textWidget); } } diff --git a/packages/flet/lib/src/controls/textfield.dart b/packages/flet/lib/src/controls/textfield.dart index b986e6b4cc..6e4d78acc1 100644 --- a/packages/flet/lib/src/controls/textfield.dart +++ b/packages/flet/lib/src/controls/textfield.dart @@ -271,11 +271,11 @@ class _TextFieldControlState extends State { isLinuxDesktop() ? ExcludeSemantics(child: textField) : textField; if (widget.control.getExpand("expand", 0)! > 0) { - return ConstrainedControl(control: widget.control, child: textField); + return LayoutControl(control: widget.control, child: textField); } else { double? width = widget.control.getDouble("width"); - return ConstrainedControl( + return LayoutControl( control: widget.control, child: width == null ? ConstrainedBox( diff --git a/packages/flet/lib/src/controls/transparent_pointer.dart b/packages/flet/lib/src/controls/transparent_pointer.dart index 1d4c363e06..42dfc91e76 100644 --- a/packages/flet/lib/src/controls/transparent_pointer.dart +++ b/packages/flet/lib/src/controls/transparent_pointer.dart @@ -17,7 +17,7 @@ class TransparentPointerControl extends StatelessWidget { var pointer = TransparentPointer( transparent: true, child: control.buildWidget("content")); - return ConstrainedControl(control: control, child: pointer); + return LayoutControl(control: control, child: pointer); } } diff --git a/packages/flet/lib/src/controls/window_drag_area.dart b/packages/flet/lib/src/controls/window_drag_area.dart index 69bb1d2a5a..e0d9bdc2d5 100644 --- a/packages/flet/lib/src/controls/window_drag_area.dart +++ b/packages/flet/lib/src/controls/window_drag_area.dart @@ -56,6 +56,6 @@ class WindowDragAreaControl extends StatelessWidget { child: content, ); - return ConstrainedControl(control: control, child: wda); + return LayoutControl(control: control, child: wda); } } diff --git a/packages/flet/lib/src/flet_core_extension.dart b/packages/flet/lib/src/flet_core_extension.dart index 9ccc9b6c12..9a3f6d9c9b 100644 --- a/packages/flet/lib/src/flet_core_extension.dart +++ b/packages/flet/lib/src/flet_core_extension.dart @@ -244,7 +244,7 @@ class FletCoreExtension extends FletExtension { return ExpansionPanelListControl(key: key, control: control); case "ExpansionTile": return ExpansionTileControl(key: key, control: control); - case "ElevatedButton": + case "Button": case "FilledButton": case "FilledTonalButton": case "TextButton": diff --git a/packages/flet/lib/src/utils/theme.dart b/packages/flet/lib/src/utils/theme.dart index 51e9a32150..36b4057e9f 100644 --- a/packages/flet/lib/src/utils/theme.dart +++ b/packages/flet/lib/src/utils/theme.dart @@ -184,8 +184,7 @@ ThemeData parseTheme( navigationBarTheme: parseNavigationBarTheme(value?["navigation_bar_theme"], theme), dataTableTheme: parseDataTableTheme(value?["data_table_theme"], context), - elevatedButtonTheme: - parseElevatedButtonTheme(value?["elevated_button_theme"], theme), + elevatedButtonTheme: parseButtonTheme(value?["button_theme"], theme), outlinedButtonTheme: parseOutlinedButtonTheme(value?["outlined_button_theme"], theme), textButtonTheme: parseTextButtonTheme(value?["text_button_theme"], theme), @@ -284,7 +283,7 @@ TextTheme? parseTextTheme( ); } -ElevatedButtonThemeData? parseElevatedButtonTheme( +ElevatedButtonThemeData? parseButtonTheme( Map? value, ThemeData theme, [ElevatedButtonThemeData? defaultValue]) { if (value == null) return defaultValue; @@ -1185,10 +1184,9 @@ extension ThemeParsers on Control { ); } - ElevatedButtonThemeData? getElevatedButtonTheme( - String propertyName, ThemeData theme, + ElevatedButtonThemeData? getButtonTheme(String propertyName, ThemeData theme, [ElevatedButtonThemeData? defaultValue]) { - return parseElevatedButtonTheme(get(propertyName), theme, defaultValue); + return parseButtonTheme(get(propertyName), theme, defaultValue); } OutlinedButtonThemeData? getOutlinedButtonTheme( diff --git a/sdk/python/examples/apps/authentication/basic-auth-async.py b/sdk/python/examples/apps/authentication/basic-auth-async.py index b9ba467207..9122ca7fed 100644 --- a/sdk/python/examples/apps/authentication/basic-auth-async.py +++ b/sdk/python/examples/apps/authentication/basic-auth-async.py @@ -25,7 +25,7 @@ async def on_login(e): print("User ID:", page.auth.user.id) page.on_login = on_login - page.add(ft.ElevatedButton("Login with GitHub", on_click=login_click)) + page.add(ft.Button("Login with GitHub", on_click=login_click)) ft.run(target=main, port=8550, view=ft.WEB_BROWSER) diff --git a/sdk/python/examples/apps/authentication/basic-auth.py b/sdk/python/examples/apps/authentication/basic-auth.py index 88bc942553..da421b0176 100644 --- a/sdk/python/examples/apps/authentication/basic-auth.py +++ b/sdk/python/examples/apps/authentication/basic-auth.py @@ -25,7 +25,7 @@ def on_login(e): print("User ID:", page.auth.user.id) page.on_login = on_login - page.add(ft.ElevatedButton("Login with GitHub", on_click=login_click)) + page.add(ft.Button("Login with GitHub", on_click=login_click)) ft.run(target=main, port=8550, view=ft.WEB_BROWSER) diff --git a/sdk/python/examples/apps/authentication/check-auth-results-and-toggle-ui.py b/sdk/python/examples/apps/authentication/check-auth-results-and-toggle-ui.py index b9fba94269..ad2b5b7566 100644 --- a/sdk/python/examples/apps/authentication/check-auth-results-and-toggle-ui.py +++ b/sdk/python/examples/apps/authentication/check-auth-results-and-toggle-ui.py @@ -1,11 +1,10 @@ import os -import flet -from flet import ElevatedButton, LoginEvent, Page +import flet as ft from flet.auth.providers import GitHubOAuthProvider -def main(page: Page): +def main(page: ft.Page): provider = GitHubOAuthProvider( client_id=os.getenv("GITHUB_CLIENT_ID"), client_secret=os.getenv("GITHUB_CLIENT_SECRET"), @@ -15,7 +14,7 @@ def main(page: Page): def login_button_click(e): page.login(provider, scope=["public_repo"]) - def on_login(e: LoginEvent): + def on_login(e: ft.LoginEvent): if not e.error: toggle_login_buttons() @@ -30,12 +29,12 @@ def toggle_login_buttons(): logout_button.visible = page.auth is not None page.update() - login_button = ElevatedButton("Login with GitHub", on_click=login_button_click) - logout_button = ElevatedButton("Logout", on_click=logout_button_click) + login_button = ft.Button("Login with GitHub", on_click=login_button_click) + logout_button = ft.Button("Logout", on_click=logout_button_click) toggle_login_buttons() page.on_login = on_login page.on_logout = on_logout page.add(login_button, logout_button) -flet.app(target=main, port=8550, view=flet.AppView.WEB_BROWSER) +ft.app(target=main, port=8550, view=ft.AppView.WEB_BROWSER) diff --git a/sdk/python/examples/apps/authentication/github-oauth-with-listing-repos-async.py b/sdk/python/examples/apps/authentication/github-oauth-with-listing-repos-async.py index fa58467b75..c2b6a9ce26 100644 --- a/sdk/python/examples/apps/authentication/github-oauth-with-listing-repos-async.py +++ b/sdk/python/examples/apps/authentication/github-oauth-with-listing-repos-async.py @@ -2,8 +2,9 @@ import logging import os -import flet as ft import httpx + +import flet as ft from flet.auth.providers import GitHubOAuthProvider from flet.security import decrypt, encrypt @@ -89,8 +90,8 @@ def toggle_login_buttons(): logged_user.visible = logout_button.visible = page.auth is not None logged_user = ft.Text() - login_button = ft.ElevatedButton("Login with GitHub", on_click=perform_login) - logout_button = ft.ElevatedButton("Logout", on_click=logout_button_click) + login_button = ft.Button("Login with GitHub", on_click=perform_login) + logout_button = ft.Button("Logout", on_click=logout_button_click) repos_view = ft.ListView(expand=True) page.on_login = on_login page.on_logout = on_logout diff --git a/sdk/python/examples/apps/authentication/github-oauth-with-listing-repos.py b/sdk/python/examples/apps/authentication/github-oauth-with-listing-repos.py index 1551595731..55d6074b70 100644 --- a/sdk/python/examples/apps/authentication/github-oauth-with-listing-repos.py +++ b/sdk/python/examples/apps/authentication/github-oauth-with-listing-repos.py @@ -2,8 +2,9 @@ import logging import os -import flet as ft import httpx + +import flet as ft from flet.auth.providers import GitHubOAuthProvider from flet.security import decrypt, encrypt @@ -86,8 +87,8 @@ def toggle_login_buttons(): logged_user.visible = logout_button.visible = page.auth is not None logged_user = ft.Text() - login_button = ft.ElevatedButton("Login with GitHub", on_click=perform_login) - logout_button = ft.ElevatedButton("Logout", on_click=logout_button_click) + login_button = ft.Button("Login with GitHub", on_click=perform_login) + logout_button = ft.Button("Logout", on_click=logout_button_click) repos_view = ft.ListView(expand=True) page.on_login = on_login page.on_logout = on_logout diff --git a/sdk/python/examples/apps/authentication/linkedin-login.py b/sdk/python/examples/apps/authentication/linkedin-login.py index 7f029e378f..be08a98cd8 100644 --- a/sdk/python/examples/apps/authentication/linkedin-login.py +++ b/sdk/python/examples/apps/authentication/linkedin-login.py @@ -1,11 +1,10 @@ import os -import flet -from flet import ElevatedButton, Page +import flet as ft from flet.auth import OAuthProvider -def main(page: Page): +def main(page: ft.Page): provider = OAuthProvider( client_id=os.getenv("LINKEDIN_CLIENT_ID"), client_secret=os.getenv("LINKEDIN_CLIENT_SECRET"), @@ -27,7 +26,7 @@ def on_login(e): print("Access token:", page.auth.token.access_token) page.on_login = on_login - page.add(ElevatedButton("Login with LinkedIn", on_click=login_click)) + page.add(ft.Button("Login with LinkedIn", on_click=login_click)) -flet.app(target=main, port=8550, view=flet.AppView.WEB_BROWSER) +ft.app(target=main, port=8550, view=ft.AppView.WEB_BROWSER) diff --git a/sdk/python/examples/apps/controls-gallery/examples/animations/animated_switcher/01_animatedswitcher_example.py b/sdk/python/examples/apps/controls-gallery/examples/animations/animated_switcher/01_animatedswitcher_example.py index a1996a5e57..5d914c00f7 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/animations/animated_switcher/01_animatedswitcher_example.py +++ b/sdk/python/examples/apps/controls-gallery/examples/animations/animated_switcher/01_animatedswitcher_example.py @@ -31,4 +31,4 @@ def animate(e): c.content = c2 if c.content == c1 else c1 c.update() - return ft.Column(controls=[c, ft.ElevatedButton("Animate!", on_click=animate)]) + return ft.Column(controls=[c, ft.Button("Animate!", on_click=animate)]) diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/cupertinodialogaction/01_cupertino_dialog_action_example.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/cupertinodialogaction/01_cupertino_dialog_action_example.py index 2422efbdce..03d7cd711c 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/cupertinodialogaction/01_cupertino_dialog_action_example.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/cupertinodialogaction/01_cupertino_dialog_action_example.py @@ -19,4 +19,4 @@ def dismiss_dialog(e): def open_dlg(e): e.control.page.show_dialog(cupertino_alert_dialog) - return ft.ElevatedButton("Open CupertinoAlertDialog", on_click=open_dlg) + return ft.Button("Open CupertinoAlertDialog", on_click=open_dlg) diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/01_basic_elevatedbuttons.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/01_basic_elevatedbuttons.py index 632d061e7f..c6e3954086 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/01_basic_elevatedbuttons.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/01_basic_elevatedbuttons.py @@ -1,12 +1,12 @@ import flet as ft -name = "Basic ElevatedButtons" +name = "Basic Buttons" def example(): return ft.Column( controls=[ - ft.ElevatedButton(content="Elevated button"), - ft.ElevatedButton("Disabled button", disabled=True), + ft.Button(content="Elevated button"), + ft.Button("Disabled button", disabled=True), ] ) diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/02_elevatedbuttons_with_icons.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/02_elevatedbuttons_with_icons.py index b147e48656..dbb6c8d03f 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/02_elevatedbuttons_with_icons.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/02_elevatedbuttons_with_icons.py @@ -1,13 +1,13 @@ import flet as ft -name = "ElevatedButtons with icons" +name = "Buttons with icons" def example(): return ft.Column( controls=[ - ft.ElevatedButton("Button with icon", icon="chair_outlined"), - ft.ElevatedButton( + ft.Button("Button with icon", icon="chair_outlined"), + ft.Button( "Button with colorful icon", icon="park_rounded", icon_color="green400", diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/03_elevatedbutton_with_click_event.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/03_elevatedbutton_with_click_event.py index 120d9c04fc..5f448b009b 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/03_elevatedbutton_with_click_event.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/03_elevatedbutton_with_click_event.py @@ -1,6 +1,6 @@ import flet as ft -name = "ElevatedButton with 'click' event" +name = "Button with 'click' event" def example(): @@ -9,7 +9,7 @@ def button_clicked(e): t.value = f"Button clicked {b.data} time(s)" t.update() - b = ft.ElevatedButton("Button with 'click' event", on_click=button_clicked, data=0) + b = ft.Button("Button with 'click' event", on_click=button_clicked, data=0) t = ft.Text() return ft.Column(controls=[b, t]) diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/04_elevatedbuttons_with_custom_content.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/04_elevatedbuttons_with_custom_content.py index 80787ccb84..a7074f02be 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/04_elevatedbuttons_with_custom_content.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/04_elevatedbuttons_with_custom_content.py @@ -1,12 +1,12 @@ import flet as ft -name = "ElevatedButtons with custom content" +name = "Buttons with custom content" def example(): return ft.Column( controls=[ - ft.ElevatedButton( + ft.Button( width=150, content=ft.Row( [ @@ -17,7 +17,7 @@ def example(): alignment=ft.MainAxisAlignment.SPACE_AROUND, ), ), - ft.ElevatedButton( + ft.Button( content=ft.Container( content=ft.Column( [ diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/05_elevatedbutton_with_url.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/05_elevatedbutton_with_url.py index c82df6651f..ce899d071e 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/05_elevatedbutton_with_url.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/05_elevatedbutton_with_url.py @@ -1,10 +1,10 @@ import flet as ft -name = "ElevatedButton with url" +name = "Button with url" def example(): - b = ft.ElevatedButton("Button with Google url", url="https://google.com") + b = ft.Button("Button with Google url", url="https://google.com") t = ft.Text() return ft.Column(controls=[b, t]) diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/06_elevatedbutton_style.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/06_elevatedbutton_style.py index aa53a59a7c..9ecb3f049d 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/06_elevatedbutton_style.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/06_elevatedbutton_style.py @@ -1,12 +1,10 @@ import flet as ft -name = ( - "ElevatedButton with style attributes configured for different ControlState values" -) +name = "Button with style attributes configured for different ControlState values" def example(): - return ft.ElevatedButton( + return ft.Button( "Styled button 1", style=ft.ButtonStyle( color={ @@ -14,10 +12,13 @@ def example(): ft.ControlState.FOCUSED: ft.Colors.BLUE, ft.ControlState.DEFAULT: ft.Colors.BLACK, }, - bgcolor={ft.ControlState.FOCUSED: ft.Colors.PINK_200, "": ft.Colors.YELLOW}, + bgcolor={ + ft.ControlState.FOCUSED: ft.Colors.PINK_200, + ft.ControlState.DEFAULT: ft.Colors.YELLOW, + }, padding={ft.ControlState.HOVERED: 20}, overlay_color=ft.Colors.TRANSPARENT, - elevation={"pressed": 0, "": 1}, + elevation={ft.ControlState.PRESSED: 0, ft.ControlState.DEFAULT: 1}, animation_duration=500, side={ ft.ControlState.DEFAULT: ft.BorderSide(1, ft.Colors.BLUE), diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/07_elevatedbutton_shapes.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/07_elevatedbutton_shapes.py index 2350a61d07..b817eae53b 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/07_elevatedbutton_shapes.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/07_elevatedbutton_shapes.py @@ -1,36 +1,36 @@ import flet as ft -name = "ElevatedButtons of different shapes" +name = "Buttons of different shapes" def example(): return ft.Column( controls=[ - ft.ElevatedButton( + ft.Button( "Stadium", style=ft.ButtonStyle( shape=ft.StadiumBorder(), ), ), - ft.ElevatedButton( + ft.Button( "Rounded rectangle", style=ft.ButtonStyle( shape=ft.RoundedRectangleBorder(radius=10), ), ), - ft.ElevatedButton( + ft.Button( "Continuous rectangle", style=ft.ButtonStyle( shape=ft.ContinuousRectangleBorder(radius=30), ), ), - ft.ElevatedButton( + ft.Button( "Beveled rectangle", style=ft.ButtonStyle( shape=ft.BeveledRectangleBorder(radius=10), ), ), - ft.ElevatedButton( + ft.Button( "Circle", style=ft.ButtonStyle(shape=ft.CircleBorder(), padding=30), ), diff --git a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/index.py b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/index.py index 9f143ba362..ff31cbffca 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/index.py +++ b/sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/index.py @@ -1,2 +1,4 @@ -name = "ElevatedButton" -description = """Elevated buttons are essentially filled tonal buttons with a shadow. To prevent shadow creep, only use them when absolutely necessary, such as when the button requires visual separation from a patterned background.""" +name = "Button" +description = """Elevated buttons are essentially filled tonal buttons with a shadow. " +"To prevent shadow creep, only use them when absolutely necessary, such as when " +"the button requires visual separation from a patterned background.""" diff --git a/sdk/python/examples/apps/controls-gallery/examples/charts/linechart/02_linechart_2.py b/sdk/python/examples/apps/controls-gallery/examples/charts/linechart/02_linechart_2.py index 4c1186d982..67723bc938 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/charts/linechart/02_linechart_2.py +++ b/sdk/python/examples/apps/controls-gallery/examples/charts/linechart/02_linechart_2.py @@ -133,4 +133,4 @@ def toggle_data(e): s.toggle = not s.toggle chart.update() - return ft.Column(controls=[ft.ElevatedButton("avg", on_click=toggle_data), chart]) + return ft.Column(controls=[ft.Button("avg", on_click=toggle_data), chart]) diff --git a/sdk/python/examples/apps/controls-gallery/examples/colors/controlcolors/03_nested_themes.py b/sdk/python/examples/apps/controls-gallery/examples/colors/controlcolors/03_nested_themes.py index 4d1d86c3d3..5bc2d54556 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/colors/controlcolors/03_nested_themes.py +++ b/sdk/python/examples/apps/controls-gallery/examples/colors/controlcolors/03_nested_themes.py @@ -14,7 +14,7 @@ def example(): [ # Outside container theme ft.Container( - content=ft.ElevatedButton("Outside Container theme button"), + content=ft.Button("Outside Container theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, @@ -22,7 +22,7 @@ def example(): # Inherited theme with primary color overridden ft.Container( theme=ft.Theme(color_scheme=ft.ColorScheme(primary=ft.Colors.PINK)), - content=ft.ElevatedButton("Inherited theme button"), + content=ft.Button("Inherited theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, @@ -31,7 +31,7 @@ def example(): ft.Container( theme=ft.Theme(color_scheme_seed=ft.Colors.INDIGO), theme_mode=ft.ThemeMode.DARK, - content=ft.ElevatedButton("Unique theme button"), + content=ft.Button("Unique theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, diff --git a/sdk/python/examples/apps/controls-gallery/examples/dialogs/alertdialog/01_basic_and_modal_dialogs.py b/sdk/python/examples/apps/controls-gallery/examples/dialogs/alertdialog/01_basic_and_modal_dialogs.py index 6daa4542d9..261b1cbf4d 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/dialogs/alertdialog/01_basic_and_modal_dialogs.py +++ b/sdk/python/examples/apps/controls-gallery/examples/dialogs/alertdialog/01_basic_and_modal_dialogs.py @@ -31,7 +31,7 @@ def open_dlg_modal(e): return ft.Column( [ - ft.ElevatedButton("Open dialog", on_click=open_dlg), - ft.ElevatedButton("Open modal dialog", on_click=open_dlg_modal), + ft.Button("Open dialog", on_click=open_dlg), + ft.Button("Open modal dialog", on_click=open_dlg_modal), ] ) diff --git a/sdk/python/examples/apps/controls-gallery/examples/dialogs/banner/01_banner_with_leading_icon_and_actions.py b/sdk/python/examples/apps/controls-gallery/examples/dialogs/banner/01_banner_with_leading_icon_and_actions.py index e6285277f5..9b55afc590 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/dialogs/banner/01_banner_with_leading_icon_and_actions.py +++ b/sdk/python/examples/apps/controls-gallery/examples/dialogs/banner/01_banner_with_leading_icon_and_actions.py @@ -11,7 +11,8 @@ def close_banner(e): bgcolor=ft.Colors.AMBER_100, leading=ft.Icon(ft.Icons.WARNING_AMBER_ROUNDED, color=ft.Colors.AMBER, size=40), content=ft.Text( - "Oops, there were some errors while trying to delete the file. What would you like me to do?" + "Oops, there were some errors while trying to delete the file. What would " + "you like me to do?" ), actions=[ ft.TextButton("Retry", on_click=close_banner), @@ -23,4 +24,4 @@ def close_banner(e): def show_banner_click(e): e.control.page.show_dialog(banner) - return ft.ElevatedButton("Show Banner", on_click=show_banner_click) + return ft.Button("Show Banner", on_click=show_banner_click) diff --git a/sdk/python/examples/apps/controls-gallery/examples/dialogs/bottomsheet/01_simple_bottomsheet.py b/sdk/python/examples/apps/controls-gallery/examples/dialogs/bottomsheet/01_simple_bottomsheet.py index 0ea57c886b..a2ded432d8 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/dialogs/bottomsheet/01_simple_bottomsheet.py +++ b/sdk/python/examples/apps/controls-gallery/examples/dialogs/bottomsheet/01_simple_bottomsheet.py @@ -4,7 +4,7 @@ def example(): - class Example(ft.ElevatedButton): + class Example(ft.Button): def __init__(self): super().__init__() self.content = "Display bottom sheet" @@ -14,9 +14,7 @@ def __init__(self): ft.Column( [ ft.Text("This is sheet's content!"), - ft.ElevatedButton( - "Close bottom sheet", on_click=self.close_bs - ), + ft.Button("Close bottom sheet", on_click=self.close_bs), ], tight=True, ), diff --git a/sdk/python/examples/apps/controls-gallery/examples/dialogs/cupertinoalertdialog/01_cupertino_alert_dialog_example.py b/sdk/python/examples/apps/controls-gallery/examples/dialogs/cupertinoalertdialog/01_cupertino_alert_dialog_example.py index 59cca24a35..7491cc2bf6 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/dialogs/cupertinoalertdialog/01_cupertino_alert_dialog_example.py +++ b/sdk/python/examples/apps/controls-gallery/examples/dialogs/cupertinoalertdialog/01_cupertino_alert_dialog_example.py @@ -19,4 +19,4 @@ def dismiss_dialog(e): def open_dlg(e): e.control.page.show_dialog(cupertino_alert_dialog) - return ft.ElevatedButton("Open CupertinoAlertDialog", on_click=open_dlg) + return ft.Button("Open CupertinoAlertDialog", on_click=open_dlg) diff --git a/sdk/python/examples/apps/controls-gallery/examples/dialogs/datepicker/01_date_picker_example.py b/sdk/python/examples/apps/controls-gallery/examples/dialogs/datepicker/01_date_picker_example.py index f192d71dc0..b9b3c6cb67 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/dialogs/datepicker/01_date_picker_example.py +++ b/sdk/python/examples/apps/controls-gallery/examples/dialogs/datepicker/01_date_picker_example.py @@ -18,7 +18,7 @@ def __init__(self): self.selected_date = ft.Text() self.controls = [ - ft.ElevatedButton( + ft.Button( "Pick date", icon=ft.Icons.CALENDAR_MONTH, on_click=self.open_date_picker, @@ -34,12 +34,14 @@ def change_date(self, e): self.selected_date.value = f"Selected date: {self.datepicker.value}" e.control.page.update() - # happens when example is added to the page (when user chooses the DatePicker control from the grid) + # happens when example is added to the page (when user chooses + # the DatePicker control from the grid) def did_mount(self): self.page.overlay.append(self.datepicker) self.page.update() - # happens when example is removed from the page (when user chooses different control group on the navigation rail) + # happens when example is removed from the page (when user chooses + # different control group on the navigation rail) def will_unmount(self): self.page.overlay.remove(self.datepicker) self.page.update() diff --git a/sdk/python/examples/apps/controls-gallery/examples/dialogs/snackbar/01_snackbar_with_dynamic_message.py b/sdk/python/examples/apps/controls-gallery/examples/dialogs/snackbar/01_snackbar_with_dynamic_message.py index 1cbc3ec41e..5b7599e2e4 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/dialogs/snackbar/01_snackbar_with_dynamic_message.py +++ b/sdk/python/examples/apps/controls-gallery/examples/dialogs/snackbar/01_snackbar_with_dynamic_message.py @@ -19,4 +19,4 @@ def on_click(e): d.counter += 1 e.control.page.update() - return ft.ElevatedButton("Open SnackBar", on_click=on_click) + return ft.Button("Open SnackBar", on_click=on_click) diff --git a/sdk/python/examples/apps/controls-gallery/examples/dialogs/timepicker/01_time_picker_example.py b/sdk/python/examples/apps/controls-gallery/examples/dialogs/timepicker/01_time_picker_example.py index 9f8de56022..633a89cb03 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/dialogs/timepicker/01_time_picker_example.py +++ b/sdk/python/examples/apps/controls-gallery/examples/dialogs/timepicker/01_time_picker_example.py @@ -16,7 +16,7 @@ def __init__(self): self.selected_time = ft.Text() self.controls = [ - ft.ElevatedButton( + ft.Button( "Pick time", icon=ft.Icons.CALENDAR_MONTH, on_click=self.open_time_picker, @@ -32,12 +32,14 @@ def change_time(self, e): self.selected_time.value = f"Selected time: {self.timepicker.value}" e.control.page.update() - # happens when example is added to the page (when user chooses the DatePicker control from the grid) + # happens when example is added to the page (when user chooses the DatePicker + # control from the grid) def did_mount(self): self.page.overlay.append(self.timepicker) self.page.update() - # happens when example is removed from the page (when user chooses different control group on the navigation rail) + # happens when example is removed from the page (when user choose + # different control group on the navigation rail) def will_unmount(self): self.page.overlay.remove(self.timepicker) self.page.update() diff --git a/sdk/python/examples/apps/controls-gallery/examples/input/checkbox/01_basic_checkboxes.py b/sdk/python/examples/apps/controls-gallery/examples/input/checkbox/01_basic_checkboxes.py index ef30465476..092ae37499 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/input/checkbox/01_basic_checkboxes.py +++ b/sdk/python/examples/apps/controls-gallery/examples/input/checkbox/01_basic_checkboxes.py @@ -5,7 +5,8 @@ def example(): def button_clicked(e): - t.value = f"Checkboxes values are: {c1.value}, {c2.value}, {c3.value}, {c4.value}, {c5.value}." + t.value = f"Checkboxes values are: {c1.value}, {c2.value}, {c3.value}, " + f"{c4.value}, {c5.value}." t.update() t = ft.Text() @@ -17,6 +18,6 @@ def button_clicked(e): label="Checkbox with rendered label_position='left'", label_position=ft.LabelPosition.LEFT, ) - b = ft.ElevatedButton(content="Submit", on_click=button_clicked) + b = ft.Button(content="Submit", on_click=button_clicked) return ft.Column(controls=[c1, c2, c3, c4, c5, b, t]) diff --git a/sdk/python/examples/apps/controls-gallery/examples/input/cupertinoradio/01_cupertino_radio_example.py b/sdk/python/examples/apps/controls-gallery/examples/input/cupertinoradio/01_cupertino_radio_example.py index 8021a260c6..0373f63798 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/input/cupertinoradio/01_cupertino_radio_example.py +++ b/sdk/python/examples/apps/controls-gallery/examples/input/cupertinoradio/01_cupertino_radio_example.py @@ -9,7 +9,7 @@ def button_clicked(e): t.update() t = ft.Text() - b = ft.ElevatedButton(content="Submit", on_click=button_clicked) + b = ft.Button(content="Submit", on_click=button_clicked) cg = ft.RadioGroup( content=ft.Column( [ @@ -30,7 +30,8 @@ def button_clicked(e): adaptive=True, active_color=ft.Colors.BLUE, tooltip=ft.Tooltip( - message="Adaptive Radio shows as CupertinoRadio on macOS and iOS and as Radio on other platforms" + message="Adaptive Radio shows as CupertinoRadio on macOS and " + "iOS and as Radio on other platforms" ), ), ] diff --git a/sdk/python/examples/apps/controls-gallery/examples/input/dropdown/01_basic_dropdown.py b/sdk/python/examples/apps/controls-gallery/examples/input/dropdown/01_basic_dropdown.py index 124f1fee88..f17757a1bf 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/input/dropdown/01_basic_dropdown.py +++ b/sdk/python/examples/apps/controls-gallery/examples/input/dropdown/01_basic_dropdown.py @@ -9,7 +9,7 @@ def button_clicked(e): t.update() t = ft.Text() - b = ft.ElevatedButton(content="Submit", on_click=button_clicked) + b = ft.Button(content="Submit", on_click=button_clicked) dd = ft.Dropdown( width=100, options=[ diff --git a/sdk/python/examples/apps/controls-gallery/examples/input/dropdown/03_add_items_to_dropdown_options.py b/sdk/python/examples/apps/controls-gallery/examples/input/dropdown/03_add_items_to_dropdown_options.py index 0bf7d83c4d..a1437ac8bf 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/input/dropdown/03_add_items_to_dropdown_options.py +++ b/sdk/python/examples/apps/controls-gallery/examples/input/dropdown/03_add_items_to_dropdown_options.py @@ -13,6 +13,6 @@ def add_clicked(e): d = ft.Dropdown() option_textbox = ft.TextField(hint_text="Enter item name") - add = ft.ElevatedButton("Add", on_click=add_clicked) + add = ft.Button("Add", on_click=add_clicked) return ft.Column(controls=[d, ft.Row(controls=[option_textbox, add])]) diff --git a/sdk/python/examples/apps/controls-gallery/examples/input/radio/01_basic_radiogroup.py b/sdk/python/examples/apps/controls-gallery/examples/input/radio/01_basic_radiogroup.py index 7392190d91..de3576e362 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/input/radio/01_basic_radiogroup.py +++ b/sdk/python/examples/apps/controls-gallery/examples/input/radio/01_basic_radiogroup.py @@ -9,7 +9,7 @@ def button_clicked(e): t.update() t = ft.Text() - b = ft.ElevatedButton(content="Submit", on_click=button_clicked) + b = ft.Button(content="Submit", on_click=button_clicked) cg = ft.RadioGroup( content=ft.Column( [ diff --git a/sdk/python/examples/apps/controls-gallery/examples/input/switch/01_basic_switches.py b/sdk/python/examples/apps/controls-gallery/examples/input/switch/01_basic_switches.py index e9877ab81b..90269e1681 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/input/switch/01_basic_switches.py +++ b/sdk/python/examples/apps/controls-gallery/examples/input/switch/01_basic_switches.py @@ -16,6 +16,6 @@ def button_clicked(e): label="Switch with rendered label_position='left'", label_position=ft.LabelPosition.LEFT, ) - b = ft.ElevatedButton(content="Submit", on_click=button_clicked) + b = ft.Button(content="Submit", on_click=button_clicked) return ft.Column(controls=[c1, c2, c3, c4, b, t]) diff --git a/sdk/python/examples/apps/controls-gallery/examples/input/textfield/01_basic_textfields.py b/sdk/python/examples/apps/controls-gallery/examples/input/textfield/01_basic_textfields.py index f3a1ec6a36..4ce871dc5a 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/input/textfield/01_basic_textfields.py +++ b/sdk/python/examples/apps/controls-gallery/examples/input/textfield/01_basic_textfields.py @@ -5,7 +5,8 @@ def example(): def button_clicked(e): - t.value = f"Textboxes values are: '{tb1.value}', '{tb2.value}', '{tb3.value}', '{tb4.value}', '{tb5.value}'." + t.value = f"Textboxes values are: '{tb1.value}', '{tb2.value}', " + f"'{tb3.value}', '{tb4.value}', '{tb5.value}'." t.update() t = ft.Text() @@ -14,6 +15,6 @@ def button_clicked(e): tb3 = ft.TextField(label="Read-only", read_only=True, value="Last name") tb4 = ft.TextField(label="With placeholder", hint_text="Please enter text here") tb5 = ft.TextField(label="With an icon", icon=ft.Icons.EMOJI_EMOTIONS) - b = ft.ElevatedButton(content="Submit", on_click=button_clicked) + b = ft.Button(content="Submit", on_click=button_clicked) return ft.Column(controls=[tb1, tb2, tb3, tb4, tb5, b, t]) diff --git a/sdk/python/examples/apps/controls-gallery/examples/layout/column/05_column_scroll_to.py b/sdk/python/examples/apps/controls-gallery/examples/layout/column/05_column_scroll_to.py index 00f03e54d6..fcf70cfc40 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/layout/column/05_column_scroll_to.py +++ b/sdk/python/examples/apps/controls-gallery/examples/layout/column/05_column_scroll_to.py @@ -61,19 +61,19 @@ async def scroll_to_d(_): ft.Text("Scroll to:"), ft.Row( [ - ft.ElevatedButton( + ft.Button( "Section A", on_click=scroll_to_a, ), - ft.ElevatedButton( + ft.Button( "Section B", on_click=scroll_to_b, ), - ft.ElevatedButton( + ft.Button( "Section C", on_click=scroll_to_c, ), - ft.ElevatedButton( + ft.Button( "Section D", on_click=scroll_to_d, ), diff --git a/sdk/python/examples/apps/controls-gallery/examples/layout/column/07_scrolling_column_programmatically.py b/sdk/python/examples/apps/controls-gallery/examples/layout/column/07_scrolling_column_programmatically.py index 058350fcef..7d4090769a 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/layout/column/07_scrolling_column_programmatically.py +++ b/sdk/python/examples/apps/controls-gallery/examples/layout/column/07_scrolling_column_programmatically.py @@ -37,18 +37,18 @@ async def scroll_to_minus_delta(e): return ft.Column( [ ft.Container(cl, border=ft.Border.all(1)), - ft.ElevatedButton("Scroll to offset 100", on_click=scroll_to_offset), + ft.Button("Scroll to offset 100", on_click=scroll_to_offset), ft.Row( [ - ft.ElevatedButton("Scroll to start", on_click=scroll_to_start), - ft.ElevatedButton("Scroll to end", on_click=scroll_to_end), + ft.Button("Scroll to start", on_click=scroll_to_start), + ft.Button("Scroll to end", on_click=scroll_to_end), ] ), - # ft.ElevatedButton("Scroll to key '20'", on_click=scroll_to_key), + # ft.Button("Scroll to key '20'", on_click=scroll_to_key), ft.Row( [ - ft.ElevatedButton("Scroll -40", on_click=scroll_to_minus_delta), - ft.ElevatedButton("Scroll +40", on_click=scroll_to_delta), + ft.Button("Scroll -40", on_click=scroll_to_minus_delta), + ft.Button("Scroll +40", on_click=scroll_to_delta), ] ), ] diff --git a/sdk/python/examples/apps/controls-gallery/examples/layout/container/03_animate_container.py b/sdk/python/examples/apps/controls-gallery/examples/layout/container/03_animate_container.py index 7221808cc2..93cfe029cb 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/layout/container/03_animate_container.py +++ b/sdk/python/examples/apps/controls-gallery/examples/layout/container/03_animate_container.py @@ -18,5 +18,5 @@ def animate_container(e): c.update() return ft.Column( - controls=[c, ft.ElevatedButton("Animate container", on_click=animate_container)] + controls=[c, ft.Button("Animate container", on_click=animate_container)] ) diff --git a/sdk/python/examples/apps/controls-gallery/examples/navigation/navigationdrawer/01_navigation_drawer_example.py b/sdk/python/examples/apps/controls-gallery/examples/navigation/navigationdrawer/01_navigation_drawer_example.py index 094a684e33..a3dc9ef229 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/navigation/navigationdrawer/01_navigation_drawer_example.py +++ b/sdk/python/examples/apps/controls-gallery/examples/navigation/navigationdrawer/01_navigation_drawer_example.py @@ -31,7 +31,7 @@ def open_drawer(e): return ft.Column( [ - ft.ElevatedButton("Open end drawer", on_click=open_end_drawer), - ft.ElevatedButton("Open drawer", on_click=open_drawer), + ft.Button("Open end drawer", on_click=open_end_drawer), + ft.Button("Open drawer", on_click=open_drawer), ] ) diff --git a/sdk/python/examples/apps/controls-gallery/examples/utility/audio/01_autoplay_audio.py b/sdk/python/examples/apps/controls-gallery/examples/utility/audio/01_autoplay_audio.py index bb9e3b931d..730c66f517 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/utility/audio/01_autoplay_audio.py +++ b/sdk/python/examples/apps/controls-gallery/examples/utility/audio/01_autoplay_audio.py @@ -16,17 +16,20 @@ def pause_audio(e): self.controls = [ ft.Text( - "This is an app with background audio. Note: this example doesn't work in Safari browser." + "This is an app with background audio. Note: this example " + "doesn't work in Safari browser." ), - ft.ElevatedButton("Stop playing", on_click=pause_audio), + ft.Button("Stop playing", on_click=pause_audio), ] - # happens when example is added to the page (when user chooses the Audio control from the grid) + # happens when example is added to the page (when user chooses + # the Audio control from the grid) def did_mount(self): self.page.overlay.append(self.audio1) self.page.update() - # happens when example is removed from the page (when user chooses different control group on the navigation rail) + # happens when example is removed from the page (when user chooses + # different control group on the navigation rail) def will_unmount(self): self.page.overlay.remove(self.audio1) self.page.update() diff --git a/sdk/python/examples/apps/controls-gallery/examples/utility/filepicker/01_pick_multiple_files.py b/sdk/python/examples/apps/controls-gallery/examples/utility/filepicker/01_pick_multiple_files.py index 1e09c156d4..c9ca41452f 100644 --- a/sdk/python/examples/apps/controls-gallery/examples/utility/filepicker/01_pick_multiple_files.py +++ b/sdk/python/examples/apps/controls-gallery/examples/utility/filepicker/01_pick_multiple_files.py @@ -14,7 +14,7 @@ def pick_files(_): self.pick_files_dialog.pick_files(allow_multiple=True) self.controls = [ - ft.ElevatedButton( + ft.Button( "Pick files", icon=ft.Icons.UPLOAD_FILE, on_click=pick_files, @@ -28,12 +28,14 @@ def pick_files_result(self, e: ft.FilePickerResultEvent): ) self.selected_files.update() - # happens when example is added to the page (when user chooses the FilePicker control from the grid) + # happens when example is added to the page (when user chooses + # the FilePicker control from the grid) def did_mount(self): self.page.overlay.append(self.pick_files_dialog) self.page.update() - # happens when example is removed from the page (when user chooses different control group on the navigation rail) + # happens when example is removed from the page (when user chooses + # different control group on the navigation rail) def will_unmount(self): self.page.overlay.remove(self.pick_files_dialog) self.page.update() diff --git a/sdk/python/examples/apps/desktop-window-manager/page_window.py b/sdk/python/examples/apps/desktop-window-manager/page_window.py index 9d819ddb9e..ba3db8eed6 100644 --- a/sdk/python/examples/apps/desktop-window-manager/page_window.py +++ b/sdk/python/examples/apps/desktop-window-manager/page_window.py @@ -1,8 +1,8 @@ import flet from flet import ( + Button, Column, Container, - ElevatedButton, IconButton, Page, Row, @@ -66,8 +66,8 @@ def resizable_changed(e): resizable = Switch(label="Resizable", value=True, on_change=resizable_changed) - maximize = ElevatedButton(text="Maximize", on_click=maximize_clicked) - minimize = ElevatedButton(text="Minimize", on_click=minimize_clicked) + maximize = Button(text="Maximize", on_click=maximize_clicked) + minimize = Button(text="Minimize", on_click=minimize_clicked) def width_changed(e): page.window.width = e.control.value diff --git a/sdk/python/examples/apps/flet-animation/main.py b/sdk/python/examples/apps/flet-animation/main.py index 46734197ee..7a1c80301a 100644 --- a/sdk/python/examples/apps/flet-animation/main.py +++ b/sdk/python/examples/apps/flet-animation/main.py @@ -1,36 +1,35 @@ import random from math import pi -import flet -from flet import Container, ElevatedButton, Page, Stack, colors +import flet as ft -def main(page: Page): +def main(page: ft.Page): size = 40 gap = 6 duration = 2000 - c1 = colors.PINK_500 - c2 = colors.AMBER_500 - c3 = colors.LIGHT_GREEN_500 - c4 = colors.DEEP_PURPLE_500 + c1 = ft.Colors.PINK_500 + c2 = ft.Colors.AMBER_500 + c3 = ft.Colors.LIGHT_GREEN_500 + c4 = ft.Colors.DEEP_PURPLE_500 all_colors = [ - colors.AMBER_400, - colors.AMBER_ACCENT_400, - colors.BLUE_400, - colors.BROWN_400, - colors.CYAN_700, - colors.DEEP_ORANGE_500, - colors.CYAN_500, - colors.INDIGO_600, - colors.ORANGE_ACCENT_100, - colors.PINK, - colors.RED_600, - colors.GREEN_400, - colors.GREEN_ACCENT_200, - colors.TEAL_ACCENT_200, - colors.LIGHT_BLUE_500, + ft.Colors.AMBER_400, + ft.Colors.AMBER_ACCENT_400, + ft.Colors.BLUE_400, + ft.Colors.BROWN_400, + ft.Colors.CYAN_700, + ft.Colors.DEEP_ORANGE_500, + ft.Colors.CYAN_500, + ft.Colors.INDIGO_600, + ft.Colors.ORANGE_ACCENT_100, + ft.Colors.PINK, + ft.Colors.RED_600, + ft.Colors.GREEN_400, + ft.Colors.GREEN_ACCENT_200, + ft.Colors.TEAL_ACCENT_200, + ft.Colors.LIGHT_BLUE_500, ] parts = [ @@ -76,7 +75,7 @@ def main(page: Page): width = 16 * (size + gap) height = 5 * (size + gap) - canvas = Stack( + canvas = ft.Stack( width=width, height=height, animate_scale=duration, @@ -84,9 +83,9 @@ def main(page: Page): ) # spread parts randomly - for i in range(len(parts)): + for _ in range(len(parts)): canvas.controls.append( - Container( + ft.Container( animate=duration, animate_position=duration, animate_rotation=duration, @@ -112,8 +111,7 @@ def randomize(e): page.update() def assemble(e): - i = 0 - for left, top, bgcolor in parts: + for i, (left, top, bgcolor) in enumerate(parts): c = canvas.controls[i] c.left = left * (size + gap) c.top = top * (size + gap) @@ -122,22 +120,21 @@ def assemble(e): c.height = size c.border_radius = 5 c.rotate = 0 - i += 1 canvas.scale = 1 canvas.opacity = 1 go_button.visible = False again_button.visible = True page.update() - go_button = ElevatedButton("Go!", on_click=assemble) - again_button = ElevatedButton("Again!", on_click=randomize) + go_button = ft.Button("Go!", on_click=assemble) + again_button = ft.Button("Again!", on_click=randomize) randomize(None) - page.horizontal_alignment = "center" - page.vertical_alignment = "center" + page.horizontal_alignment = ft.CrossAxisAlignment.CENTER + page.vertical_alignment = ft.MainAxisAlignment.CENTER page.spacing = 30 page.add(canvas, go_button, again_button) -flet.app(main) +ft.run(main) diff --git a/sdk/python/examples/apps/greeter/greeter.py b/sdk/python/examples/apps/greeter/greeter.py index 1083b30ddb..1fec7b5da5 100644 --- a/sdk/python/examples/apps/greeter/greeter.py +++ b/sdk/python/examples/apps/greeter/greeter.py @@ -13,7 +13,7 @@ def btn_click(e): txt_name = ft.TextField(label="Your name") - page.add(txt_name, ft.ElevatedButton("Say hello!", on_click=btn_click)) + page.add(txt_name, ft.Button("Say hello!", on_click=btn_click)) ft.run(main) diff --git a/sdk/python/examples/apps/routing-navigation/building-views-on-route-change.py b/sdk/python/examples/apps/routing-navigation/building-views-on-route-change.py index f1a2b118b8..ec1c603834 100644 --- a/sdk/python/examples/apps/routing-navigation/building-views-on-route-change.py +++ b/sdk/python/examples/apps/routing-navigation/building-views-on-route-change.py @@ -14,7 +14,7 @@ def route_change(e): route="/", controls=[ ft.AppBar(title=ft.Text("Flet app")), - ft.ElevatedButton("Go to settings", on_click=open_settings), + ft.Button("Go to settings", on_click=open_settings), ], ) ) @@ -28,7 +28,7 @@ def route_change(e): bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST, ), ft.Text("Settings!", theme_style=ft.TextThemeStyle.BODY_MEDIUM), - ft.ElevatedButton( + ft.Button( content="Go to mail settings", on_click=open_mail_settings, ), diff --git a/sdk/python/examples/apps/routing-navigation/home-store.py b/sdk/python/examples/apps/routing-navigation/home-store.py index 1fc32e5fbf..475a182eba 100644 --- a/sdk/python/examples/apps/routing-navigation/home-store.py +++ b/sdk/python/examples/apps/routing-navigation/home-store.py @@ -1,28 +1,31 @@ -import flet -from flet import AppBar, ElevatedButton, Page, Text, View, colors +import flet as ft -def main(page: Page): +def main(page: ft.Page): page.title = "Routes Example" def route_change(e): page.views.clear() page.views.append( - View( + ft.View( "/", [ - AppBar(title=Text("Flet app"), bgcolor=colors.SURFACE_VARIANT), - ElevatedButton("Visit Store", on_click=lambda _: page.go("/store")), + ft.AppBar( + title=ft.Text("Flet app"), bgcolor=ft.Colors.SURFACE_BRIGHT + ), + ft.Button("Visit Store", on_click=lambda _: page.go("/store")), ], ) ) if page.route == "/store": page.views.append( - View( + ft.View( "/store", [ - AppBar(title=Text("Store"), bgcolor=colors.SURFACE_VARIANT), - ElevatedButton("Go Home", on_click=lambda _: page.go("/")), + ft.AppBar( + title=ft.Text("Store"), bgcolor=ft.Colors.SURFACE_BRIGHT + ), + ft.Button("Go Home", on_click=lambda _: page.go("/")), ], ) ) @@ -39,4 +42,4 @@ def view_pop(e): page.go(page.route) -flet.app(main) +ft.run(main) diff --git a/sdk/python/examples/apps/studio-gallery/buttons.py b/sdk/python/examples/apps/studio-gallery/buttons.py index 017a024850..32d6269a7a 100644 --- a/sdk/python/examples/apps/studio-gallery/buttons.py +++ b/sdk/python/examples/apps/studio-gallery/buttons.py @@ -13,15 +13,16 @@ def example(page): ft.Text("Common buttons"), ft.IconButton( ft.Icons.INFO_OUTLINED, - tooltip="There are five types of common buttons: elevated, filled, filled tonal, outlined, and text", + tooltip="There are five types of common buttons: elevated, " + "filled, filled tonal, outlined, and text", ), ], alignment=ft.MainAxisAlignment.CENTER, ), ft.Row( controls=[ - ft.ElevatedButton(text="Elevated", expand=1), - ft.ElevatedButton(text="Elevated", disabled=True, expand=1), + ft.Button(text="Elevated", expand=1), + ft.Button(text="Elevated", disabled=True, expand=1), ], ), ft.Row( @@ -53,7 +54,8 @@ def example(page): ft.Text("Icon buttons"), ft.IconButton( ft.Icons.INFO_OUTLINED, - tooltip="Icon buttons help people take supplementary actions with a single tap", + tooltip="Icon buttons help people take supplementary actions " + "with a single tap", ), ], alignment=ft.MainAxisAlignment.CENTER, @@ -73,7 +75,8 @@ def example(page): ft.Text("Floating action buttons"), ft.IconButton( ft.Icons.INFO_OUTLINED, - tooltip="The FAB represents the most important action on a screen. It puts key actions within reach", + tooltip="The FAB represents the most important action " + "on a screen. It puts key actions within reach", ), ], alignment=ft.MainAxisAlignment.CENTER, @@ -96,8 +99,8 @@ def example(page): def main(page: ft.Page): page.title = "Flet buttons example" - page.window_width = 390 - page.window_height = 844 + page.window.width = 390 + page.window.height = 844 page.add(example(page)) diff --git a/sdk/python/examples/apps/studio-gallery/calculator.py b/sdk/python/examples/apps/studio-gallery/calculator.py index 54a63acff5..f96d7df33d 100644 --- a/sdk/python/examples/apps/studio-gallery/calculator.py +++ b/sdk/python/examples/apps/studio-gallery/calculator.py @@ -1,64 +1,63 @@ import flet as ft from flet import ( + Button, + Colors, Column, Container, - ElevatedButton, Row, Text, - UserControl, border_radius, - colors, ) -class CalculatorApp(UserControl): +class CalculatorApp(Container): def build(self): self.reset() - self.result = Text(value="0", color=colors.WHITE, size=20) + self.result = Text(value="0", color=Colors.WHITE, size=20) # application's root control (i.e. "view") containing all other controls - return Container( + self.content = Container( # width=300, - bgcolor=colors.BLACK, + bgcolor=Colors.BLACK, border_radius=border_radius.all(20), padding=20, content=Column( controls=[ - Row(controls=[self.result], alignment="end"), + Row(controls=[self.result], alignment=ft.MainAxisAlignment.END), Row( controls=[ - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="AC", - bgcolor=colors.BLUE_GREY_100, - color=colors.BLACK, + content="AC", + bgcolor=Colors.BLUE_GREY_100, + color=Colors.BLACK, expand=1, on_click=self.button_clicked, data="AC", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="+/-", - bgcolor=colors.BLUE_GREY_100, - color=colors.BLACK, + content="+/-", + bgcolor=Colors.BLUE_GREY_100, + color=Colors.BLACK, expand=1, on_click=self.button_clicked, data="+/-", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="%", - bgcolor=colors.BLUE_GREY_100, - color=colors.BLACK, + content="%", + bgcolor=Colors.BLUE_GREY_100, + color=Colors.BLACK, expand=1, on_click=self.button_clicked, data="%", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="/", - bgcolor=colors.ORANGE, - color=colors.WHITE, + content="/", + bgcolor=Colors.ORANGE, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="/", @@ -67,38 +66,38 @@ def build(self): ), Row( controls=[ - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="7", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="7", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="7", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="8", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="8", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="8", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="9", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="9", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="9", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="*", - bgcolor=colors.ORANGE, - color=colors.WHITE, + content="*", + bgcolor=Colors.ORANGE, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="*", @@ -107,38 +106,38 @@ def build(self): ), Row( controls=[ - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="4", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="4", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="4", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="5", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="5", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="5", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="6", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="6", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="6", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="-", - bgcolor=colors.ORANGE, - color=colors.WHITE, + content="-", + bgcolor=Colors.ORANGE, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="-", @@ -147,38 +146,38 @@ def build(self): ), Row( controls=[ - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="1", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="1", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="1", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="2", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="2", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="2", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="3", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="3", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="3", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="+", - bgcolor=colors.ORANGE, - color=colors.WHITE, + content="+", + bgcolor=Colors.ORANGE, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="+", @@ -187,29 +186,29 @@ def build(self): ), Row( controls=[ - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="0", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content="0", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=2, on_click=self.button_clicked, data="0", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text=".", - bgcolor=colors.WHITE24, - color=colors.WHITE, + content=".", + bgcolor=Colors.WHITE24, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data=".", ), - ElevatedButton( + Button( style=ft.ButtonStyle(padding=0), - text="=", - bgcolor=colors.ORANGE, - color=colors.WHITE, + content="=", + bgcolor=Colors.ORANGE, + color=Colors.WHITE, expand=1, on_click=self.button_clicked, data="=", @@ -227,7 +226,7 @@ def button_clicked(self, e): self.reset() elif data in ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "."): - if self.result.value == "0" or self.new_operand == True: + if self.result.value == "0" or self.new_operand: self.result.value = data self.new_operand = False else: diff --git a/sdk/python/examples/apps/studio-gallery/flet_animation.py b/sdk/python/examples/apps/studio-gallery/flet_animation.py index 8134f93ba3..f88f0b7187 100644 --- a/sdk/python/examples/apps/studio-gallery/flet_animation.py +++ b/sdk/python/examples/apps/studio-gallery/flet_animation.py @@ -2,7 +2,6 @@ from math import pi import flet as ft -from flet import Container, ElevatedButton, Stack, colors def example(page): @@ -10,27 +9,27 @@ def example(page): gap = 3 duration = 2000 - c1 = colors.PINK_500 - c2 = colors.AMBER_500 - c3 = colors.LIGHT_GREEN_500 - c4 = colors.DEEP_PURPLE_500 + c1 = ft.Colors.PINK_500 + c2 = ft.Colors.AMBER_500 + c3 = ft.Colors.LIGHT_GREEN_500 + c4 = ft.Colors.DEEP_PURPLE_500 all_colors = [ - colors.AMBER_400, - colors.AMBER_ACCENT_400, - colors.BLUE_400, - colors.BROWN_400, - colors.CYAN_700, - colors.DEEP_ORANGE_500, - colors.CYAN_500, - colors.INDIGO_600, - colors.ORANGE_ACCENT_100, - colors.PINK, - colors.RED_600, - colors.GREEN_400, - colors.GREEN_ACCENT_200, - colors.TEAL_ACCENT_200, - colors.LIGHT_BLUE_500, + ft.Colors.AMBER_400, + ft.Colors.AMBER_ACCENT_400, + ft.Colors.BLUE_400, + ft.Colors.BROWN_400, + ft.Colors.CYAN_700, + ft.Colors.DEEP_ORANGE_500, + ft.Colors.CYAN_500, + ft.Colors.INDIGO_600, + ft.Colors.ORANGE_ACCENT_100, + ft.Colors.PINK, + ft.Colors.RED_600, + ft.Colors.GREEN_400, + ft.Colors.GREEN_ACCENT_200, + ft.Colors.TEAL_ACCENT_200, + ft.Colors.LIGHT_BLUE_500, ] parts = [ @@ -77,7 +76,7 @@ def example(page): # height = 5 * (size + gap) height = 15 * (size + gap) - canvas = Stack( + canvas = ft.Stack( width=width, height=height, animate_scale=duration, @@ -85,9 +84,9 @@ def example(page): ) # spread parts randomly - for i in range(len(parts)): + for _ in range(len(parts)): canvas.controls.append( - Container( + ft.Container( animate=duration, animate_position=duration, animate_rotation=duration, @@ -113,8 +112,7 @@ def randomize(e): page.update() def assemble(e): - i = 0 - for left, top, bgcolor in parts: + for i, (left, top, bgcolor) in enumerate(parts): c = canvas.controls[i] c.left = left * (size + gap) c.top = top * (size + gap) @@ -123,33 +121,20 @@ def assemble(e): c.height = size c.border_radius = 5 c.rotate = 0 - i += 1 canvas.scale = 1 canvas.opacity = 1 go_button.visible = False again_button.visible = True page.update() - go_button = ElevatedButton("Go!", on_click=assemble, visible=True) - again_button = ElevatedButton("Again!", on_click=randomize, visible=False) + go_button = ft.Button("Go!", on_click=assemble, visible=True) + again_button = ft.Button("Again!", on_click=randomize, visible=False) randomize(None) - # return ft.Column( - # expand=True, - # alignment=ft.MainAxisAlignment.CENTER, - # horizontal_alignment=ft.CrossAxisAlignment.CENTER, - # tight=True, - # controls=[ - # canvas, - # go_button, - # again_button, - # ], - # ) - return ft.Container( expand=True, - alignment=ft.alignment.center, + alignment=ft.Alignment.CENTER, content=ft.Column( alignment=ft.MainAxisAlignment.CENTER, horizontal_alignment=ft.CrossAxisAlignment.CENTER, @@ -168,8 +153,8 @@ def main(page: ft.Page): # page.horizontal_alignment = "center" # page.vertical_alignment = "center" page.spacing = 30 - page.window_width = 390 - page.window_height = 844 + page.window.width = 390 + page.window.height = 844 page.add(example(page=page)) diff --git a/sdk/python/examples/apps/trolli/src/board.py b/sdk/python/examples/apps/trolli/src/board.py index 5ac8888384..212e9b3784 100644 --- a/sdk/python/examples/apps/trolli/src/board.py +++ b/sdk/python/examples/apps/trolli/src/board.py @@ -1,9 +1,10 @@ import itertools -import flet as ft from board_list import BoardList from data_store import DataStore +import flet as ft + class Board(ft.Container): id_counter = itertools.count() @@ -102,7 +103,7 @@ def textfield_change(e): dialog_text = ft.TextField( label="New List Name", on_submit=close_dlg, on_change=textfield_change ) - create_button = ft.ElevatedButton( + create_button = ft.Button( text="Create", bgcolor=ft.Colors.BLUE_200, on_click=close_dlg, disabled=True ) dialog = ft.AlertDialog( @@ -115,7 +116,7 @@ def textfield_change(e): color_options, ft.Row( [ - ft.ElevatedButton(text="Cancel", on_click=close_dlg), + ft.Button(text="Cancel", on_click=close_dlg), create_button, ], alignment=ft.MainAxisAlignment.SPACE_BETWEEN, diff --git a/sdk/python/examples/apps/trolli/src/main.py b/sdk/python/examples/apps/trolli/src/main.py index 10620511af..5b3bed25db 100644 --- a/sdk/python/examples/apps/trolli/src/main.py +++ b/sdk/python/examples/apps/trolli/src/main.py @@ -1,10 +1,11 @@ -import flet as ft from app_layout import AppLayout from board import Board from data_store import DataStore from memory_store import InMemoryStore from user import User +import flet as ft + class TrelloApp(AppLayout): def __init__(self, page: ft.Page, store: DataStore): @@ -92,7 +93,7 @@ async def close_dlg(e): [ user_name, password, - ft.ElevatedButton(text="Login", on_click=close_dlg), + ft.Button(text="Login", on_click=close_dlg), ], tight=True, ), @@ -134,7 +135,7 @@ def textfield_change(e): dialog_text = ft.TextField( label="New Board Name", on_submit=close_dlg, on_change=textfield_change ) - create_button = ft.ElevatedButton( + create_button = ft.Button( text="Create", bgcolor=ft.Colors.BLUE_200, on_click=close_dlg, disabled=True ) dialog = ft.AlertDialog( @@ -144,7 +145,7 @@ def textfield_change(e): dialog_text, ft.Row( [ - ft.ElevatedButton(text="Cancel", on_click=close_dlg), + ft.Button(text="Cancel", on_click=close_dlg), create_button, ], alignment=ft.MainAxisAlignment.SPACE_BETWEEN, diff --git a/sdk/python/examples/controls/alert_dialog/modal_and_non_modal.py b/sdk/python/examples/controls/alert_dialog/modal_and_non_modal.py index c6b5b77b4d..42aba9d674 100644 --- a/sdk/python/examples/controls/alert_dialog/modal_and_non_modal.py +++ b/sdk/python/examples/controls/alert_dialog/modal_and_non_modal.py @@ -25,11 +25,11 @@ def main(page: ft.Page): ) page.add( - ft.ElevatedButton( + ft.Button( content="Open dialog", on_click=lambda e: page.show_dialog(dialog), ), - ft.ElevatedButton( + ft.Button( content="Open modal dialog", on_click=lambda e: page.show_dialog(modal_dialog), ), diff --git a/sdk/python/examples/controls/animated_switcher/image_switch.py b/sdk/python/examples/controls/animated_switcher/image_switch.py index 5ececc3358..57dd38a392 100644 --- a/sdk/python/examples/controls/animated_switcher/image_switch.py +++ b/sdk/python/examples/controls/animated_switcher/image_switch.py @@ -4,7 +4,7 @@ def main(page: ft.Page): - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): switcher.content = ft.Image( src=f"https://picsum.photos/200/300?{time.time()}", width=200, @@ -25,7 +25,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): switch_in_curve=ft.AnimationCurve.BOUNCE_OUT, switch_out_curve=ft.AnimationCurve.BOUNCE_IN, ), - ft.ElevatedButton("Animate!", on_click=animate), + ft.Button("Animate!", on_click=animate), ) diff --git a/sdk/python/examples/controls/animated_switcher/image_switch_buffered.py b/sdk/python/examples/controls/animated_switcher/image_switch_buffered.py index 554b4f456c..255798be14 100644 --- a/sdk/python/examples/controls/animated_switcher/image_switch_buffered.py +++ b/sdk/python/examples/controls/animated_switcher/image_switch_buffered.py @@ -1,9 +1,10 @@ import base64 import time -import flet as ft import httpx +import flet as ft + class BufferingSwitcher(ft.AnimatedSwitcher): image_queue = [] @@ -62,7 +63,7 @@ def main(page: ft.Page): page.add( switcher, - ft.ElevatedButton("Animate!", on_click=switcher.animate), + ft.Button("Animate!", on_click=switcher.animate), ) diff --git a/sdk/python/examples/controls/animated_switcher/scale_effect.py b/sdk/python/examples/controls/animated_switcher/scale_effect.py index aeaa9620aa..eeef63638f 100644 --- a/sdk/python/examples/controls/animated_switcher/scale_effect.py +++ b/sdk/python/examples/controls/animated_switcher/scale_effect.py @@ -42,9 +42,9 @@ def rotate(e): page.add( switcher, - ft.ElevatedButton("Scale", on_click=scale), - ft.ElevatedButton("Fade", on_click=fade), - ft.ElevatedButton("Rotate", on_click=rotate), + ft.Button("Scale", on_click=scale), + ft.Button("Fade", on_click=fade), + ft.Button("Rotate", on_click=rotate), ) diff --git a/sdk/python/examples/controls/app_bar/theme_and_material_mode_toggles.py b/sdk/python/examples/controls/app_bar/theme_and_material_mode_toggles.py index 7a3e6ca8b5..b2eda194b8 100644 --- a/sdk/python/examples/controls/app_bar/theme_and_material_mode_toggles.py +++ b/sdk/python/examples/controls/app_bar/theme_and_material_mode_toggles.py @@ -94,10 +94,17 @@ def toggle_material(e: ft.Event[ft.IconButton]): ) page.add( ft.Text( - value="Flet is a framework that allows building web, desktop and mobile applications in Python without prior experience in frontend development.You can build a UI for your program with Flet controls which are based on Flutter by Google. Flet goes beyond merely wrapping Flutter widgets. It adds its own touch by combining smaller widgets, simplifying complexities, implementing UI best practices, and applying sensible defaults. This ensures that your applications look stylish and polished without requiring additional design efforts on your part.", + value="Flet is a framework that allows building web, desktop and mobile " + "applications in Python without prior experience in frontend development." + "You can build a UI for your program with Flet controls which are based " + "on Flutter by Google. Flet goes beyond merely wrapping Flutter widgets. " + "It adds its own touch by combining smaller widgets, simplifying " + "complexities, implementing UI best practices, and applying sensible " + "defaults. This ensures that your applications look stylish and polished " + "without requiring additional design efforts on your part.", text_align=ft.TextAlign.END, ), - ft.ElevatedButton("Click me!"), + ft.Button("Click me!"), ) diff --git a/sdk/python/examples/controls/banner/basic.py b/sdk/python/examples/controls/banner/basic.py index f9fc7c4f3f..b9512478d6 100644 --- a/sdk/python/examples/controls/banner/basic.py +++ b/sdk/python/examples/controls/banner/basic.py @@ -6,14 +6,15 @@ def main(page: ft.Page): def handle_banner_close(e: ft.Event[ft.TextButton]): page.pop_dialog() - page.add(ft.Text("Action clicked: " + e.control.content)) + page.add(ft.Text("Action clicked: " + e.control.data)) action_button_style = ft.ButtonStyle(color=ft.Colors.BLUE) banner = ft.Banner( bgcolor=ft.Colors.AMBER_100, leading=ft.Icon(ft.Icons.WARNING_AMBER_ROUNDED, color=ft.Colors.AMBER, size=40), content=ft.Text( - value="Oops, there were some errors while trying to delete the file. What would you like to do?", + value="Oops, there were some errors while trying to delete the file. " + "What would you like to do?", color=ft.Colors.BLACK, ), actions=[ @@ -21,23 +22,24 @@ def handle_banner_close(e: ft.Event[ft.TextButton]): content="Retry", style=action_button_style, on_click=handle_banner_close, + data="retry", ), ft.TextButton( content="Ignore", style=action_button_style, on_click=handle_banner_close, + data="ignore", ), ft.TextButton( content="Cancel", style=action_button_style, on_click=handle_banner_close, + data="cancel", ), ], ) - page.add( - ft.ElevatedButton("Show Banner", on_click=lambda e: page.show_dialog(banner)) - ) + page.add(ft.Button("Show Banner", on_click=lambda e: page.show_dialog(banner))) ft.run(main) diff --git a/sdk/python/examples/controls/bottom_sheet/basic.py b/sdk/python/examples/controls/bottom_sheet/basic.py index bc68ded0e8..076fad7954 100644 --- a/sdk/python/examples/controls/bottom_sheet/basic.py +++ b/sdk/python/examples/controls/bottom_sheet/basic.py @@ -17,14 +17,14 @@ def handle_sheet_dismissal(e: ft.Event[ft.BottomSheet]): tight=True, controls=[ ft.Text("Here is a bottom sheet!"), - ft.ElevatedButton("Dismiss", on_click=lambda _: page.pop_dialog()), + ft.Button("Dismiss", on_click=lambda _: page.pop_dialog()), ], ), ), ) page.overlay.append(sheet) page.add( - ft.ElevatedButton( + ft.Button( content="Display bottom sheet", on_click=lambda e: page.show_dialog(sheet), ) diff --git a/sdk/python/examples/controls/bursting_flet.py b/sdk/python/examples/controls/bursting_flet.py index 43c1b889f5..b066355bbe 100644 --- a/sdk/python/examples/controls/bursting_flet.py +++ b/sdk/python/examples/controls/bursting_flet.py @@ -5,7 +5,7 @@ def main(page: ft.Page): page.vertical_alignment = ft.MainAxisAlignment.CENTER page.horizontal_alignment = ft.CrossAxisAlignment.CENTER - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): image.scale = 30 image.opacity = 0 image.update() @@ -23,7 +23,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): opacity=1.0, animate_opacity=ft.Animation(300, ft.AnimationCurve.EASE_IN_QUINT), ), - ft.ElevatedButton("Boom!", on_click=animate), + ft.Button("Boom!", on_click=animate), ], ) ) diff --git a/sdk/python/examples/controls/elevated_button/animate_on_hover.py b/sdk/python/examples/controls/button/animate_on_hover.py similarity index 85% rename from sdk/python/examples/controls/elevated_button/animate_on_hover.py rename to sdk/python/examples/controls/button/animate_on_hover.py index 138b15b0c9..7853be9c98 100644 --- a/sdk/python/examples/controls/elevated_button/animate_on_hover.py +++ b/sdk/python/examples/controls/button/animate_on_hover.py @@ -2,12 +2,12 @@ def main(page: ft.Page): - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): e.control.rotate = 0.1 if e.data else 0 page.update() page.add( - ft.ElevatedButton( + ft.Button( content="Hover over me, I'm animated!", rotate=0, animate_rotation=100, diff --git a/sdk/python/examples/controls/button/basic.py b/sdk/python/examples/controls/button/basic.py new file mode 100644 index 0000000000..f5b8278799 --- /dev/null +++ b/sdk/python/examples/controls/button/basic.py @@ -0,0 +1,13 @@ +import flet as ft + + +def main(page: ft.Page): + page.title = "Button Example" + + page.add( + ft.Button(content="Elevated button"), + ft.Button(content="Disabled button", disabled=True), + ) + + +ft.run(main) diff --git a/sdk/python/examples/controls/elevated_button/button_shapes.py b/sdk/python/examples/controls/button/button_shapes.py similarity index 84% rename from sdk/python/examples/controls/elevated_button/button_shapes.py rename to sdk/python/examples/controls/button/button_shapes.py index e6d917b8ac..0d6be75e18 100644 --- a/sdk/python/examples/controls/elevated_button/button_shapes.py +++ b/sdk/python/examples/controls/button/button_shapes.py @@ -6,23 +6,23 @@ def main(page: ft.Page): page.spacing = 30 page.add( - ft.ElevatedButton( + ft.Button( content="Stadium", style=ft.ButtonStyle(shape=ft.StadiumBorder()), ), - ft.ElevatedButton( + ft.Button( content="Rounded rectangle", style=ft.ButtonStyle(shape=ft.RoundedRectangleBorder(radius=10)), ), - ft.ElevatedButton( + ft.Button( content="Continuous rectangle", style=ft.ButtonStyle(shape=ft.ContinuousRectangleBorder(radius=30)), ), - ft.ElevatedButton( + ft.Button( content="Beveled rectangle", style=ft.ButtonStyle(shape=ft.BeveledRectangleBorder(radius=10)), ), - ft.ElevatedButton( + ft.Button( content="Circle", style=ft.ButtonStyle(shape=ft.CircleBorder(), padding=30), ), diff --git a/sdk/python/examples/controls/elevated_button/custom_content.py b/sdk/python/examples/controls/button/custom_content.py similarity index 90% rename from sdk/python/examples/controls/elevated_button/custom_content.py rename to sdk/python/examples/controls/button/custom_content.py index 2a2594be9e..979faa15a2 100644 --- a/sdk/python/examples/controls/elevated_button/custom_content.py +++ b/sdk/python/examples/controls/button/custom_content.py @@ -2,10 +2,10 @@ def main(page: ft.Page): - page.title = "ElevatedButton Example" + page.title = "Button Example" page.add( - ft.ElevatedButton( + ft.Button( width=150, content=ft.Row( alignment=ft.MainAxisAlignment.SPACE_AROUND, @@ -16,7 +16,7 @@ def main(page: ft.Page): ], ), ), - ft.ElevatedButton( + ft.Button( content=ft.Container( padding=ft.Padding.all(10), content=ft.Column( diff --git a/sdk/python/examples/controls/elevated_button/handling_clicks.py b/sdk/python/examples/controls/button/handling_clicks.py similarity index 73% rename from sdk/python/examples/controls/elevated_button/handling_clicks.py rename to sdk/python/examples/controls/button/handling_clicks.py index 771fc90cda..de83e15fd2 100644 --- a/sdk/python/examples/controls/elevated_button/handling_clicks.py +++ b/sdk/python/examples/controls/button/handling_clicks.py @@ -2,16 +2,16 @@ def main(page: ft.Page): - page.title = "ElevatedButton Example" + page.title = "Button Example" page.theme_mode = ft.ThemeMode.LIGHT - def button_clicked(e: ft.Event[ft.ElevatedButton]): + def button_clicked(e: ft.Event[ft.Button]): button.data += 1 message.value = f"Button clicked {button.data} time(s)" page.update() page.add( - button := ft.ElevatedButton( + button := ft.Button( content="Button with 'click' event", data=0, on_click=button_clicked, diff --git a/sdk/python/examples/controls/elevated_button/icons.py b/sdk/python/examples/controls/button/icons.py similarity index 59% rename from sdk/python/examples/controls/elevated_button/icons.py rename to sdk/python/examples/controls/button/icons.py index 990d835e75..12f3ba15fe 100644 --- a/sdk/python/examples/controls/elevated_button/icons.py +++ b/sdk/python/examples/controls/button/icons.py @@ -2,11 +2,11 @@ def main(page: ft.Page): - page.title = "ElevatedButton Example" + page.title = "Button Example" page.add( - ft.ElevatedButton(content="Button with icon", icon=ft.Icons.WAVES_ROUNDED), - ft.ElevatedButton( + ft.Button(content="Button with icon", icon=ft.Icons.WAVES_ROUNDED), + ft.Button( content="Button with colorful icon", icon=ft.Icons.PARK_ROUNDED, icon_color=ft.Colors.GREEN_400, diff --git a/sdk/python/examples/controls/elevated_button/media/adaptive.png b/sdk/python/examples/controls/button/media/adaptive.png similarity index 100% rename from sdk/python/examples/controls/elevated_button/media/adaptive.png rename to sdk/python/examples/controls/button/media/adaptive.png diff --git a/sdk/python/examples/controls/elevated_button/media/basic.png b/sdk/python/examples/controls/button/media/basic.png similarity index 100% rename from sdk/python/examples/controls/elevated_button/media/basic.png rename to sdk/python/examples/controls/button/media/basic.png diff --git a/sdk/python/examples/controls/elevated_button/media/custom_content.png b/sdk/python/examples/controls/button/media/custom_content.png similarity index 100% rename from sdk/python/examples/controls/elevated_button/media/custom_content.png rename to sdk/python/examples/controls/button/media/custom_content.png diff --git a/sdk/python/examples/controls/elevated_button/media/handling_clicks.gif b/sdk/python/examples/controls/button/media/handling_clicks.gif similarity index 100% rename from sdk/python/examples/controls/elevated_button/media/handling_clicks.gif rename to sdk/python/examples/controls/button/media/handling_clicks.gif diff --git a/sdk/python/examples/controls/elevated_button/media/icons.png b/sdk/python/examples/controls/button/media/icons.png similarity index 100% rename from sdk/python/examples/controls/elevated_button/media/icons.png rename to sdk/python/examples/controls/button/media/icons.png diff --git a/sdk/python/examples/controls/elevated_button/media/index.png b/sdk/python/examples/controls/button/media/index.png similarity index 100% rename from sdk/python/examples/controls/elevated_button/media/index.png rename to sdk/python/examples/controls/button/media/index.png diff --git a/sdk/python/examples/controls/elevated_button/styling.py b/sdk/python/examples/controls/button/styling.py similarity index 98% rename from sdk/python/examples/controls/elevated_button/styling.py rename to sdk/python/examples/controls/button/styling.py index 05c94e5c04..d805a2b02a 100644 --- a/sdk/python/examples/controls/elevated_button/styling.py +++ b/sdk/python/examples/controls/button/styling.py @@ -6,7 +6,7 @@ def main(page: ft.Page): page.theme_mode = ft.ThemeMode.LIGHT page.add( - ft.ElevatedButton( + ft.Button( content="Styled button 1", style=ft.ButtonStyle( color={ diff --git a/sdk/python/examples/controls/checkbox/basic.py b/sdk/python/examples/controls/checkbox/basic.py index e46b30e151..fbcc76dd6e 100644 --- a/sdk/python/examples/controls/checkbox/basic.py +++ b/sdk/python/examples/controls/checkbox/basic.py @@ -2,8 +2,9 @@ def main(page: ft.Page): - def handle_button_click(e: ft.Event[ft.ElevatedButton]): - message.value = f"Checkboxes values are: {c1.value}, {c2.value}, {c3.value}, {c4.value}, {c5.value}." + def handle_button_click(e: ft.Event[ft.Button]): + message.value = f"Checkboxes values are: {c1.value}, {c2.value}, {c3.value}, " + f"{c4.value}, {c5.value}." page.update() page.add( @@ -17,7 +18,7 @@ def handle_button_click(e: ft.Event[ft.ElevatedButton]): label="Checkbox with LEFT label_position", label_position=ft.LabelPosition.LEFT, ), - ft.ElevatedButton(content="Submit", on_click=handle_button_click), + ft.Button(content="Submit", on_click=handle_button_click), message := ft.Text(), ) diff --git a/sdk/python/examples/controls/column/programmatic_scroll.py b/sdk/python/examples/controls/column/programmatic_scroll.py index 329e6ef7e0..7b5c15e5a0 100644 --- a/sdk/python/examples/controls/column/programmatic_scroll.py +++ b/sdk/python/examples/controls/column/programmatic_scroll.py @@ -34,18 +34,18 @@ async def scroll_to_minus_delta(e): page.add( ft.Container(content=column, border=ft.Border.all(1)), - ft.ElevatedButton("Scroll to offset 500", on_click=scroll_to_offset), + ft.Button("Scroll to offset 500", on_click=scroll_to_offset), ft.Row( controls=[ - ft.ElevatedButton("Scroll -100", on_click=scroll_to_minus_delta), - ft.ElevatedButton("Scroll +100", on_click=scroll_to_delta), + ft.Button("Scroll -100", on_click=scroll_to_minus_delta), + ft.Button("Scroll +100", on_click=scroll_to_delta), ] ), - ft.ElevatedButton("Scroll to key '20'", on_click=scroll_to_key), + ft.Button("Scroll to key '20'", on_click=scroll_to_key), ft.Row( controls=[ - ft.ElevatedButton("Scroll to start", on_click=scroll_to_start), - ft.ElevatedButton("Scroll to end", on_click=scroll_to_end), + ft.Button("Scroll to start", on_click=scroll_to_start), + ft.Button("Scroll to end", on_click=scroll_to_end), ] ), ) diff --git a/sdk/python/examples/controls/column/scroll.py b/sdk/python/examples/controls/column/scroll.py index 16af3a0372..f1f66404d4 100644 --- a/sdk/python/examples/controls/column/scroll.py +++ b/sdk/python/examples/controls/column/scroll.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def add_text_box(e: ft.Event[ft.ElevatedButton]): + def add_text_box(e: ft.Event[ft.Button]): text_field = ft.TextField( label=f"Text Box {len(left_column.controls)}", label_style=ft.TextStyle(color=ft.Colors.GREEN), @@ -12,27 +12,26 @@ def add_text_box(e: ft.Event[ft.ElevatedButton]): left_column.controls.append(text_field) page.update() - def remove_text_box(e: ft.Event[ft.ElevatedButton]): + def remove_text_box(e: ft.Event[ft.Button]): if left_column.controls: left_column.controls.pop() page.update() def scroll_generator(scroll_mode_list: list): while True: - for mode in scroll_mode_list: - yield mode + yield from scroll_mode_list def change_scroll(_): left_column.scroll = next(scroll_mode) scroll_mode_text.value = str(left_column.scroll) page.update() - add_text_box_button = ft.ElevatedButton("Add TextBox", on_click=add_text_box) - remove_text_box_button = ft.ElevatedButton( + add_text_box_button = ft.Button("Add TextBox", on_click=add_text_box) + remove_text_box_button = ft.Button( content="Remove TextBox", on_click=remove_text_box, ) - scroll_change_button = ft.ElevatedButton( + scroll_change_button = ft.Button( content="Change Scroll Mode", on_click=change_scroll, ) diff --git a/sdk/python/examples/controls/column/scroll_to_key.py b/sdk/python/examples/controls/column/scroll_to_key.py index a255ad2346..c4fa4ef9c9 100644 --- a/sdk/python/examples/controls/column/scroll_to_key.py +++ b/sdk/python/examples/controls/column/scroll_to_key.py @@ -61,19 +61,19 @@ async def scroll_d(): ft.Text("Scroll to:"), ft.Row( controls=[ - ft.ElevatedButton( + ft.Button( content="Section A", on_click=scroll_a, ), - ft.ElevatedButton( + ft.Button( content="Section B", on_click=scroll_b, ), - ft.ElevatedButton( + ft.Button( content="Section C", on_click=scroll_c, ), - ft.ElevatedButton( + ft.Button( content="Section D", on_click=scroll_d, ), diff --git a/sdk/python/examples/controls/container/animate_1.py b/sdk/python/examples/controls/container/animate_1.py index 2e81ab96bf..46a5389955 100644 --- a/sdk/python/examples/controls/container/animate_1.py +++ b/sdk/python/examples/controls/container/animate_1.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def animate_container(e: ft.Event[ft.ElevatedButton]): + def animate_container(e: ft.Event[ft.Button]): container.width = 100 if container.width == 150 else 150 container.height = 50 if container.height == 150 else 150 container.bgcolor = ( @@ -17,7 +17,7 @@ def animate_container(e: ft.Event[ft.ElevatedButton]): bgcolor=ft.Colors.RED, animate=ft.Animation(duration=1000, curve=ft.AnimationCurve.BOUNCE_OUT), ), - ft.ElevatedButton("Animate container", on_click=animate_container), + ft.Button("Animate container", on_click=animate_container), ) diff --git a/sdk/python/examples/controls/container/animate_2.py b/sdk/python/examples/controls/container/animate_2.py index d6d06f1188..d891b03259 100644 --- a/sdk/python/examples/controls/container/animate_2.py +++ b/sdk/python/examples/controls/container/animate_2.py @@ -17,7 +17,7 @@ def main(page: ft.Page): message = ft.Text("Animate me!") - def animate_container(e: ft.Event[ft.ElevatedButton]): + def animate_container(e: ft.Event[ft.Button]): message.value = ( "Animate me back!" if message.value == "Animate me!" else "Animate me!" ) @@ -48,7 +48,7 @@ def animate_container(e: ft.Event[ft.ElevatedButton]): border_radius=10, padding=10, ), - ft.ElevatedButton("Animate container", on_click=animate_container), + ft.Button("Animate container", on_click=animate_container), ) diff --git a/sdk/python/examples/controls/container/animate_3.py b/sdk/python/examples/controls/container/animate_3.py index 50c43b63c1..cbcf1e1145 100644 --- a/sdk/python/examples/controls/container/animate_3.py +++ b/sdk/python/examples/controls/container/animate_3.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): container.width = 100 if container.width == 150 else 150 container.height = 50 if container.height == 150 else 150 container.bgcolor = ( @@ -17,7 +17,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): bgcolor=ft.Colors.RED, animate=ft.Animation(1000, ft.AnimationCurve.BOUNCE_OUT), ), - ft.ElevatedButton("Animate container", on_click=animate), + ft.Button("Animate container", on_click=animate), ) diff --git a/sdk/python/examples/controls/container/animated_4.py b/sdk/python/examples/controls/container/animated_4.py index a326792072..8d95d1ea5d 100644 --- a/sdk/python/examples/controls/container/animated_4.py +++ b/sdk/python/examples/controls/container/animated_4.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def show_menu(e: ft.Event[ft.ElevatedButton]): + def show_menu(e: ft.Event[ft.Button]): container.offset = ft.Offset(0, 0) container.update() @@ -41,7 +41,7 @@ def hide_menu(e: ft.Event[ft.IconButton]): ) ) - page.add(ft.ElevatedButton("Show menu", on_click=show_menu)) + page.add(ft.Button("Show menu", on_click=show_menu)) ft.run(main) diff --git a/sdk/python/examples/controls/container/nested_themes_1.py b/sdk/python/examples/controls/container/nested_themes_1.py index 5ff6af800b..ae92bae5cc 100644 --- a/sdk/python/examples/controls/container/nested_themes_1.py +++ b/sdk/python/examples/controls/container/nested_themes_1.py @@ -10,7 +10,7 @@ def main(page: ft.Page): page.add( # Page theme ft.Container( - content=ft.ElevatedButton("Page theme button"), + content=ft.Button("Page theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, @@ -18,7 +18,7 @@ def main(page: ft.Page): # Inherited theme with primary color overridden ft.Container( theme=ft.Theme(color_scheme=ft.ColorScheme(primary=ft.Colors.PINK)), - content=ft.ElevatedButton("Inherited theme button"), + content=ft.Button("Inherited theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, @@ -27,7 +27,7 @@ def main(page: ft.Page): ft.Container( theme=ft.Theme(color_scheme_seed=ft.Colors.INDIGO), theme_mode=ft.ThemeMode.DARK, - content=ft.ElevatedButton("Unique theme button"), + content=ft.Button("Unique theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, diff --git a/sdk/python/examples/controls/container/nested_themes_2.py b/sdk/python/examples/controls/container/nested_themes_2.py index e9a244b75c..74b94ad87c 100644 --- a/sdk/python/examples/controls/container/nested_themes_2.py +++ b/sdk/python/examples/controls/container/nested_themes_2.py @@ -12,7 +12,7 @@ def main(page: ft.Page): page.add( ft.Row( controls=[ - ft.ElevatedButton("Page theme"), + ft.Button("Page theme"), ft.TextButton("Page theme text button"), ft.Text( "Text in primary container color", @@ -25,7 +25,7 @@ def main(page: ft.Page): theme=ft.Theme(color_scheme=ft.ColorScheme(primary=ft.Colors.PINK)), content=ft.Row( controls=[ - ft.ElevatedButton("Inherited theme with primary color overriden"), + ft.Button("Inherited theme with primary color overriden"), ft.TextButton("Button 2"), ] ), @@ -40,7 +40,7 @@ def main(page: ft.Page): ), content=ft.Row( controls=[ - ft.ElevatedButton("Always DARK theme"), + ft.Button("Always DARK theme"), ft.TextButton("Text button"), ft.Text( "Text in primary container color", @@ -57,7 +57,7 @@ def main(page: ft.Page): theme=ft.Theme(), content=ft.Row( controls=[ - ft.ElevatedButton("Always LIGHT theme"), + ft.Button("Always LIGHT theme"), ft.TextButton("Text button"), ft.Text( "Text in primary container color", @@ -75,7 +75,7 @@ def main(page: ft.Page): theme=ft.Theme(), content=ft.Row( controls=[ - ft.ElevatedButton("SYSTEM theme"), + ft.Button("SYSTEM theme"), ft.TextButton("Text button"), ft.Text( "Text in primary container color", diff --git a/sdk/python/examples/controls/container/nested_themes_3.py b/sdk/python/examples/controls/container/nested_themes_3.py index bff19a36c9..42f191ce57 100644 --- a/sdk/python/examples/controls/container/nested_themes_3.py +++ b/sdk/python/examples/controls/container/nested_themes_3.py @@ -24,7 +24,7 @@ def handle_switch_change(e: ft.Event[ft.Switch]): alignment=ft.MainAxisAlignment.SPACE_BETWEEN, controls=[ ft.Container( - content=ft.ElevatedButton("Page theme button"), + content=ft.Button("Page theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, @@ -39,7 +39,7 @@ def handle_switch_change(e: ft.Event[ft.Switch]): # Inherited theme with primary color overridden ft.Container( theme=ft.Theme(color_scheme=ft.ColorScheme(primary=ft.Colors.PINK)), - content=ft.ElevatedButton("Inherited theme button"), + content=ft.Button("Inherited theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, @@ -48,7 +48,7 @@ def handle_switch_change(e: ft.Event[ft.Switch]): ft.Container( theme=ft.Theme(color_scheme_seed=ft.Colors.INDIGO), theme_mode=ft.ThemeMode.DARK, - content=ft.ElevatedButton("Unique theme button"), + content=ft.Button("Unique theme button"), bgcolor=ft.Colors.SURFACE_TINT, padding=20, width=300, diff --git a/sdk/python/examples/controls/cupertino_button/basic.py b/sdk/python/examples/controls/cupertino_button/basic.py index 0206cd2cf5..550c8483af 100644 --- a/sdk/python/examples/controls/cupertino_button/basic.py +++ b/sdk/python/examples/controls/cupertino_button/basic.py @@ -27,14 +27,14 @@ def main(page: ft.Page): opacity_on_click=0.5, content=ft.Text("Disabled CupertinoButton"), ), - ft.ElevatedButton( + ft.Button( adaptive=True, bgcolor=ft.CupertinoColors.SYSTEM_TEAL, content=ft.Row( tight=True, controls=[ ft.Icon(ft.Icons.FAVORITE, color="pink"), - ft.Text("ElevatedButton+adaptive"), + ft.Text("Button+adaptive"), ], ), ), diff --git a/sdk/python/examples/controls/cupertino_radio/cupertino_material_and_adaptive.py b/sdk/python/examples/controls/cupertino_radio/cupertino_material_and_adaptive.py index 66d36ffb0f..d54a2e5c28 100644 --- a/sdk/python/examples/controls/cupertino_radio/cupertino_material_and_adaptive.py +++ b/sdk/python/examples/controls/cupertino_radio/cupertino_material_and_adaptive.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def handle_button_click(e: ft.Event[ft.ElevatedButton]): + def handle_button_click(e: ft.Event[ft.Button]): message.value = f"Your favorite color is: {group.value}" page.update() @@ -31,7 +31,7 @@ def handle_button_click(e: ft.Event[ft.ElevatedButton]): ] ) ), - ft.ElevatedButton(content="Submit", on_click=handle_button_click), + ft.Button(content="Submit", on_click=handle_button_click), message := ft.Text(), ) diff --git a/sdk/python/examples/controls/date_picker/basic.py b/sdk/python/examples/controls/date_picker/basic.py index 0bd45bbc45..97e31f9b61 100644 --- a/sdk/python/examples/controls/date_picker/basic.py +++ b/sdk/python/examples/controls/date_picker/basic.py @@ -13,7 +13,7 @@ def handle_dismissal(e: ft.Event[ft.DatePicker]): page.add(ft.Text("DatePicker dismissed")) page.add( - ft.ElevatedButton( + ft.Button( content="Pick date", icon=ft.Icons.CALENDAR_MONTH, on_click=lambda e: page.show_dialog( diff --git a/sdk/python/examples/controls/dropdown_m2/add_and_delete_options.py b/sdk/python/examples/controls/dropdown_m2/add_and_delete_options.py index 9177f2c0db..44781cd8ab 100644 --- a/sdk/python/examples/controls/dropdown_m2/add_and_delete_options.py +++ b/sdk/python/examples/controls/dropdown_m2/add_and_delete_options.py @@ -8,14 +8,14 @@ def find_option(option_name): return option return None - def handle_addition(e: ft.Event[ft.ElevatedButton]): + def handle_addition(e: ft.Event[ft.Button]): dropdown.options.append(ft.dropdownm2.Option(input_field.value)) dropdown.value = input_field.value input_field.value = "" page.update() def handle_deletion(e: ft.Event[ft.OutlinedButton]): - option = find_option(d.value) + option = find_option(dropdown.value) if option is not None: dropdown.options.remove(option) # d.value = None @@ -26,7 +26,7 @@ def handle_deletion(e: ft.Event[ft.OutlinedButton]): ft.Row( controls=[ input_field := ft.TextField(hint_text="Enter item name"), - ft.ElevatedButton(content="Add", on_click=handle_addition), + ft.Button(content="Add", on_click=handle_addition), ft.OutlinedButton( content="Delete selected", on_click=handle_deletion, diff --git a/sdk/python/examples/controls/dropdown_m2/basic.py b/sdk/python/examples/controls/dropdown_m2/basic.py index d96d208776..5b389e4187 100644 --- a/sdk/python/examples/controls/dropdown_m2/basic.py +++ b/sdk/python/examples/controls/dropdown_m2/basic.py @@ -17,7 +17,7 @@ def handle_button_click(e): ft.dropdownm2.Option("Blue"), ], ), - ft.ElevatedButton(content="Submit", on_click=handle_button_click), + ft.Button(content="Submit", on_click=handle_button_click), message := ft.Text(), ) diff --git a/sdk/python/examples/controls/dropdown_m2/dropdown_random_icon.py b/sdk/python/examples/controls/dropdown_m2/dropdown_random_icon.py index 3c7a515d99..890822fc71 100644 --- a/sdk/python/examples/controls/dropdown_m2/dropdown_random_icon.py +++ b/sdk/python/examples/controls/dropdown_m2/dropdown_random_icon.py @@ -8,14 +8,14 @@ def handle_dropdown_change(e: ft.Event[ft.DropdownM2]): message.value = f"{e.control.value} chosen" page.update() - def handle_new_random_item(e: ft.Event[ft.ElevatedButton]): + def handle_new_random_item(e: ft.Event[ft.Button]): icon = ft.Icon(ft.Icons.random()) dd.options.append( ft.dropdownm2.Option(text=f"{str(icon.name)[6:]}", content=icon) ) page.update() - def handle_items_shuffle(e: ft.Event[ft.ElevatedButton]): + def handle_items_shuffle(e: ft.Event[ft.Button]): random.shuffle(dd.options) page.update() @@ -23,8 +23,8 @@ def handle_items_shuffle(e: ft.Event[ft.ElevatedButton]): dd := ft.DropdownM2( options=[], options_fill_horizontally=True, on_change=handle_dropdown_change ), - ft.ElevatedButton("Add random Option", on_click=handle_new_random_item), - ft.ElevatedButton("Shuffle Options", on_click=handle_items_shuffle), + ft.Button("Add random Option", on_click=handle_new_random_item), + ft.Button("Shuffle Options", on_click=handle_items_shuffle), message := ft.Text(), ) diff --git a/sdk/python/examples/controls/elevated_button/basic.py b/sdk/python/examples/controls/elevated_button/basic.py deleted file mode 100644 index ebb1660b6b..0000000000 --- a/sdk/python/examples/controls/elevated_button/basic.py +++ /dev/null @@ -1,13 +0,0 @@ -import flet as ft - - -def main(page: ft.Page): - page.title = "ElevatedButton Example" - - page.add( - ft.ElevatedButton(content="Elevated button"), - ft.ElevatedButton(content="Disabled button", disabled=True), - ) - - -ft.run(main) diff --git a/sdk/python/examples/controls/file_picker/pick_and_upload.py b/sdk/python/examples/controls/file_picker/pick_and_upload.py index 83e611a113..9d0ad232da 100644 --- a/sdk/python/examples/controls/file_picker/pick_and_upload.py +++ b/sdk/python/examples/controls/file_picker/pick_and_upload.py @@ -12,7 +12,7 @@ def on_upload_progress(e: ft.FilePickerUploadEvent): # add to services page.services.append(file_picker := ft.FilePicker(on_upload=on_upload_progress)) - async def handle_files_pick(e: ft.Event[ft.ElevatedButton]): + async def handle_files_pick(e: ft.Event[ft.Button]): files = await file_picker.pick_files(allow_multiple=True) print("Picked files:", files) state["picked_files"] = files @@ -26,7 +26,7 @@ async def handle_files_pick(e: ft.Event[ft.ElevatedButton]): prog_bars[f.name] = prog upload_progress.controls.append(ft.Row([prog, ft.Text(f.name)])) - async def handle_file_upload(e: ft.Event[ft.ElevatedButton]): + async def handle_file_upload(e: ft.Event[ft.Button]): upload_button.disabled = True await file_picker.upload( files=[ @@ -40,13 +40,13 @@ async def handle_file_upload(e: ft.Event[ft.ElevatedButton]): page.add( ft.Text("test"), - ft.ElevatedButton( + ft.Button( content="Select files...", icon=ft.Icons.FOLDER_OPEN, on_click=handle_files_pick, ), upload_progress := ft.Column(), - upload_button := ft.ElevatedButton( + upload_button := ft.Button( content="Upload", icon=ft.Icons.UPLOAD, on_click=handle_file_upload, diff --git a/sdk/python/examples/controls/gesture_detector/mouse_cursors.py b/sdk/python/examples/controls/gesture_detector/mouse_cursors.py index b1c1e7f5a5..5745bb3342 100644 --- a/sdk/python/examples/controls/gesture_detector/mouse_cursors.py +++ b/sdk/python/examples/controls/gesture_detector/mouse_cursors.py @@ -21,7 +21,7 @@ def on_pan_update(event: ft.DragUpdateEvent[ft.GestureDetector]): top=0, ) - def handle_button_click(e: ft.Event[ft.ElevatedButton]): + def handle_button_click(e: ft.Event[ft.Button]): gesture_detector.mouse_cursor = next( generate_mouse_cursors(list(ft.MouseCursor)) ) @@ -30,12 +30,11 @@ def handle_button_click(e: ft.Event[ft.ElevatedButton]): def generate_mouse_cursors(m_list): while True: - for i in m_list: - yield i + yield from m_list page.add( ft.Stack(controls=[container], width=1000, height=500), - ft.ElevatedButton("Change mouse Cursor", on_click=handle_button_click), + ft.Button("Change mouse Cursor", on_click=handle_button_click), text := ft.Text(f"Mouse Cursor: {gesture_detector.mouse_cursor}"), ) diff --git a/sdk/python/examples/controls/haptic_feedback/basic.py b/sdk/python/examples/controls/haptic_feedback/basic.py index 5ccfe4f9aa..8240ba2970 100644 --- a/sdk/python/examples/controls/haptic_feedback/basic.py +++ b/sdk/python/examples/controls/haptic_feedback/basic.py @@ -17,10 +17,10 @@ async def vibrate(): await hf.vibrate() page.add( - ft.ElevatedButton("Heavy impact", on_click=heavy_impact), - ft.ElevatedButton("Medium impact", on_click=medium_impact), - ft.ElevatedButton("Light impact", on_click=light_impact), - ft.ElevatedButton("Vibrate", on_click=vibrate), + ft.Button("Heavy impact", on_click=heavy_impact), + ft.Button("Medium impact", on_click=medium_impact), + ft.Button("Light impact", on_click=light_impact), + ft.Button("Vibrate", on_click=vibrate), ) diff --git a/sdk/python/examples/controls/image_slideshow.py b/sdk/python/examples/controls/image_slideshow.py index bea4349adf..5f14ae33f3 100644 --- a/sdk/python/examples/controls/image_slideshow.py +++ b/sdk/python/examples/controls/image_slideshow.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): image1.left = 400 if image1.left == 0 else 0 image2.left = 0 if image2.left == -400 else -400 page.update() @@ -30,7 +30,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): ), ], ), - ft.ElevatedButton("Slide!", on_click=animate), + ft.Button("Slide!", on_click=animate), ) diff --git a/sdk/python/examples/controls/constrained_control/animate_align.py b/sdk/python/examples/controls/layout_control/animate_align.py similarity index 100% rename from sdk/python/examples/controls/constrained_control/animate_align.py rename to sdk/python/examples/controls/layout_control/animate_align.py diff --git a/sdk/python/examples/controls/constrained_control/animate_margin.py b/sdk/python/examples/controls/layout_control/animate_margin.py similarity index 100% rename from sdk/python/examples/controls/constrained_control/animate_margin.py rename to sdk/python/examples/controls/layout_control/animate_margin.py diff --git a/sdk/python/examples/controls/constrained_control/animate_opacity.py b/sdk/python/examples/controls/layout_control/animate_opacity.py similarity index 84% rename from sdk/python/examples/controls/constrained_control/animate_opacity.py rename to sdk/python/examples/controls/layout_control/animate_opacity.py index 10f2903a65..9f1f6492f9 100644 --- a/sdk/python/examples/controls/constrained_control/animate_opacity.py +++ b/sdk/python/examples/controls/layout_control/animate_opacity.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def animate_opacity(e: ft.Event[ft.ElevatedButton]): + def animate_opacity(e: ft.Event[ft.Button]): container.opacity = 0 if container.opacity == 1 else 1 container.update() @@ -14,7 +14,7 @@ def animate_opacity(e: ft.Event[ft.ElevatedButton]): border_radius=10, animate_opacity=300, ), - ft.ElevatedButton( + ft.Button( content="Animate opacity", on_click=animate_opacity, ), diff --git a/sdk/python/examples/controls/constrained_control/animate_position.py b/sdk/python/examples/controls/layout_control/animate_position.py similarity index 88% rename from sdk/python/examples/controls/constrained_control/animate_position.py rename to sdk/python/examples/controls/layout_control/animate_position.py index 44d5c30fab..3cdfee2cca 100644 --- a/sdk/python/examples/controls/constrained_control/animate_position.py +++ b/sdk/python/examples/controls/layout_control/animate_position.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def animate_container(e: ft.Event[ft.ElevatedButton]): + def animate_container(e: ft.Event[ft.Button]): c1.top = 20 c1.left = 200 c2.top = 100 @@ -36,7 +36,7 @@ def animate_container(e: ft.Event[ft.ElevatedButton]): ), ], ), - ft.ElevatedButton("Animate!", on_click=animate_container), + ft.Button("Animate!", on_click=animate_container), ) diff --git a/sdk/python/examples/controls/constrained_control/animate_rotation.py b/sdk/python/examples/controls/layout_control/animate_rotation.py similarity index 86% rename from sdk/python/examples/controls/constrained_control/animate_rotation.py rename to sdk/python/examples/controls/layout_control/animate_rotation.py index 15f12b9ad1..ef7921cb04 100644 --- a/sdk/python/examples/controls/constrained_control/animate_rotation.py +++ b/sdk/python/examples/controls/layout_control/animate_rotation.py @@ -8,7 +8,7 @@ def main(page: ft.Page): page.horizontal_alignment = ft.CrossAxisAlignment.CENTER page.spacing = 30 - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): container.rotate.angle += pi / 2 page.update() @@ -23,7 +23,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): duration=300, curve=ft.AnimationCurve.BOUNCE_OUT ), ), - ft.ElevatedButton("Animate!", on_click=animate), + ft.Button("Animate!", on_click=animate), ) diff --git a/sdk/python/examples/controls/constrained_control/animate_scale.py b/sdk/python/examples/controls/layout_control/animate_scale.py similarity index 85% rename from sdk/python/examples/controls/constrained_control/animate_scale.py rename to sdk/python/examples/controls/layout_control/animate_scale.py index 13195a1894..828c69ee8b 100644 --- a/sdk/python/examples/controls/constrained_control/animate_scale.py +++ b/sdk/python/examples/controls/layout_control/animate_scale.py @@ -6,7 +6,7 @@ def main(page: ft.Page): page.horizontal_alignment = ft.CrossAxisAlignment.CENTER page.spacing = 30 - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): container.scale = 2 if container.scale == 1 else 1 page.update() @@ -22,7 +22,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): curve=ft.AnimationCurve.BOUNCE_OUT, ), ), - ft.ElevatedButton("Animate!", on_click=animate), + ft.Button("Animate!", on_click=animate), ) diff --git a/sdk/python/examples/controls/constrained_control/animated_offset.py b/sdk/python/examples/controls/layout_control/animated_offset.py similarity index 80% rename from sdk/python/examples/controls/constrained_control/animated_offset.py rename to sdk/python/examples/controls/layout_control/animated_offset.py index a89f16c106..dd137a5c23 100644 --- a/sdk/python/examples/controls/constrained_control/animated_offset.py +++ b/sdk/python/examples/controls/layout_control/animated_offset.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): container.offset = ft.Offset(0, 0) container.update() @@ -15,7 +15,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): offset=ft.Offset(x=-2, y=0), animate_offset=ft.Animation(duration=1000), ), - ft.ElevatedButton("Reveal!", on_click=animate), + ft.Button("Reveal!", on_click=animate), ) diff --git a/sdk/python/examples/controls/constrained_control/media/animate_offset.gif b/sdk/python/examples/controls/layout_control/media/animate_offset.gif similarity index 100% rename from sdk/python/examples/controls/constrained_control/media/animate_offset.gif rename to sdk/python/examples/controls/layout_control/media/animate_offset.gif diff --git a/sdk/python/examples/controls/constrained_control/media/animate_opacity.gif b/sdk/python/examples/controls/layout_control/media/animate_opacity.gif similarity index 100% rename from sdk/python/examples/controls/constrained_control/media/animate_opacity.gif rename to sdk/python/examples/controls/layout_control/media/animate_opacity.gif diff --git a/sdk/python/examples/controls/constrained_control/media/animate_position.gif b/sdk/python/examples/controls/layout_control/media/animate_position.gif similarity index 100% rename from sdk/python/examples/controls/constrained_control/media/animate_position.gif rename to sdk/python/examples/controls/layout_control/media/animate_position.gif diff --git a/sdk/python/examples/controls/constrained_control/media/animate_rotation.gif b/sdk/python/examples/controls/layout_control/media/animate_rotation.gif similarity index 100% rename from sdk/python/examples/controls/constrained_control/media/animate_rotation.gif rename to sdk/python/examples/controls/layout_control/media/animate_rotation.gif diff --git a/sdk/python/examples/controls/constrained_control/media/animate_scale.gif b/sdk/python/examples/controls/layout_control/media/animate_scale.gif similarity index 100% rename from sdk/python/examples/controls/constrained_control/media/animate_scale.gif rename to sdk/python/examples/controls/layout_control/media/animate_scale.gif diff --git a/sdk/python/examples/controls/constrained_control/media/animated_switcher.gif b/sdk/python/examples/controls/layout_control/media/animated_switcher.gif similarity index 100% rename from sdk/python/examples/controls/constrained_control/media/animated_switcher.gif rename to sdk/python/examples/controls/layout_control/media/animated_switcher.gif diff --git a/sdk/python/examples/controls/constrained_control/switcher.py b/sdk/python/examples/controls/layout_control/switcher.py similarity index 91% rename from sdk/python/examples/controls/constrained_control/switcher.py rename to sdk/python/examples/controls/layout_control/switcher.py index 9ea3afcb92..4795c29be2 100644 --- a/sdk/python/examples/controls/constrained_control/switcher.py +++ b/sdk/python/examples/controls/layout_control/switcher.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): shader.rotate = 1 shader.scale = 3 page.update() @@ -32,7 +32,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): ) ], ), - ft.ElevatedButton("Animate!", on_click=animate), + ft.Button("Animate!", on_click=animate), ) diff --git a/sdk/python/examples/controls/navigation_drawer/position_end.py b/sdk/python/examples/controls/navigation_drawer/position_end.py index 721f8c6d21..1e3990d8e5 100644 --- a/sdk/python/examples/controls/navigation_drawer/position_end.py +++ b/sdk/python/examples/controls/navigation_drawer/position_end.py @@ -26,7 +26,7 @@ def handle_change(e: ft.Event[ft.NavigationDrawer]): ) page.add( - ft.ElevatedButton( + ft.Button( content="Show end drawer", on_click=lambda e: page.show_dialog(end_drawer), ) diff --git a/sdk/python/examples/controls/navigation_drawer/position_start.py b/sdk/python/examples/controls/navigation_drawer/position_start.py index b21d432e31..ffceb24c6c 100644 --- a/sdk/python/examples/controls/navigation_drawer/position_start.py +++ b/sdk/python/examples/controls/navigation_drawer/position_start.py @@ -34,7 +34,7 @@ def handle_change(e: ft.Event[ft.NavigationDrawer]): ) page.add( - ft.ElevatedButton( + ft.Button( content="Show drawer", on_click=lambda e: page.show_dialog(drawer), ) diff --git a/sdk/python/examples/controls/page/app_exit_confirm_dialog.py b/sdk/python/examples/controls/page/app_exit_confirm_dialog.py index 6845dfc708..7511ba0095 100644 --- a/sdk/python/examples/controls/page/app_exit_confirm_dialog.py +++ b/sdk/python/examples/controls/page/app_exit_confirm_dialog.py @@ -10,7 +10,7 @@ def window_event(e: ft.WindowEvent): page.window.prevent_close = True page.window.on_event = window_event - async def handle_yes_click(e: ft.Event[ft.ElevatedButton]): + async def handle_yes_click(e: ft.Event[ft.Button]): await page.window.destroy() def handle_no_click(e: ft.Event[ft.OutlinedButton]): @@ -22,7 +22,7 @@ def handle_no_click(e: ft.Event[ft.OutlinedButton]): title=ft.Text("Please confirm"), content=ft.Text("Do you really want to exit this app?"), actions=[ - ft.ElevatedButton(content="Yes", on_click=handle_yes_click), + ft.Button(content="Yes", on_click=handle_yes_click), ft.OutlinedButton(content="No", on_click=handle_no_click), ], actions_alignment=ft.MainAxisAlignment.END, diff --git a/sdk/python/examples/controls/page/set_platform.py b/sdk/python/examples/controls/page/set_platform.py index 414d181449..076ab89fff 100644 --- a/sdk/python/examples/controls/page/set_platform.py +++ b/sdk/python/examples/controls/page/set_platform.py @@ -2,20 +2,20 @@ def main(page: ft.Page): - def set_android(e: ft.Event[ft.ElevatedButton]): + def set_android(e: ft.Event[ft.Button]): page.platform = ft.PagePlatform.ANDROID page.update() print("New platform:", page.platform) - def set_ios(e: ft.Event[ft.ElevatedButton]): + def set_ios(e: ft.Event[ft.Button]): page.platform = ft.PagePlatform.IOS page.update() print("New platform:", page.platform) page.add( ft.Switch(label="Switch A", adaptive=True), - ft.ElevatedButton("Set Android", on_click=set_android), - ft.ElevatedButton("Set iOS", on_click=set_ios), + ft.Button("Set Android", on_click=set_android), + ft.Button("Set iOS", on_click=set_ios), ) print("Default platform:", page.platform) diff --git a/sdk/python/examples/controls/page/splash_test.py b/sdk/python/examples/controls/page/splash_test.py index 2c3901b6ab..7f09dbc93c 100644 --- a/sdk/python/examples/controls/page/splash_test.py +++ b/sdk/python/examples/controls/page/splash_test.py @@ -4,7 +4,7 @@ async def main(page: ft.Page): - async def handle_button_click(e: ft.Event[ft.ElevatedButton]): + async def handle_button_click(e: ft.Event[ft.Button]): my_bar = ft.ProgressBar() page.overlay.append(my_bar) @@ -16,7 +16,7 @@ async def handle_button_click(e: ft.Event[ft.ElevatedButton]): btn.disabled = False page.update() - btn = ft.ElevatedButton("Do some lengthy task!", on_click=handle_button_click) + btn = ft.Button("Do some lengthy task!", on_click=handle_button_click) page.add(btn) diff --git a/sdk/python/examples/controls/radio/basic.py b/sdk/python/examples/controls/radio/basic.py index 427ceb004a..b37e8a57e3 100644 --- a/sdk/python/examples/controls/radio/basic.py +++ b/sdk/python/examples/controls/radio/basic.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def handle_button_click(e: ft.Event[ft.ElevatedButton]): + def handle_button_click(e: ft.Event[ft.Button]): message.value = f"Your favorite color is: {group.value}" page.update() @@ -17,7 +17,7 @@ def handle_button_click(e: ft.Event[ft.ElevatedButton]): ] ) ), - ft.ElevatedButton(content="Submit", on_click=handle_button_click), + ft.Button(content="Submit", on_click=handle_button_click), message := ft.Text(), ) diff --git a/sdk/python/examples/controls/rocket.py b/sdk/python/examples/controls/rocket.py index 28e9198ccd..67b2db9920 100644 --- a/sdk/python/examples/controls/rocket.py +++ b/sdk/python/examples/controls/rocket.py @@ -7,7 +7,7 @@ def main(page: ft.Page): page.vertical_alignment = ft.MainAxisAlignment.CENTER page.horizontal_alignment = ft.CrossAxisAlignment.CENTER - def animate(e: ft.Event[ft.ElevatedButton]): + def animate(e: ft.Event[ft.Button]): container.rotate.angle -= 0.5 * pi container.content.scale = 2.0 if container.content.scale == 1.0 else 1.0 container.content.opacity = 0.4 if container.content.scale == 1.0 else 1.0 @@ -36,7 +36,7 @@ def animate(e: ft.Event[ft.ElevatedButton]): ), ), ), - ft.ElevatedButton("Launch!", on_click=animate), + ft.Button("Launch!", on_click=animate), ], ) ) diff --git a/sdk/python/examples/controls/snack_bar/basic.py b/sdk/python/examples/controls/snack_bar/basic.py index 9da82e4fac..2f487cc9c6 100644 --- a/sdk/python/examples/controls/snack_bar/basic.py +++ b/sdk/python/examples/controls/snack_bar/basic.py @@ -2,10 +2,10 @@ def main(page: ft.Page): - def on_click(e: ft.Event[ft.ElevatedButton]): + def on_click(e: ft.Event[ft.Button]): page.show_dialog(ft.SnackBar(ft.Text("Hello, world!"))) - page.add(ft.ElevatedButton("Open SnackBar", on_click=on_click)) + page.add(ft.Button("Open SnackBar", on_click=on_click)) ft.run(main) diff --git a/sdk/python/examples/controls/snack_bar/counter.py b/sdk/python/examples/controls/snack_bar/counter.py index c62e4277de..b1046e2a16 100644 --- a/sdk/python/examples/controls/snack_bar/counter.py +++ b/sdk/python/examples/controls/snack_bar/counter.py @@ -24,14 +24,14 @@ def main(page: ft.Page): on_action=lambda e: data.decrement(), ) - def handle_button_click(e: ft.Event[ft.ElevatedButton]): + def handle_button_click(e: ft.Event[ft.Button]): data.increment() snack_bar.content.value = f"You did it x {data.counter}" if not snack_bar.open: page.show_dialog(snack_bar) page.update() - page.add(ft.ElevatedButton("Open SnackBar", on_click=handle_button_click)) + page.add(ft.Button("Open SnackBar", on_click=handle_button_click)) ft.run(main) diff --git a/sdk/python/examples/controls/switch/basic.py b/sdk/python/examples/controls/switch/basic.py index b018d70875..dc5ad209fa 100644 --- a/sdk/python/examples/controls/switch/basic.py +++ b/sdk/python/examples/controls/switch/basic.py @@ -2,7 +2,7 @@ def main(page: ft.Page): - def handle_button_click(e: ft.Event[ft.ElevatedButton]): + def handle_button_click(e: ft.Event[ft.Button]): message.value = ( f"Switch values are: {c1.value}, {c2.value}, {c3.value}, {c4.value}." ) @@ -16,7 +16,7 @@ def handle_button_click(e: ft.Event[ft.ElevatedButton]): label="Switch with rendered label_position='left'", label_position=ft.LabelPosition.LEFT, ), - ft.ElevatedButton(content="Submit", on_click=handle_button_click), + ft.Button(content="Submit", on_click=handle_button_click), message := ft.Text(), ) diff --git a/sdk/python/examples/controls/text_field/basic.py b/sdk/python/examples/controls/text_field/basic.py index 1831409a99..e592be84af 100644 --- a/sdk/python/examples/controls/text_field/basic.py +++ b/sdk/python/examples/controls/text_field/basic.py @@ -2,8 +2,9 @@ def main(page: ft.Page): - def handle_button_click(e: ft.Event[ft.ElevatedButton]): - message.value = f"Textboxes values are: '{tb1.value}', '{tb2.value}', '{tb3.value}', '{tb4.value}', '{tb5.value}'." + def handle_button_click(e: ft.Event[ft.Button]): + message.value = f"Textboxes values are: '{tb1.value}', '{tb2.value}', " + f"'{tb3.value}', '{tb4.value}', '{tb5.value}'." page.update() page.add( @@ -14,7 +15,7 @@ def handle_button_click(e: ft.Event[ft.ElevatedButton]): label="With placeholder", hint_text="Please enter text here" ), tb5 := ft.TextField(label="With an icon", icon=ft.Icons.EMOJI_EMOTIONS), - ft.ElevatedButton(content="Submit", on_click=handle_button_click), + ft.Button(content="Submit", on_click=handle_button_click), message := ft.Text(), ) diff --git a/sdk/python/examples/controls/text_field/prefix_and_suffix.py b/sdk/python/examples/controls/text_field/prefix_and_suffix.py index 7f4854acfa..ca46563b90 100644 --- a/sdk/python/examples/controls/text_field/prefix_and_suffix.py +++ b/sdk/python/examples/controls/text_field/prefix_and_suffix.py @@ -2,8 +2,9 @@ def main(page: ft.Page): - def handle_button_click(e: ft.Event[ft.ElevatedButton]): - message.value = f"Textboxes values are: '{prefix_field.value}', '{suffix_field.value}', '{prefix_suffix_field.value}', '{color_field.value}'." + def handle_button_click(e: ft.Event[ft.Button]): + message.value = f"Textboxes values are: '{prefix_field.value}', " + f"'{suffix_field.value}', '{prefix_suffix_field.value}', '{color_field.value}'." page.update() page.add( @@ -25,7 +26,7 @@ def handle_button_click(e: ft.Event[ft.ElevatedButton]): suffix="...is your color", max_length=20, ), - ft.ElevatedButton(content="Submit", on_click=handle_button_click), + ft.Button(content="Submit", on_click=handle_button_click), message := ft.Text(), ) diff --git a/sdk/python/examples/controls/time_picker/basic.py b/sdk/python/examples/controls/time_picker/basic.py index 1057ccb183..d64f990636 100644 --- a/sdk/python/examples/controls/time_picker/basic.py +++ b/sdk/python/examples/controls/time_picker/basic.py @@ -23,7 +23,7 @@ def handle_entry_mode_change(e: ft.TimePickerEntryModeChangeEvent): ) page.add( - ft.ElevatedButton( + ft.Button( content="Pick time", icon=ft.Icons.TIME_TO_LEAVE, on_click=lambda _: page.show_dialog(time_picker), diff --git a/sdk/python/examples/controls/transparent_pointer/basic.py b/sdk/python/examples/controls/transparent_pointer/basic.py index e4964e1681..aa07e35123 100644 --- a/sdk/python/examples/controls/transparent_pointer/basic.py +++ b/sdk/python/examples/controls/transparent_pointer/basic.py @@ -14,7 +14,7 @@ def main(page: ft.Page): ), ft.TransparentPointer( content=ft.Container( - content=ft.ElevatedButton("Test button"), + content=ft.Button("Test button"), padding=50, ) ), diff --git a/sdk/python/examples/controls/types/alignment/container.py b/sdk/python/examples/controls/types/alignment/container.py index 41c5a80281..3ce99ab2a6 100644 --- a/sdk/python/examples/controls/types/alignment/container.py +++ b/sdk/python/examples/controls/types/alignment/container.py @@ -8,7 +8,7 @@ def main(page: ft.Page): ft.Row( controls=[ ft.Container( - content=ft.ElevatedButton("Center"), + content=ft.Button("Center"), bgcolor=ft.Colors.AMBER, padding=15, alignment=ft.Alignment.CENTER, @@ -16,7 +16,7 @@ def main(page: ft.Page): height=150, ), ft.Container( - content=ft.ElevatedButton("Top left"), + content=ft.Button("Top left"), bgcolor=ft.Colors.AMBER, padding=15, alignment=ft.Alignment.TOP_LEFT, @@ -24,7 +24,7 @@ def main(page: ft.Page): height=150, ), ft.Container( - content=ft.ElevatedButton("-0.5, -0.5"), + content=ft.Button("-0.5, -0.5"), bgcolor=ft.Colors.AMBER, padding=15, alignment=ft.alignment.Alignment(-0.5, -0.5), diff --git a/sdk/python/examples/controls/types/blur/container.py b/sdk/python/examples/controls/types/blur/container.py index 62524aca4c..b2ea37d6a3 100644 --- a/sdk/python/examples/controls/types/blur/container.py +++ b/sdk/python/examples/controls/types/blur/container.py @@ -11,7 +11,7 @@ def main(page: ft.Page): height=300, ) - def handle_button_click(e: ft.Event[ft.ElevatedButton]): + def handle_button_click(e: ft.Event[ft.Button]): nonlocal i img_container.image = ft.DecorationImage( src=f"https://picsum.photos/300/300?random={i}" @@ -46,7 +46,7 @@ def handle_button_click(e: ft.Event[ft.ElevatedButton]): border_radius=10, border=ft.Border.all(2, ft.Colors.BLACK), ), - ft.ElevatedButton( + ft.Button( content="Change Background", bottom=5, right=5, diff --git a/sdk/python/examples/controls/types/margin/container.py b/sdk/python/examples/controls/types/margin/container.py index 07cef3fd2f..694ee35e41 100644 --- a/sdk/python/examples/controls/types/margin/container.py +++ b/sdk/python/examples/controls/types/margin/container.py @@ -9,7 +9,7 @@ def main(page: ft.Page): spacing=0, controls=[ ft.Container( - content=ft.ElevatedButton("container_1"), + content=ft.Button("container_1"), bgcolor=ft.Colors.AMBER, # padding=ft.Padding.all(10), margin=ft.Margin.all(10), @@ -17,7 +17,7 @@ def main(page: ft.Page): height=200, ), ft.Container( - content=ft.ElevatedButton("container_2"), + content=ft.Button("container_2"), bgcolor=ft.Colors.AMBER, # padding=ft.Padding.all(20), margin=ft.Margin.all(20), @@ -25,7 +25,7 @@ def main(page: ft.Page): height=200, ), ft.Container( - content=ft.ElevatedButton("container_3"), + content=ft.Button("container_3"), bgcolor=ft.Colors.AMBER, # padding=ft.Padding.symmetric(horizontal=10), margin=ft.Margin.symmetric(vertical=10), @@ -33,7 +33,7 @@ def main(page: ft.Page): height=200, ), ft.Container( - content=ft.ElevatedButton("container_4"), + content=ft.Button("container_4"), bgcolor=ft.Colors.AMBER, # padding=ft.Padding.only(left=10), margin=ft.Margin.only(left=10), diff --git a/sdk/python/examples/controls/types/padding/container.py b/sdk/python/examples/controls/types/padding/container.py index 6d3b70a4f3..89f578601d 100644 --- a/sdk/python/examples/controls/types/padding/container.py +++ b/sdk/python/examples/controls/types/padding/container.py @@ -8,28 +8,28 @@ def main(page: ft.Page): ft.Row( controls=[ ft.Container( - content=ft.ElevatedButton("container_1"), + content=ft.Button("container_1"), bgcolor=ft.Colors.AMBER, padding=ft.Padding.all(10), width=150, height=150, ), ft.Container( - content=ft.ElevatedButton("container_2"), + content=ft.Button("container_2"), bgcolor=ft.Colors.AMBER, padding=ft.Padding.all(20), width=150, height=150, ), ft.Container( - content=ft.ElevatedButton("container_3"), + content=ft.Button("container_3"), bgcolor=ft.Colors.AMBER, padding=ft.Padding.symmetric(horizontal=10), width=150, height=150, ), ft.Container( - content=ft.ElevatedButton("container_4"), + content=ft.Button("container_4"), bgcolor=ft.Colors.AMBER, padding=ft.Padding.only(left=10), width=150, diff --git a/sdk/python/examples/cookbook/user-control-with-auto-update.py b/sdk/python/examples/cookbook/user-control-with-auto-update.py index 1cea40f987..2605519b05 100644 --- a/sdk/python/examples/cookbook/user-control-with-auto-update.py +++ b/sdk/python/examples/cookbook/user-control-with-auto-update.py @@ -12,15 +12,11 @@ def build(self): print(self.page.platform) self.content = ft.Column( [ - ft.ElevatedButton( + ft.Button( f"Make {self.color.value}", on_click=self.on_change_color_click ), ft.Row( - [ - ft.ElevatedButton( - f"Say {self.greeting}!", on_click=self.on_say_click - ) - ] + [ft.Button(f"Say {self.greeting}!", on_click=self.on_say_click)] ), ] ) diff --git a/sdk/python/examples/tutorials/calculator/calc.py b/sdk/python/examples/tutorials/calculator/calc.py index 0e66f07f04..9ebb3ec650 100644 --- a/sdk/python/examples/tutorials/calculator/calc.py +++ b/sdk/python/examples/tutorials/calculator/calc.py @@ -1,7 +1,7 @@ import flet as ft -class CalcButton(ft.ElevatedButton): +class CalcButton(ft.Button): def __init__(self, text, button_clicked, expand=1): super().__init__() self.text = text @@ -101,7 +101,7 @@ def button_clicked(self, e): self.reset() elif data in ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "."): - if self.result.value == "0" or self.new_operand == True: + if self.result.value == "0" or self.new_operand: self.result.value = data self.new_operand = False else: diff --git a/sdk/python/examples/tutorials/calculator/calc1.py b/sdk/python/examples/tutorials/calculator/calc1.py index 55e40f52b8..d0306ca28f 100644 --- a/sdk/python/examples/tutorials/calculator/calc1.py +++ b/sdk/python/examples/tutorials/calculator/calc1.py @@ -7,25 +7,25 @@ def main(page: ft.Page): page.add( result, - ft.ElevatedButton(text="AC"), - ft.ElevatedButton(text="+/-"), - ft.ElevatedButton(text="%"), - ft.ElevatedButton(text="/"), - ft.ElevatedButton(text="7"), - ft.ElevatedButton(text="8"), - ft.ElevatedButton(text="9"), - ft.ElevatedButton(text="*"), - ft.ElevatedButton(text="4"), - ft.ElevatedButton(text="5"), - ft.ElevatedButton(text="6"), - ft.ElevatedButton(text="-"), - ft.ElevatedButton(text="1"), - ft.ElevatedButton(text="2"), - ft.ElevatedButton(text="3"), - ft.ElevatedButton(text="+"), - ft.ElevatedButton(text="0"), - ft.ElevatedButton(text="."), - ft.ElevatedButton(text="="), + ft.Button(text="AC"), + ft.Button(text="+/-"), + ft.Button(text="%"), + ft.Button(text="/"), + ft.Button(text="7"), + ft.Button(text="8"), + ft.Button(text="9"), + ft.Button(text="*"), + ft.Button(text="4"), + ft.Button(text="5"), + ft.Button(text="6"), + ft.Button(text="-"), + ft.Button(text="1"), + ft.Button(text="2"), + ft.Button(text="3"), + ft.Button(text="+"), + ft.Button(text="0"), + ft.Button(text="."), + ft.Button(text="="), ) diff --git a/sdk/python/examples/tutorials/calculator/calc2.py b/sdk/python/examples/tutorials/calculator/calc2.py index 646503207d..48be7dfa16 100644 --- a/sdk/python/examples/tutorials/calculator/calc2.py +++ b/sdk/python/examples/tutorials/calculator/calc2.py @@ -9,41 +9,41 @@ def main(page: ft.Page): ft.Row(controls=[result]), ft.Row( controls=[ - ft.ElevatedButton(text="AC"), - ft.ElevatedButton(text="+/-"), - ft.ElevatedButton(text="%"), - ft.ElevatedButton(text="/"), + ft.Button(text="AC"), + ft.Button(text="+/-"), + ft.Button(text="%"), + ft.Button(text="/"), ] ), ft.Row( controls=[ - ft.ElevatedButton(text="7"), - ft.ElevatedButton(text="8"), - ft.ElevatedButton(text="9"), - ft.ElevatedButton(text="*"), + ft.Button(text="7"), + ft.Button(text="8"), + ft.Button(text="9"), + ft.Button(text="*"), ] ), ft.Row( controls=[ - ft.ElevatedButton(text="4"), - ft.ElevatedButton(text="5"), - ft.ElevatedButton(text="6"), - ft.ElevatedButton(text="-"), + ft.Button(text="4"), + ft.Button(text="5"), + ft.Button(text="6"), + ft.Button(text="-"), ] ), ft.Row( controls=[ - ft.ElevatedButton(text="1"), - ft.ElevatedButton(text="2"), - ft.ElevatedButton(text="3"), - ft.ElevatedButton(text="+"), + ft.Button(text="1"), + ft.Button(text="2"), + ft.Button(text="3"), + ft.Button(text="+"), ] ), ft.Row( controls=[ - ft.ElevatedButton(text="0"), - ft.ElevatedButton(text="."), - ft.ElevatedButton(text="="), + ft.Button(text="0"), + ft.Button(text="."), + ft.Button(text="="), ] ), ) diff --git a/sdk/python/examples/tutorials/calculator/calc3.py b/sdk/python/examples/tutorials/calculator/calc3.py index a86958ed3b..c00d0ffe7d 100644 --- a/sdk/python/examples/tutorials/calculator/calc3.py +++ b/sdk/python/examples/tutorials/calculator/calc3.py @@ -5,7 +5,7 @@ def main(page: ft.Page): page.title = "Calc App" result = ft.Text(value="0", color=ft.Colors.WHITE, size=20) - class CalcButton(ft.ElevatedButton): + class CalcButton(ft.Button): def __init__(self, text, expand=1): super().__init__() self.text = text diff --git a/sdk/python/examples/tutorials/calculator/calc4.py b/sdk/python/examples/tutorials/calculator/calc4.py index f9b80858b6..80a6796f81 100644 --- a/sdk/python/examples/tutorials/calculator/calc4.py +++ b/sdk/python/examples/tutorials/calculator/calc4.py @@ -1,7 +1,7 @@ import flet as ft -class CalcButton(ft.ElevatedButton): +class CalcButton(ft.Button): def __init__(self, text, expand=1): super().__init__() self.text = text diff --git a/sdk/python/examples/tutorials/calculator/calc5.py b/sdk/python/examples/tutorials/calculator/calc5.py index 0e66f07f04..9ebb3ec650 100644 --- a/sdk/python/examples/tutorials/calculator/calc5.py +++ b/sdk/python/examples/tutorials/calculator/calc5.py @@ -1,7 +1,7 @@ import flet as ft -class CalcButton(ft.ElevatedButton): +class CalcButton(ft.Button): def __init__(self, text, button_clicked, expand=1): super().__init__() self.text = text @@ -101,7 +101,7 @@ def button_clicked(self, e): self.reset() elif data in ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "."): - if self.result.value == "0" or self.new_operand == True: + if self.result.value == "0" or self.new_operand: self.result.value = data self.new_operand = False else: diff --git a/sdk/python/examples/tutorials/chat/chat_1.py b/sdk/python/examples/tutorials/chat/chat_1.py index 304c87d756..09fa5c6c3f 100644 --- a/sdk/python/examples/tutorials/chat/chat_1.py +++ b/sdk/python/examples/tutorials/chat/chat_1.py @@ -12,7 +12,7 @@ def send_click(e): page.add( chat, - ft.Row(controls=[new_message, ft.ElevatedButton("Send", on_click=send_click)]), + ft.Row(controls=[new_message, ft.Button("Send", on_click=send_click)]), ) diff --git a/sdk/python/examples/tutorials/chat/chat_2.py b/sdk/python/examples/tutorials/chat/chat_2.py index d09fc0e2c2..f3615f0def 100644 --- a/sdk/python/examples/tutorials/chat/chat_2.py +++ b/sdk/python/examples/tutorials/chat/chat_2.py @@ -1,10 +1,12 @@ +from dataclasses import dataclass + import flet as ft +@dataclass class Message: - def __init__(self, user: str, text: str): - self.user = user - self.text = text + user: str + text: str def main(page: ft.Page): @@ -22,9 +24,7 @@ def send_click(e): new_message.value = "" page.update() - page.add( - chat, ft.Row([new_message, ft.ElevatedButton("Send", on_click=send_click)]) - ) + page.add(chat, ft.Row([new_message, ft.Button("Send", on_click=send_click)])) ft.run(main) diff --git a/sdk/python/examples/tutorials/chat/chat_3.py b/sdk/python/examples/tutorials/chat/chat_3.py index f25d9f6e4f..b7dd40e4bc 100644 --- a/sdk/python/examples/tutorials/chat/chat_3.py +++ b/sdk/python/examples/tutorials/chat/chat_3.py @@ -1,11 +1,13 @@ +from dataclasses import dataclass + import flet as ft +@dataclass class Message: - def __init__(self, user: str, text: str, message_type: str): - self.user = user - self.text = text - self.message_type = message_type + user: str + text: str + message_type: str def main(page: ft.Page): @@ -57,13 +59,11 @@ def join_click(e): modal=True, title=ft.Text("Welcome!"), content=ft.Column([user_name], tight=True), - actions=[ft.ElevatedButton(content="Join chat", on_click=join_click)], + actions=[ft.Button(content="Join chat", on_click=join_click)], actions_alignment=ft.MainAxisAlignment.END, ) - page.add( - chat, ft.Row([new_message, ft.ElevatedButton("Send", on_click=send_click)]) - ) + page.add(chat, ft.Row([new_message, ft.Button("Send", on_click=send_click)])) ft.run(main) diff --git a/sdk/python/examples/tutorials/chat/main.py b/sdk/python/examples/tutorials/chat/main.py index 0518aee58f..2c6ba5d5fb 100644 --- a/sdk/python/examples/tutorials/chat/main.py +++ b/sdk/python/examples/tutorials/chat/main.py @@ -108,7 +108,7 @@ def on_message(message: Message): modal=True, title=ft.Text("Welcome!"), content=ft.Column([join_user_name], width=300, height=70, tight=True), - actions=[ft.ElevatedButton(content="Join chat", on_click=join_chat_click)], + actions=[ft.Button(content="Join chat", on_click=join_chat_click)], actions_alignment=ft.MainAxisAlignment.END, ) diff --git a/sdk/python/packages/flet/docs/archive/flet-controls.md b/sdk/python/packages/flet/docs/archive/flet-controls.md index 1c6d623703..3e92dbb74b 100644 --- a/sdk/python/packages/flet/docs/archive/flet-controls.md +++ b/sdk/python/packages/flet/docs/archive/flet-controls.md @@ -55,14 +55,14 @@ page.add( ) ``` -or `TextField` and `ElevatedButton` next to it: +or `TextField` and `Button` next to it: ```python page.add( ft.Row( controls=[ ft.TextField(label="Your name"), - ft.ElevatedButton(text="Say my name!") + ft.Button(text="Say my name!") ] ) ) @@ -79,13 +79,13 @@ for i in range(10): time.sleep(0.3) ``` -Some controls, like buttons, could have event handlers reacting on a user input, for example `ElevatedButton.on_click`: +Some controls, like buttons, could have event handlers reacting on a user input, for example `Button.on_click`: ```python def button_clicked(e): page.add(ft.Text("Clicked!")) -page.add(ft.ElevatedButton(text="Click me", on_click=button_clicked)) +page.add(ft.Button(text="Click me", on_click=button_clicked)) ``` and more advanced example for a simple To-Do: @@ -101,7 +101,7 @@ def main(page): new_task.update() new_task = ft.TextField(hint_text="What's needs to be done?", width=300) - page.add(ft.Row([new_task, ft.ElevatedButton("Add", on_click=add_clicked)])) + page.add(ft.Row([new_task, ft.Button("Add", on_click=add_clicked)])) ft.run(main) ``` @@ -150,7 +150,7 @@ page.add(c) `Button` is the most essential input control which generates `click` event when pressed: ```python -btn = ft.ElevatedButton("Click me!") +btn = ft.Button("Click me!") page.add(btn) ``` @@ -199,7 +199,7 @@ ft.run(main) Flet provides a number of [controls](../controls/index.md) for building forms: [`TextField`][flet.TextField], [`Checkbox`][flet.Checkbox], [`Dropdown`][flet.Dropdown], -[`ElevatedButton`][flet.ElevatedButton]. +[`Button`][flet.Button]. Let's ask a user for a name: @@ -218,7 +218,7 @@ def main(page): txt_name = ft.TextField(label="Your name") - page.add(txt_name, ft.ElevatedButton("Say hello!", on_click=btn_click)) + page.add(txt_name, ft.Button("Say hello!", on_click=btn_click)) ft.run(main) ``` @@ -263,7 +263,7 @@ def main(page: ft.Page): page.update() output_text = ft.Text() - submit_btn = ft.ElevatedButton(text="Submit", on_click=button_clicked) + submit_btn = ft.Button(text="Submit", on_click=button_clicked) color_dropdown = ft.Dropdown( width=100, options=[ diff --git a/sdk/python/packages/flet/docs/contributing/extensions/user-extensions.md b/sdk/python/packages/flet/docs/contributing/extensions/user-extensions.md index f10aa900d4..afdaaf7048 100644 --- a/sdk/python/packages/flet/docs/contributing/extensions/user-extensions.md +++ b/sdk/python/packages/flet/docs/contributing/extensions/user-extensions.md @@ -146,7 +146,7 @@ class FletSpinkitControl extends StatelessWidget { ); - return constrainedControl(context, myControl, parent, control); + return LayoutControl(context, myControl, parent, control); } } ``` @@ -326,17 +326,17 @@ Generally, there are two types of controls in Flet: Flet `Control` class has properties common for all controls such as `visible`, `opacity` and `tooltip`, to name a few. -Flet `ConstrainedControl` class is inherited from `Control` and has many additional properties such as `top` and `left` for its position within Stack and a bunch of animation properties. +Flet `LayoutControl` class is inherited from `Control` and has many additional properties such as `top` and `left` for its position within Stack and a bunch of animation properties. When creating non-visual control, your Python control should be inherited from ['Control](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet/src/flet/core/control.py). Then, to be able to use `Control` properties in your app, you need to add them to the constructor of your Python Control. In its dart counterpart (`src/flet_spinkit.dart`) use `baseControl()` to wrap your Flutter widget. -When creating visual control, your Python control should be inherited from [`ConstrainedControl`](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet/src/flet/core/constrained_control.py). In its dart counterpart (`src/flet_spinkit.dart`) use `constrainedControl()` to wrap your Flutter widget. +When creating visual control, your Python control should be inherited from [`LayoutControl`](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet/src/flet/core/layout_control.py). In its dart counterpart (`src/flet_spinkit.dart`) use `LayoutControl()` to wrap your Flutter widget. -Then, to be able to use `Control` and `ConstrainedControl` properties in your app, you need to add them to the constructor of your Python Control. +Then, to be able to use `Control` and `LayoutControl` properties in your app, you need to add them to the constructor of your Python Control. See reference for the common Control properties [here](https://flet.dev/docs/controls). -If you have created your extension project from Flet extension template, your Python Control is already inherited from `ConstrainedControl` and you can use its properties in your example app: +If you have created your extension project from Flet extension template, your Python Control is already inherited from `LayoutControl` and you can use its properties in your example app: ```python import flet as ft @@ -365,7 +365,7 @@ ft.run(main) ### Control-specific properties -Now that you have taken full advantage of the properties Flet `Control` and `ConstrainedControl` offer, let's define the properties that are specific to the new Control you are building. +Now that you have taken full advantage of the properties Flet `Control` and `LayoutControl` offer, let's define the properties that are specific to the new Control you are building. In the FletSpinkit example, let's define its `color` and `size`. @@ -375,12 +375,12 @@ In Python class, define new `color` and `size` properties: from enum import Enum from typing import Any, Optional -from flet.core.constrained_control import ConstrainedControl +from flet.core.layout_control import LayoutControl from flet.core.control import OptionalNumber from flet.core.types import ColorEnums, ColorValue -class FletSpinkit(ConstrainedControl): +class FletSpinkit(LayoutControl): """ FletSpinkit Control. """ @@ -395,7 +395,7 @@ class FletSpinkit(ConstrainedControl): visible: Optional[bool] = None, data: Any = None, # - # ConstrainedControl + # LayoutControl # left: OptionalNumber = None, top: OptionalNumber = None, @@ -407,7 +407,7 @@ class FletSpinkit(ConstrainedControl): color: Optional[ColorValue] = None, size: OptionalNumber = None, ): - ConstrainedControl.__init__( + LayoutControl.__init__( self, tooltip=tooltip, opacity=opacity, @@ -472,7 +472,7 @@ class FletSpinkitControl extends StatelessWidget { ); - return constrainedControl(context, myControl, parent, control); + return LayoutControl(context, myControl, parent, control); } } ``` @@ -597,9 +597,9 @@ In [Dart](https://github.com/flet-dev/flet/blob/main/packages/flet/lib/src/contr ##### Events -For example, `on_click` event for `ElevatedButton`. +For example, `on_click` event for `Button`. -In [Python](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet/src/flet/core/elevated_button.py): +In [Python](https://github.com/flet-dev/flet/blob/main/sdk/python/packages/flet/src/flet/core/button.py): ```python # on_click @@ -612,7 +612,7 @@ def on_click(self, handler): self._add_event_handler("click", handler) ``` -In [Dart](https://github.com/flet-dev/flet/blob/main/packages/flet/lib/src/controls/elevated_button.dart): +In [Dart](https://github.com/flet-dev/flet/blob/main/packages/flet/lib/src/controls/button.dart): ```dart Function()? onPressed = !disabled diff --git a/sdk/python/packages/flet/docs/controls/button.md b/sdk/python/packages/flet/docs/controls/button.md index 2ac7768c19..8802f695e7 100644 --- a/sdk/python/packages/flet/docs/controls/button.md +++ b/sdk/python/packages/flet/docs/controls/button.md @@ -1,5 +1,63 @@ ## Examples -See [these](elevatedbutton.md#examples). +[Live example](https://flet-controls-gallery.fly.dev/buttons/elevatedbutton) + +### Basic Example + +```python +--8<-- "../../examples/controls/button/basic.py" +``` + +![basic](../examples/controls/button/media/basic.png){width="80%"} +/// caption +/// + +### Icons + +```python +--8<-- "../../examples/controls/button/icons.py" +``` + +![icons](../examples/controls/button/media/icons.png){width="80%"} +/// caption +/// + +### Handling clicks + +```python +--8<-- "../../examples/controls/button/handling_clicks.py" +``` + +![handling-clicks](../examples/controls/button/media/handling_clicks.gif){width="80%"} +/// caption +/// + +### Custom content + +```python +--8<-- "../../examples/controls/button/custom_content.py" +``` + +![custom-content](../examples/controls/button/media/custom_content.png){width="80%"} +/// caption +/// + +### Shapes + +```python +--8<-- "../../examples/controls/button/shapes.py" +``` + +### Styling + +```python +--8<-- "../../examples/controls/button/styling.py" +``` + +### Animate on hover + +```python +--8<-- "../../examples/controls/button/animate_on_hover.py" +``` ::: flet.Button diff --git a/sdk/python/packages/flet/docs/controls/buttons/index.md b/sdk/python/packages/flet/docs/controls/buttons/index.md index 35f982bc9b..0517d2a392 100644 --- a/sdk/python/packages/flet/docs/controls/buttons/index.md +++ b/sdk/python/packages/flet/docs/controls/buttons/index.md @@ -5,7 +5,7 @@ - [:octicons-arrow-right-24: `Button`][flet.Button] --- - ![Button](../../examples/controls/elevated_button/media/index.png){width="100%"} + ![Button](../../examples/controls/button/media/index.png){width="100%"} - [:octicons-arrow-right-24: `CupertinoActionSheetAction`][flet.CupertinoActionSheetAction] @@ -47,10 +47,10 @@ --- -- [:octicons-arrow-right-24: `ElevatedButton`][flet.ElevatedButton] +- [:octicons-arrow-right-24: `Button`][flet.Button] --- - ![ElevatedButton](../../examples/controls/elevated_button/media/index.png){width="100%"} + ![Button](../../examples/controls/button/media/index.png){width="100%"} - [:octicons-arrow-right-24: `FilledButton`][flet.FilledButton] diff --git a/sdk/python/packages/flet/docs/controls/constrainedcontrol.md b/sdk/python/packages/flet/docs/controls/constrainedcontrol.md deleted file mode 100644 index 4bf286f0c3..0000000000 --- a/sdk/python/packages/flet/docs/controls/constrainedcontrol.md +++ /dev/null @@ -1 +0,0 @@ -::: flet.ConstrainedControl diff --git a/sdk/python/packages/flet/docs/controls/elevatedbutton.md b/sdk/python/packages/flet/docs/controls/elevatedbutton.md deleted file mode 100644 index 4cc905ef57..0000000000 --- a/sdk/python/packages/flet/docs/controls/elevatedbutton.md +++ /dev/null @@ -1,63 +0,0 @@ -## Examples - -[Live example](https://flet-controls-gallery.fly.dev/buttons/elevatedbutton) - -### Basic Example - -```python ---8<-- "../../examples/controls/elevated_button/basic.py" -``` - -![basic](../examples/controls/elevated_button/media/basic.png){width="80%"} -/// caption -/// - -### Icons - -```python ---8<-- "../../examples/controls/elevated_button/icons.py" -``` - -![icons](../examples/controls/elevated_button/media/icons.png){width="80%"} -/// caption -/// - -### Handling clicks - -```python ---8<-- "../../examples/controls/elevated_button/handling_clicks.py" -``` - -![handling-clicks](../examples/controls/elevated_button/media/handling_clicks.gif){width="80%"} -/// caption -/// - -### Custom content - -```python ---8<-- "../../examples/controls/elevated_button/custom_content.py" -``` - -![custom-content](../examples/controls/elevated_button/media/custom_content.png){width="80%"} -/// caption -/// - -### Shapes - -```python ---8<-- "../../examples/controls/elevated_button/shapes.py" -``` - -### Styling - -```python ---8<-- "../../examples/controls/elevated_button/styling.py" -``` - -### Animate on hover - -```python ---8<-- "../../examples/controls/elevated_button/animate_on_hover.py" -``` - -::: flet.ElevatedButton diff --git a/sdk/python/packages/flet/docs/controls/index.md b/sdk/python/packages/flet/docs/controls/index.md index a88da7210b..0a65da8cb1 100644 --- a/sdk/python/packages/flet/docs/controls/index.md +++ b/sdk/python/packages/flet/docs/controls/index.md @@ -10,7 +10,7 @@ Page │ └─ Image └─ Row ├─ Checkbox - └─ ElevatedButton + └─ Button ``` The [control gallery](https://flet-controls-gallery.fly.dev/layout) provides a live demo of most of our controls. diff --git a/sdk/python/packages/flet/docs/controls/layoutcontrol.md b/sdk/python/packages/flet/docs/controls/layoutcontrol.md new file mode 100644 index 0000000000..59fb5bfc88 --- /dev/null +++ b/sdk/python/packages/flet/docs/controls/layoutcontrol.md @@ -0,0 +1 @@ +::: flet.LayoutControl diff --git a/sdk/python/packages/flet/docs/cookbook/adaptive-apps.md b/sdk/python/packages/flet/docs/cookbook/adaptive-apps.md index dee320ca41..580d0cbef7 100644 --- a/sdk/python/packages/flet/docs/cookbook/adaptive-apps.md +++ b/sdk/python/packages/flet/docs/cookbook/adaptive-apps.md @@ -236,9 +236,9 @@ Below is the list of adaptive Material controls and their matching Cupertino con --- ![CupertinoIconButton](../examples/controls/cupertino_button/media/adaptive_icon_button.png){width="45%"} -- [:octicons-arrow-right-24: `ElevatedButton`][flet.ElevatedButton] +- [:octicons-arrow-right-24: `Button`][flet.Button] - ![ElevatedButton](../examples/controls/elevated_button/media/adaptive.png){width="45%"} + ![Button](../examples/controls/button/media/adaptive.png){width="45%"} --- [:octicons-arrow-right-24: `OutlinedButton`][flet.OutlinedButton] diff --git a/sdk/python/packages/flet/docs/cookbook/animations.md b/sdk/python/packages/flet/docs/cookbook/animations.md index dc12714149..79bdaa728e 100644 --- a/sdk/python/packages/flet/docs/cookbook/animations.md +++ b/sdk/python/packages/flet/docs/cookbook/animations.md @@ -16,7 +16,7 @@ beginning of the animation and then slows down until the target value is reached /// caption /// -[`ConstrainedControl`][flet.ConstrainedControl] (and its subclasses) provides a number of `animate_{something}` +[`LayoutControl`][flet.LayoutControl] (and its subclasses) provides a number of `animate_{something}` properties, described below, to enable implicit animation of its appearance: * `animate_opacity` @@ -49,46 +49,46 @@ properties, described below, to enable implicit animation of its appearance: ### Opacity animation Setting control's `animate_opacity` to either `True`, number or an instance of `Animation` class (see above) -enables implicit animation of [`ConstrainedControl.opacity`][flet.ConstrainedControl.opacity] property. +enables implicit animation of [`LayoutControl.opacity`][flet.LayoutControl.opacity] property. ```python ---8<-- "../../examples/controls/constrained_control/animate_opacity.py" +--8<-- "../../examples/controls/layout_control/animate_opacity.py" ``` -![animate-opacity](../examples/controls/constrained_control/media/animate_opacity.gif){width="80%"} +![animate-opacity](../examples/controls/layout_control/media/animate_opacity.gif){width="80%"} /// caption /// ### Rotation animation Setting control's `animate_rotation` to either `True`, number or an instance of `Animation` class (see above) -enables implicit animation of [`ConstrainedControl.rotate`][flet.ConstrainedControl.rotate] property. +enables implicit animation of [`LayoutControl.rotate`][flet.LayoutControl.rotate] property. ```python --8<-- "../../examples/controls/constrained-control/animate_rotation.py" ``` -![animate-rotation](../examples/controls/constrained_control/media/animate_rotation.gif){width="80%"} +![animate-rotation](../examples/controls/layout_control/media/animate_rotation.gif){width="80%"} /// caption /// ### Scale animation Setting control's `animate_scale` to either `True`, number or an instance of `Animation` class (see above) -enables implicit animation of [`ConstrainedControl.scale`][flet.ConstrainedControl.scale] property. +enables implicit animation of [`LayoutControl.scale`][flet.LayoutControl.scale] property. ```python ---8<-- "../../examples/controls/constrained_control/animate_scale.py" +--8<-- "../../examples/controls/layout_control/animate_scale.py" ``` -![animate-scale](../examples/controls/constrained_control/media/animate_scale.gif){width="80%"} +![animate-scale](../examples/controls/layout_control/media/animate_scale.gif){width="80%"} /// caption /// ### Offset animation Setting control's `animate_offset` to either `True`, number or an instance of `Animation` class (see above) -enables implicit animation of [`ConstrainedControl.offset`][flet.ConstrainedControl.offset] property. +enables implicit animation of [`LayoutControl.offset`][flet.LayoutControl.offset] property. `offset` property is an instance of `Offset` class which specifies horizontal `x` and vertical `y` offset of a control scaled to control's size. For example, an offset `Offset(-0.25, 0)` will result in @@ -97,19 +97,19 @@ a horizontal translation of one quarter the width of the control. Offset animation is used for various sliding effects: ```python ---8<-- "../../examples/controls/constrained_control/animate_offset.py" +--8<-- "../../examples/controls/layout_control/animate_offset.py" ``` -![animate-offset](../examples/controls/constrained_control/media/animate_offset.gif){width="80%"} +![animate-offset](../examples/controls/layout_control/media/animate_offset.gif){width="80%"} /// caption /// ### Position animation Setting control's `animate_position` to either `True`, number or an instance of `Animation` class -(see above) enables implicit animation of the following `ConstrainedControl` properties: -[`left`][flet.ConstrainedControl.left], [`right`][flet.ConstrainedControl.right], -[`bottom`][flet.ConstrainedControl.bottom], [`top`][flet.ConstrainedControl.top]. +(see above) enables implicit animation of the following `LayoutControl` properties: +[`left`][flet.LayoutControl.left], [`right`][flet.LayoutControl.right], +[`bottom`][flet.LayoutControl.bottom], [`top`][flet.LayoutControl.top]. Note: @@ -119,10 +119,10 @@ Note: - [`Page.overlay`][flet.Page.overlay] list ```python ---8<-- "../../examples/controls/constrained_control/animate_position.py" +--8<-- "../../examples/controls/layout_control/animate_position.py" ``` -![animate-position](../examples/controls/constrained_control/media/animate_position.gif){width="80%"} +![animate-position](../examples/controls/layout_control/media/animate_position.gif){width="80%"} /// caption /// @@ -169,7 +169,7 @@ def main(page: ft.Page): page.add( sw, - ft.ElevatedButton("Animate!", on_click=animate), + ft.Button("Animate!", on_click=animate), ) ft.run(main) @@ -181,8 +181,8 @@ ft.run(main) ### Animation end callback -[`ConstrainedControl`][flet.ConstrainedControl] also has an -[`on_animation_end`][flet.ConstrainedControl.on_animation_end] event handler, which is called +[`LayoutControl`][flet.LayoutControl] also has an +[`on_animation_end`][flet.LayoutControl.on_animation_end] event handler, which is called when an animation is complete. It can be used to chain multiple animations. Event's [`data`][flet.Event.data] field/property contains the name of animation: diff --git a/sdk/python/packages/flet/docs/cookbook/async-apps.md b/sdk/python/packages/flet/docs/cookbook/async-apps.md index 6c3018ea14..432a79b2c9 100644 --- a/sdk/python/packages/flet/docs/cookbook/async-apps.md +++ b/sdk/python/packages/flet/docs/cookbook/async-apps.md @@ -45,7 +45,7 @@ async def main(page: ft.Page): await some_async_method() page.add(ft.Text("Hello!")) - page.add(ft.ElevatedButton("Say hello!", on_click=button_click)) + page.add(ft.Button("Say hello!", on_click=button_click)) ft.run(main) ``` @@ -74,7 +74,7 @@ def main(page: ft.Page): page.add(ft.Text("Hello!")) page.add( - ft.ElevatedButton("Say hello with delay!", on_click=button_click) + ft.Button("Say hello with delay!", on_click=button_click) ) ft.run(main) diff --git a/sdk/python/packages/flet/docs/cookbook/authentication.md b/sdk/python/packages/flet/docs/cookbook/authentication.md index 3300d1de06..507323c00f 100644 --- a/sdk/python/packages/flet/docs/cookbook/authentication.md +++ b/sdk/python/packages/flet/docs/cookbook/authentication.md @@ -93,7 +93,7 @@ def main(page: ft.Page): print("User ID:", page.auth.user.id) page.on_login = on_login - page.add(ft.ElevatedButton("Login with GitHub", on_click=login_click)) + page.add(ft.Button("Login with GitHub", on_click=login_click)) ft.run(main, port=8550, view=ft.WEB_BROWSER) ``` @@ -187,7 +187,7 @@ You can use this event handler to toggle signed in/out UI, for example: import os import flet -from flet import ElevatedButton, LoginEvent, Page +from flet import Button, LoginEvent, Page from flet.auth.providers import GitHubOAuthProvider def main(page: Page): @@ -215,8 +215,8 @@ def main(page: Page): logout_button.visible = page.auth is not None page.update() - login_button = ElevatedButton("Login with GitHub", on_click=login_button_click) - logout_button = ElevatedButton("Logout", on_click=logout_button_click) + login_button = Button("Login with GitHub", on_click=login_button_click) + logout_button = Button("Logout", on_click=logout_button_click) toggle_login_buttons() page.on_login = on_login page.on_logout = on_logout @@ -421,7 +421,7 @@ with their LinkedIn accounts: import os import flet -from flet import ElevatedButton, Page +from flet import Button, Page from flet.auth import OAuthProvider def main(page: Page): @@ -446,7 +446,7 @@ def main(page: Page): print("Access token:", page.auth.token.access_token) page.on_login = on_login - page.add(ElevatedButton("Login with LinkedIn", on_click=login_click)) + page.add(Button("Login with LinkedIn", on_click=login_click)) flet.app(main, port=8550, view=flet.WEB_BROWSER) ``` diff --git a/sdk/python/packages/flet/docs/cookbook/control-refs.md b/sdk/python/packages/flet/docs/cookbook/control-refs.md index 6abede5c36..ad52ac0e2f 100644 --- a/sdk/python/packages/flet/docs/cookbook/control-refs.md +++ b/sdk/python/packages/flet/docs/cookbook/control-refs.md @@ -20,7 +20,7 @@ def main(page): page.add( first_name, last_name, - ft.ElevatedButton("Say hello!", on_click=btn_click), + ft.Button("Say hello!", on_click=btn_click), greetings, ) @@ -40,7 +40,7 @@ hard to imagine (without constant jumping to variable definitions in IDE) what w page.add( first_name, last_name, - ft.ElevatedButton("Say hello!", on_click=btn_click), + ft.Button("Say hello!", on_click=btn_click), greetings, ) ``` @@ -101,7 +101,7 @@ def main(page): page.add( ft.TextField(ref=first_name, label="First name", autofocus=True), ft.TextField(ref=last_name, label="Last name"), - ft.ElevatedButton("Say hello!", on_click=btn_click), + ft.Button("Say hello!", on_click=btn_click), ft.Column(ref=greetings), ) diff --git a/sdk/python/packages/flet/docs/cookbook/custom-controls.md b/sdk/python/packages/flet/docs/cookbook/custom-controls.md index 011ff81b9b..8839cb6065 100644 --- a/sdk/python/packages/flet/docs/cookbook/custom-controls.md +++ b/sdk/python/packages/flet/docs/cookbook/custom-controls.md @@ -6,10 +6,10 @@ You can create custom controls in Python by styling and/or combining existing Fl The most simple custom control you can create is a styled control, for example, a button of a certain color and behaviour that will be used multiple times throughout your app. -To create a styled control, you need to create a new class in Python that inherits from the Flet control you are going to customize, `ElevatedButton` in this case: +To create a styled control, you need to create a new class in Python that inherits from the Flet control you are going to customize, `Button` in this case: ```python -class MyButton(ft.ElevatedButton): +class MyButton(ft.Button): def __init__(self, text): super().__init__() self.bgcolor = ft.Colors.ORANGE_300 @@ -42,7 +42,7 @@ Similar to properties, you can pass event handlers as parameters into your custo ```python import flet as ft -class MyButton(ft.ElevatedButton): +class MyButton(ft.Button): def __init__(self, text, on_click): super().__init__() self.bgcolor = ft.Colors.ORANGE_300 diff --git a/sdk/python/packages/flet/docs/cookbook/expanding-controls.md b/sdk/python/packages/flet/docs/cookbook/expanding-controls.md index b49c28084f..31c8c85900 100644 --- a/sdk/python/packages/flet/docs/cookbook/expanding-controls.md +++ b/sdk/python/packages/flet/docs/cookbook/expanding-controls.md @@ -18,13 +18,13 @@ You can set `expand` to one of the following values: ### Example 1 In this example, a [`TextField`][flet.TextField] stretches to fill all remaining space in the row, -while the [`ElevatedButton`][flet.ElevatedButton] stays sized to its content: +while the [`Button`][flet.Button] stays sized to its content: ```python ft.Row( controls=[ ft.TextField(hint_text="Enter your name", expand=True), - ft.ElevatedButton(text="Join chat") + ft.Button(text="Join chat") ] ) ``` diff --git a/sdk/python/packages/flet/docs/cookbook/file-picker-and-uploads.md b/sdk/python/packages/flet/docs/cookbook/file-picker-and-uploads.md index 1be1bd7170..7d63f06ed3 100644 --- a/sdk/python/packages/flet/docs/cookbook/file-picker-and-uploads.md +++ b/sdk/python/packages/flet/docs/cookbook/file-picker-and-uploads.md @@ -53,7 +53,7 @@ To open file picker dialog call one of the three methods: Lambda works pretty nice for that: ```python -ft.ElevatedButton( +ft.Button( content="Choose files...", on_click=lambda _: file_picker.pick_files(allow_multiple=True) ) @@ -102,7 +102,7 @@ async def upload_files(e): ) await file_picker.upload(upload_list) -ft.ElevatedButton("Upload", on_click=upload_files) +ft.Button("Upload", on_click=upload_files) ``` /// admonition diff --git a/sdk/python/packages/flet/docs/cookbook/navigation-and-routing.md b/sdk/python/packages/flet/docs/cookbook/navigation-and-routing.md index 18ab993380..8a2d378a28 100644 --- a/sdk/python/packages/flet/docs/cookbook/navigation-and-routing.md +++ b/sdk/python/packages/flet/docs/cookbook/navigation-and-routing.md @@ -75,7 +75,7 @@ def main(page: ft.Page): page.update() page.on_route_change = route_change - page.add(ft.ElevatedButton("Go to Store", on_click=go_store)) + page.add(ft.Button("Go to Store", on_click=go_store)) ft.run(main, view=ft.AppView.WEB_BROWSER) ``` @@ -122,7 +122,7 @@ def main(page: ft.Page): "/", [ ft.AppBar(title=ft.Text("Flet app"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST), - ft.ElevatedButton("Visit Store", on_click=lambda _: page.go("/store")), + ft.Button("Visit Store", on_click=lambda _: page.go("/store")), ], ) ) @@ -132,7 +132,7 @@ def main(page: ft.Page): "/store", [ ft.AppBar(title=ft.Text("Store"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST), - ft.ElevatedButton("Go Home", on_click=lambda _: page.go("/")), + ft.Button("Go Home", on_click=lambda _: page.go("/")), ], ) ) diff --git a/sdk/python/packages/flet/docs/cookbook/pub-sub.md b/sdk/python/packages/flet/docs/cookbook/pub-sub.md index d37f3c37c5..ccd9ca16ef 100644 --- a/sdk/python/packages/flet/docs/cookbook/pub-sub.md +++ b/sdk/python/packages/flet/docs/cookbook/pub-sub.md @@ -35,7 +35,7 @@ def main(page: ft.Page): messages = ft.Column() user = ft.TextField(hint_text="Your name", width=150) message = ft.TextField(hint_text="Your message...", expand=True) # fill all the space - send = ft.ElevatedButton("Send", on_click=send_click) + send = ft.Button("Send", on_click=send_click) page.add(messages, ft.Row(controls=[user, message, send])) ft.run(main, view=ft.AppView.WEB_BROWSER) diff --git a/sdk/python/packages/flet/docs/cookbook/theming.md b/sdk/python/packages/flet/docs/cookbook/theming.md index 59a08b070d..7a431d41b7 100644 --- a/sdk/python/packages/flet/docs/cookbook/theming.md +++ b/sdk/python/packages/flet/docs/cookbook/theming.md @@ -38,7 +38,7 @@ def main(page: ft.Page): page.add( # Page theme ft.Container( - content=ft.ElevatedButton("Page theme button"), + content=ft.Button("Page theme button"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST, padding=20, width=300, @@ -47,7 +47,7 @@ def main(page: ft.Page): # Inherited theme with primary color overridden ft.Container( theme=ft.Theme(color_scheme=ft.ColorScheme(primary=ft.Colors.PINK)), - content=ft.ElevatedButton("Inherited theme button"), + content=ft.Button("Inherited theme button"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST, padding=20, width=300, @@ -57,7 +57,7 @@ def main(page: ft.Page): ft.Container( theme=ft.Theme(color_scheme_seed=ft.Colors.INDIGO), theme_mode=ft.ThemeMode.DARK, - content=ft.ElevatedButton("Unique theme button"), + content=ft.Button("Unique theme button"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST, padding=20, width=300, diff --git a/sdk/python/packages/flet/docs/publish/web/dynamic-website/index.md b/sdk/python/packages/flet/docs/publish/web/dynamic-website/index.md index 4f6befae12..a51573ec5a 100644 --- a/sdk/python/packages/flet/docs/publish/web/dynamic-website/index.md +++ b/sdk/python/packages/flet/docs/publish/web/dynamic-website/index.md @@ -24,8 +24,8 @@ def main(page: ft.Page): page.add(ft.Text("Async handler clicked")) page.add( - ft.ElevatedButton("Call handler", on_click=handler), - ft.ElevatedButton("Call async handler", on_click=handler_async) + ft.Button("Call handler", on_click=handler), + ft.Button("Call async handler", on_click=handler_async) ) ft.run(main) diff --git a/sdk/python/packages/flet/docs/tutorials/calculator.md b/sdk/python/packages/flet/docs/tutorials/calculator.md index 3f745f4a03..63ce57c226 100644 --- a/sdk/python/packages/flet/docs/tutorials/calculator.md +++ b/sdk/python/packages/flet/docs/tutorials/calculator.md @@ -54,7 +54,7 @@ Run this app and you will see a new window with a greeting: Now you are ready to create a calculator app. To start, you'll need a [`Text`][flet.Text] control for showing the result of calculation, -and a few [`ElevatedButton`][flet.ElevatedButton]s with all the numbers and actions on them. +and a few [`Button`][flet.Button]s with all the numbers and actions on them. Create `calc.py` with the following contents: @@ -67,25 +67,25 @@ def main(page: ft.Page): page.add( result, - ft.ElevatedButton(text="AC"), - ft.ElevatedButton(text="+/-"), - ft.ElevatedButton(text="%"), - ft.ElevatedButton(text="/"), - ft.ElevatedButton(text="7"), - ft.ElevatedButton(text="8"), - ft.ElevatedButton(text="9"), - ft.ElevatedButton(text="*"), - ft.ElevatedButton(text="4"), - ft.ElevatedButton(text="5"), - ft.ElevatedButton(text="6"), - ft.ElevatedButton(text="-"), - ft.ElevatedButton(text="1"), - ft.ElevatedButton(text="2"), - ft.ElevatedButton(text="3"), - ft.ElevatedButton(text="+"), - ft.ElevatedButton(text="0"), - ft.ElevatedButton(text="."), - ft.ElevatedButton(text="="), + ft.Button(text="AC"), + ft.Button(text="+/-"), + ft.Button(text="%"), + ft.Button(text="/"), + ft.Button(text="7"), + ft.Button(text="8"), + ft.Button(text="9"), + ft.Button(text="*"), + ft.Button(text="4"), + ft.Button(text="5"), + ft.Button(text="6"), + ft.Button(text="-"), + ft.Button(text="1"), + ft.Button(text="2"), + ft.Button(text="3"), + ft.Button(text="+"), + ft.Button(text="0"), + ft.Button(text="."), + ft.Button(text="="), ) ft.run(main) @@ -115,41 +115,41 @@ def main(page: ft.Page): ft.Row(controls=[result]), ft.Row( controls=[ - ft.ElevatedButton(text="AC"), - ft.ElevatedButton(text="+/-"), - ft.ElevatedButton(text="%"), - ft.ElevatedButton(text="/"), + ft.Button(text="AC"), + ft.Button(text="+/-"), + ft.Button(text="%"), + ft.Button(text="/"), ] ), ft.Row( controls=[ - ft.ElevatedButton(text="7"), - ft.ElevatedButton(text="8"), - ft.ElevatedButton(text="9"), - ft.ElevatedButton(text="*"), + ft.Button(text="7"), + ft.Button(text="8"), + ft.Button(text="9"), + ft.Button(text="*"), ] ), ft.Row( controls=[ - ft.ElevatedButton(text="4"), - ft.ElevatedButton(text="5"), - ft.ElevatedButton(text="6"), - ft.ElevatedButton(text="-"), + ft.Button(text="4"), + ft.Button(text="5"), + ft.Button(text="6"), + ft.Button(text="-"), ] ), ft.Row( controls=[ - ft.ElevatedButton(text="1"), - ft.ElevatedButton(text="2"), - ft.ElevatedButton(text="3"), - ft.ElevatedButton(text="+"), + ft.Button(text="1"), + ft.Button(text="2"), + ft.Button(text="3"), + ft.Button(text="+"), ] ), ft.Row( controls=[ - ft.ElevatedButton(text="0"), - ft.ElevatedButton(text="."), - ft.ElevatedButton(text="="), + ft.Button(text="0"), + ft.Button(text="."), + ft.Button(text="="), ] ), ) @@ -208,9 +208,9 @@ For the buttons, if we look again at the UI we are aiming to achieve, there are The buttons will be used multiple time in the program, so we will be creating custom [Styled Controls](../cookbook/custom-controls.md#styled-controls) to reuse the code. -Since all those types should inherit from `ElevatedButton` class and have common `text` and `expand` properties, let's create a parent `CalcButton` class: +Since all those types should inherit from `Button` class and have common `text` and `expand` properties, let's create a parent `CalcButton` class: ```python -class CalcButton(ft.ElevatedButton): +class CalcButton(ft.Button): def __init__(self, text, expand=1): super().__init__() self.text = text @@ -340,7 +340,7 @@ depending on the button clicked. For `CalcButton` class, let's specify `on_click event and set `data` property equal to button's text: ```python -class CalcButton(ft.ElevatedButton): +class CalcButton(ft.Button): def __init__(self, text, button_clicked, expand=1): super().__init__() self.text = text diff --git a/sdk/python/packages/flet/docs/tutorials/chat.md b/sdk/python/packages/flet/docs/tutorials/chat.md index 8d0531376f..2abed69030 100644 --- a/sdk/python/packages/flet/docs/tutorials/chat.md +++ b/sdk/python/packages/flet/docs/tutorials/chat.md @@ -63,8 +63,8 @@ To implement this layout, we will be using these Flet controls: * [`Column`][flet.Column] - a container to display chat messages (`Text` controls) vertically. * [`Text`][flet.Text] - chat message displayed in the chat Column. * [`TextField`][flet.TextField] - input control used for taking new message input from the user. -* [`ElevatedButton`][flet.ElevatedButton] - "Send" button that will add new message to the chat Column. -* [`Row`][flet.Row] - a container to display `TextField` and `ElevatedButton` horizontally. +* [`Button`][flet.Button] - "Send" button that will add new message to the chat Column. +* [`Row`][flet.Row] - a container to display `TextField` and `Button` horizontally. Create `chat.py` with the following contents: @@ -81,13 +81,13 @@ def main(page: ft.Page): page.update() page.add( - chat, ft.Row(controls=[new_message, ft.ElevatedButton("Send", on_click=send_click)]) + chat, ft.Row(controls=[new_message, ft.Button("Send", on_click=send_click)]) ) ft.run(main) ``` -When user clicks on the "Send" button, it triggers [`on_click`][flet.ElevatedButton.on_click] event which calls `send_click` method. `send_click` +When user clicks on the "Send" button, it triggers [`on_click`][flet.Button.on_click] event which calls `send_click` method. `send_click` then adds new [`Text`][flet.Text] control to the list of [`Column.controls`][flet.Column.controls] and clears `new_message` text field value. /// admonition | Note @@ -142,7 +142,7 @@ Finally, you need to call `pubsub.send_all()` method when the user clicks on "Se new_message.value = "" page.update() - page.add(chat, ft.Row([new_message, ft.ElevatedButton("Send", on_click=send_click)])) + page.add(chat, ft.Row([new_message, ft.Button("Send", on_click=send_click)])) ``` `pubsub.send_all()` will call the `on_message()` and pass on the Message object down to it. @@ -173,7 +173,7 @@ def main(page: ft.Page): new_message.value = "" page.update() - page.add(chat, ft.Row([new_message, ft.ElevatedButton("Send", on_click=send_click)])) + page.add(chat, ft.Row([new_message, ft.Button("Send", on_click=send_click)])) ft.run(main) ``` @@ -199,7 +199,7 @@ we will be using [`AlertDialog`][flet.AlertDialog] control. Let's add it to the modal=True, title=ft.Text("Welcome!"), content=ft.Column([user_name], tight=True), - actions=[ft.ElevatedButton(text="Join chat", on_click=join_click)], + actions=[ft.Button(text="Join chat", on_click=join_click)], actions_alignment="end", ) ``` @@ -384,7 +384,7 @@ Other improvements suggested with the new layout are: * [`ListView`][flet.ListView] instead of [`Column`][flet.Column] for displaying messages, to be able to scroll through the messages later * [`Container`][flet.Container] for displaying border around [`ListView`][flet.ListView] -* [`IconButton`][flet.IconButton] instead of [`ElevatedButton`][flet.ElevatedButton] to send messages +* [`IconButton`][flet.IconButton] instead of [`Button`][flet.Button] to send messages * Use of [`expand`][flet.Control.expand] property for controls to fill available space Here is how you can implement this layout: diff --git a/sdk/python/packages/flet/docs/tutorials/trolli.md b/sdk/python/packages/flet/docs/tutorials/trolli.md index 6b9db31c89..5d57b59908 100644 --- a/sdk/python/packages/flet/docs/tutorials/trolli.md +++ b/sdk/python/packages/flet/docs/tutorials/trolli.md @@ -607,7 +607,7 @@ def login(self, e): [ user_name, password, - ft.ElevatedButton(text="Login", on_click=close_dlg), + ft.Button(text="Login", on_click=close_dlg), ], tight=True, ), diff --git a/sdk/python/packages/flet/docs/types/buttonstyle.md b/sdk/python/packages/flet/docs/types/buttonstyle.md index a5680d00a5..bb1fc1e227 100644 --- a/sdk/python/packages/flet/docs/types/buttonstyle.md +++ b/sdk/python/packages/flet/docs/types/buttonstyle.md @@ -81,7 +81,7 @@ import flet as ft def main(page: ft.Page): page.add( - ft.ElevatedButton( + ft.Button( "Styled button 1", style=ft.ButtonStyle( color={ diff --git a/sdk/python/packages/flet/docs/types/buttontheme.md b/sdk/python/packages/flet/docs/types/buttontheme.md new file mode 100644 index 0000000000..3ad1eb4a13 --- /dev/null +++ b/sdk/python/packages/flet/docs/types/buttontheme.md @@ -0,0 +1 @@ +::: flet.ButtonTheme diff --git a/sdk/python/packages/flet/docs/types/elevatedbuttontheme.md b/sdk/python/packages/flet/docs/types/elevatedbuttontheme.md deleted file mode 100644 index 20f8a0af35..0000000000 --- a/sdk/python/packages/flet/docs/types/elevatedbuttontheme.md +++ /dev/null @@ -1 +0,0 @@ -::: flet.ElevatedButtonTheme diff --git a/sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/basic.png b/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/basic.png similarity index 100% rename from sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/basic.png rename to sdk/python/packages/flet/integration_tests/controls/golden/macos/button/basic.png diff --git a/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_1.png b/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_1.png deleted file mode 100644 index 37b225c370..0000000000 Binary files a/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_1.png and /dev/null differ diff --git a/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_2.png b/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_2.png deleted file mode 100644 index e3613f3407..0000000000 Binary files a/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_2.png and /dev/null differ diff --git a/sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/button_style.png b/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_style.png similarity index 100% rename from sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/button_style.png rename to sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_style.png diff --git a/sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/button_style_conflicts.png b/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_style_conflicts.png similarity index 100% rename from sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/button_style_conflicts.png rename to sdk/python/packages/flet/integration_tests/controls/golden/macos/button/button_style_conflicts.png diff --git a/sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/issue_5538.png b/sdk/python/packages/flet/integration_tests/controls/golden/macos/button/issue_5538.png similarity index 100% rename from sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/issue_5538.png rename to sdk/python/packages/flet/integration_tests/controls/golden/macos/button/issue_5538.png diff --git a/sdk/python/packages/flet/integration_tests/controls/test_banner.py b/sdk/python/packages/flet/integration_tests/controls/test_banner.py index a1ea6cd779..4a1061d8ee 100644 --- a/sdk/python/packages/flet/integration_tests/controls/test_banner.py +++ b/sdk/python/packages/flet/integration_tests/controls/test_banner.py @@ -19,7 +19,7 @@ def handle_banner_close(e: ft.Event[ft.TextButton]): flet_app.page.pop_dialog() flet_app.page.add(ft.Text(f"Action clicked: {e.control.content}")) - eb = ft.ElevatedButton( + eb = ft.Button( "Show Banner", on_click=lambda e: flet_app.page.show_dialog(banner), key="eb" ) banner = ft.Banner( diff --git a/sdk/python/packages/flet/integration_tests/controls/test_bottom_sheet.py b/sdk/python/packages/flet/integration_tests/controls/test_bottom_sheet.py index 01640481d0..e8f73ff02a 100644 --- a/sdk/python/packages/flet/integration_tests/controls/test_bottom_sheet.py +++ b/sdk/python/packages/flet/integration_tests/controls/test_bottom_sheet.py @@ -14,9 +14,7 @@ async def test_bottom_sheet_basic(flet_app: ftt.FletTestApp, request): tight=True, controls=[ ft.Text("Here is a bottom sheet!"), - ft.ElevatedButton( - "Dismiss", on_click=lambda _: flet_app.page.pop_dialog() - ), + ft.Button("Dismiss", on_click=lambda _: flet_app.page.pop_dialog()), ], ), ), diff --git a/sdk/python/packages/flet/integration_tests/controls/test_button.py b/sdk/python/packages/flet/integration_tests/controls/test_button.py index 4a2f8f3463..83adcf35ea 100644 --- a/sdk/python/packages/flet/integration_tests/controls/test_button.py +++ b/sdk/python/packages/flet/integration_tests/controls/test_button.py @@ -5,7 +5,8 @@ @pytest.mark.asyncio(loop_scope="module") -async def test_button_1(flet_app: ftt.FletTestApp, request): +async def test_basic(flet_app: ftt.FletTestApp, request): + flet_app.page.theme_mode = ft.ThemeMode.LIGHT await flet_app.assert_control_screenshot( request.node.name, ft.Button("Click me"), @@ -13,8 +14,61 @@ async def test_button_1(flet_app: ftt.FletTestApp, request): @pytest.mark.asyncio(loop_scope="module") -async def test_button_2(flet_app: ftt.FletTestApp, request): +async def test_issue_5538(flet_app: ftt.FletTestApp, request): await flet_app.assert_control_screenshot( request.node.name, - ft.Button("Something else!"), + ft.Column( + controls=[ + ft.Button( + content="Button 1", + style=ft.ButtonStyle(shape=ft.RoundedRectangleBorder(radius=4)), + ), + ft.Button( + content="Button 2", + bgcolor=ft.Colors.RED, + style=ft.ButtonStyle(shape=ft.RoundedRectangleBorder(radius=4)), + ), + ] + ), + ) + + +@pytest.mark.asyncio(loop_scope="module") +async def test_button_style(flet_app: ftt.FletTestApp, request): + flet_app.page.theme_mode = ft.ThemeMode.LIGHT + await flet_app.assert_control_screenshot( + request.node.name, + ft.Button( + content="Test Button", + style=ft.ButtonStyle( + bgcolor=ft.Colors.BLUE, + shape=ft.RoundedRectangleBorder(radius=10), + side=ft.BorderSide(width=3, color=ft.Colors.YELLOW), + padding=ft.Padding.all(20), + text_style=ft.TextStyle( + size=15, + weight=ft.FontWeight.BOLD, + color=ft.Colors.WHITE, + ), + ), + ), + ) + + +@pytest.mark.asyncio(loop_scope="module") +async def test_button_style_conflicts(flet_app: ftt.FletTestApp, request): + flet_app.page.theme_mode = ft.ThemeMode.LIGHT + await flet_app.assert_control_screenshot( + request.node.name, + ft.Button( + content="Test Button", + elevation=10, + color=ft.Colors.BLACK, + bgcolor=ft.Colors.BLUE, + style=ft.ButtonStyle( + elevation=2, + color=ft.Colors.WHITE, + bgcolor=ft.Colors.RED, + ), + ), ) diff --git a/sdk/python/packages/flet/integration_tests/controls/test_elevated_button.py b/sdk/python/packages/flet/integration_tests/controls/test_elevated_button.py deleted file mode 100644 index cdd4a64a86..0000000000 --- a/sdk/python/packages/flet/integration_tests/controls/test_elevated_button.py +++ /dev/null @@ -1,74 +0,0 @@ -import pytest - -import flet as ft -import flet.testing as ftt - - -@pytest.mark.asyncio(loop_scope="module") -async def test_basic(flet_app: ftt.FletTestApp, request): - flet_app.page.theme_mode = ft.ThemeMode.LIGHT - await flet_app.assert_control_screenshot( - request.node.name, - ft.ElevatedButton("Click me"), - ) - - -@pytest.mark.asyncio(loop_scope="module") -async def test_issue_5538(flet_app: ftt.FletTestApp, request): - await flet_app.assert_control_screenshot( - request.node.name, - ft.Column( - controls=[ - ft.ElevatedButton( - content="Button 1", - style=ft.ButtonStyle(shape=ft.RoundedRectangleBorder(radius=4)), - ), - ft.ElevatedButton( - content="Button 2", - bgcolor=ft.Colors.RED, - style=ft.ButtonStyle(shape=ft.RoundedRectangleBorder(radius=4)), - ), - ] - ), - ) - - -@pytest.mark.asyncio(loop_scope="module") -async def test_button_style(flet_app: ftt.FletTestApp, request): - flet_app.page.theme_mode = ft.ThemeMode.LIGHT - await flet_app.assert_control_screenshot( - request.node.name, - ft.ElevatedButton( - content="Test Button", - style=ft.ButtonStyle( - bgcolor=ft.Colors.BLUE, - shape=ft.RoundedRectangleBorder(radius=10), - side=ft.BorderSide(width=3, color=ft.Colors.YELLOW), - padding=ft.Padding.all(20), - text_style=ft.TextStyle( - size=15, - weight=ft.FontWeight.BOLD, - color=ft.Colors.WHITE, - ), - ), - ), - ) - - -@pytest.mark.asyncio(loop_scope="module") -async def test_button_style_conflicts(flet_app: ftt.FletTestApp, request): - flet_app.page.theme_mode = ft.ThemeMode.LIGHT - await flet_app.assert_control_screenshot( - request.node.name, - ft.ElevatedButton( - content="Test Button", - elevation=10, - color=ft.Colors.BLACK, - bgcolor=ft.Colors.BLUE, - style=ft.ButtonStyle( - elevation=2, - color=ft.Colors.WHITE, - bgcolor=ft.Colors.RED, - ), - ), - ) diff --git a/sdk/python/packages/flet/mkdocs.yml b/sdk/python/packages/flet/mkdocs.yml index cc2f44878e..38dd8e5759 100644 --- a/sdk/python/packages/flet/mkdocs.yml +++ b/sdk/python/packages/flet/mkdocs.yml @@ -225,11 +225,11 @@ nav: - Base: - AdaptiveControl: controls/adaptivecontrol.md - BaseControl: controls/basecontrol.md - - ConstrainedControl: controls/constrainedcontrol.md + - BasePage: controls/basepage.md - Control: controls/control.md - DialogControl: controls/dialogcontrol.md + - LayoutControl: controls/layoutcontrol.md - MultiView: controls/multiview.md - - BasePage: controls/basepage.md - ScrollableControl: controls/scrollablecontrol.md - Service: controls/service.md - Buttons: @@ -243,7 +243,6 @@ nav: - CupertinoSegmentedButton: controls/cupertinosegmentedbutton.md - CupertinoSlidingSegmentedButton: controls/cupertinoslidingsegmentedbutton.md - CupertinoTintedButton: controls/cupertinotintedbutton.md - - ElevatedButton: controls/elevatedbutton.md - FilledButton: controls/filledbutton.md - FilledIconButton: controls/fillediconbutton.md - FilledTonalButton: controls/filledtonalbutton.md @@ -472,6 +471,7 @@ nav: - BannerTheme: types/bannertheme.md - BottomAppBarTheme: types/bottomappbartheme.md - BottomSheetTheme: types/bottomsheettheme.md + - ButtonTheme: types/buttontheme.md - CardTheme: types/cardtheme.md - CheckboxTheme: types/checkboxtheme.md - ChipTheme: types/chiptheme.md @@ -481,7 +481,6 @@ nav: - DialogTheme: types/dialogtheme.md - DividerTheme: types/dividertheme.md - DropdownTheme: types/dropdowntheme.md - - ElevatedButtonTheme: types/elevatedbuttontheme.md - ExpansionTileTheme: types/expansiontiletheme.md - FilledButtonTheme: types/filledbuttontheme.md - FloatingActionButtonTheme: types/floatingactionbuttontheme.md diff --git a/sdk/python/packages/flet/src/flet/__init__.py b/sdk/python/packages/flet/src/flet/__init__.py index f7239bdc5c..564b6685dd 100644 --- a/sdk/python/packages/flet/src/flet/__init__.py +++ b/sdk/python/packages/flet/src/flet/__init__.py @@ -50,7 +50,6 @@ ) from flet.controls.cache import cache from flet.controls.colors import Colors -from flet.controls.constrained_control import ConstrainedControl from flet.controls.context import Context, context from flet.controls.control import Control from flet.controls.control_event import ( @@ -220,6 +219,7 @@ ) from flet.controls.icon_data import IconData from flet.controls.keys import Key, KeyValue, ScrollKey, ValueKey +from flet.controls.layout_control import ConstrainedControl, LayoutControl from flet.controls.margin import Margin, MarginValue from flet.controls.material import dropdown, dropdownm2, icons from flet.controls.material.alert_dialog import AlertDialog @@ -406,6 +406,7 @@ BannerTheme, BottomAppBarTheme, BottomSheetTheme, + ButtonTheme, CardTheme, CheckboxTheme, ChipTheme, @@ -415,7 +416,6 @@ DialogTheme, DividerTheme, DropdownTheme, - ElevatedButtonTheme, ExpansionTileTheme, FilledButtonTheme, FloatingActionButtonTheme, @@ -555,6 +555,7 @@ "BrowserContextMenu", "Button", "ButtonStyle", + "ButtonTheme", "Card", "CardTheme", "CardVariant", @@ -648,7 +649,6 @@ "Duration", "DurationValue", "ElevatedButton", - "ElevatedButtonTheme", "Event", "EventControlType", "EventHandler", @@ -703,6 +703,7 @@ "KeyboardListener", "KeyboardType", "LabelPosition", + "LayoutControl", "LinearGradient", "ListTile", "ListTileStyle", diff --git a/sdk/python/packages/flet/src/flet/controls/core/animated_switcher.py b/sdk/python/packages/flet/src/flet/controls/core/animated_switcher.py index 08eb3227df..883ace65a0 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/animated_switcher.py +++ b/sdk/python/packages/flet/src/flet/controls/core/animated_switcher.py @@ -3,9 +3,9 @@ from flet.controls.animation import AnimationCurve from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.duration import Duration, DurationValue +from flet.controls.layout_control import LayoutControl __all__ = ["AnimatedSwitcher", "AnimatedSwitcherTransition"] @@ -17,7 +17,7 @@ class AnimatedSwitcherTransition(Enum): @control("AnimatedSwitcher") -class AnimatedSwitcher(ConstrainedControl): +class AnimatedSwitcher(LayoutControl): """ Used to switch between controls with an animation. @@ -27,38 +27,38 @@ class AnimatedSwitcher(ConstrainedControl): content: Control """ - The content to display. When the [`content`][flet.AnimatedSwitcher.content] changes, - this switcher will animate the transition from the old/previous + The content to display. When the [`content`][flet.AnimatedSwitcher.content] changes, + this switcher will animate the transition from the old/previous [`content`][flet.AnimatedSwitcher.content] to the new one. """ duration: DurationValue = field(default_factory=lambda: Duration(seconds=1)) """ - The duration of the transition from the old [`content`][flet.AnimatedSwitcher.content] - to the new one. + The duration of the transition from the old + [`content`][flet.AnimatedSwitcher.content] to the new one. """ reverse_duration: DurationValue = field(default_factory=lambda: Duration(seconds=1)) """ - The duration of the transition from the new [`content`][flet.AnimatedSwitcher.content] - to the old one. + The duration of the transition from the new + [`content`][flet.AnimatedSwitcher.content] to the old one. """ switch_in_curve: AnimationCurve = AnimationCurve.LINEAR """ - The animation curve to use when transitioning in a + The animation curve to use when transitioning in a new [`content`][flet.AnimatedSwitcher.content]. """ switch_out_curve: AnimationCurve = AnimationCurve.LINEAR """ - The animation curve to use when transitioning an old + The animation curve to use when transitioning an old [`content`][flet.AnimatedSwitcher.content] out. """ transition: AnimatedSwitcherTransition = AnimatedSwitcherTransition.FADE """ - An animation type to transition between new and old + An animation type to transition between new and old [`content`][flet.AnimatedSwitcher.content]. """ diff --git a/sdk/python/packages/flet/src/flet/controls/core/canvas/canvas.py b/sdk/python/packages/flet/src/flet/controls/core/canvas/canvas.py index f62cc7f21b..e0879167fd 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/canvas/canvas.py +++ b/sdk/python/packages/flet/src/flet/controls/core/canvas/canvas.py @@ -2,10 +2,10 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import Event, EventHandler from flet.controls.core.canvas.shape import Shape +from flet.controls.layout_control import LayoutControl from flet.controls.types import Number __all__ = ["Canvas", "CanvasResizeEvent"] @@ -25,7 +25,7 @@ class CanvasResizeEvent(Event["Canvas"]): @control("Canvas") -class Canvas(ConstrainedControl): +class Canvas(LayoutControl): """ Canvas is a control for drawing arbitrary graphics using a set of primitives or "shapes" such as line, arc, path and text. diff --git a/sdk/python/packages/flet/src/flet/controls/core/column.py b/sdk/python/packages/flet/src/flet/controls/core/column.py index ab906b1bb5..966c9f036e 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/column.py +++ b/sdk/python/packages/flet/src/flet/controls/core/column.py @@ -2,8 +2,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.scrollable_control import ScrollableControl from flet.controls.types import CrossAxisAlignment, MainAxisAlignment, Number @@ -11,7 +11,7 @@ @control("Column") -class Column(ConstrainedControl, ScrollableControl, AdaptiveControl): +class Column(LayoutControl, ScrollableControl, AdaptiveControl): """ Container allows to decorate a control with background color and border and position it with padding, margin and alignment. @@ -36,8 +36,8 @@ class Column(ConstrainedControl, ScrollableControl, AdaptiveControl): """ Spacing between the `controls`. - It is applied only when [`alignment`][flet.Column.alignment] is `MainAxisAlignment.START`, - `MainAxisAlignment.END` or `MainAxisAlignment.CENTER`. + It is applied only when [`alignment`][flet.Column.alignment] is + `MainAxisAlignment.START`, `MainAxisAlignment.END` or `MainAxisAlignment.CENTER`. """ tight: bool = False @@ -50,8 +50,8 @@ class Column(ConstrainedControl, ScrollableControl, AdaptiveControl): wrap: bool = False """ - Whether the [`controls`][flet.Column.controls] should wrap into additional columns (runs) - when they don't fit in a single vertical column. + Whether the [`controls`][flet.Column.controls] should wrap into additional + columns (runs) when they don't fit in a single vertical column. """ run_spacing: Number = 10 @@ -61,7 +61,8 @@ class Column(ConstrainedControl, ScrollableControl, AdaptiveControl): run_alignment: MainAxisAlignment = MainAxisAlignment.START """ - How the runs should be placed in the cross-axis when [`wrap`][flet.Column.wrap] is `True`. + How the runs should be placed in the cross-axis when [`wrap`][flet.Column.wrap] + is `True`. """ def init(self): diff --git a/sdk/python/packages/flet/src/flet/controls/core/dismissible.py b/sdk/python/packages/flet/src/flet/controls/core/dismissible.py index 09953e76d7..3503a1b513 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/dismissible.py +++ b/sdk/python/packages/flet/src/flet/controls/core/dismissible.py @@ -3,7 +3,6 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ( ControlEventHandler, @@ -11,6 +10,7 @@ EventHandler, ) from flet.controls.duration import Duration, DurationValue +from flet.controls.layout_control import LayoutControl from flet.controls.material.snack_bar import DismissDirection from flet.controls.types import ( Number, @@ -33,7 +33,7 @@ class DismissibleUpdateEvent(Event["Dismissible"]): @control("Dismissible") -class Dismissible(ConstrainedControl, AdaptiveControl): +class Dismissible(LayoutControl, AdaptiveControl): """ A control that can be dismissed by dragging in the indicated [`dismiss_direction`][(c).]. diff --git a/sdk/python/packages/flet/src/flet/controls/core/flet_app.py b/sdk/python/packages/flet/src/flet/controls/core/flet_app.py index 164495d31a..f65185c82a 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/flet_app.py +++ b/sdk/python/packages/flet/src/flet/controls/core/flet_app.py @@ -1,14 +1,14 @@ from typing import Any, Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl __all__ = ["FletApp"] @control("FletApp") -class FletApp(ConstrainedControl): +class FletApp(LayoutControl): """ Renders another Flet app in the current app, similar to HTML IFrame, but for Flet. """ diff --git a/sdk/python/packages/flet/src/flet/controls/core/gesture_detector.py b/sdk/python/packages/flet/src/flet/controls/core/gesture_detector.py index 0142f51152..965681fb85 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/gesture_detector.py +++ b/sdk/python/packages/flet/src/flet/controls/core/gesture_detector.py @@ -2,7 +2,6 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import EventHandler from flet.controls.events import ( @@ -19,20 +18,21 @@ ScrollEvent, TapEvent, ) +from flet.controls.layout_control import LayoutControl from flet.controls.types import MouseCursor, PointerDeviceType __all__ = ["GestureDetector"] @control("GestureDetector") -class GestureDetector(ConstrainedControl, AdaptiveControl): +class GestureDetector(LayoutControl, AdaptiveControl): """ A control that detects gestures. Attempts to recognize gestures that correspond to its non-None callbacks. - If this control has a [`content`][(c).], it defers to that child control for its sizing - behavior, else it grows to fit the parent instead. + If this control has a [`content`][(c).], it defers to that child control for + its sizing behavior, else it grows to fit the parent instead. """ content: Optional[Control] = None @@ -89,14 +89,14 @@ class GestureDetector(ConstrainedControl, AdaptiveControl): on_tap_down: Optional[EventHandler[TapEvent["GestureDetector"]]] = None """ - Called when a pointer that might cause a tap with a primary button has contacted the screen - at a particular location. + Called when a pointer that might cause a tap with a primary button has contacted + the screen at a particular location. """ on_tap_up: Optional[EventHandler[TapEvent["GestureDetector"]]] = None """ - Called when a pointer that will trigger a tap with a primary button has stopped contacting the - screen at a particular location. + Called when a pointer that will trigger a tap with a primary button has stopped + contacting the screen at a particular location. """ on_multi_tap: Optional[EventHandler[TapEvent["GestureDetector"]]] = None @@ -118,14 +118,14 @@ class GestureDetector(ConstrainedControl, AdaptiveControl): on_secondary_tap_down: Optional[EventHandler[TapEvent["GestureDetector"]]] = None """ - Called when a pointer that might cause a tap with a secondary button has contacted the screen - at a particular location. + Called when a pointer that might cause a tap with a secondary button has contacted + the screen at a particular location. """ on_secondary_tap_up: Optional[EventHandler[TapEvent["GestureDetector"]]] = None """ - Called when a pointer that will trigger a tap with a secondary button has stopped contacting the - screen at a particular location. + Called when a pointer that will trigger a tap with a secondary button has stopped + contacting the screen at a particular location. """ on_long_press_start: Optional[ @@ -142,8 +142,8 @@ class GestureDetector(ConstrainedControl, AdaptiveControl): None ) """ - Called when a pointer that has triggered a long-press with a primary button has stopped - contacting the screen. + Called when a pointer that has triggered a long-press with a primary button has + stopped contacting the screen. """ on_secondary_long_press_start: Optional[ @@ -160,8 +160,8 @@ class GestureDetector(ConstrainedControl, AdaptiveControl): EventHandler[LongPressEndEvent["GestureDetector"]] ] = None """ - Called when a pointer that has triggered a long-press with a secondary button has stopped - contacting the screen. + Called when a pointer that has triggered a long-press with a secondary button has + stopped contacting the screen. """ on_double_tap: Optional[EventHandler[TapEvent["GestureDetector"]]] = None @@ -172,8 +172,8 @@ class GestureDetector(ConstrainedControl, AdaptiveControl): on_double_tap_down: Optional[EventHandler[TapEvent["GestureDetector"]]] = None """ - Called when a pointer that might cause a double tap has contacted the screen at a particular - location. + Called when a pointer that might cause a double tap has contacted the screen at + a particular location. Triggered immediately after the down event of the second tap. """ @@ -182,24 +182,24 @@ class GestureDetector(ConstrainedControl, AdaptiveControl): EventHandler[DragStartEvent["GestureDetector"]] ] = None """ - Called when a pointer has contacted the screen with a primary button and has begun to move - horizontally. + Called when a pointer has contacted the screen with a primary button and has + begun to move horizontally. """ on_horizontal_drag_update: Optional[ EventHandler[DragUpdateEvent["GestureDetector"]] ] = None """ - Called when a pointer that is in contact with the screen and moving horizontally has moved in - the horizontal direction. + Called when a pointer that is in contact with the screen and moving horizontally + has moved in the horizontal direction. """ on_horizontal_drag_end: Optional[EventHandler[DragEndEvent["GestureDetector"]]] = ( None ) """ - Called when a pointer moving horizontally is no longer in contact and was moving at a specific - velocity. + Called when a pointer moving horizontally is no longer in contact and was + moving at a specific velocity. """ on_vertical_drag_start: Optional[ @@ -218,8 +218,8 @@ class GestureDetector(ConstrainedControl, AdaptiveControl): on_vertical_drag_end: Optional[EventHandler[DragEndEvent["GestureDetector"]]] = None """ - Called when a pointer moving vertically is no longer in contact and was moving at a specific - velocity. + Called when a pointer moving vertically is no longer in contact and was + moving at a specific velocity. """ on_pan_start: Optional[EventHandler[DragStartEvent["GestureDetector"]]] = None @@ -257,8 +257,8 @@ class GestureDetector(ConstrainedControl, AdaptiveControl): on_scale_start: Optional[EventHandler[ScaleStartEvent["GestureDetector"]]] = None """ - Called when the pointers in contact with the screen have established a focal point and initial - scale of `1.0`. + Called when the pointers in contact with the screen have established a focal + point and initial scale of `1.0`. """ on_scale_update: Optional[EventHandler[ScaleUpdateEvent["GestureDetector"]]] = None diff --git a/sdk/python/packages/flet/src/flet/controls/core/grid_view.py b/sdk/python/packages/flet/src/flet/controls/core/grid_view.py index 14c7be175c..ca23ca9b6b 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/grid_view.py +++ b/sdk/python/packages/flet/src/flet/controls/core/grid_view.py @@ -3,8 +3,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.scrollable_control import ScrollableControl from flet.controls.types import ClipBehavior, Number @@ -13,12 +13,13 @@ @control("GridView") -class GridView(ConstrainedControl, ScrollableControl, AdaptiveControl): +class GridView(LayoutControl, ScrollableControl, AdaptiveControl): """ A scrollable, 2D array of controls. It is very effective for large lists (thousands of items). - Prefer it over wrapping [`Column`][flet.Column]s or [`Row`][flet.Row]s for smooth scrolling. + Prefer it over wrapping [`Column`][flet.Column]s or + [`Row`][flet.Row]s for smooth scrolling. """ controls: list[Control] = field(default_factory=list) diff --git a/sdk/python/packages/flet/src/flet/controls/core/icon.py b/sdk/python/packages/flet/src/flet/controls/core/icon.py index 33b0ae91ae..0b8d1caf71 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/icon.py +++ b/sdk/python/packages/flet/src/flet/controls/core/icon.py @@ -2,14 +2,14 @@ from flet.controls.base_control import control from flet.controls.box import BoxShadowValue -from flet.controls.constrained_control import ConstrainedControl +from flet.controls.layout_control import LayoutControl from flet.controls.types import BlendMode, ColorValue, IconData, Number __all__ = ["Icon"] @control("Icon") -class Icon(ConstrainedControl): +class Icon(LayoutControl): """ A control that displays an icon from a built-in or custom icon set. diff --git a/sdk/python/packages/flet/src/flet/controls/core/image.py b/sdk/python/packages/flet/src/flet/controls/core/image.py index 0a5484965b..494a7ecf27 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/image.py +++ b/sdk/python/packages/flet/src/flet/controls/core/image.py @@ -3,8 +3,8 @@ from flet.controls.base_control import control from flet.controls.border_radius import BorderRadiusValue from flet.controls.box import BoxFit, FilterQuality -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( BlendMode, ColorValue, @@ -15,7 +15,7 @@ @control("Image") -class Image(ConstrainedControl): +class Image(LayoutControl): """ Displays an image. The following popular formats are supported: JPEG, PNG, SVG, GIF, Animated GIF, WebP, Animated WebP, BMP, and WBMP. diff --git a/sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py b/sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py index 087c94eab7..1c515f5a5b 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py +++ b/sdk/python/packages/flet/src/flet/controls/core/interactive_viewer.py @@ -2,7 +2,6 @@ from flet.controls.alignment import Alignment from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import EventHandler from flet.controls.duration import DurationValue @@ -11,6 +10,7 @@ ScaleStartEvent, ScaleUpdateEvent, ) +from flet.controls.layout_control import LayoutControl from flet.controls.margin import MarginValue from flet.controls.types import ClipBehavior, Number @@ -18,7 +18,7 @@ @control("InteractiveViewer") -class InteractiveViewer(ConstrainedControl): +class InteractiveViewer(LayoutControl): """ Allows you to pan, zoom, and rotate its [`content`][(c).]. diff --git a/sdk/python/packages/flet/src/flet/controls/core/list_view.py b/sdk/python/packages/flet/src/flet/controls/core/list_view.py index ce286ff93e..0b257a18f2 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/list_view.py +++ b/sdk/python/packages/flet/src/flet/controls/core/list_view.py @@ -3,8 +3,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.scrollable_control import ScrollableControl from flet.controls.types import ClipBehavior, Number @@ -13,7 +13,7 @@ @control("ListView") -class ListView(ConstrainedControl, ScrollableControl, AdaptiveControl): +class ListView(LayoutControl, ScrollableControl, AdaptiveControl): """ A scrollable list of controls arranged linearly. @@ -36,7 +36,8 @@ class ListView(ConstrainedControl, ScrollableControl, AdaptiveControl): """ Whether the scroll view scrolls in the reading direction. - For example, if the reading direction is left-to-right and [`horizontal`][flet.ListView.horizontal] is `True`, + For example, if the reading direction is left-to-right and + [`horizontal`][flet.ListView.horizontal] is `True`, then the scroll view scrolls from left to right when `reverse` is `False` and from right to left when `reverse` is `True`. diff --git a/sdk/python/packages/flet/src/flet/controls/core/markdown.py b/sdk/python/packages/flet/src/flet/controls/core/markdown.py index 0805080084..6954e2cd50 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/markdown.py +++ b/sdk/python/packages/flet/src/flet/controls/core/markdown.py @@ -4,10 +4,10 @@ from flet.controls.base_control import control from flet.controls.box import BoxDecoration -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler, EventHandler from flet.controls.core.text import TextSelectionChangeEvent +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.text_style import TextStyle from flet.controls.types import ( @@ -19,10 +19,10 @@ __all__ = [ "Markdown", - "MarkdownExtensionSet", - "MarkdownStyleSheet", "MarkdownCodeTheme", "MarkdownCustomCodeTheme", + "MarkdownExtensionSet", + "MarkdownStyleSheet", ] @@ -230,7 +230,7 @@ class MarkdownCustomCodeTheme: @control("Markdown") -class Markdown(ConstrainedControl): +class Markdown(LayoutControl): """ Renders text in markdown format. """ @@ -317,7 +317,8 @@ class Markdown(ConstrainedControl): """ Called when a link within Markdown document is clicked/tapped. - The [`data`][flet.Event.data] property of the event handler argument contains the clickedURL. + The [`data`][flet.Event.data] property of the event handler argument + contains the clickedURL. Example: https://github.com/flet-dev/examples/blob/main/python/controls/information-displays/markdown/markdown-event-example.py diff --git a/sdk/python/packages/flet/src/flet/controls/core/pagelet.py b/sdk/python/packages/flet/src/flet/controls/core/pagelet.py index a096c82821..88b52a9b05 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/pagelet.py +++ b/sdk/python/packages/flet/src/flet/controls/core/pagelet.py @@ -2,10 +2,10 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.cupertino.cupertino_app_bar import CupertinoAppBar from flet.controls.cupertino.cupertino_navigation_bar import CupertinoNavigationBar +from flet.controls.layout_control import LayoutControl from flet.controls.material.app_bar import AppBar from flet.controls.material.bottom_app_bar import BottomAppBar from flet.controls.material.navigation_bar import NavigationBar @@ -17,12 +17,13 @@ @control("Pagelet") -class Pagelet(ConstrainedControl, AdaptiveControl): +class Pagelet(LayoutControl, AdaptiveControl): """ Implements the basic Material Design visual layout structure. - Use it for projects that require a "page within a page" layouts with its own [`AppBar`][flet..], - [`BottomAppBar`][flet..], [`NavigationDrawer`][flet..], such as demos and galleries. + Use it for projects that require a "page within a page" layouts with its own + [`AppBar`][flet..], [`BottomAppBar`][flet..], [`NavigationDrawer`][flet..], + such as demos and galleries. Raises: AssertionError: If [`content`][(c).] is not visible. @@ -50,7 +51,8 @@ class Pagelet(ConstrainedControl, AdaptiveControl): Note: If both the `navigation_bar` and [`bottom_appbar`][flet.Pagelet.bottom_appbar] - properties are specified, `navigation_bar` takes precedence and will be displayed. + properties are specified, `navigation_bar` takes precedence and will + be displayed. """ bottom_appbar: Optional[BottomAppBar] = None @@ -60,7 +62,8 @@ class Pagelet(ConstrainedControl, AdaptiveControl): Note: If both the `bottom_appbar` and [`navigation_bar`][flet.Pagelet.navigation_bar] - properties are specified, `bottom_appbar` takes precedence and will be displayed. + properties are specified, `bottom_appbar` takes precedence and will + be displayed. """ bottom_sheet: Optional[Control] = None diff --git a/sdk/python/packages/flet/src/flet/controls/core/placeholder.py b/sdk/python/packages/flet/src/flet/controls/core/placeholder.py index 0bc22defe9..538fcc25b4 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/placeholder.py +++ b/sdk/python/packages/flet/src/flet/controls/core/placeholder.py @@ -2,15 +2,15 @@ from flet.controls.base_control import control from flet.controls.colors import Colors -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.types import ColorValue, Number __all__ = ["Placeholder"] @control("Placeholder") -class Placeholder(ConstrainedControl): +class Placeholder(LayoutControl): """ A placeholder box. """ diff --git a/sdk/python/packages/flet/src/flet/controls/core/reorderable_draggable.py b/sdk/python/packages/flet/src/flet/controls/core/reorderable_draggable.py index 2ecc62cc65..af2f6e531c 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/reorderable_draggable.py +++ b/sdk/python/packages/flet/src/flet/controls/core/reorderable_draggable.py @@ -1,11 +1,11 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl @control("ReorderableDraggable") -class ReorderableDraggable(ConstrainedControl, AdaptiveControl): +class ReorderableDraggable(LayoutControl, AdaptiveControl): """ Used to drag an item in a [`ReorderableListView`][flet.ReorderableListView]. diff --git a/sdk/python/packages/flet/src/flet/controls/core/responsive_row.py b/sdk/python/packages/flet/src/flet/controls/core/responsive_row.py index 4679de3463..b57d1d61ad 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/responsive_row.py +++ b/sdk/python/packages/flet/src/flet/controls/core/responsive_row.py @@ -3,8 +3,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( CrossAxisAlignment, MainAxisAlignment, @@ -13,19 +13,19 @@ ResponsiveRowBreakpoint, ) -__all__ = ["ResponsiveRow", "ResponsiveRowBreakpoint", "ResponsiveNumber"] +__all__ = ["ResponsiveNumber", "ResponsiveRow", "ResponsiveRowBreakpoint"] @control("ResponsiveRow") -class ResponsiveRow(ConstrainedControl, AdaptiveControl): +class ResponsiveRow(LayoutControl, AdaptiveControl): """ Allows aligning child controls to virtual columns. By default, a virtual grid has 12 columns, but that can be customized with [`columns`][(c).] property. - Similar to `expand` property, every control has [`col`][flet.Control.col] property which allows - specifying how many columns a control should span. + Similar to `expand` property, every control has [`col`][flet.Control.col] + property which allows specifying how many columns a control should span. """ controls: list[Control] = field(default_factory=list) @@ -40,12 +40,14 @@ class ResponsiveRow(ConstrainedControl, AdaptiveControl): alignment: MainAxisAlignment = MainAxisAlignment.START """ - Defines how the child [`controls`][flet.ResponsiveRow.controls] should be placed horizontally. + Defines how the child [`controls`][flet.ResponsiveRow.controls] should be + placed horizontally. """ vertical_alignment: CrossAxisAlignment = CrossAxisAlignment.START """ - Defines how the child [`controls`][flet.ResponsiveRow.controls] should be placed vertically. + Defines how the child [`controls`][flet.ResponsiveRow.controls] should be placed + vertically. """ spacing: ResponsiveNumber = 10 diff --git a/sdk/python/packages/flet/src/flet/controls/core/row.py b/sdk/python/packages/flet/src/flet/controls/core/row.py index c12cfdd0b2..a15e22b5c7 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/row.py +++ b/sdk/python/packages/flet/src/flet/controls/core/row.py @@ -2,8 +2,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.scrollable_control import ScrollableControl from flet.controls.types import CrossAxisAlignment, MainAxisAlignment, Number @@ -11,7 +11,7 @@ @control("Row") -class Row(ConstrainedControl, ScrollableControl, AdaptiveControl): +class Row(LayoutControl, ScrollableControl, AdaptiveControl): """ Displays its children in a horizontal array. diff --git a/sdk/python/packages/flet/src/flet/controls/core/safe_area.py b/sdk/python/packages/flet/src/flet/controls/core/safe_area.py index b4d79fadfb..58ceb19347 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/safe_area.py +++ b/sdk/python/packages/flet/src/flet/controls/core/safe_area.py @@ -1,17 +1,17 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue __all__ = ["SafeArea"] @control("SafeArea") -class SafeArea(ConstrainedControl, AdaptiveControl): +class SafeArea(LayoutControl, AdaptiveControl): """ - A control that insets its [`content`][(c).] by sufficient padding to avoid intrusions by - the operating system. + A control that insets its [`content`][(c).] by sufficient padding to avoid + intrusions by the operating system. For example, this will indent the `content` by enough to avoid the status bar at the top of the screen. @@ -19,8 +19,8 @@ class SafeArea(ConstrainedControl, AdaptiveControl): It will also indent the `content` by the amount necessary to avoid the Notch on the iPhone X, or other similar creative physical features of the display. - When a [`minimum_padding`][(c).] is specified, the greater of the minimum padding or the - safe area padding will be applied. + When a [`minimum_padding`][(c).] is specified, the greater of the minimum padding + or the safe area padding will be applied. Raises: AssertionError: If [`content`][(c).] is not visible. diff --git a/sdk/python/packages/flet/src/flet/controls/core/shader_mask.py b/sdk/python/packages/flet/src/flet/controls/core/shader_mask.py index a414ddb196..7f2b2c680c 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/shader_mask.py +++ b/sdk/python/packages/flet/src/flet/controls/core/shader_mask.py @@ -2,16 +2,16 @@ from flet.controls.base_control import control from flet.controls.border_radius import BorderRadiusValue -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.gradients import Gradient +from flet.controls.layout_control import LayoutControl from flet.controls.types import BlendMode __all__ = ["ShaderMask"] @control("ShaderMask") -class ShaderMask(ConstrainedControl): +class ShaderMask(LayoutControl): """ Applies a mask generated by a shader to its [`content`][(c).]. @@ -31,7 +31,8 @@ class ShaderMask(ConstrainedControl): blend_mode: BlendMode = BlendMode.MODULATE """ - The blend mode to use when applying the shader to the [`content`][flet.ShaderMask.content]. + The blend mode to use when applying the shader to the + [`content`][flet.ShaderMask.content]. """ border_radius: Optional[BorderRadiusValue] = None diff --git a/sdk/python/packages/flet/src/flet/controls/core/stack.py b/sdk/python/packages/flet/src/flet/controls/core/stack.py index 70023dd65f..85ed23521c 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/stack.py +++ b/sdk/python/packages/flet/src/flet/controls/core/stack.py @@ -5,8 +5,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.alignment import Alignment from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.types import ClipBehavior __all__ = ["Stack", "StackFit"] @@ -19,9 +19,10 @@ class StackFit(Enum): @control("Stack") -class Stack(ConstrainedControl, AdaptiveControl): +class Stack(LayoutControl, AdaptiveControl): """ - Positions its children on top of each other, following a LIFO (Last In First Out) order. + Positions its children on top of each other, following a LIFO (Last In First Out) + order. This control is useful if you want to overlap several children in a simple way. For example having some text and an image, overlaid with a gradient and a button @@ -48,8 +49,8 @@ class Stack(ConstrainedControl, AdaptiveControl): alignment: Optional[Alignment] = None """ Specifies the alignment for non-positioned (those without explicit - alignment properties such as [`top`][flet.ConstrainedControl.top] - or [`bottom`][flet.ConstrainedControl.bottom]) and + alignment properties such as [`top`][flet.LayoutControl.top] + or [`bottom`][flet.LayoutControl.bottom]) and partially-positioned [`controls`][flet.Stack.controls]. """ diff --git a/sdk/python/packages/flet/src/flet/controls/core/text.py b/sdk/python/packages/flet/src/flet/controls/core/text.py index 00b1dc7c05..3fe1f23af8 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/text.py +++ b/sdk/python/packages/flet/src/flet/controls/core/text.py @@ -3,7 +3,6 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ( ControlEventHandler, Event, @@ -11,6 +10,7 @@ EventHandler, ) from flet.controls.core.text_span import TextSpan +from flet.controls.layout_control import LayoutControl from flet.controls.text_style import TextOverflow, TextStyle, TextThemeStyle from flet.controls.types import ( ColorValue, @@ -21,10 +21,10 @@ __all__ = [ "Text", + "TextAffinity", "TextSelection", - "TextSelectionChangeEvent", "TextSelectionChangeCause", - "TextAffinity", + "TextSelectionChangeEvent", ] @@ -172,7 +172,7 @@ class TextSelectionChangeEvent(Event[EventControlType]): @control("Text") -class Text(ConstrainedControl): +class Text(LayoutControl): """ Display text. @@ -319,8 +319,8 @@ class Text(ConstrainedControl): The cursor will be drawn under the text. The cursor width will extend to the right of the boundary between characters for - left-to-right text and to the left for right-to-left text. This corresponds to extending - downstream relative to the selected position. + left-to-right text and to the left for right-to-left text. This corresponds + to extending downstream relative to the selected position. Negative values may be used to reverse this behavior. Note: diff --git a/sdk/python/packages/flet/src/flet/controls/core/transparent_pointer.py b/sdk/python/packages/flet/src/flet/controls/core/transparent_pointer.py index b26e2a3784..520a27e82d 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/transparent_pointer.py +++ b/sdk/python/packages/flet/src/flet/controls/core/transparent_pointer.py @@ -1,20 +1,20 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl __all__ = ["TransparentPointer"] @control("TransparentPointer") -class TransparentPointer(ConstrainedControl): +class TransparentPointer(LayoutControl): """ TransparentPointer is the solution to ["How to pass through all gestures between two widgets in Stack"](https://stackoverflow.com/questions/65269190/pass-trough-all- gestures-between-two-widgets-in-stack) problem. - For example, if there is an [`ElevatedButton`][flet.ElevatedButton] + For example, if there is an [`Button`][flet.Button] inside [`Container`][flet.Container] with [`GestureDetector`][flet.GestureDetector] then tapping on a button won't be "visible" to a gesture detector behind it. With diff --git a/sdk/python/packages/flet/src/flet/controls/core/view.py b/sdk/python/packages/flet/src/flet/controls/core/view.py index 84617adf0b..fc825e5bb3 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/view.py +++ b/sdk/python/packages/flet/src/flet/controls/core/view.py @@ -3,11 +3,11 @@ from flet.controls.base_control import BaseControl, control from flet.controls.box import BoxDecoration -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler from flet.controls.cupertino.cupertino_app_bar import CupertinoAppBar from flet.controls.cupertino.cupertino_navigation_bar import CupertinoNavigationBar +from flet.controls.layout_control import LayoutControl from flet.controls.material.app_bar import AppBar from flet.controls.material.bottom_app_bar import BottomAppBar from flet.controls.material.floating_action_button import FloatingActionButton @@ -28,7 +28,7 @@ @control("View") -class View(ScrollableControl, ConstrainedControl): +class View(ScrollableControl, LayoutControl): """ View is the top most container for all other controls. diff --git a/sdk/python/packages/flet/src/flet/controls/core/window_drag_area.py b/sdk/python/packages/flet/src/flet/controls/core/window_drag_area.py index 3fb2834dfe..5889742bc4 100644 --- a/sdk/python/packages/flet/src/flet/controls/core/window_drag_area.py +++ b/sdk/python/packages/flet/src/flet/controls/core/window_drag_area.py @@ -1,15 +1,15 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import EventHandler from flet.controls.core.window import WindowEvent from flet.controls.events import DragEndEvent, DragStartEvent +from flet.controls.layout_control import LayoutControl @control("WindowDragArea") -class WindowDragArea(ConstrainedControl): +class WindowDragArea(LayoutControl): """ It mimics the behavior (drag, move, maximize, restore) of a native OS window title bar on the [`content`][(c).] control. @@ -36,9 +36,9 @@ class WindowDragArea(ConstrainedControl): Called when the `WindowDragArea` is double-tapped and `maximizable=True`. Info: - When a double-tap event is fired, the [`type`][flet.WindowEvent.type] property of the - event handler argument can only be one of the following: `WindowEventType.MAXIMIZE`, - `WindowEventType.UNMAXIMIZE`. + When a double-tap event is fired, the [`type`][flet.WindowEvent.type] + property of the event handler argument can only be one of the following: + `WindowEventType.MAXIMIZE`, `WindowEventType.UNMAXIMIZE`. """ on_drag_start: Optional[EventHandler[DragStartEvent["WindowDragArea"]]] = None diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_action_sheet.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_action_sheet.py index c92804d83b..b9c7d0e055 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_action_sheet.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_action_sheet.py @@ -1,15 +1,15 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.types import StrOrControl __all__ = ["CupertinoActionSheet"] @control("CupertinoActionSheet") -class CupertinoActionSheet(ConstrainedControl): +class CupertinoActionSheet(LayoutControl): """ An iOS-style action sheet. """ @@ -33,7 +33,8 @@ class CupertinoActionSheet(ConstrainedControl): """ A list of action buttons to be shown in the sheet. - These actions are typically [`CupertinoActionSheetAction`][flet.CupertinoActionSheetAction]s. + These actions are typically + [`CupertinoActionSheetAction`][flet.CupertinoActionSheetAction]s. This list must have at least one action. """ diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_action_sheet_action.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_action_sheet_action.py index b7cdbe51aa..20544f2968 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_action_sheet_action.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_action_sheet_action.py @@ -1,15 +1,15 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.types import MouseCursor, StrOrControl __all__ = ["CupertinoActionSheetAction"] @control("CupertinoActionSheetAction") -class CupertinoActionSheetAction(ConstrainedControl): +class CupertinoActionSheetAction(LayoutControl): """ An action button typically used in a CupertinoActionSheet. diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_activity_indicator.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_activity_indicator.py index 8a92efe9d9..f811b96bfc 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_activity_indicator.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_activity_indicator.py @@ -1,14 +1,14 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl +from flet.controls.layout_control import LayoutControl from flet.controls.types import ColorValue, Number __all__ = ["CupertinoActivityIndicator"] @control("CupertinoActivityIndicator") -class CupertinoActivityIndicator(ConstrainedControl): +class CupertinoActivityIndicator(LayoutControl): """ An iOS-style activity indicator that spins clockwise. diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_button.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_button.py index 4c4f974b61..783ecfecd9 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_button.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_button.py @@ -5,9 +5,9 @@ from flet.controls.alignment import Alignment from flet.controls.base_control import control from flet.controls.border_radius import BorderRadius, BorderRadiusValue -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.geometry import Size +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ( ColorValue, @@ -28,7 +28,7 @@ class CupertinoButtonSize(Enum): @control("CupertinoButton") -class CupertinoButton(ConstrainedControl): +class CupertinoButton(LayoutControl): """ An iOS-style button. diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_checkbox.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_checkbox.py index 009cb2e291..9b0a9d36b1 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_checkbox.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_checkbox.py @@ -3,10 +3,10 @@ from flet.controls.base_control import control from flet.controls.border import BorderSide from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue from flet.controls.cupertino.cupertino_colors import CupertinoColors +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ColorValue, LabelPosition, @@ -17,7 +17,7 @@ @control("CupertinoCheckbox") -class CupertinoCheckbox(ConstrainedControl): +class CupertinoCheckbox(LayoutControl): """ A macOS style checkbox. Checkbox allows to select one or more items from a group, or switch between two mutually exclusive options (checked or unchecked, on or off). @@ -30,7 +30,8 @@ class CupertinoCheckbox(ConstrainedControl): label_position: LabelPosition = LabelPosition.RIGHT """ - Defines on which side of the checkbox the [`label`][flet.CupertinoCheckbox.label] should be shown. + Defines on which side of the checkbox the [`label`][flet.CupertinoCheckbox.label] + should be shown. """ value: Optional[bool] = False @@ -39,12 +40,14 @@ class CupertinoCheckbox(ConstrainedControl): - If `True` the checkbox is checked. - If `False` the checkbox is unchecked. - - If `None` and [`tristate`][flet.CupertinoCheckbox.tristate] is `True` the checkbox is indeterminate. (displayed as a dash) + - If `None` and [`tristate`][flet.CupertinoCheckbox.tristate] is `True` + the checkbox is indeterminate. (displayed as a dash) """ tristate: bool = False """ - If `True` the checkbox's [`value`][flet.CupertinoCheckbox.value] can be `True`, `False`, or `None`. + If `True` the checkbox's [`value`][flet.CupertinoCheckbox.value] can be `True`, + `False`, or `None`. """ autofocus: bool = False @@ -89,9 +92,10 @@ class CupertinoCheckbox(ConstrainedControl): [`ControlState.FOCUSED`][flet.ControlState.FOCUSED], and [`ControlState.DEFAULT`][flet.ControlState.DEFAULT]. - [`active_color`][flet.CupertinoCheckbox.active_color] is used as fallback color when the checkbox is in the `SELECTED` - state, `CupertinoColors.WHITE` at 50% opacity is used as fallback color when this - checkbox is in the `DISABLED` state, and `CupertinoColors.WHITE` otherwise. + [`active_color`][flet.CupertinoCheckbox.active_color] is used as fallback color when + the checkbox is in the `SELECTED` state, `CupertinoColors.WHITE` at 50% opacity + is used as fallback color when this checkbox is in the `DISABLED` state, + and `CupertinoColors.WHITE` otherwise. """ shape: Optional[OutlinedBorder] = None diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_date_picker.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_date_picker.py index 444e63311b..05aaca2541 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_date_picker.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_date_picker.py @@ -4,15 +4,15 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.duration import DateTimeValue +from flet.controls.layout_control import LayoutControl from flet.controls.types import ColorValue, Number __all__ = [ "CupertinoDatePicker", - "CupertinoDatePickerMode", "CupertinoDatePickerDateOrder", + "CupertinoDatePickerMode", ] @@ -31,7 +31,7 @@ class CupertinoDatePickerDateOrder(Enum): @control("CupertinoDatePicker") -class CupertinoDatePicker(ConstrainedControl): +class CupertinoDatePicker(LayoutControl): """ An iOS-styled date picker. """ @@ -52,7 +52,8 @@ class CupertinoDatePicker(ConstrainedControl): Defaults to `None` - no limit. When not `None` (no limit), one can still scroll the picker to dates earlier than - `first_date`, with the exception that the [`on_change`][flet.CupertinoDatePicker.on_change] will not be called. + `first_date`, with the exception that the + [`on_change`][flet.CupertinoDatePicker.on_change] will not be called. Once let go, the picker will scroll back to `first_date`. In `CupertinoDatePickerMode.TIME` mode, a time becomes unselectable if the @@ -69,7 +70,8 @@ class CupertinoDatePicker(ConstrainedControl): `last_date`, with the exception that the `on_change` will not be called. Once let go, the picker will scroll back to `last_date`. - In [`CupertinoDatePickerMode.TIME`][flet.CupertinoDatePickerMode.TIME] mode, a time becomes unselectable if the + In [`CupertinoDatePickerMode.TIME`][flet.CupertinoDatePickerMode.TIME] mode, + a time becomes unselectable if the datetime produced by combining that particular time and the date part of initialDateTime is later than `last_date`. So typically `last_date` needs to be set to a datetime that is on the same date as initialDateTime. @@ -133,18 +135,20 @@ class CupertinoDatePicker(ConstrainedControl): Note: The final order in which the columns are displayed is also influenced by - the [`date_picker_mode`][flet.CupertinoDatePicker.date_picker_mode]. For example, if - `date_picker_mode` is [`CupertinoDatePickerMode.MONTH_YEAR`][flet.CupertinoDatePickerMode.MONTH_YEAR] + the [`date_picker_mode`][flet.CupertinoDatePicker.date_picker_mode]. + For example,if `date_picker_mode` is + [`CupertinoDatePickerMode.MONTH_YEAR`][flet.CupertinoDatePickerMode.MONTH_YEAR] both [`CupertinoDatePickerDateOrder.DAY_MONTH_YEAR`][flet.CupertinoDatePickerDateOrder.DAY_MONTH_YEAR] and [`CupertinoDatePickerDateOrder.MONTH_DAY_YEAR`][flet.CupertinoDatePickerDateOrder.MONTH_DAY_YEAR] will result in the month|year order. - """ + """ # noqa: E501 on_change: Optional[ControlEventHandler["CupertinoDatePicker"]] = None """ Called when the selected date and/or time changes. Will not fire if the new - selected value is not valid, or is not in the range of [`first_date`][flet.CupertinoDatePicker.first_date] and + selected value is not valid, or is not in the range of + [`first_date`][flet.CupertinoDatePicker.first_date] and [`last_date`][flet.CupertinoDatePicker.last_date]. """ @@ -161,7 +165,8 @@ def before_update(self): f"item_extent must be strictly greater than 0, got {self.item_extent}" ) assert self.minute_interval > 0 and 60 % self.minute_interval == 0, ( - f"minute_interval must be a positive integer factor of 60, got {self.minute_interval}" + f"minute_interval must be a positive integer factor of 60, " + f"got {self.minute_interval}" ) if self.date_picker_mode == CupertinoDatePickerMode.DATE_AND_TIME: @@ -201,7 +206,8 @@ def before_update(self): if self.date_picker_mode != CupertinoDatePickerMode.DATE: assert not self.show_day_of_week, ( - "show_day_of_week is only supported when date_picker_mode is CupertinoDatePickerMode.DATE" + "show_day_of_week is only supported when date_picker_mode is " + "CupertinoDatePickerMode.DATE" ) assert value.minute % self.minute_interval == 0, ( diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_list_tile.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_list_tile.py index 88aae3cded..98108ec24a 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_list_tile.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_list_tile.py @@ -1,8 +1,8 @@ from typing import Optional, Union from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ( ColorValue, @@ -16,7 +16,7 @@ @control("CupertinoListTile") -class CupertinoListTile(ConstrainedControl): +class CupertinoListTile(LayoutControl): """ An iOS-style list tile. diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_navigation_bar.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_navigation_bar.py index 857bb44142..d7784944a1 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_navigation_bar.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_navigation_bar.py @@ -2,9 +2,9 @@ from flet.controls.base_control import control from flet.controls.border import Border -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.cupertino.cupertino_colors import CupertinoColors +from flet.controls.layout_control import LayoutControl from flet.controls.material.navigation_bar import NavigationBarDestination from flet.controls.types import ( ColorValue, @@ -15,7 +15,7 @@ @control("CupertinoNavigationBar") -class CupertinoNavigationBar(ConstrainedControl): +class CupertinoNavigationBar(LayoutControl): """ An iOS-styled bottom navigation tab bar. diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_picker.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_picker.py index a7cb39362f..e7d530a3d1 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_picker.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_picker.py @@ -2,10 +2,10 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler from flet.controls.cupertino.cupertino_colors import CupertinoColors +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ColorValue, Number, @@ -15,12 +15,13 @@ @control("CupertinoPicker") -class CupertinoPicker(ConstrainedControl): +class CupertinoPicker(LayoutControl): """ An iOS-styled picker. Raises: - AssertionError: If [`item_extent`][(c).], [`squeeze`][(c).], or [`magnification`][(c).] is not strictly greater than `0.0`. + AssertionError: If [`item_extent`][(c).], [`squeeze`][(c).], + or [`magnification`][(c).] is not strictly greater than `0.0`. """ controls: list[Control] = field(default_factory=list) @@ -35,7 +36,8 @@ class CupertinoPicker(ConstrainedControl): selected_index: int = 0 """ - The index (starting from `0`) of the selected item in the [`controls`][flet.CupertinoPicker.controls] list. + The index (starting from `0`) of the selected item in + the [`controls`][flet.CupertinoPicker.controls] list. """ bgcolor: Optional[ColorValue] = None @@ -86,7 +88,7 @@ class CupertinoPicker(ConstrainedControl): Defaults to a rounded rectangle in iOS 14 style with [`default_selection_overlay_bgcolor`][flet.CupertinoPicker.default_selection_overlay_bgcolor] as background color. - """ + """ # noqa: E501 default_selection_overlay_bgcolor: ColorValue = CupertinoColors.TERTIARY_SYSTEM_FILL """ diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_radio.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_radio.py index 0cf34d81da..3876c0ee5f 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_radio.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_radio.py @@ -2,8 +2,8 @@ from flet.controls.base_control import control from flet.controls.colors import Colors -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ColorValue, LabelPosition, @@ -14,9 +14,10 @@ @control("CupertinoRadio") -class CupertinoRadio(ConstrainedControl): +class CupertinoRadio(LayoutControl): """ - A macOS-styled radio button, allowing the user to select a single option from two or more choices. + A macOS-styled radio button, allowing the user to select a single option from two + or more choices. """ label: Optional[str] = None @@ -26,7 +27,8 @@ class CupertinoRadio(ConstrainedControl): value: str = "" """ - The value to set to [`RadioGroup`][flet.RadioGroup] ancestor/parent when the radio is selected. + The value to set to [`RadioGroup`][flet.RadioGroup] ancestor/parent when the radio + is selected. """ label_position: LabelPosition = LabelPosition.RIGHT diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_segmented_button.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_segmented_button.py index 83d11eb8b5..3db01b0df1 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_segmented_button.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_segmented_button.py @@ -1,9 +1,9 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ColorValue @@ -11,13 +11,15 @@ @control("CupertinoSegmentedButton") -class CupertinoSegmentedButton(ConstrainedControl): +class CupertinoSegmentedButton(LayoutControl): """ An iOS-style segmented button. Raises: - AssertionError: If [`controls`][(c).] does not contain at least two visible controls. - IndexError: If [`selected_index`][flet.CupertinoSegmentedButton.selected_index] is out of range. + AssertionError: If [`controls`][(c).] does not contain at least two visible + controls. + IndexError: If [`selected_index`][flet.CupertinoSegmentedButton.selected_index] + is out of range. """ controls: list[Control] @@ -61,14 +63,16 @@ class CupertinoSegmentedButton(ConstrainedControl): The color used to fill the background of this control when temporarily interacting with through a long press or drag. - Defaults to the [`selected_color`][flet.CupertinoSegmentedButton.selected_color] with 20% opacity. + Defaults to the [`selected_color`][flet.CupertinoSegmentedButton.selected_color] + with 20% opacity. """ disabled_color: Optional[ColorValue] = None """ The color used to fill the background of the segment when it is disabled. - If `None`, this color will be 50% opacity of the [`selected_color`][flet.CupertinoSegmentedButton.selected_color] when + If `None`, this color will be 50% opacity of the + [`selected_color`][flet.CupertinoSegmentedButton.selected_color] when the segment is selected. If the segment is unselected, this color will be set to the [`unselected_color`][flet.CupertinoSegmentedButton.unselected_color]. """ @@ -94,5 +98,6 @@ def before_update(self): if not (0 <= self.selected_index < visible_controls_count): raise IndexError( f"selected_index ({self.selected_index}) is out of range. " - f"Expected a value between 0 and {visible_controls_count - 1}, inclusive." + f"Expected a value between 0 and {visible_controls_count - 1}, " + "inclusive." ) diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_slider.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_slider.py index 7fbffc032d..5b99dca52f 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_slider.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_slider.py @@ -1,8 +1,8 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ColorValue, Number, @@ -12,7 +12,7 @@ @control("CupertinoSlider") -class CupertinoSlider(ConstrainedControl): +class CupertinoSlider(LayoutControl): """ An iOS-type slider. @@ -42,7 +42,8 @@ class CupertinoSlider(ConstrainedControl): Note: - Must be less than or equal to [`max`][flet.CupertinoSlider.max]. - - If the [`max`][flet.CupertinoSlider.max] is equal to the `min`, then the slider is disabled. + - If the [`max`][flet.CupertinoSlider.max] is equal to the `min`, + then the slider is disabled. """ max: Number = 1.0 @@ -51,7 +52,8 @@ class CupertinoSlider(ConstrainedControl): Note: - Must be greater than or equal to [`min`][flet.CupertinoSlider.min]. - - If the [`min`][flet.CupertinoSlider.min] is equal to the `max`, then the slider is disabled. + - If the [`min`][flet.CupertinoSlider.min] is equal to the `max`, + then the slider is disabled. """ divisions: Optional[int] = None diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_sliding_segmented_button.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_sliding_segmented_button.py index 12f3e58410..28aa265d4b 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_sliding_segmented_button.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_sliding_segmented_button.py @@ -2,10 +2,10 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler from flet.controls.cupertino.cupertino_colors import CupertinoColors +from flet.controls.layout_control import LayoutControl from flet.controls.padding import Padding, PaddingValue from flet.controls.types import ( ColorValue, @@ -15,14 +15,15 @@ @control("CupertinoSlidingSegmentedButton") -class CupertinoSlidingSegmentedButton(ConstrainedControl): +class CupertinoSlidingSegmentedButton(LayoutControl): """ A cupertino sliding segmented button. Raises: - AssertionError: If [`controls`][(c).] does not contain at least two visible controls. + AssertionError: If [`controls`][(c).] does not contain at least two + visible controls. IndexError: If [`selected_index`][flet.CupertinoSlidingSegmentedButton.selected_index] is out of range. - """ + """ # noqa: E501 controls: list[Control] """ @@ -52,7 +53,8 @@ class CupertinoSlidingSegmentedButton(ConstrainedControl): default_factory=lambda: Padding.symmetric(vertical=2, horizontal=3) ) """ - The amount of space by which to inset the [`controls`][flet.CupertinoSlidingSegmentedButton.controls]. + The amount of space by which to inset the + [`controls`][flet.CupertinoSlidingSegmentedButton.controls]. """ proportional_width: bool = False @@ -86,5 +88,6 @@ def before_update(self): if not (0 <= self.selected_index < visible_controls_count): raise IndexError( f"selected_index ({self.selected_index}) is out of range. " - f"Expected a value between 0 and {visible_controls_count - 1}, inclusive." + f"Expected a value between 0 and {visible_controls_count - 1}, " + "inclusive." ) diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_switch.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_switch.py index ccd2b1e16d..1e9722a777 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_switch.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_switch.py @@ -1,9 +1,9 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ColorValue, IconData, @@ -15,7 +15,7 @@ @control("CupertinoSwitch") -class CupertinoSwitch(ConstrainedControl): +class CupertinoSwitch(LayoutControl): """ An iOS-style switch. Used to toggle the on/off state of a single setting. """ diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_textfield.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_textfield.py index 5a787504fa..63aef200ef 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_textfield.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_textfield.py @@ -94,8 +94,10 @@ class CupertinoTextField(TextField): padding: PaddingValue = field(default_factory=lambda: Padding.all(7)) """ - The padding around the text entry area between the [`prefix`][flet.CupertinoTextField.prefix] + The padding around the text entry area between the + [`prefix`][flet.CupertinoTextField.prefix] and [`suffix`][flet.CupertinoTextField.suffix] or the - clear button when [`clear_button_visibility_mode`][flet.CupertinoTextField.clear_button_visibility_mode] + clear button when + [`clear_button_visibility_mode`][flet.CupertinoTextField.clear_button_visibility_mode] is not [`OverlayVisibilityMode.NEVER`][flet.OverlayVisibilityMode.NEVER]. """ diff --git a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_timer_picker.py b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_timer_picker.py index 9e7a1cb9fe..ae31f07b56 100644 --- a/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_timer_picker.py +++ b/sdk/python/packages/flet/src/flet/controls/cupertino/cupertino_timer_picker.py @@ -4,9 +4,9 @@ from flet.controls.alignment import Alignment from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.duration import Duration, DurationValue +from flet.controls.layout_control import LayoutControl from flet.controls.types import ColorValue, Number __all__ = ["CupertinoTimerPicker", "CupertinoTimerPickerMode"] @@ -19,7 +19,7 @@ class CupertinoTimerPickerMode(Enum): @control("CupertinoTimerPicker") -class CupertinoTimerPicker(ConstrainedControl): +class CupertinoTimerPicker(LayoutControl): """ A countdown timer picker in iOS style. @@ -29,10 +29,14 @@ class CupertinoTimerPicker(ConstrainedControl): Raises: AssertionError: If [`value`][(c).] is negative. AssertionError: If [`value`][(c).] is 24 hours or more. - AssertionError: If [`minute_interval`][(c).] is not a positive integer factor of `60`. - AssertionError: If [`second_interval`][(c).] is not a positive integer factor of `60`. - AssertionError: If [`value`][(c).] is not a multiple of [`minute_interval`][(c).]. - AssertionError: If [`value`][(c).] is not a multiple of [`second_interval`][(c).]. + AssertionError: If [`minute_interval`][(c).] is not a positive integer + factor of `60`. + AssertionError: If [`second_interval`][(c).] is not a positive integer + factor of `60`. + AssertionError: If [`value`][(c).] is not a multiple + of [`minute_interval`][(c).]. + AssertionError: If [`value`][(c).] is not a multiple + of [`second_interval`][(c).]. AssertionError: If [`item_extent`][(c).] is not strictly greater than `0.0`. """ @@ -80,9 +84,10 @@ class CupertinoTimerPicker(ConstrainedControl): on_change: Optional[ControlEventHandler["CupertinoTimerPicker"]] = None """ Called when the timer's duration changes. - + The [`data`][flet.Event] property of the event handler argument is the new duration. - It has the same [type][flet.DurationValue] as [`value`][flet.CupertinoTimerPicker.value]. + It has the same [type][flet.DurationValue] as + [`value`][flet.CupertinoTimerPicker.value]. """ def before_update(self): @@ -94,21 +99,25 @@ def before_update(self): else Duration(seconds=self.value) ) assert value >= Duration(), "value must be a non-negative duration" - assert value < Duration( - hours=24 - ), f"value must be strictly less than 24 hours, got {value.in_hours} hours" - assert ( - self.minute_interval > 0 and 60 % self.minute_interval == 0 - ), f"minute_interval ({self.minute_interval}) must be a positive integer factor of 60" - assert ( - self.second_interval > 0 and 60 % self.second_interval == 0 - ), f"second_interval ({self.second_interval}) must be a positive integer factor of 60" - assert ( - value.in_minutes % self.minute_interval == 0 - ), f"value ({value.in_minutes} minutes) must be a multiple of minute_interval ({self.minute_interval})" - assert ( - value.in_seconds % self.second_interval == 0 - ), f"value ({value.in_seconds} seconds) must be a multiple of second_interval ({self.second_interval})" - assert ( - self.item_extent > 0 - ), f"item_extent must be strictly greater than 0.0, got {self.item_extent}" + assert value < Duration(hours=24), ( + f"value must be strictly less than 24 hours, got {value.in_hours} hours" + ) + assert self.minute_interval > 0 and 60 % self.minute_interval == 0, ( + f"minute_interval ({self.minute_interval}) must be a positive " + "integer factor of 60" + ) + assert self.second_interval > 0 and 60 % self.second_interval == 0, ( + f"second_interval ({self.second_interval}) must be a positive " + "integer factor of 60" + ) + assert value.in_minutes % self.minute_interval == 0, ( + f"value ({value.in_minutes} minutes) must be a multiple " + f"of minute_interval ({self.minute_interval})" + ) + assert value.in_seconds % self.second_interval == 0, ( + f"value ({value.in_seconds} seconds) must be a multiple " + f"of second_interval ({self.second_interval})" + ) + assert self.item_extent > 0, ( + f"item_extent must be strictly greater than 0.0, got {self.item_extent}" + ) diff --git a/sdk/python/packages/flet/src/flet/controls/constrained_control.py b/sdk/python/packages/flet/src/flet/controls/layout_control.py similarity index 86% rename from sdk/python/packages/flet/src/flet/controls/constrained_control.py rename to sdk/python/packages/flet/src/flet/controls/layout_control.py index 50b1b73aa4..4d67faddaa 100644 --- a/sdk/python/packages/flet/src/flet/controls/constrained_control.py +++ b/sdk/python/packages/flet/src/flet/controls/layout_control.py @@ -8,12 +8,13 @@ from flet.controls.margin import MarginValue from flet.controls.transform import OffsetValue, RotateValue, ScaleValue from flet.controls.types import Number +from flet.utils import deprecated_class -__all__ = ["ConstrainedControl"] +__all__ = ["LayoutControl"] @control(kw_only=True) -class ConstrainedControl(Control): +class LayoutControl(Control): width: Optional[Number] = None """ Imposed Control width in virtual pixels. @@ -168,7 +169,7 @@ def main(page: ft.Page): animate_opacity: Optional[AnimationValue] = None """ - Enables implicit animation of the [`opacity`][flet.ConstrainedControl.opacity] + Enables implicit animation of the [`opacity`][flet.LayoutControl.opacity] property. More information [here](https://docs.flet-docs.pages.dev/cookbook/cookbook/animations). @@ -182,16 +183,16 @@ def main(page: ft.Page): animate_position: Optional[AnimationValue] = None """ Enables implicit animation of the positioning properties - ([`left`][flet.ConstrainedControl.left], [`right`][flet.ConstrainedControl.right], - [`top`][flet.ConstrainedControl.top] and - [`bottom`][flet.ConstrainedControl.bottom]). + ([`left`][flet.LayoutControl.left], [`right`][flet.LayoutControl.right], + [`top`][flet.LayoutControl.top] and + [`bottom`][flet.LayoutControl.bottom]). More information [here](https://docs.flet-docs.pages.dev/cookbook/cookbook/animations). """ animate_align: Optional[AnimationValue] = None """ - Enables implicit animation of the [`align`][flet.ConstrainedControl.align] + Enables implicit animation of the [`align`][flet.LayoutControl.align] property. More information [here](https://docs.flet-docs.pages.dev/cookbook/cookbook/animations). @@ -199,7 +200,7 @@ def main(page: ft.Page): animate_margin: Optional[AnimationValue] = None """ - Enables implicit animation of the [`margin`][flet.ConstrainedControl.margin] + Enables implicit animation of the [`margin`][flet.LayoutControl.margin] property. More information [here](https://docs.flet-docs.pages.dev/cookbook/cookbook/animations). @@ -207,7 +208,7 @@ def main(page: ft.Page): animate_rotation: Optional[AnimationValue] = None """ - Enables implicit animation of the [`rotate`][flet.ConstrainedControl.rotate] + Enables implicit animation of the [`rotate`][flet.LayoutControl.rotate] property. More information [here](https://docs.flet-docs.pages.dev/cookbook/cookbook/animations). @@ -215,20 +216,20 @@ def main(page: ft.Page): animate_scale: Optional[AnimationValue] = None """ - Enables implicit animation of the [`scale`][flet.ConstrainedControl.scale] property. + Enables implicit animation of the [`scale`][flet.LayoutControl.scale] property. More information [here](https://docs.flet-docs.pages.dev/cookbook/cookbook/animations). """ animate_offset: Optional[AnimationValue] = None """ - Enables implicit animation of the [`offset`][flet.ConstrainedControl.offset] + Enables implicit animation of the [`offset`][flet.LayoutControl.offset] property. More information [here](https://docs.flet-docs.pages.dev/cookbook/cookbook/animations). """ - on_animation_end: Optional[ControlEventHandler["ConstrainedControl"]] = None + on_animation_end: Optional[ControlEventHandler["LayoutControl"]] = None """ Called when animation completes. @@ -239,3 +240,12 @@ def main(page: ft.Page): More information [here](https://docs.flet-docs.pages.dev/cookbook/cookbook/animations). """ + + +@deprecated_class( + reason="Inherit from LayoutControl instead.", + version="0.70.0", + delete_version="1.0", +) +class ConstrainedControl(LayoutControl): + pass diff --git a/sdk/python/packages/flet/src/flet/controls/material/bottom_app_bar.py b/sdk/python/packages/flet/src/flet/controls/material/bottom_app_bar.py index f3cf7ea12b..b64a5f3e70 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/bottom_app_bar.py +++ b/sdk/python/packages/flet/src/flet/controls/material/bottom_app_bar.py @@ -1,8 +1,8 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ( ClipBehavior, @@ -15,7 +15,7 @@ @control("BottomAppBar") -class BottomAppBar(ConstrainedControl): +class BottomAppBar(LayoutControl): """ A material design bottom app bar. diff --git a/sdk/python/packages/flet/src/flet/controls/material/button.py b/sdk/python/packages/flet/src/flet/controls/material/button.py index 0f66666993..dc8cc993ab 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/button.py @@ -1,11 +1,89 @@ -from flet.controls.material.elevated_button import ElevatedButton +from dataclasses import field +from typing import Optional, Union + +from flet.controls.adaptive_control import AdaptiveControl +from flet.controls.base_control import control +from flet.controls.buttons import ButtonStyle +from flet.controls.control import Control +from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl +from flet.controls.types import ( + ClipBehavior, + ColorValue, + IconDataOrControl, + Number, + StrOrControl, + Url, +) __all__ = ["Button"] -class Button(ElevatedButton): +@control("Button") +class Button(LayoutControl, AdaptiveControl): """ - Elevated buttons or Buttons are essentially filled tonal buttons with a shadow. To - prevent shadow creep, only use them when absolutely necessary, such as when the - button requires visual separation from a patterned background. + A customizable button control that can display text, icons, or both. It supports + various styles, colors, and event handlers for user interaction. + + Example: + ```python + import flet as ft + + + def main(page: ft.Page): + def on_click(e): + print("Button clicked!") + + page.add( + ft.Button( + content="Click Me", + icon=ft.Icons.ADD, + color="white", + bgcolor="blue", + on_click=on_click, + ) + ) + + + ft.run(main) + ``` """ + + content: Optional[StrOrControl] = None + icon: Optional[IconDataOrControl] = None + icon_color: Optional[ColorValue] = None + color: Optional[ColorValue] = field(default=None, metadata={"skip": True}) + bgcolor: Optional[ColorValue] = field(default=None, metadata={"skip": True}) + elevation: Number = field(default=1, metadata={"skip": True}) + style: Optional[ButtonStyle] = field(default=None, metadata={"skip": True}) + autofocus: Optional[bool] = None + clip_behavior: Optional[ClipBehavior] = None + url: Optional[Union[str, Url]] = None + on_click: Optional[ControlEventHandler["Button"]] = None + on_long_press: Optional[ControlEventHandler["Button"]] = None + on_hover: Optional[ControlEventHandler["Button"]] = None + on_focus: Optional[ControlEventHandler["Button"]] = None + on_blur: Optional[ControlEventHandler["Button"]] = None + + def before_update(self): + super().before_update() + assert ( + self.icon + or isinstance(self.content, str) + or (isinstance(self.content, Control) and self.content.visible) + ), "At least icon or content (string or visible Control) must be provided" + + if ( + self.style is not None + or self.color is not None + or self.bgcolor is not None + or self.elevation != 1 + ): + self._internals["style"] = (self.style or ButtonStyle()).copy( + color=self.color, + bgcolor=self.bgcolor, + elevation=self.elevation, + ) + + async def focus(self): + await self._invoke_method("focus") diff --git a/sdk/python/packages/flet/src/flet/controls/material/card.py b/sdk/python/packages/flet/src/flet/controls/material/card.py index 0c8376ab21..8bc4bebb4e 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/card.py +++ b/sdk/python/packages/flet/src/flet/controls/material/card.py @@ -4,8 +4,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control +from flet.controls.layout_control import LayoutControl from flet.controls.types import ClipBehavior, ColorValue, Number __all__ = ["Card", "CardVariant"] @@ -18,7 +18,7 @@ class CardVariant(Enum): @control("Card") -class Card(ConstrainedControl, AdaptiveControl): +class Card(LayoutControl, AdaptiveControl): """ A material design card: a panel with slightly rounded corners and an elevation shadow. diff --git a/sdk/python/packages/flet/src/flet/controls/material/checkbox.py b/sdk/python/packages/flet/src/flet/controls/material/checkbox.py index c7620db18c..74b74d9b62 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/checkbox.py +++ b/sdk/python/packages/flet/src/flet/controls/material/checkbox.py @@ -4,9 +4,9 @@ from flet.controls.base_control import control from flet.controls.border import BorderSide from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.text_style import TextStyle from flet.controls.types import ( ColorValue, @@ -21,7 +21,7 @@ @control("Checkbox") -class Checkbox(ConstrainedControl, AdaptiveControl): +class Checkbox(LayoutControl, AdaptiveControl): """ Checkbox allows to select one or more items from a group, or switch between two mutually exclusive options (checked or unchecked, on or off). @@ -38,7 +38,8 @@ class Checkbox(ConstrainedControl, AdaptiveControl): - If `True` the checkbox is checked. - If `False` the checkbox is unchecked. - - If `None` and [`tristate`][flet.Checkbox.tristate] is `True` the checkbox is indeterminate. (displayed as a dash) + - If `None` and [`tristate`][flet.Checkbox.tristate] is `True` the checkbox + is indeterminate. (displayed as a dash) """ label_position: LabelPosition = LabelPosition.RIGHT @@ -53,7 +54,8 @@ class Checkbox(ConstrainedControl, AdaptiveControl): tristate: bool = False """ - If `True` the checkbox's [`value`][flet.Checkbox.value] can be `True`, `False`, or `None`. + If `True` the checkbox's [`value`][flet.Checkbox.value] can be `True`, `False`, + or `None`. """ autofocus: bool = False @@ -131,13 +133,14 @@ class Checkbox(ConstrainedControl, AdaptiveControl): """ The radius of the circular Material ink response (ripple) in logical pixels. - Defaults to [`CheckboxTheme.splash_radius`][flet.CheckboxTheme.splash_radius], or if that is `None`, - falls back to `20.0`. + Defaults to [`CheckboxTheme.splash_radius`][flet.CheckboxTheme.splash_radius], + or if that is `None`, falls back to `20.0`. """ border_side: Optional[ControlStateValue[BorderSide]] = None """ - The color and width of the checkbox's border in all or specific [`ControlState`][flet.ControlState]s. + The color and width of the checkbox's border in all or specific + [`ControlState`][flet.ControlState]s. Supported states: [`ControlState.SELECTED`][flet.ControlState.SELECTED], [`ControlState.HOVERED`][flet.ControlState.HOVERED], @@ -147,7 +150,8 @@ class Checkbox(ConstrainedControl, AdaptiveControl): [`ControlState.ERROR`][flet.ControlState.ERROR], and [`ControlState.DEFAULT`][flet.ControlState.DEFAULT]. - Defaults to [`CheckboxTheme.border_side`][flet.CheckboxTheme.border_side], or if that is `None`, + Defaults to [`CheckboxTheme.border_side`][flet.CheckboxTheme.border_side], + or if that is `None`, falls back to `BorderSide` with a width of `2.0`. """ @@ -169,8 +173,8 @@ class Checkbox(ConstrainedControl, AdaptiveControl): The cursor to be displayed when a mouse pointer enters or is hovering over this control. - Defaults to [`CheckboxTheme.mouse_cursor`][flet.CheckboxTheme.mouse_cursor], or if that is `None`, - falls back to `MouseCursor.CLICK`. + Defaults to [`CheckboxTheme.mouse_cursor`][flet.CheckboxTheme.mouse_cursor], + or if that is `None`, falls back to `MouseCursor.CLICK`. """ on_change: Optional[ControlEventHandler["Checkbox"]] = None diff --git a/sdk/python/packages/flet/src/flet/controls/material/chip.py b/sdk/python/packages/flet/src/flet/controls/material/chip.py index 6def4942cd..ed2c77c6d4 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/chip.py +++ b/sdk/python/packages/flet/src/flet/controls/material/chip.py @@ -5,10 +5,10 @@ from flet.controls.border import BorderSide from flet.controls.box import BoxConstraints from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.text_style import TextStyle from flet.controls.types import ( @@ -23,7 +23,7 @@ @control("Chip") -class Chip(ConstrainedControl): +class Chip(LayoutControl): """ Chips are compact elements that represent an attribute, text, entity, or action. diff --git a/sdk/python/packages/flet/src/flet/controls/material/circle_avatar.py b/sdk/python/packages/flet/src/flet/controls/material/circle_avatar.py index 8eb6704b9e..9568dead0f 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/circle_avatar.py +++ b/sdk/python/packages/flet/src/flet/controls/material/circle_avatar.py @@ -1,8 +1,8 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ColorValue, Number, @@ -13,7 +13,7 @@ @control("CircleAvatar") -class CircleAvatar(ConstrainedControl): +class CircleAvatar(LayoutControl): """ A circle that represents a user. @@ -21,16 +21,18 @@ class CircleAvatar(ConstrainedControl): and if this also fails, then [`bgcolor`][(c).] is used. Raises: - AssertionError: If [`radius`][(c).] or [`min_radius`][(c).] or [`max_radius`][(c).] is negative. - AssertionError: If [`radius`][(c).] is set and [`min_radius`][(c).] or [`max_radius`][(c).] is not None. + AssertionError: If [`radius`][(c).] or [`min_radius`][(c).] + or [`max_radius`][(c).] is negative. + AssertionError: If [`radius`][(c).] is set and [`min_radius`][(c).] + or [`max_radius`][(c).] is not None. """ content: Optional[StrOrControl] = None """ The content of this avatar. - - Typically a [`Text`][flet.Text] control. - + + Typically a [`Text`][flet.Text] control. + If this avatar is to have an image, use [`background_image_src`][flet.CircleAvatar.background_image_src] instead. """ @@ -38,79 +40,85 @@ class CircleAvatar(ConstrainedControl): foreground_image_src: Optional[str] = None """ The source (local asset file or URL) of the foreground image in the circle. - + Fallbacks to [`background_image_src`][flet.CircleAvatar.background_image_src]. - - Typically used as profile image. + + Typically used as profile image. """ background_image_src: Optional[str] = None """ The source (local asset file or URL) of the background image in the circle. Changing the background image will cause the avatar to animate to the new image. - - Typically used as a fallback image for [`foreground_image_src`][flet.CircleAvatar.foreground_image_src]. - If this avatar is to have the user's initials, use [`content`][flet.CircleAvatar.content] instead. + + Typically used as a fallback image for + [`foreground_image_src`][flet.CircleAvatar.foreground_image_src]. + If this avatar is to have the user's initials, use + [`content`][flet.CircleAvatar.content] instead. """ color: Optional[ColorValue] = None """ - The default color for text in this avatar. - + The default color for text in this avatar. + Defaults to the primary text theme color if no `bgcolor` is specified. """ bgcolor: Optional[ColorValue] = None """ The color with which to fill the circle. - + Changing the background color will cause this avatar to animate to the new color. """ radius: Optional[Number] = None """ The size of the avatar, expressed as the radius (half the diameter). If `radius` is - specified, then neither [`min_radius`][flet.CircleAvatar.min_radius] nor + specified, then neither [`min_radius`][flet.CircleAvatar.min_radius] nor [`max_radius`][flet.CircleAvatar.max_radius] may be specified. """ min_radius: Optional[Number] = None """ The minimum size of the avatar, expressed as the radius (half the diameter). If - `min_radius` is specified, then [`radius`][flet.CircleAvatar.radius] should not be specified. - + `min_radius` is specified, then [`radius`][flet.CircleAvatar.radius] should not + be specified. + Defaults to `0.0`. """ max_radius: Optional[Number] = None """ - The maximum size of the avatar, expressed as the radius (half the diameter). - - If `max_radius` is specified, then [`radius`][flet.CircleAvatar.radius] should not be specified. - + The maximum size of the avatar, expressed as the radius (half the diameter). + + If `max_radius` is specified, then [`radius`][flet.CircleAvatar.radius] should + not be specified. + Defaults to "infinity". """ on_image_error: Optional[ControlEventHandler["CircleAvatar"]] = None """ - Called when an error occurs while loading the [`background_image_src`][flet.CircleAvatar.background_image_src] or + Called when an error occurs while loading the + [`background_image_src`][flet.CircleAvatar.background_image_src] or [`foreground_image_src`][flet.CircleAvatar.foreground_image_src]. - The [`data`][flet.Event.data] property of the event handler argument is a string whose value is - either `"background"` or `"foreground"` indicating the error's origin. + The [`data`][flet.Event.data] property of the event handler argument is + a string whose value is either `"background"` or `"foreground"` indicating + the error's origin. """ def before_update(self): super().before_update() - assert ( - self.radius is None or self.radius >= 0 - ), f"radius must be greater than or equal to 0, got {self.radius}" - assert ( - self.min_radius is None or self.min_radius >= 0 - ), f"min_radius must be greater than or equal to 0, got {self.min_radius}" - assert ( - self.max_radius is None or self.max_radius >= 0 - ), f"max_radius must be greater than or equal to 0, got {self.max_radius}" + assert self.radius is None or self.radius >= 0, ( + f"radius must be greater than or equal to 0, got {self.radius}" + ) + assert self.min_radius is None or self.min_radius >= 0, ( + f"min_radius must be greater than or equal to 0, got {self.min_radius}" + ) + assert self.max_radius is None or self.max_radius >= 0, ( + f"max_radius must be greater than or equal to 0, got {self.max_radius}" + ) assert self.radius is None or ( self.min_radius is None and self.max_radius is None ), "If radius is set, min_radius and max_radius must be None" diff --git a/sdk/python/packages/flet/src/flet/controls/material/container.py b/sdk/python/packages/flet/src/flet/controls/material/container.py index e273d9a692..a9a500bc46 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/container.py +++ b/sdk/python/packages/flet/src/flet/controls/material/container.py @@ -14,11 +14,11 @@ ColorFilter, DecorationImage, ) -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler, EventHandler from flet.controls.events import TapEvent from flet.controls.gradients import Gradient +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.theme import Theme from flet.controls.types import ( @@ -33,7 +33,7 @@ @control("Container") -class Container(ConstrainedControl, AdaptiveControl): +class Container(LayoutControl, AdaptiveControl): """ Allows to decorate a control with background color and border and position it with padding, margin and alignment. @@ -197,7 +197,7 @@ def main(page: ft.Page): page.add( # Page theme ft.Container( - content=ft.ElevatedButton("Page theme button"), + content=ft.Button("Page theme button"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST, padding=20, width=300, @@ -206,7 +206,7 @@ def main(page: ft.Page): # Inherited theme with primary color overridden ft.Container( theme=ft.Theme(color_scheme=ft.ColorScheme(primary=ft.Colors.PINK)), - content=ft.ElevatedButton("Inherited theme button"), + content=ft.Button("Inherited theme button"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST, padding=20, width=300, @@ -216,7 +216,7 @@ def main(page: ft.Page): ft.Container( theme=ft.Theme(color_scheme_seed=ft.Colors.INDIGO), theme_mode=ft.ThemeMode.DARK, - content=ft.ElevatedButton("Unique theme button"), + content=ft.Button("Unique theme button"), bgcolor=ft.Colors.SURFACE_CONTAINER_HIGHEST, padding=20, width=300, diff --git a/sdk/python/packages/flet/src/flet/controls/material/datatable.py b/sdk/python/packages/flet/src/flet/controls/material/datatable.py index 4a70e6c92a..3fff9fb0a5 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/datatable.py +++ b/sdk/python/packages/flet/src/flet/controls/material/datatable.py @@ -4,7 +4,6 @@ from flet.controls.base_control import control from flet.controls.border import Border, BorderSide from flet.controls.border_radius import BorderRadiusValue -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ( ControlEventHandler, @@ -14,6 +13,7 @@ from flet.controls.control_state import ControlStateValue from flet.controls.events import TapEvent from flet.controls.gradients import Gradient +from flet.controls.layout_control import LayoutControl from flet.controls.text_style import TextStyle from flet.controls.types import ( ClipBehavior, @@ -292,7 +292,7 @@ def before_update(self): @control("DataTable") -class DataTable(ConstrainedControl): +class DataTable(LayoutControl): """ A Material Design data table. diff --git a/sdk/python/packages/flet/src/flet/controls/material/dropdown.py b/sdk/python/packages/flet/src/flet/controls/material/dropdown.py index e3bd52bcc4..8a13cf3dfe 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/dropdown.py +++ b/sdk/python/packages/flet/src/flet/controls/material/dropdown.py @@ -4,10 +4,10 @@ from flet.controls.base_control import control from flet.controls.border_radius import BorderRadiusValue from flet.controls.buttons import ButtonStyle -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.material.form_field_control import InputBorder from flet.controls.material.icons import Icons from flet.controls.material.textfield import InputFilter, TextCapitalization @@ -74,7 +74,7 @@ def before_update(self): @control("Dropdown") -class Dropdown(ConstrainedControl): +class Dropdown(LayoutControl): """ A dropdown control that allows users to select a single option from a list of options. diff --git a/sdk/python/packages/flet/src/flet/controls/material/elevated_button.py b/sdk/python/packages/flet/src/flet/controls/material/elevated_button.py index 3df80dcee8..029aa97862 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/elevated_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/elevated_button.py @@ -1,179 +1,13 @@ -from dataclasses import field -from typing import Optional, Union - -from flet.controls.adaptive_control import AdaptiveControl -from flet.controls.base_control import control -from flet.controls.buttons import ButtonStyle -from flet.controls.constrained_control import ConstrainedControl -from flet.controls.control import Control -from flet.controls.control_event import ControlEventHandler -from flet.controls.types import ( - ClipBehavior, - ColorValue, - IconDataOrControl, - Number, - StrOrControl, - Url, -) +from flet.controls.material.button import Button +from flet.utils.deprecated import deprecated_class __all__ = ["ElevatedButton"] -@control("ElevatedButton") -class ElevatedButton(ConstrainedControl, AdaptiveControl): - """ - Elevated buttons are essentially filled tonal buttons with a shadow. To prevent - shadow creep, only use them when absolutely necessary, such as when the button - requires visual separation from a patterned background. - - Raises: - AssertionError: If both [`content`][(c).] and [`icon`][(c).] are not set - or invalid. - """ - - content: Optional[StrOrControl] = None - """ - A Control representing custom button content. - """ - - icon: Optional[IconDataOrControl] = None - """ - Icon shown in the button. - """ - - icon_color: Optional[ColorValue] = None - """ - Icon color. - """ - - color: Optional[ColorValue] = field(default=None, metadata={"skip": True}) - """ - Button's text color. - - Note: - If both `color` and [`style.color`][flet.ElevatedButton.style] - are provided, `color` value will be used. - """ - - bgcolor: Optional[ColorValue] = field(default=None, metadata={"skip": True}) - """ - Button's background color. - - Note: - If both `bgcolor` and [`style.bgcolor`][flet.ElevatedButton.style] - are provided, `bgcolor` value will be used. - """ - - elevation: Number = field(default=1, metadata={"skip": True}) - """ - Button's elevation. - - Note: - If both `elevation` and [`style.elevation`][flet.ElevatedButton.style] - are provided, `elevation` value will be used. - """ - - style: Optional[ButtonStyle] = field(default=None, metadata={"skip": True}) - """ - The style of the button. - - Note: - The values of [`color`][flet.ElevatedButton.color], - [`bgcolor`][flet.ElevatedButton.bgcolor`] and - [`elevation`][flet.ElevatedButton.elevation], if not `None`, will override - the respective values of this `style`. - """ - - autofocus: Optional[bool] = None - """ - True if the control will be selected as the initial focus. If there is more than - one control on a page with autofocus set, then the first one added to the page will - get focus. - """ - - clip_behavior: Optional[ClipBehavior] = None - """ - The content will be clipped (or not) according to this option. - - Defaults to `ClipBehavior.NONE`. - """ - - url: Optional[Union[str, Url]] = None - """ - The URL to open when this button is clicked. - - Additionally, if [`on_click`][flet.ElevatedButton.on_click] event callback is - provided, it is fired after that. - """ - - on_click: Optional[ControlEventHandler["ElevatedButton"]] = None - """ - Called when a user clicks the button. - """ - - on_long_press: Optional[ControlEventHandler["ElevatedButton"]] = None - """ - Called when the button is long-pressed. - """ - - on_hover: Optional[ControlEventHandler["ElevatedButton"]] = None - """ - Called when a mouse pointer enters or exists the button response area. `data` - property of event object contains `true` (string) when cursor enters and `false` - when it exits. - - /// details | Example - type: example - ```python - import flet as ft - - def main(page: ft.Page): - def on_hover(e): - e.control.bgcolor = ft.Colors.ORANGE if e.data else ft.Colors.YELLOW - e.control.update() - - page.add( - ft.ElevatedButton( - "I'm changing color on hover", - bgcolor="ft.Colors.YELLOW", - on_hover=on_hover, - ) - ) - - ft.run(main) - ``` - /// - """ - - on_focus: Optional[ControlEventHandler["ElevatedButton"]] = None - """ - Called when the control has received focus. - """ - - on_blur: Optional[ControlEventHandler["ElevatedButton"]] = None - """ - Called when the control has lost focus. - """ - - def before_update(self): - super().before_update() - assert ( - self.icon - or isinstance(self.content, str) - or (isinstance(self.content, Control) and self.content.visible) - ), "at least icon or content (string or visible Control) must be provided" - - if ( - self.style is not None - or self.color is not None - or self.bgcolor is not None - or self.elevation != 1 - ): - self._internals["style"] = (self.style or ButtonStyle()).copy( - color=self.color, - bgcolor=self.bgcolor, - elevation=self.elevation, - ) - - async def focus(self): - await self._invoke_method("focus") +@deprecated_class( + reason="Use Button instead.", + version="0.70.0", + delete_version="1.0", +) +class ElevatedButton(Button): + pass diff --git a/sdk/python/packages/flet/src/flet/controls/material/expansion_panel.py b/sdk/python/packages/flet/src/flet/controls/material/expansion_panel.py index bad692eb25..6040ebf738 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/expansion_panel.py +++ b/sdk/python/packages/flet/src/flet/controls/material/expansion_panel.py @@ -3,9 +3,9 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import Padding, PaddingValue from flet.controls.types import ( ColorValue, @@ -16,7 +16,7 @@ @control("ExpansionPanel") -class ExpansionPanel(ConstrainedControl, AdaptiveControl): +class ExpansionPanel(LayoutControl, AdaptiveControl): """ A material expansion panel. It can either be expanded or collapsed. Its body is only visible when it is expanded. @@ -68,7 +68,7 @@ class ExpansionPanel(ConstrainedControl, AdaptiveControl): @control("ExpansionPanelList") -class ExpansionPanelList(ConstrainedControl): +class ExpansionPanelList(LayoutControl): """ A material expansion panel list that lays out its children and animates expansions. """ diff --git a/sdk/python/packages/flet/src/flet/controls/material/expansion_tile.py b/sdk/python/packages/flet/src/flet/controls/material/expansion_tile.py index 5bd176697b..f0fba6dc48 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/expansion_tile.py +++ b/sdk/python/packages/flet/src/flet/controls/material/expansion_tile.py @@ -5,9 +5,9 @@ from flet.controls.alignment import Alignment from flet.controls.base_control import control from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ( ClipBehavior, @@ -29,7 +29,7 @@ class TileAffinity(Enum): @control("ExpansionTile") -class ExpansionTile(ConstrainedControl, AdaptiveControl): +class ExpansionTile(LayoutControl, AdaptiveControl): """ A single-line ListTile with an expansion arrow icon that expands or collapses the tile to reveal or hide its controls. diff --git a/sdk/python/packages/flet/src/flet/controls/material/filled_button.py b/sdk/python/packages/flet/src/flet/controls/material/filled_button.py index 0fc293a7a4..68eb2af91b 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/filled_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/filled_button.py @@ -1,11 +1,14 @@ from flet.controls.base_control import control -from flet.controls.material.elevated_button import ElevatedButton +from flet.controls.material.button import Button @control("FilledButton") -class FilledButton(ElevatedButton): +class FilledButton(Button): """ - Filled buttons have the most visual impact after the [`FloatingActionButton`][flet.FloatingActionButton], - and is typically used for important, final actions that complete a flow, like "Save", + Filled buttons have the most visual impact after the + [`FloatingActionButton`][flet.FloatingActionButton], and is typically used for + important, final actions that complete a flow, like "Save", "Join now", or "Confirm". """ + + pass diff --git a/sdk/python/packages/flet/src/flet/controls/material/filled_tonal_button.py b/sdk/python/packages/flet/src/flet/controls/material/filled_tonal_button.py index b4b9180694..5684157d0b 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/filled_tonal_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/filled_tonal_button.py @@ -1,12 +1,14 @@ from flet.controls.base_control import control -from flet.controls.material.elevated_button import ElevatedButton +from flet.controls.material.button import Button @control("FilledTonalButton") -class FilledTonalButton(ElevatedButton): +class FilledTonalButton(Button): """ A filled tonal button is an alternative middle ground between FilledButton and - OutlinedButton buttons. They’re useful in contexts where a lower-priority button + OutlinedButton buttons. They're useful in contexts where a lower-priority button requires slightly more emphasis than an outline would give, such as "Next" in an onboarding flow. Tonal buttons use the secondary color mapping. """ + + pass diff --git a/sdk/python/packages/flet/src/flet/controls/material/floating_action_button.py b/sdk/python/packages/flet/src/flet/controls/material/floating_action_button.py index f63656b804..6f0ca16b0e 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/floating_action_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/floating_action_button.py @@ -2,9 +2,9 @@ from flet.controls.base_control import control from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ClipBehavior, ColorValue, @@ -19,7 +19,7 @@ @control("FloatingActionButton") -class FloatingActionButton(ConstrainedControl): +class FloatingActionButton(LayoutControl): """ A floating action button is a circular icon button that hovers over content to promote a primary action in the application. Floating action button is usually set diff --git a/sdk/python/packages/flet/src/flet/controls/material/form_field_control.py b/sdk/python/packages/flet/src/flet/controls/material/form_field_control.py index 67a1b1a15a..1fbcd18cbe 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/form_field_control.py +++ b/sdk/python/packages/flet/src/flet/controls/material/form_field_control.py @@ -5,8 +5,8 @@ from flet.controls.base_control import control from flet.controls.border_radius import BorderRadiusValue from flet.controls.box import BoxConstraints -from flet.controls.constrained_control import ConstrainedControl from flet.controls.duration import DurationValue +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.text_style import TextStyle from flet.controls.types import ( @@ -25,7 +25,7 @@ class InputBorder(Enum): @control(kw_only=True) -class FormFieldControl(ConstrainedControl): +class FormFieldControl(LayoutControl): text_size: Optional[Number] = None """ Text size in virtual pixels. diff --git a/sdk/python/packages/flet/src/flet/controls/material/icon_button.py b/sdk/python/packages/flet/src/flet/controls/material/icon_button.py index f165a61f61..a60a2d637c 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/icon_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/icon_button.py @@ -6,8 +6,8 @@ from flet.controls.base_control import control from flet.controls.box import BoxConstraints from flet.controls.buttons import ButtonStyle -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ( ColorValue, @@ -27,7 +27,7 @@ @control("IconButton") -class IconButton(ConstrainedControl, AdaptiveControl): +class IconButton(LayoutControl, AdaptiveControl): """ An icon button is a round button with an icon in the middle that reacts to touches by filling with color (ink). diff --git a/sdk/python/packages/flet/src/flet/controls/material/list_tile.py b/sdk/python/packages/flet/src/flet/controls/material/list_tile.py index 40e341f3a2..6ad7a4f83a 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/list_tile.py +++ b/sdk/python/packages/flet/src/flet/controls/material/list_tile.py @@ -4,8 +4,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.text_style import TextStyle from flet.controls.types import ( @@ -35,7 +35,7 @@ class ListTileStyle(Enum): @control("ListTile") -class ListTile(ConstrainedControl, AdaptiveControl): +class ListTile(LayoutControl, AdaptiveControl): """ A single fixed-height row that typically contains some text as well as a leading or trailing icon. diff --git a/sdk/python/packages/flet/src/flet/controls/material/menu_item_button.py b/sdk/python/packages/flet/src/flet/controls/material/menu_item_button.py index 1c6440bb7a..be35656d79 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/menu_item_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/menu_item_button.py @@ -3,16 +3,16 @@ from flet.controls.alignment import Axis from flet.controls.base_control import control from flet.controls.buttons import ButtonStyle -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.types import ClipBehavior, StrOrControl __all__ = ["MenuItemButton"] @control("MenuItemButton") -class MenuItemButton(ConstrainedControl): +class MenuItemButton(LayoutControl): """ A button for use in a MenuBar or on its own, that can be activated by click or keyboard navigation. diff --git a/sdk/python/packages/flet/src/flet/controls/material/navigation_bar.py b/sdk/python/packages/flet/src/flet/controls/material/navigation_bar.py index 2146374f38..f146641b08 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/navigation_bar.py +++ b/sdk/python/packages/flet/src/flet/controls/material/navigation_bar.py @@ -6,10 +6,10 @@ from flet.controls.base_control import control from flet.controls.border import Border from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue from flet.controls.duration import DurationValue +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ( ColorValue, @@ -91,7 +91,7 @@ class NavigationBarDestination(AdaptiveControl): @control("NavigationBar") -class NavigationBar(ConstrainedControl, AdaptiveControl): +class NavigationBar(LayoutControl, AdaptiveControl): """ Material 3 Navigation Bar component. diff --git a/sdk/python/packages/flet/src/flet/controls/material/navigation_rail.py b/sdk/python/packages/flet/src/flet/controls/material/navigation_rail.py index 3710a520a6..630d7e56f7 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/navigation_rail.py +++ b/sdk/python/packages/flet/src/flet/controls/material/navigation_rail.py @@ -4,9 +4,9 @@ from flet.controls.base_control import control from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.text_style import TextStyle from flet.controls.types import ( @@ -77,7 +77,7 @@ class NavigationRailDestination(Control): @control("NavigationRail") -class NavigationRail(ConstrainedControl): +class NavigationRail(LayoutControl): """ A material widget that is meant to be displayed at the left or right of an app to navigate between a small number of views, typically between three and five. diff --git a/sdk/python/packages/flet/src/flet/controls/material/outlined_button.py b/sdk/python/packages/flet/src/flet/controls/material/outlined_button.py index 29235a254d..b21d8ae781 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/outlined_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/outlined_button.py @@ -3,9 +3,9 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control from flet.controls.buttons import ButtonStyle -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ClipBehavior, ColorValue, @@ -18,7 +18,7 @@ @control("OutlinedButton") -class OutlinedButton(ConstrainedControl, AdaptiveControl): +class OutlinedButton(LayoutControl, AdaptiveControl): """ Outlined buttons are medium-emphasis buttons. They contain actions that are important, but aren’t the primary action in an app. Outlined buttons pair well with diff --git a/sdk/python/packages/flet/src/flet/controls/material/popup_menu_button.py b/sdk/python/packages/flet/src/flet/controls/material/popup_menu_button.py index 3f6e7efc59..eb890c2493 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/popup_menu_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/popup_menu_button.py @@ -6,9 +6,9 @@ from flet.controls.base_control import control from flet.controls.box import BoxConstraints from flet.controls.buttons import ButtonStyle, OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.text_style import TextStyle from flet.controls.types import ( @@ -83,7 +83,7 @@ class PopupMenuItem(Control): @control("PopupMenuButton") -class PopupMenuButton(ConstrainedControl): +class PopupMenuButton(LayoutControl): """ An icon button which displays a menu when clicked. """ diff --git a/sdk/python/packages/flet/src/flet/controls/material/progress_bar.py b/sdk/python/packages/flet/src/flet/controls/material/progress_bar.py index b47f081794..4c3a082920 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/progress_bar.py +++ b/sdk/python/packages/flet/src/flet/controls/material/progress_bar.py @@ -2,14 +2,14 @@ from flet.controls.base_control import control from flet.controls.border_radius import BorderRadiusValue -from flet.controls.constrained_control import ConstrainedControl +from flet.controls.layout_control import LayoutControl from flet.controls.types import ColorValue, Number __all__ = ["ProgressBar"] @control("ProgressBar") -class ProgressBar(ConstrainedControl): +class ProgressBar(LayoutControl): """ A material design linear progress indicator, also known as a progress bar. @@ -64,67 +64,70 @@ class ProgressBar(ConstrainedControl): """ The color of the stop indicator. - If [`ProgressBar.year2023`][flet.ProgressBar.year_2023] is `True` or - [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then no stop + If [`ProgressBar.year2023`][flet.ProgressBar.year_2023] is `True` or + [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then no stop indicator will be drawn. - If not set, then the - [`ProgressIndicatorTheme.stop_indicator_color`][flet.ProgressIndicatorTheme.stop_indicator_color] - will be used. If that is not set, then the - [`ColorScheme.primary`][flet.ColorScheme.primary] will be used. + If not set, then the + [`ProgressIndicatorTheme.stop_indicator_color`][flet.ProgressIndicatorTheme.stop_indicator_color] + will be used. If that is not set, then the + [`ColorScheme.primary`][flet.ColorScheme.primary] will be used. """ stop_indicator_radius: Optional[Number] = None """ The radius of the stop indicator. - If [`ProgressBar.year2023`][flet.ProgressBar.year_2023] is `True` or - [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then no stop + If [`ProgressBar.year2023`][flet.ProgressBar.year_2023] is `True` or + [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then no stop indicator will be drawn. Set `stop_indicator_radius` to `0` to hide the stop indicator. - If not set, then the - [`ProgressIndicatorTheme.stop_indicator_radius`][flet.ProgressIndicatorTheme.stop_indicator_radius] + If not set, then the + [`ProgressIndicatorTheme.stop_indicator_radius`][flet.ProgressIndicatorTheme.stop_indicator_radius] will be used. If that is not set, then defaults to `2`. """ track_gap: Optional[Number] = None """ - The gap between the indicator and the track. - - If [`ProgressBar.year2023`][flet.ProgressBar.year_2023] is `True` or - [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then no track gap + The gap between the indicator and the track. + + If [`ProgressBar.year2023`][flet.ProgressBar.year_2023] is `True` or + [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then no track gap will be drawn. Set `track_gap` to `0` to hide the track gap. - If not set, then the - [`ProgressIndicatorTheme.track_gap`][flet.ProgressIndicatorTheme.track_gap] will be + If not set, then the + [`ProgressIndicatorTheme.track_gap`][flet.ProgressIndicatorTheme.track_gap] will be used. If that is not set, then defaults to `4`. """ year_2023: Optional[bool] = None """ - If this is set to `False`, the ProgressBar will use the latest Material Design 3 + If this is set to `False`, the ProgressBar will use the latest Material Design 3 appearance, which was introduced in December 2023. When `True`, the ProgressBar will use the 2023 Material Design 3 appearance. - If not set, then the - [`ProgressIndicatorTheme.year_2023`][flet.ProgressIndicatorTheme.year_2023] will be + If not set, then the + [`ProgressIndicatorTheme.year_2023`][flet.ProgressIndicatorTheme.year_2023] will be used, which is `False` by default. - If [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then this property + If [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then this property is ignored. """ def before_update(self): super().before_update() - assert self.value is None or self.value >= 0, f"value must be greater than or equal to 0, got {self.value}" + assert self.value is None or self.value >= 0, ( + f"value must be greater than or equal to 0, got {self.value}" + ) assert self.bar_height is None or self.bar_height >= 0, ( f"bar_height must be greater than or equal to 0, got {self.bar_height}" ) assert self.semantics_value is None or self.semantics_value >= 0, ( - f"semantics_value must be greater than or equal to 0, got {self.semantics_value}" + f"semantics_value must be greater than or equal to 0, " + f"got {self.semantics_value}" ) diff --git a/sdk/python/packages/flet/src/flet/controls/material/progress_ring.py b/sdk/python/packages/flet/src/flet/controls/material/progress_ring.py index b6ff59a751..845fc6db34 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/progress_ring.py +++ b/sdk/python/packages/flet/src/flet/controls/material/progress_ring.py @@ -2,7 +2,7 @@ from flet.controls.base_control import control from flet.controls.box import BoxConstraints -from flet.controls.constrained_control import ConstrainedControl +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ColorValue, Number, StrokeCap @@ -10,7 +10,7 @@ @control("ProgressRing") -class ProgressRing(ConstrainedControl): +class ProgressRing(LayoutControl): """ A material design circular progress indicator, which spins to indicate that the application is busy. @@ -53,7 +53,7 @@ class ProgressRing(ConstrainedControl): A value of 0 (center stroke) will center the border on the edge of the control. - If [`ProgressRing.year_2023`][flet.ProgressRing.year_2023] is `True`, then the + If [`ProgressRing.year_2023`][flet.ProgressRing.year_2023] is `True`, then the default value is `0`. Otherwise, the default value is `-1`. """ @@ -64,66 +64,66 @@ class ProgressRing(ConstrainedControl): semantics_label: Optional[str] = None """ - Used to identify the purpose of this progress bar for screen reading software. + Used to identify the purpose of this progress bar for screen reading software. """ semantics_value: Optional[Number] = None """ - Used for determinate progress indicators to indicate how much progress has been + Used for determinate progress indicators to indicate how much progress has been made. """ track_gap: Optional[Number] = None """ The gap between the active indicator and the background track. - - If [`year_2023`][flet.ProgressRing.year_2023] is `True` or `Theme.use_material3` is + + If [`year_2023`][flet.ProgressRing.year_2023] is `True` or `Theme.use_material3` is `False`, then no track gap will be drawn. - + Set `track_gap` to `0` to hide this track gap. - If `None`, + If `None`, [`ProgressIndicatorTheme.track_gap`][flet.ProgressIndicatorTheme.track_gap] is used. - + If that's is also `None`, defaults to `4.0`. """ size_constraints: Optional[BoxConstraints] = None """ Defines the minimum and maximum size of the progress indicator. - - If `None`, - [`ProgressIndicatorTheme.size_constraints`][flet.ProgressIndicatorTheme.size_constraints] + + If `None`, + [`ProgressIndicatorTheme.size_constraints`][flet.ProgressIndicatorTheme.size_constraints] is used. - + If that's is also `None`, defaults to a minimum width and height of `36`. """ padding: Optional[PaddingValue] = None """ The padding around the indicator track. - - If `None`, - [`ProgressIndicatorTheme.circular_track_padding`][flet.ProgressIndicatorTheme.circular_track_padding] + + If `None`, + [`ProgressIndicatorTheme.circular_track_padding`][flet.ProgressIndicatorTheme.circular_track_padding] is used. - - If that's is also `None` and [`year_2023`][flet.ProgressRing.year_2023] is `False`, + + If that's is also `None` and [`year_2023`][flet.ProgressRing.year_2023] is `False`, defaults to `Padding.all(4.0)`. - + Otherwise, defaults to `Padding.all(0.0)`. """ year_2023: Optional[bool] = None """ - If this is set to `False`, the `ProgressRing` will use the latest Material Design 3 + If this is set to `False`, the `ProgressRing` will use the latest Material Design 3 appearance, which was introduced in December 2023. When `True`, the `ProgressRing` will use the 2023 Material Design 3 appearance. - If not set, then the - [`ProgressIndicatorTheme.year_2023`][flet.ProgressIndicatorTheme.year_2023] will be + If not set, then the + [`ProgressIndicatorTheme.year_2023`][flet.ProgressIndicatorTheme.year_2023] will be used, which is `False` by default. - If [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then this property + If [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then this property is ignored. """ diff --git a/sdk/python/packages/flet/src/flet/controls/material/radio.py b/sdk/python/packages/flet/src/flet/controls/material/radio.py index 3b88eabd85..98039a0d7d 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/radio.py +++ b/sdk/python/packages/flet/src/flet/controls/material/radio.py @@ -2,9 +2,9 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.text_style import TextStyle from flet.controls.types import ( ColorValue, @@ -18,7 +18,7 @@ @control("Radio") -class Radio(ConstrainedControl, AdaptiveControl): +class Radio(LayoutControl, AdaptiveControl): """ Radio buttons let people select a single option from two or more choices. """ diff --git a/sdk/python/packages/flet/src/flet/controls/material/range_slider.py b/sdk/python/packages/flet/src/flet/controls/material/range_slider.py index 483f023944..2f91f90f89 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/range_slider.py +++ b/sdk/python/packages/flet/src/flet/controls/material/range_slider.py @@ -1,9 +1,9 @@ from typing import Optional from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ColorValue, MouseCursor, @@ -14,7 +14,7 @@ @control("RangeSlider") -class RangeSlider(ConstrainedControl): +class RangeSlider(LayoutControl): """ A Material Design range slider. Used to select a range from a range of values. A range slider can be used to select from either a continuous or a discrete diff --git a/sdk/python/packages/flet/src/flet/controls/material/search_bar.py b/sdk/python/packages/flet/src/flet/controls/material/search_bar.py index 1b96f042a0..435cacd12c 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/search_bar.py +++ b/sdk/python/packages/flet/src/flet/controls/material/search_bar.py @@ -5,10 +5,10 @@ from flet.controls.border import BorderSide from flet.controls.box import BoxConstraints from flet.controls.buttons import OutlinedBorder -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.material.textfield import KeyboardType, TextCapitalization from flet.controls.padding import PaddingValue from flet.controls.text_style import TextStyle @@ -21,7 +21,7 @@ @control("SearchBar") -class SearchBar(ConstrainedControl): +class SearchBar(LayoutControl): """ Manages a "search view" route that allows the user to select one of the suggested completions for a search query. diff --git a/sdk/python/packages/flet/src/flet/controls/material/segmented_button.py b/sdk/python/packages/flet/src/flet/controls/material/segmented_button.py index 14e8865c64..5aa18722d9 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/segmented_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/segmented_button.py @@ -4,9 +4,9 @@ from flet.controls.alignment import Axis from flet.controls.base_control import control from flet.controls.buttons import ButtonStyle -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ( IconData, @@ -54,7 +54,7 @@ def before_update(self): @control("SegmentedButton") -class SegmentedButton(ConstrainedControl): +class SegmentedButton(LayoutControl): """ A segmented button control. diff --git a/sdk/python/packages/flet/src/flet/controls/material/slider.py b/sdk/python/packages/flet/src/flet/controls/material/slider.py index de0b5d0e9d..78e64a0308 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/slider.py +++ b/sdk/python/packages/flet/src/flet/controls/material/slider.py @@ -3,9 +3,9 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.types import ( ColorValue, @@ -24,7 +24,7 @@ class SliderInteraction(Enum): @control("Slider") -class Slider(ConstrainedControl, AdaptiveControl): +class Slider(LayoutControl, AdaptiveControl): """ A slider provides a visual indication of adjustable content, as well as the current setting in the total range of content. @@ -66,16 +66,18 @@ class Slider(ConstrainedControl, AdaptiveControl): Note: - Must be less than or equal to [`max`][flet.Slider.max]. - - If the [`max`][flet.Slider.max] is equal to the `min`, then this slider is disabled. + - If the [`max`][flet.Slider.max] is equal to the `min`, then this slider + is disabled. """ max: Number = 1.0 """ The maximum value the user can select. - + Note: - Must be greater than or equal to [`min`][flet.Slider.min]. - - If the [`min`][flet.Slider.min] is equal to the `max`, then this slider is disabled. + - If the [`min`][flet.Slider.min] is equal to the `max`, then this slider + is disabled. """ divisions: Optional[int] = None @@ -89,7 +91,7 @@ class Slider(ConstrainedControl, AdaptiveControl): round: int = 0 """ - The number of decimals displayed on the [`label`][flet.Slider.label] + The number of decimals displayed on the [`label`][flet.Slider.label] containing [`value`][flet.Slider.value]. Defaults to `0`, which displays value rounded to the nearest integer. @@ -127,25 +129,26 @@ class Slider(ConstrainedControl, AdaptiveControl): interaction: Optional[SliderInteraction] = None """ - The allowed way for the user to interact with this slider. - + The allowed way for the user to interact with this slider. + If `None`, [`SliderTheme.interaction`][flet.SliderTheme.interaction] is used. - If that's is also `None`, defaults to + If that's is also `None`, defaults to [`SliderInteraction.TAP_AND_SLIDE`][flet.SliderInteraction.TAP_AND_SLIDE]. """ secondary_active_color: Optional[ColorValue] = None """ The color to use for the portion of - the slider track between the thumb and + the slider track between the thumb and the [`secondary_track_value`][flet.Slider.secondary_track_value]. """ overlay_color: Optional[ControlStateValue[ColorValue]] = None """ The highlight color that's typically - used to indicate that the range slider thumb is in [`ControlState.HOVERED`][flet.ControlState.HOVERED] - or [`ControlState.DRAGGED`][flet.ControlState.DRAGGED] states. + used to indicate that the range slider thumb is in + [`ControlState.HOVERED`][flet.ControlState.HOVERED] or + [`ControlState.DRAGGED`][flet.ControlState.DRAGGED] states. """ secondary_track_value: Optional[Number] = None @@ -173,16 +176,16 @@ class Slider(ConstrainedControl, AdaptiveControl): year_2023: Optional[bool] = None """ - If this is set to `False`, this slider will use the latest + If this is set to `False`, this slider will use the latest Material Design 3 appearance, which was introduced in December 2023. When `True`, the Slider will use the 2023 Material Design 3 appearance. - - If not set, then the - [`SliderTheme.year_2023`][flet.SliderTheme.year_2023] will be + + If not set, then the + [`SliderTheme.year_2023`][flet.SliderTheme.year_2023] will be used, which is `False` by default. - - If [`Theme.use_material3`][flet.Theme.use_material3] is `False`, + + If [`Theme.use_material3`][flet.Theme.use_material3] is `False`, then this property is ignored. """ diff --git a/sdk/python/packages/flet/src/flet/controls/material/submenu_button.py b/sdk/python/packages/flet/src/flet/controls/material/submenu_button.py index 0b2e9cbdb7..0ca9ef324b 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/submenu_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/submenu_button.py @@ -3,9 +3,9 @@ from flet.controls.base_control import control from flet.controls.buttons import ButtonStyle -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.material.menu_bar import MenuStyle from flet.controls.transform import OffsetValue from flet.controls.types import ClipBehavior, StrOrControl @@ -14,7 +14,7 @@ @control("SubmenuButton") -class SubmenuButton(ConstrainedControl): +class SubmenuButton(LayoutControl): """ A menu button that displays a cascading menu. @@ -32,7 +32,7 @@ class SubmenuButton(ConstrainedControl): """ A list of controls that appear in the menu when it is opened. - Typically either [`MenuItemButton`][flet.MenuItemButton] or + Typically either [`MenuItemButton`][flet.MenuItemButton] or `SubMenuButton` controls. If this list is empty, then the button for this menu item will be disabled. @@ -70,7 +70,7 @@ class SubmenuButton(ConstrainedControl): alignment_offset: Optional[OffsetValue] = None """ The offset of the menu relative to the alignment origin determined by - [`MenuStyle.alignment`][flet.MenuStyle.alignment] on the + [`MenuStyle.alignment`][flet.MenuStyle.alignment] on the [`style`][flet.SubmenuButton.style] attribute. """ diff --git a/sdk/python/packages/flet/src/flet/controls/material/switch.py b/sdk/python/packages/flet/src/flet/controls/material/switch.py index 1d92d104ef..eb9039295d 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/switch.py +++ b/sdk/python/packages/flet/src/flet/controls/material/switch.py @@ -2,9 +2,9 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler from flet.controls.control_state import ControlStateValue +from flet.controls.layout_control import LayoutControl from flet.controls.padding import PaddingValue from flet.controls.text_style import TextStyle from flet.controls.types import ( @@ -20,7 +20,7 @@ @control("Switch") -class Switch(ConstrainedControl, AdaptiveControl): +class Switch(LayoutControl, AdaptiveControl): """ A toggle represents a physical switch that allows someone to choose between two mutually exclusive options. diff --git a/sdk/python/packages/flet/src/flet/controls/material/tabs.py b/sdk/python/packages/flet/src/flet/controls/material/tabs.py index 238127d44f..fd1e144d4d 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/tabs.py +++ b/sdk/python/packages/flet/src/flet/controls/material/tabs.py @@ -8,11 +8,11 @@ from flet.controls.border import BorderSide from flet.controls.border_radius import BorderRadiusValue from flet.controls.colors import Colors -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control import Control from flet.controls.control_event import ControlEventHandler, Event, EventHandler from flet.controls.control_state import ControlStateValue from flet.controls.duration import Duration, DurationValue +from flet.controls.layout_control import LayoutControl from flet.controls.margin import MarginValue from flet.controls.material.form_field_control import IconDataOrControl from flet.controls.padding import Padding, PaddingValue @@ -148,7 +148,7 @@ class UnderlineTabIndicator: @control("Tabs") -class Tabs(ConstrainedControl, AdaptiveControl): +class Tabs(LayoutControl, AdaptiveControl): """ Used for navigating frequently accessed, distinct content categories. Tabs allow for navigation between two or more content views and relies @@ -275,7 +275,7 @@ async def move_to( @control("TabBarView") -class TabBarView(ConstrainedControl, AdaptiveControl): +class TabBarView(LayoutControl, AdaptiveControl): """ A page view with one child per tab. @@ -310,7 +310,7 @@ class TabBarView(ConstrainedControl, AdaptiveControl): @control("TabBar") -class TabBar(ConstrainedControl, AdaptiveControl): +class TabBar(LayoutControl, AdaptiveControl): """ Used for navigating frequently accessed, distinct content categories. Tabs allow for navigation between two or more content views and relies diff --git a/sdk/python/packages/flet/src/flet/controls/material/text_button.py b/sdk/python/packages/flet/src/flet/controls/material/text_button.py index 0d3714b0e1..586b1a7ef5 100644 --- a/sdk/python/packages/flet/src/flet/controls/material/text_button.py +++ b/sdk/python/packages/flet/src/flet/controls/material/text_button.py @@ -3,8 +3,8 @@ from flet.controls.adaptive_control import AdaptiveControl from flet.controls.base_control import control from flet.controls.buttons import ButtonStyle -from flet.controls.constrained_control import ConstrainedControl from flet.controls.control_event import ControlEventHandler +from flet.controls.layout_control import LayoutControl from flet.controls.types import ( ClipBehavior, ColorValue, @@ -17,7 +17,7 @@ @control("TextButton") -class TextButton(ConstrainedControl, AdaptiveControl): +class TextButton(LayoutControl, AdaptiveControl): """ Text buttons are used for the lowest priority actions, especially when presenting multiple options. Text buttons can be placed on a variety of backgrounds. Until the diff --git a/sdk/python/packages/flet/src/flet/controls/scrollable_control.py b/sdk/python/packages/flet/src/flet/controls/scrollable_control.py index 14cc567f59..8d012fd2b8 100644 --- a/sdk/python/packages/flet/src/flet/controls/scrollable_control.py +++ b/sdk/python/packages/flet/src/flet/controls/scrollable_control.py @@ -126,7 +126,7 @@ async def scroll_to_key(e): page.add( ft.Container(cl, border=ft.border.all(1)), - ft.ElevatedButton("Scroll to key '20'", on_click=scroll_to_key), + ft.Button("Scroll to key '20'", on_click=scroll_to_key), ) diff --git a/sdk/python/packages/flet/src/flet/controls/theme.py b/sdk/python/packages/flet/src/flet/controls/theme.py index ac2cb59226..af869be865 100644 --- a/sdk/python/packages/flet/src/flet/controls/theme.py +++ b/sdk/python/packages/flet/src/flet/controls/theme.py @@ -73,7 +73,7 @@ class ColorScheme: primary: Optional[ColorValue] = None """ - The color displayed most frequently across your app’s screens and components. + The color displayed most frequently across your app's screens and components. """ on_primary: Optional[ColorValue] = None @@ -382,7 +382,7 @@ class TextTheme: Largest of the label styles. Label styles are smaller, utilitarian styles, used for areas of the UI such as text inside of components or very small supporting text in the content body, like captions. Used for text on - [`ElevatedButton`][flet.ElevatedButton], [`TextButton`][flet.TextButton] and + [`Button`][flet.Button], [`TextButton`][flet.TextButton] and [`OutlinedButton`][flet.OutlinedButton]. """ @@ -733,16 +733,16 @@ class DialogTheme: @dataclass -class ElevatedButtonTheme: +class ButtonTheme: """ - Customizes the appearance of [`ElevatedButton`][flet.ElevatedButton] across the app. + Customizes the appearance of [`Button`][flet.Button] across the app. """ style: Optional[ButtonStyle] = None """ Overrides the default value of - [`ElevatedButton.style`][flet.ElevatedButton.style] in all descendant - [`ElevatedButton`][flet.ElevatedButton] controls. + [`Button.style`][flet.Button.style] in all descendant + [`Button`][flet.Button] controls. """ @@ -3340,7 +3340,7 @@ class Theme: dialog_theme: Optional[DialogTheme] = None divider_theme: Optional[DividerTheme] = None dropdown_theme: Optional[DropdownTheme] = None - elevated_button_theme: Optional[ElevatedButtonTheme] = None + button_theme: Optional[ButtonTheme] = None outlined_button_theme: Optional[OutlinedButtonTheme] = None text_button_theme: Optional[TextButtonTheme] = None filled_button_theme: Optional[FilledButtonTheme] = None diff --git a/sdk/python/packages/flet/src/flet/utils/deprecated.py b/sdk/python/packages/flet/src/flet/utils/deprecated.py index a1a233d69e..1653e358e9 100644 --- a/sdk/python/packages/flet/src/flet/utils/deprecated.py +++ b/sdk/python/packages/flet/src/flet/utils/deprecated.py @@ -12,12 +12,14 @@ def deprecated( show_parentheses: bool = False, ): """ - A decorator that marks a function, method, or class as deprecated. - - :param reason: The reason for deprecation. - :param version: (Optional) The version from which the function was deprecated. - :param delete_version: (Optional) The version in which the function will be removed. - :param show_parentheses: Whether to show parentheses after the function/class name in the warning. + Marks a function, method, or class as deprecated. + + Args: + reason: The reason for deprecation. + version: The version from which the function was deprecated. + delete_version: The version in which the function will be removed. + show_parentheses: Whether to show parentheses after the function/class name + in the warning. """ def decorator(func): @@ -44,7 +46,10 @@ def wrapper(*args, **kwargs): def deprecated_class(reason: str, version: str, delete_version: str): def decorator(cls): - msg = f"{cls.__name__} is deprecated since version {version} and will be removed in version {delete_version}. {reason}" + msg = ( + f"{cls.__name__} is deprecated since version {version} and will be removed " + f"in version {delete_version}. {reason}" + ) # Wrap the original __init__ method orig_init = cls.__init__ @@ -55,6 +60,17 @@ def new_init(self, *args, **kwargs): orig_init(self, *args, **kwargs) cls.__init__ = new_init + + # Wrap the original __post_init__ method + orig_post_init = cls.__post_init__ + + @functools.wraps(orig_post_init) + def new_post_init(self, *args, **kwargs): + warnings.warn(msg, category=DeprecationWarning, stacklevel=2) + orig_post_init(self, *args, **kwargs) + + cls.__post_init__ = new_post_init + return cls return decorator @@ -70,15 +86,22 @@ def deprecated_warning( """ Helper function to issue a standardized deprecation warning message. - :param name: The name of the deprecated object. - :param reason: A short explanation of why the object is deprecated and/or what to use instead. - :param version: The version in which the object was marked as deprecated. - :param delete_version: Optional; the version in which the object is scheduled to be removed. - :param type: The type of the object being deprecated (e.g., "property"). Defaults to "property". + Args: + name: The name of the deprecated object. + reason: A short explanation of why the object is deprecated and/or what to + use instead. + version: The version in which the object was marked as deprecated. + delete_version: The version in which the object is scheduled to be + removed (optional). + type: The type of the object being deprecated (e.g., "property"). + Defaults to "property". """ + delete_version_text = ( + f" and will be removed in version {delete_version}" if delete_version else "" + ) warnings.warn( - f"{name} {type} is deprecated since version {version}" - f"{' and will be removed in version ' + delete_version if delete_version else ''}. {reason}", + f"{name} {type} is deprecated since version {version}{delete_version_text}. " + f"{reason}", category=DeprecationWarning, stacklevel=2, ) diff --git a/sdk/python/packages/flet/tests/common.py b/sdk/python/packages/flet/tests/common.py index 98f6a14d92..356f03a7b1 100644 --- a/sdk/python/packages/flet/tests/common.py +++ b/sdk/python/packages/flet/tests/common.py @@ -2,9 +2,10 @@ from dataclasses import field from typing import Any, Optional -import flet as ft import msgpack +import flet as ft + # import flet as ft # import flet.canvas as cv from flet.controls.object_patch import ObjectPatch @@ -27,7 +28,7 @@ class LineChartData(ft.BaseControl): @ft.control("LineChart") -class LineChart(ft.ConstrainedControl): +class LineChart(ft.LayoutControl): data_series: list[LineChartData] = field(default_factory=list) animation: ft.AnimationValue = field( default_factory=lambda: ft.Animation( diff --git a/sdk/python/packages/flet/tests/test_events.py b/sdk/python/packages/flet/tests/test_events.py index d870395e56..b11c0c37de 100644 --- a/sdk/python/packages/flet/tests/test_events.py +++ b/sdk/python/packages/flet/tests/test_events.py @@ -4,8 +4,8 @@ from flet.controls.control_event import ControlEvent, Event, get_event_field_type from flet.controls.core.column import Column from flet.controls.events import TapEvent +from flet.controls.material.button import Button from flet.controls.material.container import Container -from flet.controls.material.elevated_button import ElevatedButton from flet.controls.material.reorderable_list_view import ( OnReorderEvent, ReorderableListView, @@ -20,10 +20,10 @@ def test_get_event_field_type(): - btn = ElevatedButton() + btn = Button() on_click_type = get_event_field_type(btn, "on_click") assert get_origin(on_click_type) is Event - assert get_args(on_click_type)[0] == ForwardRef("ElevatedButton") + assert get_args(on_click_type)[0] == ForwardRef("Button") c = Container() on_tap_down_type = get_event_field_type(c, "on_tap_down") diff --git a/sdk/python/packages/flet/tests/test_object_diff_in_place.py b/sdk/python/packages/flet/tests/test_object_diff_in_place.py index a56f367b33..9d87803fa9 100644 --- a/sdk/python/packages/flet/tests/test_object_diff_in_place.py +++ b/sdk/python/packages/flet/tests/test_object_diff_in_place.py @@ -14,7 +14,6 @@ # import flet as ft # import flet.canvas as cv from flet.controls.material.container import Container -from flet.controls.material.elevated_button import ElevatedButton from flet.controls.page import Page from flet.controls.painting import Paint, PaintLinearGradient from flet.controls.ref import Ref @@ -35,20 +34,20 @@ @control -class SuperElevatedButton(ElevatedButton): +class SuperButton(Button): prop_2: Optional[str] = None def init(self): - print("SuperElevatedButton.init()") + print("SuperButton.init()") assert not self.page def build(self): - print("SuperElevatedButton.build()") + print("SuperButton.build()") assert self.page @control("MyButton") -class MyButton(ElevatedButton): +class MyButton(Button): prop_1: Optional[str] = None @@ -74,18 +73,18 @@ class Div(Control): def test_control_type(): - btn = ElevatedButton("some button") - assert btn._c == "ElevatedButton" + btn = Button("some button") + assert btn._c == "Button" def test_control_id(): - btn = ElevatedButton("some button") + btn = Button("some button") assert btn._i > 0 def test_inherited_control_has_the_same_type(): - btn = SuperElevatedButton(prop_2="2") - assert btn._c == "ElevatedButton" + btn = SuperButton(prop_2="2") + assert btn._c == "Button" def test_inherited_control_with_overridden_type(): @@ -203,14 +202,14 @@ def test_simple_page(): page.on_login = None page.controls[0].some_value = "Another text" page.controls[0].controls = [ - SuperElevatedButton( + SuperButton( "Button 😬", style=ButtonStyle(color=Colors.RED), on_click=lambda e: print(e), opacity=1, ref=None, ), - SuperElevatedButton("Another Button"), + SuperButton("Another Button"), ] del page.fonts["font2"] assert page.controls[0].controls[0].page is None @@ -235,7 +234,7 @@ def test_simple_page(): { "op": "replace", "path": ["views", 0, "controls", 0, "controls"], - # "value": [SuperElevatedButton, SuperElevatedButton], + # "value": [SuperButton, SuperButton], }, {"op": "remove", "path": ["fonts", "font2"], "value": "font_url_2"}, { @@ -256,11 +255,11 @@ def test_simple_page(): ], ) assert len(patch[2]["value"]) == 2 - assert isinstance(patch[2]["value"][0], SuperElevatedButton) - assert isinstance(patch[2]["value"][1], SuperElevatedButton) + assert isinstance(patch[2]["value"][0], SuperButton) + assert isinstance(patch[2]["value"][1], SuperButton) # replace control in a list - page.controls[0].controls[0] = SuperElevatedButton("Foo") + page.controls[0].controls[0] = SuperButton("Foo") _, patch, _, added_controls, removed_controls = make_msg(page, show_details=True) # for ac in added_controls: # print("\nADDED CONTROL:", ac) @@ -274,13 +273,13 @@ def test_simple_page(): { "op": "replace", "path": ["views", 0, "controls", 0, "controls", 0], - "value": SuperElevatedButton("Foo"), + "value": SuperButton("Foo"), }, ], ) # insert a new button to the start of a list - page.controls[0].controls.insert(0, SuperElevatedButton("Bar")) + page.controls[0].controls.insert(0, SuperButton("Bar")) page.controls[0].controls[1].content = "Baz" _, patch, _, added_controls, removed_controls = make_msg(page, show_details=True) assert len(added_controls) == 1 @@ -291,7 +290,7 @@ def test_simple_page(): { "op": "add", "path": ["views", 0, "controls", 0, "controls", 0], - "value": SuperElevatedButton("Bar"), + "value": SuperButton("Bar"), }, { "op": "replace",