Make a menu list with Xdialog (Checklist box)

Moderator: Forum moderators

Post Reply
User avatar
amethyst
Posts: 2420
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

Make a menu list with Xdialog (Checklist box)

Post 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.

Attachments
WineProgs.gz
(2.43 KiB) Downloaded 80 times
capture32531.png
capture32531.png (27.91 KiB) Viewed 2642 times
Last edited by amethyst on Fri Jun 10, 2022 6:24 am, edited 2 times in total.
User avatar
Flash
Moderator
Posts: 979
Joined: Tue Dec 03, 2019 3:13 pm
Location: Arizona, U.S.
Has thanked: 52 times
Been thanked: 127 times

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

Post by Flash »

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

Chaos coordinator :?
sfein1000
Posts: 96
Joined: Fri Mar 25, 2022 1:38 am
Been thanked: 4 times

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

Post 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.

User avatar
amethyst
Posts: 2420
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

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

Post by amethyst »

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

User avatar
amethyst
Posts: 2420
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

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

Post 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.

User avatar
Flash
Moderator
Posts: 979
Joined: Tue Dec 03, 2019 3:13 pm
Location: Arizona, U.S.
Has thanked: 52 times
Been thanked: 127 times

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

Post by Flash »

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

Chaos coordinator :?
User avatar
amethyst
Posts: 2420
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

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

Post 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.

user1111

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

Post 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.

User avatar
amethyst
Posts: 2420
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

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

Post 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.

donkes12
Posts: 8
Joined: Wed Jun 16, 2021 12:13 pm

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

Post 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"
User avatar
fredx181
Posts: 3096
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 376 times
Been thanked: 1321 times
Contact:

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

Post 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.

donkes12
Posts: 8
Joined: Wed Jun 16, 2021 12:13 pm

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

Post 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.

Attachments
treeview.png
treeview.png (6 KiB) Viewed 2506 times
1.png
1.png (5.96 KiB) Viewed 2506 times
User avatar
amethyst
Posts: 2420
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

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

Post 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?

donkes12
Posts: 8
Joined: Wed Jun 16, 2021 12:13 pm

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

Post 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 
User avatar
amethyst
Posts: 2420
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

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

Post 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.

Attachments
Screenshot.jpg
Screenshot.jpg (24.95 KiB) Viewed 2439 times
donkes12
Posts: 8
Joined: Wed Jun 16, 2021 12:13 pm

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

Post 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:

Attachments
2.png
2.png (8.2 KiB) Viewed 2435 times
User avatar
amethyst
Posts: 2420
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 57 times
Been thanked: 506 times

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

Post 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).

Post Reply

Return to “Utility”