pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

Why do you force the output and errors to be visible after you evaluate an expression?

Open dylanjcastillo opened this issue 3 years ago • 4 comments

Checklist

  • [X] I added a descriptive title
  • [X] I searched for other issues and couldn't find a duplication
  • [X] I already searched in Google and didn't find any good information or help

What is the issue/comment/problem?

I noticed that you force the output and errors to be visible once an expression is executed. But there might be times when you don't want this to happen.

For example, I made an app with two outputs shown in different tabs. Depending on where the user is, only one of the outputs should be visible.

I noticed that whenever I ran a python script or the repl, both outputs would show. Hiding them was not possible only with classes given that you force that by setting style="display:block;". After digging a bit into the code, I found that in lines 577, 578, 602, 603, 24033, and 24034 you set the style setting mentioned earlier and remove the hidden attribute from the output and error elements. In my case, the easiest workaround was just to comment out those lines (see image).

But I was wondering if there's any reason why you set style="display: block;? If this behavior isn't intended, it might be better to use the block class of tailwind or nothing at all.

dylanjcastillo avatar Sep 08 '22 21:09 dylanjcastillo

Hey @dylanjcastillo I'm currently changing a lot around the output system, you can see my progress here https://github.com/pyscript/pyscript/pull/749.

First, I'd like to thank you for the absolutely awesome app :D Super cool.

I'm sorry, I don't really understand what you mean here

For example, I made an app with two outputs shown in different tabs. Depending on where the user is, only one of the outputs should be visible.

I clicked your example and the error output is only visible on the Graph tab, do you mean it should show up on both of them...?

Or you just mean we shouldn't display block things? I think it'd be easier for me to understand if you offer a minimal reproducible example 😊 if you can!

But what I'm taking out of this issue is that, the error messages should be configurable, in the sense of the PyScript users should be able to turn their notifications on/off on the HTML, correct? :)

marimeireles avatar Sep 12 '22 12:09 marimeireles

Hey @marimeireles,

Thank you. PyScript is such a great library. I have been loving working with it!

I realized that the issue isn't really what I described. There seems to be some weird behavior if you have a py-repl sending its output to a specific element and a py-script listening to events and sending its output to a different element.

I made a minimal reproducible example here: https://codepen.io/dylanjcastillo/pen/MWGjYpO

Notice that:

  1. After the site loads, the loaded new df! message is in the Output 2 tab.
  2. If you click the button Load new dataframe nothing happens unless you already have an output from the py-repl element.
  3. After you generate an output from py-repl, the output of py-script starts showing in #output_div_1 instead of #output_div_2.

It's also possible I'm not using the library as intended tbh

dylanjcastillo avatar Sep 12 '22 17:09 dylanjcastillo

Hi @dylanjcastillo thank you for the example. I see what you mean now. This issue will be fixed once the PR I posted earlier is merged. Our current output mode is v. wonky, but hopefully the PR will make it more consistent :)

marimeireles avatar Sep 13 '22 08:09 marimeireles

Awesome, thank you very much!

dylanjcastillo avatar Sep 13 '22 13:09 dylanjcastillo

I can't reproduce your error anymore. But also your code in general. I think the API went through many changes for this to be relevant. I'll close this issue as not relevant anymore, but hopefully your bug will not happen when you're using the tip of the branch! If it does, please let us know in a new issue. Thanks again for the awesome work.

marimeireles avatar Oct 24 '22 16:10 marimeireles