Run the app and see it in the action: Packaging as a desktop app Ĭongratulations! You have created your Calculator app with Flet, and it looks awesome! Now it's time to share your app with the world!įlet Python app and all its dependencies can be packaged into an executable and user can run it on their computer without installing a Python interpreter or any modules.įollow these instructions to package your Calculator app into an executable. Copy the entire code for this step from here. With similar approach, specify on_click event and data property for each button and add expected action to the button_clicked event handler depending on e.data value. To make a reusable Calc app component, we are going to encapsulate its state and presentation logic in a separate CalculatorApp class. Imagine you are working on an app header, a side menu, or UI that will be a part of a larger project (for example, at Flet we will be using this Calculator app in a bigger "Gallery" app that will show all the examples for Flet framework).Įven if you can't think of such uses right now, we still recommend creating all your web apps with composability and reusability in mind. While you can continue writing your app in the main function, the best practice would be to create a reusable UI component. Just what we wanted! Reusable UI components Run the app and you should see a page like this: Since the program is too long now to be fully included in this tutorial, copy the entire code for this step from here. For even alignment of the buttons within the rows, we will be using expand property as shown on the diagram above. To complete the UI portion of the program, update color and size properties for the Text, and color and bgcolor properties for the buttons. Container may decorate only one control, so we will need to wrap all the 6 rows into a single vertical Column that will be used as the container's content: To add a black background with rounded border around the calculator, we will be using Container control. Run the app and you should see a page like this: Using Container for decoration
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |