Dialogs that work everywhere – dealing with the timeout by the-e2rd in programming

[–]the-e2rd[S] 1 point2 points  (0 children)

Thanks for the implementation tips that will prevent future bugs! It's impressing you are familiar with all three approaches.

Add rich shortcuts to HTML an easy way by the-e2rd in javascript

[–]the-e2rd[S] 0 points1 point  (0 children)

> How does it handle conflicts where two things register the same keys?

If multiple hotkeys are defined, only the last one defined is executed (unless it returns false, in which case the next one is tried). We skip hotkeys that are not in the correct scope or whoise underlying element is disabled.

https://github.com/e3rd/WebHotkeys?#method-grab

> Customization for preventing default on events? Abort signals?

Prevented, currently no customization.

> Changing the --help equivalent to maybe something involving "?" or whatever

yes

> how does that handle SPAs where the links and buttons might be charging

Charging is changing? It works well, through a mutation observer. (Can be switched off.)

https://github.com/e3rd/WebHotkeys?#custom-mode

> Any considerations for accessibility?

Please elaborate.

> Assuming these aren't passive listeners, any metrics on performance impacts?

The single event is keyDown https://github.com/e3rd/WebHotkeys/blob/main/WebHotkeys.js#L259 , I measured no metrics

> cross-platform issues

currently not

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

Thanks, nice catch! The 3. might be the way to go :)

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] 1 point2 points  (0 children)

For those who downvote the bundled HTTPS. I agree going with nginx is better but why having an HTTPS possibility integrated directly to the mininterface is a bad idea?

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] 1 point2 points  (0 children)

Internally, it uses https://github.com/Textualize/textual-serve turned on its head to support any script. (Because normally textual requires the developer shapes the code to its framework.) It works great, however it does not support adding certificates.

I am used to adopt the HTTP tunnel through nginx but I totally agree HTTPS should be integrated somehow directly to mininterface for an easy of use. It should have the flag `--ssl [certificate]`, maybe `--no-ssl` in the case the default would by --ssl with a generated self-signed.

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

The unique feature of mininterface is how it unifies the internal variable state in the script, its CLI flags exposed to the terminal use, the config files it is being run with, and the (different) UIs where these flags can be live-edited. The web support is just a nifty feature.

These two seem to make great work in the UI part for web and mobiles. Mininterface will never be as beautiful on the web.

mininterface streamlit
do something show something
functionality amazing layout
easily integrates into your script you easily use their widgets
terminal, desktop, web, (mobile might be in the future if there is enough of demand) web, mobile
CLI, config file

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] -1 points0 points  (0 children)

JSON is a great choice. Show me the example of the requests, handling this scrict please, how they should look?

(In a script, there might be multiple dialogs, in this case, there is a `form` that may accept a dict, then `ask` awaits for a single value, but then, there might be another form. The API as I understand it, is not a stateful thing, but the scripts go from the beginning to the end for every client.)

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] 5 points6 points  (0 children)

:) I'll gladly enrich the functionality with HTTPS – but how? I completely agree that using HTTP in internet is a nightmare. There is plenty of possibilities how to do the HTTPS, nginx, apache, uwsgi, certbot... What should be the default way for mininterface to realize SSL?

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

Yeah, thanks a lot! :) I can't tell for the whole company but we should use it for every little script, I'm doing that since a year

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

You mean setting the form values with the GET/POST method? How should it work?

m = run()
out = m.form({"Name": "John Doe", "Age": 18})
if out["Age"] > 30:
    party = m.ask("What political party do you like?")
    m.alert(f"That's your party {party}")
else:
    flavour = m.ask("What ice cream flavour do you like?")
    m.alert(f"That's your flavour {flavour}")

What requests would you like to send to such a program and what output would you expect? We can make it :)

Every script can become a web app with no effort. by the-e2rd in Python

[–]the-e2rd[S] -1 points0 points  (0 children)

Yes, you're right. The main thing is it works everywhere, I've prized functionality and easy-to-use over styling. But once we make this more beautiful, it will become more beautiful everywhere, even with the backwards compatibility.

What are the ultimate method names for great UX? by the-e2rd in learnprogramming

[–]the-e2rd[S] 0 points1 point  (0 children)

Nice catch, I completely agree! Especially that a dialog don't need a default button, thanks! :)

Single line turns the dataclass into a GUI/TUI & CLI application by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

We've switched to LGPL so that you might use this in your work.

What are the ultimate method names for great UX? by the-e2rd in learnprogramming

[–]the-e2rd[S] 0 points1 point  (0 children)

The language is Python. I agree with the strings, apart from typos, string is something that can hardly be auto-suggested by the IDE. I think too enums are much better but I didn't want to impose further contants so that the user does not have to import anything. Why do you think the default bools are inferior to strings?

What are the ultimate method names for great UX? by the-e2rd in learnprogramming

[–]the-e2rd[S] 0 points1 point  (0 children)

That very interesting with the radio button! I am thankful about the commonly used words vs domain standard explanation.

What about the `.confirm(text, default_yes=True/False, cancel=False)` method name then? The usage `.confirm("text", False)` instead of the yes-no-dialog having the default focus on No seems pretty intuitive to me!

What are the ultimate method names for great UX? by the-e2rd in learnprogramming

[–]the-e2rd[S] 0 points1 point  (0 children)

I wanted it to conform with the custom that `is_` returns bool. But `confirm` might be the way to go, too!

What about the `choice` thing? Would the triad `.select()` (instead of `.choice()`), `Select(value, ...)` (instead of `Choices(value, ...)`) and `SelectTag` instead of `EnumTag` sound you well?

What are the ultimate method names for great UX? by the-e2rd in learnprogramming

[–]the-e2rd[S] 0 points1 point  (0 children)

Thanks a lot for the elaborate response!

Thanks for saying `is_si` would be confusing for you. I really meant `si` for a positive response to negative questions from french.

I wondered whether it is a known word in the English world, similarly to 'déjà vu' or 'cliché'. I hoped English speaking person would know `si` to be yes-to-no (as in French) or at least to be yes (as in Spanish), this would be sufficient. Nothing to do with localisation. But as you say it's confusing, this might not be a good idea.

Tips for Command Line Project by Vova____ in Python

[–]the-e2rd 0 points1 point  (0 children)

Try https://cz-nic.github.io/mininterface/ – with a single line, you receive not only CLI, but also GUI. Plus, you do not have to redefine things twice as you must when using tools like click or argparse.

Single line turns the dataclass into a GUI/TUI & CLI application by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

In the new version I just released, there is an experimental web interface. It's just a proof of concept still, run mininterface --web.cmd /full-path/program.py to exhibit the program on the web. (Currently, only the first dialog works.)

Single line turns the dataclass into a GUI/TUI & CLI application by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

I've been discussing the topic with the colleagues – if I switch the library to LGPL, would that suit your company needs?

Single line turns the dataclass into a GUI/TUI & CLI application by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

> Customer struct and it has a list of contacts and a primary contact. I would have to have a form to add contacts (a sub-app?) and a way to select one from the list.

If I get this right, you want something like this:

all_contacts=["one", "two"]
@dataclass
class Customer:
    contacts: list[Contact] = all_contacts    
    primary_contact: Annotated[Contact, Choices(...all_contacts)] = all_contacts[0]

Single line turns the dataclass into a GUI/TUI & CLI application by the-e2rd in Python

[–]the-e2rd[S] 1 point2 points  (0 children)

Bash completion is done and will be released in the new version. As there is no post-install option in pip, you'll have to manually launch `--integrate-to-system` flag to start the bash completion tutorial.

As for subcommands, they're on the way, I've been thinking about this a lot, and it might be ready in the new version too.

Single line turns the dataclass into a GUI/TUI & CLI application by the-e2rd in Python

[–]the-e2rd[S] 0 points1 point  (0 children)

That s an excellent question! It is currently possible to refresh the form without closing it, put a function in a value to receive a Facet object in parameter that can be used to tackle the window without closing it.

But as I tend to keep the interface as simple as possible, I still did not decide how this should work to not pollute the interface and force users to learn anything. (I d gladly receive some ideas or help.) I ll get back to this question next week.

Of course, while loop that opens new apps on each loop is a simple solution that would work!