Certain methods not working under Linux Mint Topic is solved

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.
Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Certain methods not working under Linux Mint

Post by Ksawery » Thu Aug 22, 2019 8:42 am

Hello,

As mentioned in my previous post, I'm in the process of porting my wxWidgets application from Windows 10 to Linux Mint. I have the latest version of Linux and wxWidgets (installed from source), and I'm using the Code::Blocks IDE with all wxWidgets plugins installed. I setup a wxWidgets 3.0.x project when creating my application. Now i'm running into some problems with certain methods (which worked fine in Windows). For example:

- The SetBackgroundColour() method doesn't seem to work at all, when used with buttons and static texts.
- The wxALIGN_CENTRE_HORIZONTAL static text style option doesn't always work - the text remains left indented. Neither does wxALIGN_RIGHT.
- The position of some static texts doesn't change despite changing the wxPoint() parameter.

Here is an example of the static texts:

Code: Select all

m_static_txt_reference = new wxStaticText(this, wxID_ANY, _T("Pomiar Referencyjny"), wxPoint(580, 240), wxSize(120, 20), wxALIGN_CENTRE_HORIZONTAL);
m_static_txt_adc1 = new wxStaticText(this, wxID_ANY, "N/A", wxPoint(610, 270), wxSize(110, 20), wxALIGN_CENTRE_HORIZONTAL);
m_static_txt_adc2 = new wxStaticText(this, wxID_ANY, "N/A", wxPoint(270, 70), wxSize(110, 30), wxALIGN_CENTRE_HORIZONTAL);
m_static_txt_adc3 = new wxStaticText(this, wxID_ANY, "N/A", wxPoint(270, 155), wxSize(110, 30), wxALIGN_CENTRE_HORIZONTAL);
m_static_txt_adc4 = new wxStaticText(this, wxID_ANY, "N/A", wxPoint(270, 270), wxSize(110, 30), wxALIGN_CENTRE_HORIZONTAL);
Here is an example of setting the background colours of buttons:

Code: Select all

if (mbConfigurationCoil == 1)
{
	if ((m_btn_wsun->GetBackgroundColour()) != wxColour(0, 210, 0)) m_btn_wsun->SetBackgroundColour(wxColour(0, 210, 0));
	if ((m_btn_wysun->GetBackgroundColour()) != wxColour(210, 210, 210)) m_btn_wysun->SetBackgroundColour(wxColour(210, 210, 210));
}
else
{
	if ((m_btn_wysun->GetBackgroundColour()) != wxColour(0, 210, 0)) m_btn_wysun->SetBackgroundColour(wxColour(0, 210, 0));
	if ((m_btn_wsun->GetBackgroundColour()) != wxColour(210, 210, 210)) m_btn_wsun->SetBackgroundColour(wxColour(210, 210, 210));
}
I'm not sure what's causing these problems. I would really appreciate any help.

Regards,
Ksawery

DavidHart
Site Admin
Site Admin
Posts: 3881
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Certain methods not working under Linux Mint

Post by DavidHart » Thu Aug 22, 2019 12:43 pm

Hi,
- The SetBackgroundColour() method doesn't seem to work at all, when used with buttons and static texts
Some wx controls are implemented by wx itself; others use the native implementation. I don't know if the latter is true for wxButton and wxStaticText (your debugger might help, or you could examine the wx source) but, if it is, that would explain the difference in behaviour.
- The wxALIGN_CENTRE_HORIZONTAL static text style option doesn't always work - the text remains left indented.
"doesn't always". What do you have to change to make a working one fail, and a failing one work?
- The position of some static texts doesn't change despite changing the wxPoint() parameter.
Don't do that! The control is inside a sizer; the sizer sets its position. If you want it to be offset, either give that side a border or add wxSpacer(s) with the appropriate width/height.

Regards,

David

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: Certain methods not working under Linux Mint

Post by Ksawery » Thu Aug 22, 2019 1:03 pm

Thanks for your reply. What exactly do you mean by the following?
Don't do that! The control is inside a sizer; the sizer sets its position. If you want it to be offset, either give that side a border or add wxSpacer(s) with the appropriate width/height.
How do I add a wxSpacer with the appropriate width/height? Could you provide an example please?

wxALIGN_CENTRE_HORIZONTAL seems to work with multi-line text, but not single line text. I have the following situation, where I create several static texts and update them on each itteration of a helper thread:

Code: Select all

//Create static texts
m_static_txt_adc1 = new wxStaticText(this, wxID_ANY, "N/A", wxPoint(610, 270), wxSize(110, 30), wxALIGN_CENTRE_HORIZONTAL);
m_static_txt_adc2 = new wxStaticText(this, wxID_ANY, "N/A", wxPoint(270, 70), wxSize(110, 30), wxALIGN_CENTRE_HORIZONTAL);
m_static_txt_adc3 = new wxStaticText(this, wxID_ANY, "N/A", wxPoint(270, 155), wxSize(110, 30), wxALIGN_CENTRE_HORIZONTAL);
m_static_txt_adc4 = new wxStaticText(this, wxID_ANY, "N/A", wxPoint(270, 270), wxSize(110, 30), wxALIGN_CENTRE_HORIZONTAL);

...

//Update static texts
m_static_txt_adc1->SetLabel(std::to_string(mbADCRegisters[0]));
m_static_txt_adc2->SetLabel(std::to_string(mbADCRegisters[1]));
m_static_txt_adc3->SetLabel(std::to_string(mbADCRegisters[2]));
m_static_txt_adc4->SetLabel(std::to_string(mbADCRegisters[3]));

As a result, my GUI looks as follows:

Screenshot from 2019-08-22 15-14-54.png
Screenshot from 2019-08-22 15-14-54.png (43.52 KiB) Viewed 253 times

The displayed numbers aren't centred horizontally (although they were centered in Windows 10). So when the length of the numbers changes, they are no longer in the middle of the background image:

Screenshot from 2019-08-22 15-20-05.png
Screenshot from 2019-08-22 15-20-05.png (37.17 KiB) Viewed 251 times

The red text at the top right of the frame is centred horizontally using the same style option, and it seems to be displayed correctly:

Screenshot from 2019-08-22 15-23-15.png
Screenshot from 2019-08-22 15-23-15.png (43.2 KiB) Viewed 249 times

In the case of the following static texts, I need them to be right-indented:

Code: Select all

//Initialize diagnostic counters
m_static_txt_diag1 = new wxStaticText(this, wxID_ANY, std::to_string(this->mbDiagnosticsRegister[0]), wxPoint(370, 50), wxSize(50, 20), wxALIGN_RIGHT);
m_static_txt_diag2 = new wxStaticText(this, wxID_ANY, std::to_string(this->mbDiagnosticsRegister[1]), wxPoint(370, 100), wxSize(50, 20), wxALIGN_RIGHT);
m_static_txt_diag3 = new wxStaticText(this, wxID_ANY, std::to_string(this->mbDiagnosticsRegister[2]), wxPoint(370, 150), wxSize(50, 20), wxALIGN_RIGHT);
m_static_txt_diag4 = new wxStaticText(this, wxID_ANY, std::to_string(this->mbDiagnosticsRegister[3]), wxPoint(370, 200), wxSize(50, 20), wxALIGN_RIGHT);
m_static_txt_diag5 = new wxStaticText(this, wxID_ANY, std::to_string(this->mbDiagnosticsRegister[4]), wxPoint(370, 250), wxSize(50, 20), wxALIGN_RIGHT);
m_static_txt_diag6 = new wxStaticText(this, wxID_ANY, std::to_string(this->mbDiagnosticsRegister[5]), wxPoint(370, 300), wxSize(50, 20), wxALIGN_RIGHT);
m_static_txt_diag7 = new wxStaticText(this, wxID_ANY, std::to_string(this->mbDiagnosticsRegister[6]), wxPoint(370, 350), wxSize(50, 20), wxALIGN_RIGHT);
m_static_txt_diag8 = new wxStaticText(this, wxID_ANY, std::to_string(this->mbDiagnosticsRegister[7]), wxPoint(370, 400), wxSize(50, 20), wxALIGN_RIGHT);
However, they remain left-indented in the window.

I don't know whether I'm doing this correctly, I'm still pretty new to wxWidgets. It did work in Windows, though.

Regards,
Ksawery

DavidHart
Site Admin
Site Admin
Posts: 3881
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Certain methods not working under Linux Mint

Post by DavidHart » Thu Aug 22, 2019 3:13 pm

What exactly do you mean by the following?...
wxWidgets seldom uses absolute positioning. Instead it positions using wxSizer. See this (very old but still valid) sizer demo.

Try removing all the code that sets wxPoint() and wxSize() in your statictexts etc. You may find that some things suddenly work again.

Adding a spacer is easy (and I expect C::B will do it if you ask it nicely). You either use this wxSizer::Add overload or, for setting a proportion >0 so that it fills the available space, use wxSizer::AddStretchSpacer. You can see this in some of the samples (e.g. 'combo') that come with the wx source; or, if you installed the wx3.1-examples package, that are in /usr/share/doc/wx/wx3.1-examples/ (see its readme).

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3408
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Certain methods not working under Linux Mint

Post by ONEEYEMAN » Thu Aug 22, 2019 3:44 pm

Hi,
1. Try to build and run "widgets" sample. It has a menu for changing the colors of the widgets. Does it work for you?
What version of GTK+ did you compile against? What theme do you use?
2. Still in the widgets sample - does alignment work there? There are old ticket on trac which you can try to search about alignment on *nix/GTK. Try to see if its the case here.
3. Are you rendering everything yourself? It looks like you creating some text in the circles...

Thank you.

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: Certain methods not working under Linux Mint

Post by Ksawery » Fri Aug 23, 2019 11:11 am

Thank you for your replies.
wxWidgets seldom uses absolute positioning. Instead it positions using wxSizer. See this (very old but still valid) sizer demo.
I tried using the sizer according to the article, but no combination of options would make the static text center horizontally; despite removing all uses of wxPoint() and wxSize() in the static texts.
Try to build and run "widgets" sample. It has a menu for changing the colors of the widgets. Does it work for you?
I get errors when trying the run the widgets sample:

Code: Select all

[email protected]:~/sdks/wx312/gtk-build/samples/widgets# make
/home/ksawery/sdks/wxWidgets-3.1.2/gtk-build/bk-deps g++ -c -o widgets_activityindicator.o -D__WXGTK__      -I../../../samples/widgets -DWXUSINGDLL -I../../../samples/widgets/../../samples -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wno-deprecated-declarations  -D_FILE_OFFSET_BITS=64 -I/home/ksawery/sdks/wxWidgets-3.1.2/gtk-build/lib/wx/include/gtk3-unicode-3.1 -I../../../include -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -g -O0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -pthread -I/usr/include/gtk-3.0/unix-print -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fvisibility=hidden -fvisibility-inlines-hidden ../../../samples/widgets/activityindicator.cpp
make: /home/ksawery/sdks/wxWidgets-3.1.2/gtk-build/bk-deps: Command not found
Makefile:214: recipe for target 'widgets_activityindicator.o' failed
make: *** [widgets_activityindicator.o] Error 127
What version of GTK+ did you compile against?
I don't know what version of GTK+ I compiled against. Here is a list of packages related to gtk on my system:

Code: Select all

[email protected]:~/sdks/wx312/gtk-build/samples/widgets# apt list --installed "*gtk*"
Listing... Done
gir1.2-gtk-3.0/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
gir1.2-gtkclutter-1.0/bionic,now 1.8.4-3 amd64 [installed]
gir1.2-gtksource-3.0/bionic,now 3.24.7-1 amd64 [installed]
gir1.2-javascriptcoregtk-3.0/bionic,now 2.4.11-3ubuntu3 amd64 [installed]
gir1.2-javascriptcoregtk-4.0/bionic-updates,bionic-security,now 2.24.2-0ubuntu0.18.04.1 amd64 [installed]
gtk-update-icon-cache/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
gtk2-engines/bionic,now 1:2.20.2-5 amd64 [installed]
gtk2-engines-murrine/bionic,now 0.98.2-2ubuntu1 amd64 [installed]
gtk2-engines-pixbuf/bionic,now 2.24.32-1ubuntu1 amd64 [installed]
libcanberra-gtk3-0/bionic,now 0.30-5ubuntu1 amd64 [installed]
libcanberra-gtk3-module/bionic,now 0.30-5ubuntu1 amd64 [installed]
libchamplain-gtk-0.12-0/bionic,now 0.12.16-2 amd64 [installed]
libclutter-gtk-1.0-0/bionic,now 1.8.4-3 amd64 [installed]
libdbusmenu-gtk3-4/bionic-updates,now 16.04.1+18.04.20171206-0ubuntu2 amd64 [installed]
libdbusmenu-gtk4/bionic-updates,now 16.04.1+18.04.20171206-0ubuntu2 amd64 [installed]
libgtk-3-0/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
libgtk-3-bin/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
libgtk-3-common/bionic-updates,bionic-updates,now 3.22.30-1ubuntu4 all [installed]
libgtk-3-dev/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
libgtk2-perl/bionic,now 2:1.24992-1build1 amd64 [installed]
libgtk2.0-0/bionic,now 2.24.32-1ubuntu1 amd64 [installed]
libgtk2.0-bin/bionic,now 2.24.32-1ubuntu1 amd64 [installed]
libgtk2.0-cil/bionic,now 2.12.40-2 amd64 [installed]
libgtk2.0-common/bionic,bionic,now 2.24.32-1ubuntu1 all [installed]
libgtk3-perl/bionic,bionic,now 0.032-1 all [installed]
libgtkmm-2.4-1v5/bionic,now 1:2.24.5-2 amd64 [installed]
libgtkmm-3.0-1v5/bionic,now 3.22.2-2 amd64 [installed]
libgtksourceview-3.0-1/bionic,now 3.24.7-1 amd64 [installed]
libgtksourceview-3.0-common/bionic,bionic,now 3.24.7-1 all [installed]
libgtkspell0/bionic,now 2.0.16-1.2 amd64 [installed]
libjavascriptcoregtk-1.0-0/bionic,now 2.4.11-3ubuntu3 amd64 [installed,auto-removable]
libjavascriptcoregtk-3.0-0/bionic,now 2.4.11-3ubuntu3 amd64 [installed]
libjavascriptcoregtk-4.0-18/bionic-updates,bionic-security,now 2.24.2-0ubuntu0.18.04.1 amd64 [installed]
libreoffice-gtk3/bionic-updates,bionic-security,now 1:6.0.7-0ubuntu0.18.04.9 amd64 [installed]
libswt-cairo-gtk-3-jni/bionic,now 3.8.2-5 amd64 [installed,auto-removable]
libswt-gtk-3-java/bionic,now 3.8.2-5 amd64 [installed,auto-removable]
libswt-gtk-3-jni/bionic,now 3.8.2-5 amd64 [installed,auto-removable]
libswt-webkit-gtk-3-jni/bionic,now 3.8.2-5 amd64 [installed,auto-removable]
libwebkit2gtk-4.0-37/bionic-updates,bionic-security,now 2.24.2-0ubuntu0.18.04.1 amd64 [installed]
libwebkitgtk-1.0-0/bionic,now 2.4.11-3ubuntu3 amd64 [installed,auto-removable]
libwebkitgtk-3.0-0/bionic,now 2.4.11-3ubuntu3 amd64 [installed]
libwmf0.2-7-gtk/bionic,now 0.2.8.4-12 amd64 [installed]
libwxgtk-media3.0-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-media3.0-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-media3.0-gtk3-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-media3.0-gtk3-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-webview3.0-gtk3-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-webview3.0-gtk3-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk3.0-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed,automatic]
libwxgtk3.0-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk3.0-gtk3-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk3.0-gtk3-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
python-gtk2/bionic,now 2.24.0-5.1ubuntu2 amd64 [installed]
python3-aptdaemon.gtk3widgets/bionic-updates,bionic-updates,now 1.1.1+bzr982-0ubuntu19.1 all [installed]
qt5-gtk-platformtheme/bionic-updates,bionic-security,now 5.9.5+dfsg-0ubuntu2.1 amd64 [installed]
redshift-gtk/tessa,tessa,now 1.11-1ubuntu1mint1 all [installed]
transmission-gtk/bionic,now 2.92-3ubuntu2 amd64 [installed]
xdg-desktop-portal-gtk/bionic-updates,now 1.0.2-0ubuntu1.1 amd64 [installed]
xdg-user-dirs-gtk/bionic,now 0.10-2 amd64 [installed]
Here is a screenshot from the package manager:

Screenshot from 2019-08-23 13-14-52.png

Looks like I might have two versions installed? I'm not sure which was used to compile wxWidgets.

Are you rendering everything yourself? It looks like you creating some text in the circles...
The circles are just a background .png image.
What theme do you use?
I'm using the Linux Mint theme.

Regards,
Ksawery

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: Certain methods not working under Linux Mint

Post by Ksawery » Fri Aug 23, 2019 11:48 am

I found the following post, which seems to indicate that this is an issue with GTK2, but not GTK3. Perhaps I compiled wxWidgets using the wrong GTK version?

https://trac.wxwidgets.org/ticket/12539

Regards,
Ksawery

DavidHart
Site Admin
Site Admin
Posts: 3881
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Certain methods not working under Linux Mint

Post by DavidHart » Fri Aug 23, 2019 12:56 pm

I tried using the sizer according to the article, but no combination of options would make the static text center horizontally; despite removing all uses of wxPoint() and wxSize() in the static texts.
Assuming that sizer is a horizontal boxsizer:
sizer->AddStretchSpacer(); sizer->Add(new wxStaticText(this, wxID_ANY, "Foobar")); sizer->AddStretchSpacer();
I don't know what version of GTK+ I compiled against.
While your (any) wx program is running, do over it: Ctrl-Alt-Middleclick
I found the following post, which seems to indicate that this is an issue with GTK2, but not GTK3.
I'd completely forgotten about that thread. But you are using wx3.1.2, so it should be fixed.
Perhaps I compiled wxWidgets using the wrong GTK version?
There's nothing 'wrong' with GTK+2. Indeed it's less buggy.

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: Certain methods not working under Linux Mint

Post by Ksawery » Fri Aug 23, 2019 1:28 pm

While your (any) wx program is running, do over it: Ctrl-Alt-Middleclick
Looks like I was wrong regarding the version of wxWidgets that I am using:

Screenshot from 2019-08-23 14-58-01.png
Screenshot from 2019-08-23 14-58-01.png (19.71 KiB) Viewed 198 times

I'm also pretty new to Linux, and I (wrongly) assumed that Code::Blocks will automatically use the latest version of wxWidgets that I installed from source. Turns out that I will have to point to it manually. Currently, I have a wxWidgets 3.0.x project set up in Code::Blocks - how can I point it to the new newest version installed from source? I installed the library according to the instructions in:

https://wiki.wxwidgets.org/Compiling_an ... ng_started

I believe it's located in /home/username/sdks/wx312/gtk-build. Or should I create an empty project and link wxWidgets in the build options?

Regards,
Ksawery

DavidHart
Site Admin
Site Admin
Posts: 3881
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Certain methods not working under Linux Mint

Post by DavidHart » Fri Aug 23, 2019 1:46 pm

I installed the library according to the instructions in: https://wiki.wxwidgets.org/Compiling_an ... ng_started
If your configure line included: --prefix=`pwd` (or --prefix=/home/username/sdks/wx312/gtk-build) then (afaik; I don't use C::B) you need to change your Compiler and Linker settings from `wx-config...` to `/home/username/sdks/wx312/gtk-build/wx-config...`

If you didn't use -prefix=, and you did run sudo make install, then your wx3.1.2 build is probably inside /usr/local/. Have a look there, and set the project's Compiler and Linker settings to point to the correct path.

You can check by opening a terminal and doing:
/home/username/sdks/wx312/gtk-build/wx-config --version
or similar.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3408
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Certain methods not working under Linux Mint

Post by ONEEYEMAN » Fri Aug 23, 2019 2:27 pm

Hi,
Ksawery wrote:
Fri Aug 23, 2019 11:11 am
Thank you for your replies.
wxWidgets seldom uses absolute positioning. Instead it positions using wxSizer. See this (very old but still valid) sizer demo.
I tried using the sizer according to the article, but no combination of options would make the static text center horizontally; despite removing all uses of wxPoint() and wxSize() in the static texts.
This should be covered by David's post.
Ksawery wrote:
Fri Aug 23, 2019 11:11 am
Try to build and run "widgets" sample. It has a menu for changing the colors of the widgets. Does it work for you?
I get errors when trying the run the widgets sample:

Code: Select all

[email protected]:~/sdks/wx312/gtk-build/samples/widgets# make
/home/ksawery/sdks/wxWidgets-3.1.2/gtk-build/bk-deps g++ -c -o widgets_activityindicator.o -D__WXGTK__      -I../../../samples/widgets -DWXUSINGDLL -I../../../samples/widgets/../../samples -Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wno-deprecated-declarations  -D_FILE_OFFSET_BITS=64 -I/home/ksawery/sdks/wxWidgets-3.1.2/gtk-build/lib/wx/include/gtk3-unicode-3.1 -I../../../include -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -g -O0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -pthread -I/usr/include/gtk-3.0/unix-print -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -fvisibility=hidden -fvisibility-inlines-hidden ../../../samples/widgets/activityindicator.cpp
make: /home/ksawery/sdks/wxWidgets-3.1.2/gtk-build/bk-deps: Command not found
Makefile:214: recipe for target 'widgets_activityindicator.o' failed
make: *** [widgets_activityindicator.o] Error 127
That's weird.
You did compile the library without any issues, right?
Out of curiosity - what was the exact configure line you used?
Ksawery wrote:
Fri Aug 23, 2019 11:11 am
What version of GTK+ did you compile against?
I don't know what version of GTK+ I compiled against. Here is a list of packages related to gtk on my system:

Code: Select all

[email protected]:~/sdks/wx312/gtk-build/samples/widgets# apt list --installed "*gtk*"
Listing... Done
gir1.2-gtk-3.0/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
gir1.2-gtkclutter-1.0/bionic,now 1.8.4-3 amd64 [installed]
gir1.2-gtksource-3.0/bionic,now 3.24.7-1 amd64 [installed]
gir1.2-javascriptcoregtk-3.0/bionic,now 2.4.11-3ubuntu3 amd64 [installed]
gir1.2-javascriptcoregtk-4.0/bionic-updates,bionic-security,now 2.24.2-0ubuntu0.18.04.1 amd64 [installed]
gtk-update-icon-cache/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
gtk2-engines/bionic,now 1:2.20.2-5 amd64 [installed]
gtk2-engines-murrine/bionic,now 0.98.2-2ubuntu1 amd64 [installed]
gtk2-engines-pixbuf/bionic,now 2.24.32-1ubuntu1 amd64 [installed]
libcanberra-gtk3-0/bionic,now 0.30-5ubuntu1 amd64 [installed]
libcanberra-gtk3-module/bionic,now 0.30-5ubuntu1 amd64 [installed]
libchamplain-gtk-0.12-0/bionic,now 0.12.16-2 amd64 [installed]
libclutter-gtk-1.0-0/bionic,now 1.8.4-3 amd64 [installed]
libdbusmenu-gtk3-4/bionic-updates,now 16.04.1+18.04.20171206-0ubuntu2 amd64 [installed]
libdbusmenu-gtk4/bionic-updates,now 16.04.1+18.04.20171206-0ubuntu2 amd64 [installed]
libgtk-3-0/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
libgtk-3-bin/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
libgtk-3-common/bionic-updates,bionic-updates,now 3.22.30-1ubuntu4 all [installed]
libgtk-3-dev/bionic-updates,now 3.22.30-1ubuntu4 amd64 [installed]
libgtk2-perl/bionic,now 2:1.24992-1build1 amd64 [installed]
libgtk2.0-0/bionic,now 2.24.32-1ubuntu1 amd64 [installed]
libgtk2.0-bin/bionic,now 2.24.32-1ubuntu1 amd64 [installed]
libgtk2.0-cil/bionic,now 2.12.40-2 amd64 [installed]
libgtk2.0-common/bionic,bionic,now 2.24.32-1ubuntu1 all [installed]
libgtk3-perl/bionic,bionic,now 0.032-1 all [installed]
libgtkmm-2.4-1v5/bionic,now 1:2.24.5-2 amd64 [installed]
libgtkmm-3.0-1v5/bionic,now 3.22.2-2 amd64 [installed]
libgtksourceview-3.0-1/bionic,now 3.24.7-1 amd64 [installed]
libgtksourceview-3.0-common/bionic,bionic,now 3.24.7-1 all [installed]
libgtkspell0/bionic,now 2.0.16-1.2 amd64 [installed]
libjavascriptcoregtk-1.0-0/bionic,now 2.4.11-3ubuntu3 amd64 [installed,auto-removable]
libjavascriptcoregtk-3.0-0/bionic,now 2.4.11-3ubuntu3 amd64 [installed]
libjavascriptcoregtk-4.0-18/bionic-updates,bionic-security,now 2.24.2-0ubuntu0.18.04.1 amd64 [installed]
libreoffice-gtk3/bionic-updates,bionic-security,now 1:6.0.7-0ubuntu0.18.04.9 amd64 [installed]
libswt-cairo-gtk-3-jni/bionic,now 3.8.2-5 amd64 [installed,auto-removable]
libswt-gtk-3-java/bionic,now 3.8.2-5 amd64 [installed,auto-removable]
libswt-gtk-3-jni/bionic,now 3.8.2-5 amd64 [installed,auto-removable]
libswt-webkit-gtk-3-jni/bionic,now 3.8.2-5 amd64 [installed,auto-removable]
libwebkit2gtk-4.0-37/bionic-updates,bionic-security,now 2.24.2-0ubuntu0.18.04.1 amd64 [installed]
libwebkitgtk-1.0-0/bionic,now 2.4.11-3ubuntu3 amd64 [installed,auto-removable]
libwebkitgtk-3.0-0/bionic,now 2.4.11-3ubuntu3 amd64 [installed]
libwmf0.2-7-gtk/bionic,now 0.2.8.4-12 amd64 [installed]
libwxgtk-media3.0-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-media3.0-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-media3.0-gtk3-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-media3.0-gtk3-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-webview3.0-gtk3-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk-webview3.0-gtk3-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk3.0-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed,automatic]
libwxgtk3.0-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk3.0-gtk3-0v5/bionic,now 3.0.4+dfsg-3 amd64 [installed]
libwxgtk3.0-gtk3-dev/bionic,now 3.0.4+dfsg-3 amd64 [installed]
python-gtk2/bionic,now 2.24.0-5.1ubuntu2 amd64 [installed]
python3-aptdaemon.gtk3widgets/bionic-updates,bionic-updates,now 1.1.1+bzr982-0ubuntu19.1 all [installed]
qt5-gtk-platformtheme/bionic-updates,bionic-security,now 5.9.5+dfsg-0ubuntu2.1 amd64 [installed]
redshift-gtk/tessa,tessa,now 1.11-1ubuntu1mint1 all [installed]
transmission-gtk/bionic,now 2.92-3ubuntu2 amd64 [installed]
xdg-desktop-portal-gtk/bionic-updates,now 1.0.2-0ubuntu1.1 amd64 [installed]
xdg-user-dirs-gtk/bionic,now 0.10-2 amd64 [installed]
Here is a screenshot from the package manager:


Screenshot from 2019-08-23 13-14-52.png


Looks like I might have two versions installed? I'm not sure which was used to compile wxWidgets.

Are you rendering everything yourself? It looks like you creating some text in the circles...
The circles are just a background .png image.
What theme do you use?
I'm using the Linux Mint theme.

Regards,
Ksawery

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: Certain methods not working under Linux Mint

Post by Ksawery » Fri Aug 23, 2019 2:42 pm

Out of curiosity - what was the exact configure line you used?
I followed the instructions at: https://wiki.wxwidgets.org/Compiling_an ... ng_started. I used ../configure --enable-unicode --enable-debug with admin privileges and it installed without problems. I then tested it with the ./minimal sample, which worked well. But then for some reason I could no longer make and run the other samples. I'm not sure what broke in-between running the samples (whether I accidentally changed some configuration).
If your configure line included: --prefix=`pwd` (or --prefix=/home/username/sdks/wx312/gtk-build) then (afaik; I don't use C::B) you need to change your Compiler and Linker settings from `wx-config...` to `/home/username/sdks/wx312/gtk-build/wx-config...`

If you didn't use -prefix=, and you did run sudo make install, then your wx3.1.2 build is probably inside /usr/local/. Have a look there, and set the project's Compiler and Linker settings to point to the correct path.
I added the full path to wx-config to my compiler and linker flags (as described in https://wiki.wxwidgets.org/Compiling_an ... ng_started), however nothing changed. Code::Blocks is still running wxWidgets version 3.0.4. I'm not sure why it doesn't want to work and whether I should create a whole new project?

When I run wx-config --version in the terminal, I see the latest installation, which also uses the latest version of GTK.

Regards,
Ksawery

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3408
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Certain methods not working under Linux Mint

Post by ONEEYEMAN » Fri Aug 23, 2019 2:50 pm

Hi,
Ksawery wrote:
Fri Aug 23, 2019 2:42 pm
Out of curiosity - what was the exact configure line you used?
I followed the instructions at: https://wiki.wxwidgets.org/Compiling_an ... ng_started. I used ../configure --enable-unicode --enable-debug with admin privileges and it installed without problems. I then tested it with the ./minimal sample, which worked well. But then for some reason I could no longer make and run the other samples.
Are you saying you used:

Code: Select all

sudo ../configure --enable-debug --enable-unicode
?

This is wrong.
You should just do:

Code: Select all

../configure --enable-debug && make
There is no need for sudo to do both.

That might be an issue with your C::B build.

Thank you.

DavidHart
Site Admin
Site Admin
Posts: 3881
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Certain methods not working under Linux Mint

Post by DavidHart » Fri Aug 23, 2019 2:53 pm

I added the full path to wx-config to my compiler and linker flags
Yes, but which path. You have 2 wx installations. The wx3.1.2 one is probably in /usr/local/.

The reason why the sample doesn't build might be because it's a wx3.1.2 sample, configured for wx3.1.2, but you are trying to compile it with wx3.0.4. That's a guess, though.

One sensible option that you might wish to use is the one that I do all the time. In the wx3.1.2 source dir do:

Code: Select all

mkdir build-gtk2 && cd build-gtk2
../configure --enable-debug --with-gtk=2 --prefix=`pwd`
make -j
You don't need to 'make install', you just use the wx-config in build-gtk2/

You can then repeat the process, with build-gtk3 && ../configure --enable-debug --with-gtk=3 --prefix=`pwd`
and you then have two wx3.1.2 builds, for gtk2 & 3, that don't conflict with with each other or with the Mint wx3.0.4 package.

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: Certain methods not working under Linux Mint

Post by Ksawery » Mon Aug 26, 2019 11:39 am

Thank you again for your help. I reinstalled wxWidgets 3.1.2, making sure I'm installing it into the gtk-build directory. I then copied the wx-config commands from the terminal directly into the compiler and linker flags - instead of using 'wx-config --cxxflags', for example. The application now works correctly, under wxWidets 3.1.2 and GTK+ 3.22.30. Any issues I had with the GUI now went away - texts are centered correctly and I can change the background colour of certain items (but not all, since some are locked by the Linux theme).

Regards,
Ksawery

Post Reply