sliders ignore min value in linux? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

sliders ignore min value in linux?

Post by ouch67 »

in windows when you set the minimum value when created the slider defaults to whatever that minimum value is.

in linux (ubuntu) it appears to be ignored and is always set to 0.

running 2.8 of wxwidgets.
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

Post by ouch67 »

ok folks, I can't even force "setvalue" a slider. Nothing seems to happen if I manually set the range either.

So sliders are completely broken in linux then?

Can anyone else confirm this?
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

Hi,

It works for me, on wxGTK-2.8.8 (which is probably what you're using).

Try the wxSlider in the 'widgets' sample, where you can alter the min/max values successfully. (Click on the slider afterwards to refresh it.)

Regards,

David
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

Post by ouch67 »

Sorry for not getting back to you I've been busy...

anyway, I tried the demo and it looks like the slider doesn't auto update when the min-max values are changed like it does in windows.

And this crashes my app because the slider position is critical.

To test, start up the demo, go to the slider tab.

change the min-max value to be 1-10, move the slider to 5.

change the min-max to be 10-20

the sliders position changes (incorrectly I might add) but the value does not.

The demo also does not let you set the min-max values to be the same. I'm not sure if that's intentional or not under linux. But I do know you can do do it in your own apps within windows without errors.

is there a way to force an slider update through code?
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

To test, start up the demo
Do you mean the 'widgets' sample?
change the min-max value to be 1-10, move the slider to 5.
change the min-max to be 10-20
Doing exactly that in the wxGTK-2.8.8 'widgets' sample works just as it should: the control's value changes to 10, and the slider position changes correctly. It doesn't crash.

It won't let you set min==max, but then it wouldn't be much use as a slider in those circumstances... ;)

Again, what are you using exactly? Which wx version, which toolkit, which sample/demo?
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

Post by ouch67 »

I'm using ubuntu hardy (everything updated according to the updater) with these libraries:

libwxbase2.8-0
libwxbase2.8-dev
libwxgtk2.8-0
libwxgtk2.8-dev
wx2.8-doc
wx2.8-headers
wx2.8-i18n

using codeblocks build 5382
with the wxsmith wxWidgets form builder.

the demo app I'm talking about is the one found here:

http://www.wxwidgets.org/downloads/demos.htm

the GTK+ version of the one called "Widgets Demo"

it doesn't crash when you change it, but the value stays at 5 for me.

and I need the min-max set the same because the slider represents the number of database entries. If there is only one entry and you are able to move it to another position the app crashes trying to load a second entry that is not there.

thanks for your replies btw.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

the demo app I'm talking about is the one found here:
Ah, that's why you call it 'demo' ;) .

I don't think they're in any hardy package, but if you download the wxGTK-2.8.8 tarball from http://biolpc22.york.ac.uk/pub/2.8.8/wxGTK-2.8.8.tar.gz you'll find the 'widgets' sample in the 'samples' dir. You'd probably have to run configure before you can build it; but you shouldn't need to build wxGTK too, as the samples should build against your current wx.

And you can compare its code with that of the 'demo' and see what the demo does wrong.
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

Post by ouch67 »

well that's the thing, My app and the demo both behave incorrectly.

and the demo does come with the code too. It does pretty much the same thing as mine.

to re-cap:

start up the demo, go to the slider tab.

change the min-max value to be 1-10, move the slider to 5.

change the min-max to be 10-20

the sliders position changes (incorrectly I might add) but the value does not and stays at 5.

If I click on the slider then it changes to 10.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

But this doesn't happen for me, in samples/widgets. So why not test it yourself and, if you agree, copy that code instead?
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

Post by ouch67 »

Yes, I dicided I'm going to have to break down and build wxWidgets from SVN.

I was going to eventually But I kept putting it off...

I'll see if I can build this thing in linux, I've already done it windows, but linux is whole different story as you know... ;)

I'll get back to you after I've done it and made it compile properly in codeblocks. (might take me a few days though)
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart »

ouch67 wrote:Yes, I dicided I'm going to have to break down and build wxWidgets from SVN.
You don't have to build it too, but it's not a bad idea. But why svn? You can download a stable tarball (2.8.8 to match what you've already got, or 2.8.9 which is the latest one).
I'll see if I can build this thing in linux, I've already done it windows, but linux is whole different story as you know... ;)
Yes: it's easier!

Especially as you've already got an installed version, I strongly suggest you make a 'local' build, by:
  • 1)Make a new directory in the source directory. If you're going to make a unicode debug build, you might choose to name it 'udb': mkdir udb
    2) cd udb
    3) ../configure --with-gtk --enable-unicode --enable-debug --prefix=$(pwd)
    (Note the 2 dots in front of /configure)
    4) Now make You don't need to 'make install'
Doing this keeps the new build separate from any others on the system. When you want to use it, just make sure that the new wx-config in 'udb' is the one used. You can do that easily in a terminal by first doing:
PATH=/path/to/udb:$PATH
or in an IDE, where you currently have wx-config, put /path/to/udb/wx-config
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

Post by ouch67 »

well the widget example is completely different from the widget demo...

anyway, yes it does work fine in that app. looking at the code it looks like they check values after altering the slider and if it's not correct then they force the values...

not the most efficient thing, but it works I guess.

The code for the demo app does not have these checks in place which is why it happens there.
ouch67
Earned some good credits
Earned some good credits
Posts: 135
Joined: Sun Mar 23, 2008 12:09 am

Post by ouch67 »

heh, compiling my code against the svn version fixed the problem.

apparently it was a bug after all and has been fixed.

thanks for your help though!

edit: damn it! they fixed it, but now they don't allow the min and max to be the same value!

So I'm effectively screwed over even more than before...

edit2: I've now replaced all my sliders with spinners. Would still like to use sliders though if the min and max can be set to the same value again in the future.
Post Reply