Skip to content

Commit

Permalink
- Fred comments
Browse files Browse the repository at this point in the history
- Rename element documentation example directory names to make them module (mypy)
  • Loading branch information
FabienLelaquais committed Sep 20, 2024
1 parent d3b758b commit b177780
Show file tree
Hide file tree
Showing 23 changed files with 241 additions and 11 deletions.
1 change: 1 addition & 0 deletions doc/gui/examples/blocks/pane_anchor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file makes this directory a module on its own, mandatody for mypy.
31 changes: 31 additions & 0 deletions doc/gui/examples/blocks/pane_anchor/builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2021-2024 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
import taipy.gui.builder as tgb
from taipy.gui import Gui

show_pane = True

with tgb.Page() as page:
with tgb.pane("{show_pane}", anchor="top", height="50px"):
tgb.text("Here is some text that is displayed at the top of the page in a pane.")

tgb.text("# Main page content", mode="md")

tgb.text("This is the content of the page.")


if __name__ == "__main__":
Gui(page).run()
File renamed without changes.
1 change: 1 addition & 0 deletions doc/gui/examples/blocks/pane_as_page/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file makes this directory a module on its own, mandatody for mypy.
61 changes: 61 additions & 0 deletions doc/gui/examples/blocks/pane_as_page/builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2021-2024 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
import taipy.gui.builder as tgb
from taipy.gui import Gui

# Initially invested amount
initial_investment = 100
# Number of periods
periods = 0
# Number of periods
final_amount = initial_investment
# Interest rate by period
rate = 5
# Is the interest rate setting panel shown
show_rate = False

with tgb.Page() as rate_page:
tgb.text("Rate (in %):")
tgb.number("{rate}")

with tgb.Page() as page:
tgb.text("# Interest Calculator", mode="md")

tgb.pane("{show_rate}", show_button=True, page="_rate_pane")

tgb.text("Initial amount: ", inline=True)
tgb.number("{initial_investment}")

tgb.text("Periods", inline=True)
tgb.number("{periods}", min=0, max=50)

tgb.text("Final amount: ", inline=True)
tgb.text("{final_amount}", format="%.2f", inline=True)


# Invoked when any control value (initial_investment, rate, or periods) is changed.
def on_change(state, var_name: str):
# Cumulated interest percentage
progress = pow(1 + state.rate / 100, state.periods)
state.final_amount = state.initial_investment * progress


if __name__ == "__main__":
pages = {
"main": page,
"_rate_pane": rate_page,
}
Gui(pages=pages).run()
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,33 @@

# Initially invested amount
initial_investment = 100
# Interest rate by period
rate = 5
# Number of periods
periods = 0
# Number of periods
final_amount = initial_investment
# Interest rate by period
rate = 5
# Is the interest rate setting panel shown
show_rate = False

pane_page = """
rate_page = """
Rate (in %):
<|{rate}|number|>
"""

page = """
# Interest Calculator
<|{show_rate}|pane|show_button|page=_rate_pane|>
# Interest Calculator
Initial amount: <|{initial_investment}|number|>
Periods: <|{periods}|number|min=0|max=50|>
Final amount: <|{final_amount}|format=%.2f|>
Final amount: <|{final_amount}|text|format=%.2f|>
"""


# Invoked when any control value is changed.
# Invoked when any control value (initial_investment, rate, or periods) is changed.
def on_change(state, var_name: str):
# Cumulated interest percentage
progress = pow(1 + state.rate / 100, state.periods)
Expand All @@ -54,6 +53,6 @@ def on_change(state, var_name: str):
if __name__ == "__main__":
pages = {
"main": page,
"_rate_pane": pane_page,
"_rate_pane": rate_page,
}
Gui(pages=pages).run()
1 change: 1 addition & 0 deletions doc/gui/examples/blocks/pane_persistent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file makes this directory a module on its own, mandatody for mypy.
30 changes: 30 additions & 0 deletions doc/gui/examples/blocks/pane_persistent/builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2021-2024 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
import taipy.gui.builder as tgb
from taipy.gui import Gui

show_pane = False

with tgb.Page() as page:
with tgb.part("d-flex"):
with tgb.pane("{show_pane}", persistent=True, show_button=True, width="150px"):
tgb.text("Here is the content of the pane.")
with tgb.part():
tgb.text("# Main page", mode="md")
tgb.text("Here is the content of the page.")

if __name__ == "__main__":
Gui(page).run()
33 changes: 33 additions & 0 deletions doc/gui/examples/blocks/pane_persistent/markdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2021-2024 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
from taipy.gui import Gui

show_pane = False

page = """
<|d-flex|
<|{show_pane}|pane|persistent|show_button|width=150px|
Here is the content of the pane.
|>
<|
# Main page
Here is the content of the page.
|>
|>
"""

if __name__ == "__main__":
Gui(page).run()
1 change: 1 addition & 0 deletions doc/gui/examples/blocks/pane_simple/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file makes this directory a module on its own, mandatody for mypy.
38 changes: 38 additions & 0 deletions doc/gui/examples/blocks/pane_simple/builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2021-2024 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
import taipy.gui.builder as tgb
from taipy.gui import Gui

show_pane = False


# When the button is pressed, set the variable controlling the pane visibility to True
def on_action(state):
state.show_pane = True


with tgb.Page() as page:
tgb.text("# The **pane** block", mode="md")

Check failure on line 28 in doc/gui/examples/blocks/pane_simple/builder.py

View workflow job for this annotation

GitHub Actions / partial-tests / linter

Module has no attribute "text" [attr-defined]

with tgb.pane("{show_pane}"):

Check failure on line 30 in doc/gui/examples/blocks/pane_simple/builder.py

View workflow job for this annotation

GitHub Actions / partial-tests / linter

Module has no attribute "pane" [attr-defined]
tgb.text("Here is the content of the pane.")

Check failure on line 31 in doc/gui/examples/blocks/pane_simple/builder.py

View workflow job for this annotation

GitHub Actions / partial-tests / linter

Module has no attribute "text" [attr-defined]

tgb.text("This is the content of the page.")

tgb.button("Show pane")

if __name__ == "__main__":
Gui(page).run()
File renamed without changes.
1 change: 1 addition & 0 deletions doc/gui/examples/blocks/pane_simple_lambda/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file makes this directory a module on its own, mandatody for mypy.
32 changes: 32 additions & 0 deletions doc/gui/examples/blocks/pane_simple_lambda/builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2021-2024 Avaiga Private Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
# -----------------------------------------------------------------------------------------
# To execute this script, make sure that the taipy-gui package is installed in your
# Python environment and run:
# python <script>
# -----------------------------------------------------------------------------------------
import taipy.gui.builder as tgb
from taipy.gui import Gui

show_pane = False

with tgb.Page() as page:
tgb.text("# The **pane** block", mode="md")

Check failure on line 22 in doc/gui/examples/blocks/pane_simple_lambda/builder.py

View workflow job for this annotation

GitHub Actions / partial-tests / linter

Module has no attribute "text" [attr-defined]

with tgb.pane("{show_pane}"):

Check failure on line 24 in doc/gui/examples/blocks/pane_simple_lambda/builder.py

View workflow job for this annotation

GitHub Actions / partial-tests / linter

Module has no attribute "pane" [attr-defined]
tgb.text("Here is the content of the pane.")

Check failure on line 25 in doc/gui/examples/blocks/pane_simple_lambda/builder.py

View workflow job for this annotation

GitHub Actions / partial-tests / linter

Module has no attribute "text" [attr-defined]

tgb.text("This is the content of the page.")

Check failure on line 27 in doc/gui/examples/blocks/pane_simple_lambda/builder.py

View workflow job for this annotation

GitHub Actions / partial-tests / linter

Module has no attribute "text" [attr-defined]

tgb.button("Show pane", on_action=lambda s: s.assign("show_pane", True))

Check failure on line 29 in doc/gui/examples/blocks/pane_simple_lambda/builder.py

View workflow job for this annotation

GitHub Actions / partial-tests / linter

Module has no attribute "button" [attr-defined]

if __name__ == "__main__":
Gui(page).run()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file makes this directory a module on its own, mandatody for mypy.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file makes this directory a module on its own, mandatody for mypy.
File renamed without changes.
3 changes: 1 addition & 2 deletions taipy/gui/_renderers/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,7 @@ class _Factory:
("render", PropertyType.dynamic_boolean, True),
("width", PropertyType.string_or_number),
]
)
._set_propagate(),
),
"selector": lambda gui, control_type, attrs: _Builder(
gui=gui, control_type=control_type, element_name="Selector", attributes=attrs, default_value=None
)
Expand Down
2 changes: 1 addition & 1 deletion taipy/gui/viselements.json
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@
"name": "title_anchor",
"type": "str",
"default_value": "\"bottom\"",
"doc": "The anchor of the title."
"doc": "The anchor of the title.<br/>Possible values are:\n<ul>\n<li>\"bottom\"</li>\n<li>\"top\"</li>\n<li>\"left\"</li>\n<li>\"right\"</li>\n<li>\"none\" (no title is displayed)</li>\n</ul>"
},
{
"name": "render",
Expand Down

0 comments on commit b177780

Please sign in to comment.