I want to use a better version of alert that allows me to format its appearance and install other functionalities.
What I’ve tried and what’s not working:
I found @stefano.menci revised alert demoed at: https://stefano-validator-demo.anvil.app. I installed the Input_box and validator as modules, and also installed anvil extras as a 3rd party dependency. I pasted the relevant def codes of Input_box in the main page of my app along with other methods and had all dependencies imported.
When running and calling alert2 to show a modified alert, my app couldn’t find the the validator module ( ModuleNotFoundError: No module named 'Validator.validator')
Is there a proper way to add the validator module? I simply copied and pasted the codes in a validator module (named it as Validator).
Incidentally, when I run a clone of the original demo that runs fine on the browser in Anvil.works, I run into these errors:
The app you requested could not be loaded.
The app may be misconfigured. The following error occurred:
Permission denied when loading app dependency.
Can you take a screenshot of your dependencies in the dependencies tab of settings? That probably has some details on what’s broken in the clone. That will then probably tell you what your missing in your use.
While looking at the dependencies, I thought I’d hook up the validator module to Input_box module. So, when I did that I get past the module missing error: (ModuleNotFoundError: No module named ‘Validator.validator’).
When I ran the app, it gave me the same issue when running the Input_box demo in Anvil.works. Here’s the screenshot of the problem:
The only dependency I addes is anvil extra, installed as third party. I had Input_box earlier linked to validator but it was causing trouble running my app so I deleted it.
But what did the validator dependency’s line look like? If it was causing problems in the running then maybe that needs to be fixed for the app to actually work.
Are you sure that the code in your validator file is the same as the dependency?
I’m on my cell now, so I haven’t cloned your app, but I have the feeling that both validator and inputbox should be their own apps used as dependencies.
If you copy the code into your own modules, then you need to adjust all the imports accordingly.
Yes, I copied your Input_box and validator as modules inside my own app and import them into my Main page (probably should be imported differently) as:
from InputBox.input_box import InputBox, alert2, input_box, multi_select_dropdown
import json
from anvil import js as _js
from anvil.js.window import jQuery as _S
I had all the def codes of Input_box inside my Main page and call them as, for instance, self.simple_alert_click() to display your alert2 that I could play around with to display my own alert. But, it could not display anything…'alert2" is not defined error.
You need at least one, probably two, dots before from InputBox. You should let the anvil auto complete help you with that, it is always accurate at getting the correct import paths. I suspect that’s at least one of your issues.
I deactivated the 2 modules that I copied to my Main page and brought them both as dependencies. Unfortunately, when I ran my app as before I get the error that I posted a screenshot above…basicaly,
The app you requested could not be loaded.
The app may be misconfigured. The following error occurred:
Permission denied when loading app dependency.
I am sorry but that was what I got when I changed the standard main window to dark mode (.jpg). When I did that, I could no longer input my app’s modules using double dot. Sorry, the app is nearly ready for roll out. The company would not allow me to share the link.
I checked out your modified alert. It looks good but I am only after one that uses rich text so that I could accentuate certain words or phrases by highlighting, bold or some other text format. I still prefer to use @stefano.menci alert2.
Thank you just the same. I may go back to it when its usability makes more sense for what I need.
If you change where the code is stored and don’t give us a clone link, it’s difficult to understand what’s wrong with your changed code without seeing it.
Instead of copy/pasting the code, try cloning the InputBox app, making sure the name is correct (doesn’t have “clone” in its name), then add that as a dependency to your app. If you do that, it will work just like the demo works.
Hi @stefano.menci.
I am still keen on using your modifled Alert and tried as you suggested but still ran into ‘permission denied’ issue on any modification I tried. So, I checked if the clone of InputBox would run on Anvil Editor. As before I ran into the same ‘permission denied’ issue. Here’s what I found out about the nature of this issue (ref screen grab below).
Update: I managed to run your Alert2 app by changing the token for Anvil Extras to C6ZZPAPN4YYF5NVJ in the Clone of InputBox2 and that’s all it took to resolve the dependencies mismatch and run it.
Thanks. Your Alert2 is nice. I will definitely use it for guided alerts from here on.
Great work! Keep it up.
NOTE (to those interested to use Alert2): for full functionality, eg., colored OK button and rectangular alert window, add the Theme CSS and the standard html that InputBox2 has as Assets.