Novice needs help with wxFileDialog in X11

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ndiamond
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Feb 16, 2018 7:37 am

Novice needs help with wxFileDialog in X11

Post by ndiamond »

I am new to wxWidgets.

wxWidgets 3.0.3 with native X11 bindings is installed. wxFileDialog displays empty panels. Screenshot:
http://www.geocities.jp/hitotsubishi/sc ... roblem.png
Image

What am I doing wrong?

m_fileDialog = new wxFileDialog(this, _("Select Source File"), _("/"), wxEmptyString, _("*|*"), (wxFD_OPEN | wxFD_FILE_MUST_EXIST));
if (m_fileDialog->ShowModal() == wxID_CANCEL) {
//
};
m_fileDialog->Destroy();
delete m_fileDialog;
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Novice needs help with wxFileDialog in X11

Post by doublemax »

First of all, the X11 port of wxWidgets is hardly used any more and is not so well maintained as the ports for the three major platforms. So you should only use it if GTK is not available on the target machine.

Can you build and run any of the wxWidgets samples that use a wxFileDialog, e.g. the "dialogs" sample?
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Novice needs help with wxFileDialog in X11

Post by ONEEYEMAN »

Hi,
Judging from the screenshot you are not running plain X server, but rather (I think) KDE. Which means that the toolkits like gtk/qt are available.
So, what you should do is to install the gtk+ from the repository (either gtk+2 or gtk+3 - whatever is available), install gtk development package (in order to have the headers installed) and then recompile wxWidgets with the following options:

Code: Select all

../configure --enable-debug --enable-debug_gdb --with--gtk
Thank you.
ndiamond
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Feb 16, 2018 7:37 am

Re: Novice needs help with wxFileDialog in X11

Post by ndiamond »

One reason for not building against gtk is that the executable has to run on machines that might not have gtk. The licence for gtk is not as free as for wxwidgets. In fact I did install gtk development tools but after seeing gtk's licence I configured wxWidgets for plain X11.

However, yes I could build the samples. Some work better than others. Fairly recently someone patched the widgets sample to add a setting to the slider constructor so the slider doesn't crash, and I made a similar patch to the slider constructor in the controls sample. I didn't see a sample filedialog.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Novice needs help with wxFileDialog in X11

Post by ONEEYEMAN »

Hi,
The sample you need to build is called "dialogs".

But more general, if you decide to go with X11, you are on your own. This port is rarely receive any attention from the wx core team as nobody cares about it too much. It is in a buildable state and most samples can be build and some can be run. But the overall condition of the port is - it is very seriously outdated.

The only reason it is kept in the tree is for people who want to create a new port as a starting point.

So if you want to become an official maintainer of the X11 port - send an E-mail to wx-dev and ask for that possibility.

Also, keep in mind - we are not talking about GNOME here, just the GTK+. Which I believe can be installed even on Raspberry PI as well as other mini-computers.

Thank you.
ndiamond
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Feb 16, 2018 7:37 am

Re: Novice needs help with wxFileDialog in X11

Post by ndiamond »

I have no trouble believing that GTK+ will run on a Raspberry Pi, but the licence isn't as free as the wxWidgets licence.

[edit]
#if 0
I'll look at the dialogs sample.
#else
The dialogs sample crashes immediately.
X Error of failed request: BadWindow (invalid Window parameter)
If I could program raw X11 stuff, I might not have tried using wxWidgets.
#endif
ndiamond
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Feb 16, 2018 7:37 am

Re: Novice needs help with wxFileDialog in X11

Post by ndiamond »

Although the dialogs sample doesn't execute, I could understand part of its source code. There's an undocumented class wxGenericFileDialog which I could try using in my project,

[editing this reply too]
#if 0
and it works in raw X11. I'm not sure if I'm going to read internals to learn the difference between wxFileDialog and wxGenericFileDialog, but I'll use the one that works.
#else
and it worked twice in raw X11, but then it stopped working. After the first two times, wxGenericFileDialog stopped working and looks like wxFileDialog.
#endif
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Novice needs help with wxFileDialog in X11

Post by DavidHart »

Hi,
The dialogs sample crashes immediately.
Yes, I get that too in wxWidgets-3.1.1-rc. That sort of thing is one reason to avoid wxX11.

However the 'widgets' sample uses the similar wxFileCtrl successfully. You might like to substitute that.
In fact I did install gtk development tools but after seeing gtk's licence...
Out of interest, what problem do you have with its licence?
AFAIK the only significant difference is that you can't distribute non-GPL programs that statically-link to it. And that's not something you should want to do anyway: it's simpler and safer to link dynamically to the gtk+ libs that come with that distro/version. Even if you were allowed to link statically, you couldn't rely on any particular build being binary-compatible with other distros or versions.

Regards,

David
ndiamond
In need of some credit
In need of some credit
Posts: 7
Joined: Fri Feb 16, 2018 7:37 am

Re: Novice needs help with wxFileDialog in X11

Post by ndiamond »

I didn't realize that dynamic linking had a more permissive licence. I'm still not sure if we can assume all end users will have GTK+.
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Novice needs help with wxFileDialog in X11

Post by DavidHart »

I'm still not sure if we can assume all end users will have GTK+
I'm not aware of any current gui distro that doesn't provide gtk+; certainly all the common ones do.

Of course that doesn't guarantee that the particular user will have the libs actually installed, but that's why you distribute the app as a deb/rpm/whatever that depends on the correct gtk+ libs, rather than as a plain binary. Or I suppose nowadays, why you use a AppImage/Flatpak/Snap/...
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Novice needs help with wxFileDialog in X11

Post by ONEEYEMAN »

Hi,
And for the distro that do everything from sources you can write a simple script that will install all dependencies (like ebuild for Gentoo).

Thank you.
Post Reply