markdown.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright 2021-2024 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. # -----------------------------------------------------------------------------------------
  12. # To execute this script, make sure that the taipy-gui package is installed in your
  13. # Python environment and run:
  14. # python <script>
  15. # -----------------------------------------------------------------------------------------
  16. from taipy.gui import Gui
  17. # Initially invested amount
  18. initial_investment = 100
  19. # Number of periods
  20. periods = 0
  21. # Number of periods
  22. final_amount = initial_investment
  23. # Interest rate by period
  24. rate = 5
  25. # Is the interest rate setting panel shown
  26. show_rate = False
  27. rate_page = """
  28. Rate (in %):
  29. <|{rate}|number|>
  30. """
  31. page = """
  32. <|{show_rate}|pane|show_button|page=_rate_pane|>
  33. # Interest Calculator
  34. Initial amount: <|{initial_investment}|number|>
  35. Periods: <|{periods}|number|min=0|max=50|>
  36. Final amount: <|{final_amount}|text|format=%.2f|>
  37. """
  38. # Invoked when any control value (initial_investment, rate, or periods) is changed.
  39. def on_change(state, var_name: str):
  40. # Cumulated interest percentage
  41. progress = pow(1 + state.rate / 100, state.periods)
  42. state.final_amount = state.initial_investment * progress
  43. if __name__ == "__main__":
  44. pages = {
  45. "main": page,
  46. "_rate_pane": rate_page,
  47. }
  48. Gui(pages=pages).run()