GetPath() function no working in Ubuntu 18, wxWidget 3.0

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
omahdezavalos
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Jan 07, 2019 9:40 pm

GetPath() function no working in Ubuntu 18, wxWidget 3.0

Post by omahdezavalos » Sun Jan 20, 2019 6:10 pm

I have this code from a tutorial of a6mg
PART 1: C++ GUI - Drawing, Copying in the clipboard and Saving image with wxWidgets and CodeBlocks
https://www.youtube.com/watch?v=42jJDAfFVfI
and the original code is at https://drive.google.com/file/d/0B1Jtvy ... djS3c/view

My code is running but not loading the file, nor displaying either.... researching into the matter and found something about GetPath() no getting the path correctly, in a Linux sys.

Code: Select all

void wxWidget_2_utubeFrame::OnLoadClick(wxCommandEvent& event)
{
    // //manually added
    int dlg=FileDialog1->ShowModal();                        //manually added
        if(dlg==wxID_OK)                                     //manually added
        {
            my_bitmap.LoadFile(FileDialog1->GetPath(),wxBITMAP_TYPE_ANY);    //manually added
            my_wxclientdc->DrawBitmap(my_bitmap,0,0,false);                 //manually added
            //os.path.dirname(file_dialog.GetPath()) this was a solution recommended and did not work.
        }
}
thanks getting the time and know how in this.... :?
Last edited by omahdezavalos on Sun Jan 20, 2019 9:12 pm, edited 1 time in total.

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

Re: GetPath() function no working in Ubuntu 18, wxWidget 3.0

Post by DavidHart » Sun Jan 20, 2019 6:22 pm

Hi,

1) I've moved your thread to the 'Platform Related Issues' sub-forum as you said it occurs "in a Linux sys". Do you have it working correctly on other platforms?

2) With this sort of issue, I strongly suggest that, instead of online references, you provide a patch to one of the wxWidgets samples that makes it demonstrate the issue. First, that will greatly increase the chance of someone testing your problem and potentially supplying a fix (or at least agreeing that you've found a bug and pointing to trac as the place to report it); and second, it's surprising how often the process of minimising your code to create the patch results in you yourself finding the cause of the issue.

Regards,

David

PB
Part Of The Furniture
Part Of The Furniture
Posts: 1834
Joined: Sun Jan 03, 2010 5:45 pm

Re: GetPath() function no working in Ubuntu 18, wxWidget 3.0

Post by PB » Sun Jan 20, 2019 6:52 pm

In addition to what David said:
What does the string returned by GetPath() contain?
Can you reproduce the issue with bundled dialogs sample?
Have you tried the last release in the 3.0 branch, i.e . 3.04?

TBH, the code fragment posted looks a bit suspect to me. Modal dialogs such as wxFileDialog are usually created and destroyed locally on the stack instead of being kept alive on a larger scope. You should also always check the result of methods such as wxBitmap::LoadFile(). Additionally, drawing someting outside of the paint event handler can lead to unexpected results, such as the window content being drawn over in the paint event...

omahdezavalos
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Jan 07, 2019 9:40 pm

Re: GetPath() function no working in Ubuntu 18, wxWidget 3.0

Post by omahdezavalos » Sun Jan 20, 2019 8:26 pm

DavidHart wrote:Hi,
David the code link is listed in line 3 of my comment, there are the complete project file and code.

omahdezavalos
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Jan 07, 2019 9:40 pm

Re: GetPath() function no working in Ubuntu 18, wxWidget 3.0

Post by omahdezavalos » Sun Jan 20, 2019 8:33 pm

PB wrote:In addition to what David said:
No I have no the skill in order to do that, I just get, to a page in the google search, that said, this function and GetDirectory(), weren't working in Fedora and Gnome, with the culprit, in some kind of gtk version, a really deep explanation to advanced for me, to understand or follow.

omahdezavalos
In need of some credit
In need of some credit
Posts: 7
Joined: Mon Jan 07, 2019 9:40 pm

Re: GetPath() function no working in Ubuntu 18, wxWidget 3.0

Post by omahdezavalos » Sun Jan 20, 2019 9:08 pm

Don't have any idea what are you saying bit suspect to me in the comments, and yes I just check and I'm running 3.04

Post Reply