Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悰 BUG] Cannot use Page Builder's dialog() in a context manager #1387

Open
1 of 2 tasks
FlorianJacta opened this issue Jun 11, 2024 · 4 comments
Open
1 of 2 tasks
Labels
馃柊 GUI Related to GUI 馃啒 Help wanted Open to participation from the community 馃挜Malfunction Addresses an identified problem. 馃煣 Priority: High Must be addressed as soon

Comments

@FlorianJacta
Copy link
Member

FlorianJacta commented Jun 11, 2024

What went wrong? 馃

It is not possible to use the dialog as a block.

Traceback (most recent call last):
  File "c:\Users\jacta\OneDrive\Bureau\taipy\Code\TTT-SDM-Interview\src_complete\h.py", line 8, in <module>
    with tgb.dialog(open="{open_modal}"):
  File "C:\Users\jacta\.conda\envs\develop\lib\site-packages\taipy\gui\builder\_element.py", line 189, in __enter__
    raise RuntimeError(f"Can't use Context Manager for control type '{self._ELEMENT_NAME}'")
RuntimeError: Can't use Context Manager for control type 'dialog'

Expected Behavior

We should be able to use the syntax below because dialog() is not a Context Manager.

Steps to Reproduce Issue

from taipy import Core, Gui
import taipy.gui.builder as tgb


open_modal = False

with tgb.Page() as page:
    with tgb.dialog(open="{open_modal}"):
        tgb.text("Hello")


if __name__ == "__main__":
    gui = Gui(page=page)
    gui.run(title="Sales Prediction", port=1221)

Version of Taipy

develop - 6/10/24 (M/D/Y)

Code of Conduct

  • I have checked the existing issues.
  • I am willing to work on this issue (optional)
@FlorianJacta FlorianJacta added 馃挜Malfunction Addresses an identified problem. Core Related to Taipy Core 馃煣 Priority: High Must be addressed as soon labels Jun 11, 2024
@jrobinAV jrobinAV added 馃柊 GUI Related to GUI and removed Core Related to Taipy Core labels Jun 11, 2024
@jrobinAV jrobinAV changed the title [馃悰 BUG] Cannot use dialog with "with" [馃悰 BUG] Cannot use dialog with "with" context manager Jun 11, 2024
@FabienLelaquais FabienLelaquais changed the title [馃悰 BUG] Cannot use dialog with "with" context manager [馃悰 BUG] Cannot use Page Builder's dialog() in a context manager Jun 11, 2024
@jrobinAV jrobinAV added the 馃啒 Help wanted Open to participation from the community label Jun 11, 2024
@yaten2302
Copy link
Contributor

Hey @FlorianJacta, I would like to work on this issue, could you please assign it to me?
Also, could you please elaborate a bit on using 'dialog as a block'. I've understood this partially, but I'm not able to completely understand that what exactly is the problem?
As far as I've understood according to taipy docs, the on_action property return -1, 0, 1 or for closing, validating, cancelling respectively, am I right?

@FlorianJacta
Copy link
Member Author

FlorianJacta commented Jun 14, 2024

@yaten2302 I have updated the issue. The problem is that you cannot use it inside the context manager. I will show you the Markdown syntax and the Python API.

Markdown syntax that works:

page = """
<|dialog|open={open_modal}|
Hello
|>
"""

Here, it is not working with a with.

with tgb.Page() as page:
    with tgb.dialog(open="{open_modal}"):
        tgb.text("Hello")

We will maybe put this issue in Staff Only.

@yaten2302
Copy link
Contributor

I'll try to work on some other issues, if this one is Staff Only 馃憤

@FredLL-Avaiga
Copy link
Member

The problem here is that dialog is a control and a block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃柊 GUI Related to GUI 馃啒 Help wanted Open to participation from the community 馃挜Malfunction Addresses an identified problem. 馃煣 Priority: High Must be addressed as soon
Projects
None yet
Development

No branches or pull requests

4 participants