1
0

table_formatting.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. import datetime
  17. from taipy.gui import Gui
  18. stock = {
  19. "date": [datetime.datetime(year=2000, month=12, day=d) for d in range(20, 30)],
  20. "price": [119.88, 112.657, 164.5, 105.42, 188.36, 103.9, 143.97, 160.11, 136.3, 174.06],
  21. "change": [7.814, -5.952, 0.01, 8.781, 7.335, 6.623, -6.635, -6.9, 0.327, -0.089],
  22. "volume": [773, 2622, 2751, 1108, 7400, 3772, 9398, 4444, 9264, 1108],
  23. }
  24. columns = {
  25. "date": {"title": "Data", "format": "MMM d"},
  26. "price": {"title": "Price", "format": "$%.02f"},
  27. "change": {"title": "% change", "format": "%.01f"},
  28. "volume": {"title": "Volume"},
  29. }
  30. page = """
  31. <|{stock}|table|columns={columns}|>
  32. """
  33. if __name__ == "__main__":
  34. Gui(page).run(title="Table - Formatting cells")