Skip to content

Conversation

@InesaFitsner
Copy link
Contributor

@InesaFitsner InesaFitsner commented Nov 27, 2025

Description

Test Code

# Test code for the review of this PR

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Screenshots

Additional details

Summary by Sourcery

Refresh the calculator tutorial and sample apps to use the latest Flet control patterns and add screenshot-based integration tests for the tutorial examples.

Enhancements:

  • Refactor calculator tutorial example code to use @ft.control-based custom controls, dataclass-style fields, and updated Flet APIs (BorderRadius, Colors, content, and event wiring).
  • Simplify calculator example scripts and chip control examples with consistent button construction and main guards for running apps.

Documentation:

  • Update the calculator tutorial documentation to reference shared example files, new image assets, and the current Flet control model and event-handling approach.

Tests:

  • Add integration tests for the calculator tutorial examples that capture and compare golden screenshots for multiple calculator layouts.

InesaFitsner and others added 12 commits November 19, 2025 10:16
Simplified button instantiation in calc1.py and calc2.py by removing 'text=' keyword. Refactored calc3.py to use 'content' instead of 'text', updated color and alignment usage, and improved class structure. Added calc3_dataclasses.py to demonstrate using Python dataclasses for calculator button components.
Replaces the default value assignment for 'expand' in CalcButton with an initializer that sets it to 1 if not already set. This ensures the expand property is always initialized properly.
Replaces manual class definitions in calc3.py with dataclass-based button classes for cleaner and more concise code. Removes the now-redundant calc3_dataclasses.py file, consolidating the dataclass approach into calc3.py.
Refactored calc4.py to use Python dataclasses for button and app classes, simplifying initialization and property management. Added calc5_dataclasses.py, a new example with a fully functional calculator app using dataclasses, including button click handling and calculation logic.
Replaces @DataClass with @ft.control for button classes in calc3.py and calc4.py to align with Flet's control system. Also updates calc5_dataclasses.py to consistently pass the on_click handler to all DigitButton and ActionButton instances, ensuring button click events are handled properly.
Refactored calc.py and calc5.py to use @ft.control decorator and dataclass-style field definitions for button and app classes, replacing manual __init__ methods. Updated button instantiation to use 'content' and 'on_click' instead of 'text' and 'button_clicked'. Removed the now-redundant calc5_dataclasses.py file.
Refactored the calculator tutorial documentation to use code includes for examples, updated code snippets for clarity, and improved button class definitions. Added an __init__.py to the calculator example directory and introduced an integration test for the basic calculator example. Also updated calc1.py to use a main guard for script execution.
Added __init__.py to chip examples and updated main entry points to use '__name__ == "__main__"' guard. Improved calculator tutorial documentation for clarity. Enhanced integration tests for calculator examples, added golden screenshots for macOS, and expanded test coverage to include calc2 and calc3.
Added a main guard to calc2.py to allow direct execution. Updated calculator tutorial documentation to use new image paths, correct code references, and improve clarity.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: a93b193
Status: ✅  Deploy successful!
Preview URL: https://47addfcd.flet-docs.pages.dev
Branch Preview URL: https://inesa-fix-tutorials.flet-docs.pages.dev

View logs

]
)

def button_clicked(self, e):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

button_clicked can be assigned to the base CalcButton.on_click.

Introduced @overload annotations for the control decorator to improve type hinting and clarify supported call signatures.
@FeodorFitsner FeodorFitsner merged commit 44a81f2 into main Dec 1, 2025
24 of 49 checks passed
@FeodorFitsner FeodorFitsner deleted the inesa/fix-tutorials branch December 1, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants