The GUI and the Command Line

Once upon a time, there was a thing called HaikuWare, and when I wrote something new, I could post it there, and people would see it. (Now there are repositories, but there’s no way to distinguish new stuff there. You just have to browse…) Anyway, in the absence of a better solution, when I write something I think might be of interest to others, I guess I’ll just post about it here.

Over the years I’ve often bemoaned the lack of a way to open a panel of GUI elements from, say, a bash script, so that one could for instance open text controls to accept user input, rather than having to prompt and get a response. I finally had a project that cried out for such a feature, so I decided to actually write one!

“Gadgeteer” is the result. It is an app that lets you specify on its command-line the controls you want displayed in ‘Control Panel’. It then passes back the data that the user inputs on standard output. Here’s a screen shot of my initial usage: http://goodeveca.net/beos/gadgeteer_in_use.png
Currently it provides TextControls, (popup) Menus, CheckBoxes, Buttons, and Labels.

I hope this may be of use to others who, like me, are fond of writing scripts to do things. (It can be used with things like Python and ruby scripts, too, of course.) I’ve put it on the web at http://goodeveca.net/beos/#gadgeteer No hpkg yet, so it has to be installed from the zip, but I’ll get around to packaging it, soon.


While I’m at it, I’ll mention another little thing that I wrote and put on HaikuWare some time ago, but has been pretty much lost since then. I was continually infuriated by the CapsLock key on my laptop, which is perfectly placed for accidental activation [and it’s always accidental in my case! It’s the one key I never use…] So I have a little input filter http://goodeveca.net/haiku/capslockfilter/ that gives me peace of mind!

Thank you for this code, I already have a CLI program that this would be useful for.

It looks similar to https://github.com/atalax/hdialog and https://github.com/bbjimmy/Yoshi . So it looks like we really need a way to advertise new software…

Haiku Depot Server does provide a view on “Recent Updates”. I think the design/GUI of the web front-end could be improved. Andrew is quite open to suggestions and patches for that. Also, if anyone wanted to create their own BeBits-like website, that also hosts non-hpkg software etc., they could use HDS to keep uptodate with the various package depots.

Regards,
Humdinger

yab can more and it is simpel to add your cli app in the yab code.

I think hdialog only allows a single control in the panel. (I couldn’t get it to work at all, so I can’t say for sure. Actually I’m not sure that was the hdialog I tried (which I think was also YAB based); looks different. I’ll check it out.)

bbjimmy took a different approach – using YAB. I wanted a self-contained app, with a lot of flexibility in layout and options. (Can you easily combine YAB and Python, for instance?)

Yes to both my suspicions above… That’s not the hdialog I tried before. This one works fine, but it does only allow one (kind of) control in any window. (I think ‘xdialog’ which it mimics is the same.)

Gadgeteer [auto-promo here… (:-))] is much more flexible. You can mix all available types of control in one panel, and lay them out as you desire [See the image linked in my initial post]. (At the cost of a more complex command line and a larger executable…)

Hmm, the yab-based hdialog is mine. I’ll change its name to avoid conflicts.

Just a small point: If you use https://depot.haiku-os.org you can set it to sort on “Recent Updates”.

Done. It is now called yabdialog. If you were using it, please uninstall the old one, install yabdialog and update your scripts.

And then there is Yoshi … https://github.com/bbjimmy/Yoshi/wiki Yoshi is a work in progress, but open source, and built with yab.

yoshi, why not used json file to make a mini app?

example:
http://www.json.org/example

[quote=stargater]yoshi, why not used json file to make a mini app?

example:
http://www.json.org/example[/quote]

I don’t understand how this would help yoshi. Yoshi reads a command file that defines the window and widgets. It then returns the entered data. The script calling yoshi then has access to the data as variables. The example script shows how to call yoshi and get the information back to the script. A group of command files can build a mini app on top of your bash script. The same method should be usable in python or other scripted languages. As long as one can execute a command line and read a data file yoshi makes the gui part work.

Ok, I should record that an hpkg version is now available at the same place.

BTW, there is a slight difference in philosophy between Gadgeteer and Yoshi. Gadgeteer specifies the controls and their layout on the command line (as does hdialog). Yoshi uses a separate specification file. (Though Gadgeteer can also accept a file if needed.) I guess one or the other might me preferable depending on the context.

I tend to prefer the command line because it’s self-contained. Also I’ve found shell variables very useful there – for setting initial text in a textcontrol, for instance.

[quote=Pete]Ok, I should record that an hpkg version is now available at the same place.

BTW, there is a slight difference in philosophy between Gadgeteer and Yoshi. Gadgeteer specifies the controls and their layout on the command line (as does hdialog). Yoshi uses a separate specification file. (Though Gadgeteer can also accept a file if needed.) I guess one or the other might me preferable depending on the context.

I tend to prefer the command line because it’s self-contained. Also I’ve found shell variables very useful there – for setting initial text in a textcontrol, for instance.[/quote]

Yoshi can do many things from the command line, including setting the text in a textfield. Not everything is documented yet, but some of the command-line stuff is shown in https://github.com/bbjimmy/Yoshi/blob/master/Example/yoshitest.sh Yoshi allows the power of the command line withoput needing the command line to define everything in an input window.

I don’t know about others, but “hdialog” is meant to be a [x]dialog replacement, and hence compatible with it.
There is also https://github.com/peja/shanty

[quote=mmu_man]I don’t know about others, but “hdialog” is meant to be a [x]dialog replacement, and hence compatible with it.
There is also https://github.com/peja/shanty[/quote]

Yes, but those are very restricted compared to both Gadgeteer and Yoshi. They only allow a single control in the window. Gadgeteer and Yoshi can present a “Control Panel”, with a wholre range of desired controls. e.g.

Not to be out-shown:

But yes indeed both yoshi and Gadgeteer are designed to do more than get one piece of information per window.

The first .hpkg for yoshi is at http://fatelk.com/repo

http://fatelk.com/repo/packages/yoshi-0.2.0-2-x86_gcc2.hpkg

:slight_smile:

Gadgeteer Status Update:
It’s now at version 0.8, and I expect it to remain there for a while. It’s doing everything I need, and no current glitches have shown up. I now would rather concentrate on using it in the projects that sparked its development in the first place!

Gadgeteer 0.8 has Labels, TextControls, (popup) Menus, CheckBoxes, Buttons, and Sliders. The sliders are not quite like the usual Interface Kit ones, as they have a ‘live’ display of their current value. This seems more useful when you would probably rather know what the slider is set to before hitting ‘DONE’! See the DEMO image above for an example.

Buttons seem to be one of the more useful features, as I can use them to trigger actions (with the current panel values) without closing the window. The ‘DONE’ and ‘CANCEL’ buttons are now both suppressable, so they don’t get in the way if you don’t need them.

Worth noting that Gadgeteer is self-contained — dependency-free. It runs in any release of Haiku. I’m even using it (with a recompile) on my old BeOS machine. I apologize that there is still no publishable source — too many debug-printfs and commenting-things-out… I’ll try to get it out soon.

Direct links to the current version (website link in original post):

In ZIP form: http://goodeveca.net/beos/gadgeteer_0.8.zip
As an hpkg: http://goodeveca.net/beos/gadgeteer_0.8-1_x86_gcc2.hpkg