You are not logged in.

#1 2016-01-12 04:03:56

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,567
Website

Yad height issues - any suggestions?

I mentioned this issue here: https://forums.bunsenlabs.org/viewtopic.php?id=1006
but now it's a support request!

Yad seems to have inherited a bug from Zenity whereby long --text messages cause the window to be stretched down too low, possibly to the space that would be needed if the window was squeezed to the minimum possible width. (This has been fixed in Zenity itself since Wheezy.)
A window with long text:
Yad_too_high_120116_12_40_36.jpg
A workaround is to set the --fixed option, which prevents resizing, but fixes the bug:
Yad_height_fixed_120116_12_41_36.jpg

Now, with radiolists I'm getting the opposite problem, the window is too small, and the user has to scroll to see it all:
Yad_radio_shortmessage_120116_12_42_59.jpg
If the message is long, the previous bug kicks in and fixes it!
Yad_radio_longmessage_120116_12_43_48.jpg
But if the --fixed hack is added, as would usually be needed for a window with a long message, then it's too short again:
Yad_radio_longmessage_fixed_120116_12_44_57.jpg

Of course, forcing the window height with --height would work, but only for a certain font-size and/or theme, message length and list length - it would have to be set by trial and error each time, and easily broken.

Has anybody heard of a way to make yad/zenity display a list without having to scroll?


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

#2 2016-01-12 05:05:19

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 1,029

Re: Yad height issues - any suggestions?

One way would be to use a form instead of a listbox, I think. I have a form setup with quite a bit of text and several radio buttons and have not seen this issue. Plus you can make a form scrollable if need be. While I am not ready to roll this thing out for general viewing yet, I will share with you some code snippets to show you how I went about it. Hopefully, you can read and understand python.
Here is the function to create the dialog string:

#function to create the yad dialog
def yad_dialog(mc, tf):
	monitorCount = mc
	# create a string containing all of the options for our yad
	# command.
	yad_cmd = 'yad --title="Select a Display"'
	yad_cmd += ' --width=600'
	yad_cmd += ' --height=400'
	yad_cmd += ' --text="Select one or more monitors to apply the background too:"'
	yad_cmd += ' --left'
	yad_cmd += ' --on-top'
	yad_cmd += ' --skip-taskbar'
	yad_cmd += ' --image-on-top'
	yad_cmd += ' --image='
	yad_cmd += tf
	yad_cmd += ' --form'
	yad_cmd += ' --columns=1'
	yad_cmd += ' --align=left'
	yad_cmd += ' --field="\n\nApply image to "'
	yad_cmd += ':LBL'
	# Output a checkbox for each connected monitor
	for i in range(0, int(monitorCount)):
		yad_cmd += ' --field="Monitor: '
		yad_cmd += str(i)
		yad_cmd += '"'
		yad_cmd += ':CHK'
	yad_cmd += ' --field="\n\n Please note that any previous versions of .fehbg will  be moved to $HOME/.config/feh/.fehbg_bak'
	yad_cmd += '\n\n A new .fehbg file will be created in $HOME/.config/feh/.fehbg with the command that this dialog will create.'
	yad_cmd += '\n\n Additionally, the openbox autostart file can be updated so that the new wallpaper selection will autostart.\n":LBL'
	yad_cmd += ' --field="Update $HOME/.config/openbox/autostart":CHK'
	return yad_cmd

Here is the execute code:

	yad_cmd = yad_dialog(monitorCount, thumbnailFile)
        retVal = subprocess.Popen(yad_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
        retList = parse_retVal(retVal)

Then here is the function which cleans up the return array into something I can use to create the feh command. Basically labels are returning empty strings, so I want to remove them from the list.

#function to split the yad return value into a useable list
def parse_retVal(retVal):
	retList = retVal.split("|")
	retList = [i for i in retList if i != '']
	retList = [i for i in retList if i != '\n']
	return retList

And a screenshot of it running, along with a unit test to show the resulting array:
['TRUE', 'TRUE', 'FALSE', 'FALSE']
2016-01-11-23-02-14_scrot.th.png

Offline

#3 2016-01-12 06:39:30

hhh
Meep!
Registered: 2015-09-17
Posts: 9,325
Website

Re: Yad height issues - any suggestions?

johnraff wrote:

http://s17.postimg.org/fwatxzb6z/Yad_radio_longmessage_fixed_120116_12_44_57.jpg

Of course, forcing the window height with --height would work, but only for a certain font-size and/or theme, message length and list length - it would have to be set by trial and error each time, and easily broken.

Has anybody heard of a way to make yad/zenity display a list without having to scroll?

If I could fix every computer problem by scrolling 2 lines down (1.666???)... I'd think I'd be OK with that.

Offline

#4 2016-01-12 06:41:17

hhh
Meep!
Registered: 2015-09-17
Posts: 9,325
Website

Re: Yad height issues - any suggestions?

^Crap, are you sure it's not just a bug in my themes?

tongue

Offline

#5 2016-01-12 15:18:25

damo
....moderator....
Registered: 2015-08-20
Posts: 5,837

Re: Yad height issues - any suggestions?

hhh wrote:

^Crap, are you sure it's not just a bug in my themes?

tongue

Same thing happens with Adwaita.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#6 2016-01-12 16:52:17

tknomanzr
BL Die Hard
From: Around the Bend
Registered: 2015-09-29
Posts: 1,029

Re: Yad height issues - any suggestions?

I should add that I found a bit of additional odd behavior with checkboxes in a form. In order to convince yad to set a default checkbox as TRUE(checked) I have to add an additional true for each field preceding the checkbox field that I want checked by default. So my code in the logic that outputs a checkbox for each connected monitor changes to this:

 # Output a checkbox for each connected monitor
     for i in range(0, int(monitorCount)):
        yad_cmd += ' --field="Monitor '
	yad_cmd += str(i)
	yad_cmd += ':CHK'
	yad_cmd += '"'
	if i == 0:
		yad_cmd += ' TRUE TRUE'

I believe this is a side-effect of every field in a form ending up in a list, which I subsequently clean up because I am only interested in the output of the checkboxes. The above code is a simple workaround, because fortunately, the first checbox is a reasonable default. If it were not a reasonable default, however, I would need to either rearrange the list of checkbox or introduce a counting variable that would allow me access to the item in the uncleaned list so that I could add the necessary additional TRUE|FALSE directives that ensure the proper checkbox ends up checked.

EDIT:
Here is an issue in yad's issue tracker that explains it. Basically if you want to specify a default option in a form, you should do so for every widget in the form. However, it is not necessary to tack them all onto the end of the yad command. They can be programmatically added per widget. I can safely say that failing to add defaults to all widgets when you need one specified can lead to some very odd output.

https://code.google.com/p/yad/issues/detail?id=121

Last edited by tknomanzr (2016-01-12 17:13:42)

Offline

#7 2016-01-15 06:31:29

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,567
Website

Re: Yad height issues - any suggestions?

hhh wrote:

If I could fix every computer problem by scrolling 2 lines down (1.666???)... I'd think I'd be OK with that.

Well it's more like 5 lines (options 0 10 20 30 40 50 60) and while it's not broken or anything, I'd have tought yad should know how to make a window big enough to hold the whole list without scrolling - or with scrolling if the command specifies a particular window size.

A pity you can't specify height in em like css - that would get round the font-size thing.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Online

Board footer

Powered by FluxBB