Page 1 of 1

Make a menu list with Xdialog (Checklist box)

Posted: Sat May 21, 2022 8:46 am
by amethyst

I use these menus a lot for selecting items. So I'm sharing an Xdialog script (all Puppys should have XDialog, I think). Right-click the script and select "Open As Text" to edit. Use the attached example script to work from (remove the fake file extension). You can start an item by selecting its button and then clicking "OK" or just by double-clicking the item OR you can select a few items to open simultaneously. In the attached script I have all the Windows Programs I want to run with WINE listed and to be run quickly from the menu. You can manipulate the size of the box, use spaces to arrange the Title and contents of the box, change the icon, etc.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Sat May 21, 2022 4:11 pm
by Flash

Very nice, looks useful. Instead of checklist box, do you mean checkbox list?


Re: Make a menu list with Xdialog (Checklist box)

Posted: Sat May 21, 2022 4:38 pm
by sfein1000

Very nice. I was thinking of doing something similar for my appimages and wine apps instead of adding menus to jwm. This will come in handy.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Sun May 22, 2022 4:49 am
by amethyst

I've updated the script to make the box look a bit nicer. See first post.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Sun May 22, 2022 9:49 am
by amethyst
Flash wrote: Sat May 21, 2022 4:11 pm

Very nice, looks useful. Instead of checklist box, do you mean checkbox list?

No, you get different boxes with different functions and different setups. The example used here is a checklist box. A menubox and radiolist box will also work in this instance but the checklist box has more options.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Sun May 22, 2022 3:17 pm
by Flash

Ah, I see. You mean the box that contains the whole checklist, not the little checkboxes. :oops:


Re: Make a menu list with Xdialog (Checklist box)

Posted: Sun May 22, 2022 3:54 pm
by amethyst
Flash wrote: Sun May 22, 2022 3:17 pm

Ah, I see. You mean the box that contains the whole checklist, not the little checkboxes. :oops:

The whole thing is called a widget. You decide which box you need inside the widget. The boxes have different functions, looks differently and are set up differently.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Mon Jun 06, 2022 7:43 pm
by user1111
sfein1000 wrote: Sat May 21, 2022 4:38 pm

Very nice. I was thinking of doing something similar for my appimages and wine apps instead of adding menus to jwm. This will come in handy.

I like/prefer the jwm choice myself. onroot=N ... menus created and add a button to the tray or assign it to a keycode. I have WIN+spacebar show the main menu, ALT+spacebar shows my bookmarks/urls.

I don't have a MENU button in my tray, I use the clock instead, where in jwm

Code: Select all

       <Clock format="%H:%M %a %d %b">
            <Button mask="1">root:1</Button>
            <Button mask="2">showdesktop</Button>
            <Button mask="3">root:3</Button>
        </Clock>

Left mouse click (button 1) shows the main menu, middle button (2) acts as show/hide desktop and right mouse click (button 3) shows my bookmarks menu (root:3), where previously that root:3 was defined looking something like (snippet of the list of URL's) ...

Code: Select all

    <RootMenu label="BookMarks" labeled="false" height="26" onroot="3">
        <Program icon="yt" label="ytplayer">ytplayer</Program>
        <Program icon="mini-dog" label="PuppyLinux">/opt/google/chrome/chrome --no-sandbox --start-maximized  --js-flags='--jitless' -d https://forum.puppylinux.com</Program>
        </RootMenu>
    

and where for the key based launching of those menus, in the keys section including

Code: Select all

    <Key mask="4"   key="space">root:1</Key> <!-- WIN-space main jwm menu          -->
    <Key mask="A"   key="space">root:3</Key> <!-- ALT-space URL bookmarks menu     -->

Keymask 4 being the WIN key.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Fri Jun 10, 2022 6:25 am
by amethyst

I've updated the example script. It will now allow you to run either 1 selected item OR more than one selected items simultaneously. See first post.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Mon Aug 01, 2022 5:23 am
by donkes12

Thank you for sharing this script. I digged Xdialog documentation and discovered that list may be represented as tree with --treeview instead of --checklist, sort of more organized, but can not figure out how to make it with my poor knowledge.

checklist and treeview examples looks similar, but <item_depth1> is what confusing me:
--checklist <text> <height> <width> <list height> <tag1> <item1> <status1>
--treeview <text> <height> <width> <list height> <tag1> <item1> <status1> <item_depth1>

I want my tree to look like this:

Code: Select all

text
 | |-Spreadsheet32
 | |-Wordpad
 |
 |
 mp3
 | |-Mp3Trackmaker
 | |-mp3DirectCut
 | |-Mp3tag
 |
 |
etc

As far as I understand, main branch entries (text, mp3, etc) should be "1" depth; sub-branches (Spreadsheet32, Wordpad) - "2" depth, but it doesn't work.
I just need a tip what need to be changed in this part of code:

Code: Select all

answer=`Xdialog --left --wrap --no-tags --icon /usr/share/pixmaps/wine48.png --stdout --title "Scripts"  --treeview "Select your program of choice from the list." 0 0 11 "1" "text" "off" "1" "2" "Spreadsheet32" "off" "2" "3" "Wordpad" "off" "2" "4" "mp3" "off" "1"

Re: Make a menu list with Xdialog (Checklist box)

Posted: Mon Aug 01, 2022 8:34 am
by fredx181

@donkes12
Can't help with your code, but here samples for treeview can be found https://fossies.org/linux/misc/dialog-1.3-20220526.tgz/ (for dialog but often works with Xdialog too), perhaps helpful.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Mon Aug 01, 2022 10:21 am
by donkes12

Thanks, that was helpful indeed. I've checked examples and figured out that main branch has "0" depth instead of "1". Now it's working, but for some reason branches not being drawn as on treeview demo.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Mon Aug 01, 2022 11:43 am
by amethyst

@donkes12
Could be a version or GTK thing. I've done other boxes before that did not look exactly like the examples published. I only get the main branches (0 level) to display and not the sub-branches. Can you post the code for your example, please?


Re: Make a menu list with Xdialog (Checklist box)

Posted: Mon Aug 01, 2022 12:23 pm
by donkes12

I was thinking about trying older versions of Xdialog too. But still treeview require a bit more clicks compared to checklist, as I need click to unfold branch, choose sub-branch and then click OK button (double click on selected sub-branch program doesn't fire it up).
Here is the script

Code: Select all

answer=`Xdialog --left --wrap --no-tags --icon /usr/share/pixmaps/wine48.png --stdout --title "Scripts"  --treeview "Select your program of choice from the list." 0 0 11 "1" "text" "off" "0" "2" "Spreadsheet32" "off" "1" "3" "Wordpad" "off" "1"`
case /$answer/ in 
*/2/*) wine "/initrd/mnt/dev_save/WineProgs/Spreadsheet32/Spread32.exe" & ;;&
*/3/*) wine "/initrd/mnt/dev_save/WineProgs/wordpad.exe" & ;;&
esac
 
exit 

Re: Make a menu list with Xdialog (Checklist box)

Posted: Mon Aug 01, 2022 1:10 pm
by amethyst
donkes12 wrote: Mon Aug 01, 2022 12:23 pm

I was thinking about trying older versions of Xdialog too. But still treeview require a bit more clicks compared to checklist, as I need click to unfold branch, choose sub-branch and then click OK button (double click on selected sub-branch program doesn't fire it up).
Here is the script

Code: Select all

answer=`Xdialog --left --wrap --no-tags --icon /usr/share/pixmaps/wine48.png --stdout --title "Scripts"  --treeview "Select your program of choice from the list." 0 0 11 "1" "text" "off" "0" "2" "Spreadsheet32" "off" "1" "3" "Wordpad" "off" "1"`
case /$answer/ in 
*/2/*) wine "/initrd/mnt/dev_save/WineProgs/Spreadsheet32/Spread32.exe" & ;;&
*/3/*) wine "/initrd/mnt/dev_save/WineProgs/wordpad.exe" & ;;&
esac
 
exit 

Hmm. Still does not work for me with Stretch 7.5 and I copied and pasted your exact code. :? BTW - With a bit of innovation you can give the checklist and radiolist boxes a treeview look actually by using spaces. This way you will be able to double-click for opening an item and your "tree" will already be expanded. See example attached.

Edit: Treeview does actually work for me as it should. I haven't used it before so I didn't click on the arrows to expand the branch. :oops: But as you say, extra clicks with treeview so not really all that convenient.


Re: Make a menu list with Xdialog (Checklist box)

Posted: Tue Aug 02, 2022 8:00 am
by donkes12

Great idea, and put inactive entries as separators.

Great thing about Xdialog is that you can replace wine in your case, with rox /path/to/location/ for opening location or geany (or whatever) /path/to/file.ext for firing up some file, etc. And this whole thing is less than 2KB depending on how big is the list. And you can easily customize it to fit your needs, just by editing few text lines.
The only thing difficult is to center the text :lol:


Re: Make a menu list with Xdialog (Checklist box)

Posted: Tue Aug 02, 2022 8:52 am
by amethyst

Great thing about the checklist is that you can select several user options for example. I've produced several utilities using this to run through several commands of a script (which could be huge like a remaster script). Check out my utilities (links in my signature).