11---
22title : Calculator Tutorial
33examples : ../../examples/tutorials/calculator
4+ example_images : ../test-images/tutorials/golden/macos/calculator
45---
56
67In this tutorial you will learn, step-by-step, how to create a Calculator app in
@@ -17,7 +18,6 @@ In this tutorial, we will cover all of the basic concepts for creating a Flet ap
1718building a page layout, adding controls, making reusable UI components, handling
1819events, and publishing options.
1920
20- The tutorial consists of the following steps:
2121
2222## Getting started with Flet
2323
@@ -62,7 +62,7 @@ Create `calc.py` with the following contents:
6262
6363Run the app and you should see a page like this:
6464
65- {{ image("../examples/tutorials/calculator/media/app-1 .png", alt="app-1 ", width="80 %") }}
65+ {{ image(example_images + "/calc1 .png", alt="calc1 ", width="50 %") }}
6666
6767
6868## Building page layout
@@ -77,7 +77,7 @@ Replace `calc.py` contents with the following:
7777
7878Run the app and you should see a page like this:
7979
80- {{ image("../examples/tutorials/calculator/media/app-2 .png", alt="app-2 ", width="80 %") }}
80+ {{ image(example_images + "/calc2 .png", alt="calc2 ", width="50 %") }}
8181
8282
8383### Using Container for decoration
@@ -162,7 +162,7 @@ We will be using these new classes now to create rows of buttons in the Containe
162162content = ft.Column(
163163 controls = [
164164 ft.Row(
165- controls = [self . result],
165+ controls = [result],
166166 alignment = ft.MainAxisAlignment.END ,
167167 ),
168168 ft.Row(
@@ -216,7 +216,7 @@ content = ft.Column(
216216```
217217///
218218
219- {{ image("../examples/tutorials/calculator/media/app .png", alt="calc-app ", width="80 %") }}
219+ {{ image(example_images + "/calc3 .png", alt="calc3 ", width="50 %") }}
220220
221221
222222Just what we wanted!
@@ -235,7 +235,7 @@ Flet apps with composability and reusability in mind.
235235To make a reusable Calc app component, we are going to encapsulate its state and
236236presentation logic in a separate ` CalculatorApp ` class.
237237
238- Copy the entire code for this step from [ here] ( https://github.com/flet-dev/flet/blob/main/sdk/python/examples/tutorials/calc /calc4.py ) .
238+ Copy the entire code for this step from [ here] ( https://github.com/flet-dev/flet/blob/main/sdk/python/examples/tutorials/calculator /calc4.py ) .
239239
240240/// admonition | Try something
241241 type: example
@@ -271,7 +271,7 @@ def button_clicked(self, e):
271271With similar approach, ` button_click ` method will handle different calculator actions
272272depending on ` content ` property for each button.
273273Copy the entire code for this step from
274- [ here] ( https://github.com/flet-dev/flet/blob/main/sdk/python/examples/tutorials/calc /calc.py ) .
274+ [ here] ( https://github.com/flet-dev/flet/blob/main/sdk/python/examples/tutorials/calculator /calc.py ) .
275275
276276Run the app and see it in the action:
277277{{ image("../examples/tutorials/calculator/media/app.gif", alt="calc-app2", width="80%") }}
0 commit comments