wx-3.3.0 - Ubuntu 24.04.2 - wxFilePickerCtrl

63 views
Skip to first unread message

Black Jack

unread,
Jun 22, 2025, 2:40:56 PMJun 22
to wx-u...@googlegroups.com
Hi all.
I built 3.3.0 today, and found error or am I wrong....

wxFilePickerCtrl  returns empty file path. 
Both wxFileName wxFilePickerCtrl::GetFileName()
and wxString wxFilePickerCtrl::GetPath()

Here is minimal demo-app code to reproduce it.
//-------------------------------------------
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/filepicker.h>
#include <wx/filename.h>
#include <wx/textctrl.h>

class MyFrame : public wxFrame
{
    wxFilePickerCtrl* m_filePicker;
    wxTextCtrl* m_textCtrl1;
    wxTextCtrl* m_textCtrl2;
    wxTextCtrl* m_textCtrl3;
    wxTextCtrl* m_textCtrl4;

public:
    MyFrame(wxWindow *parent, int id = wxID_ANY, wxString title = wxT("wx330 FilePicker Error Demo")) : wxFrame(parent, id, title)
    {
        m_filePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT("Select a file"), wxT("*.*"), wxPoint(0,0), wxSize( 200,30 ), wxFLP_OPEN );

        m_textCtrl1 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxPoint(0, 50), wxSize(100, 30) );
        m_textCtrl2 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxPoint(0, 90), wxSize(100, 30) );
        m_textCtrl3 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxPoint(0, 130), wxSize(100, 30) );
        m_textCtrl4 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxPoint(0, 170), wxSize(100, 30) );

        m_filePicker->Bind( wxEVT_COMMAND_FILEPICKER_CHANGED, &MyFrame::OnFilePickUpChanged, this );
    }

    void OnFilePickUpChanged( wxFileDirPickerEvent& event )
    {
        wxFileName fname = m_filePicker->GetFileName();

        wxString longPath = fname.GetLongPath();
        wxString fullName = fname.GetFullName();
        wxString fnamePath = fname.GetPath();
        wxString pickerPath = m_filePicker->GetPath();

        m_textCtrl1->AppendText(longPath);
        m_textCtrl2->AppendText(fullName);
        m_textCtrl3->AppendText(fnamePath);
        m_textCtrl4->AppendText(pickerPath);
    }

    ~MyFrame(){}
};

class MyApp : public wxApp
{
public:
    virtual bool OnInit()
    {
        MyFrame* frame = new MyFrame(0L);
        frame->Show(true);
        return true;
    }
};

wxIMPLEMENT_APP(MyApp);
//------------------------------------------------------------

Am I doing something wrong or is this really an error?

Vadim Zeitlin

unread,
Jun 22, 2025, 3:09:23 PMJun 22
to wx-u...@googlegroups.com
On Sun, 22 Jun 2025 21:40:38 +0300 Black Jack wrote:

BJ> Hi all.
BJ> I built 3.3.0 today, and found error or am I wrong....
BJ>
BJ> wxFilePickerCtrl returns empty file path.
BJ> Both wxFileName wxFilePickerCtrl::GetFileName()
BJ> and wxString wxFilePickerCtrl::GetPath()

Yes, unfortunately there is indeed a problem with them, as can be seen on
the "picker" page of the widgets samples. This was possibly introduced by
071b4dd0f1 (Use GtkFileChooserNative for wxFileDialog/wxDirDialog when
possible, 2025-02-09), but I don't see what is wrong immediately, we're
somehow using the wrong widget for getting the path, but I am not sure how
this was actually intended to work.

Please open an issue for it, I'll try to look at it later if nobody else
does.

Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
https://www.tt-solutions.com/

Vadim Zeitlin

unread,
Jul 2, 2025, 7:11:21 PMJul 2
to wx-u...@googlegroups.com
On Sun, 22 Jun 2025 21:40:38 +0300 Black Jack wrote:

BJ> Hi all.
BJ> I built 3.3.0 today, and found error or am I wrong....
BJ>
BJ> wxFilePickerCtrl returns empty file path.
BJ> Both wxFileName wxFilePickerCtrl::GetFileName()
BJ> and wxString wxFilePickerCtrl::GetPath()

I've created https://github.com/wxWidgets/wxWidgets/pull/25591 which
should fix this, please test it if you can.

Black Jack

unread,
Jul 4, 2025, 6:13:21 AMJul 4
to wx-users


>>I've created https://github.com/wxWidgets/wxWidgets/pull/25591 which
>>should fix this, please test it if you can.

Thanks Vadim, I will test it

четверг, 3 июля 2025 г. в 02:11:21 UTC+3, Vadim Zeitlin:
Reply all
Reply to author
Forward
0 new messages