Page 1 of 1

Dialog save file

Posted: Monday 27th May 2019 8:04pm
by sadams54
I am stumped on what should be simple. I call the dialog to save a file but I want a default file name to save as in the dialog in case the person doesn't feel like typing in a filename an automatically generated one is available if they just hit ok. It should work similar to the inputbox command where you can have a default already for the user.
Anybody know how to make this happen?

Re: Dialog save file

Posted: Tuesday 28th May 2019 1:18am
by Cedron
If I am understanding you right, it is simple.

Have you tried setting "Dialog.Path" to the full file specification?

Yeah, "Path" in Gambas seems to refer to file/dir specifiers, not necessarily just directories.

Ced

Re: Dialog save file

Posted: Tuesday 28th May 2019 1:30pm
by cogier
I had a look at this but it seems that the Dialogue wont let you do this. However you can do it with a FileChooser. Have a look at the attached code.

Image
File_Save.tar.gz
(79.37 KiB) Downloaded 414 times

Re: Dialog save file

Posted: Tuesday 28th May 2019 2:14pm
by Cedron
I tested this before I replied.
Dialog.Path = User.Home &/ "Pictures/test.jpg"
This left "test.jpg" in the filename slot.

Am I misunderstanding something?

Re: Dialog save file

Posted: Tuesday 28th May 2019 2:55pm
by cogier
Further investigation discovered that the Dialog.Path works as required using gb.qt.gui but not if using gb.gui in a GTK desktop (Linux Mint 19.1 Cinnamon).

Now why is that?

Re: Dialog save file

Posted: Tuesday 28th May 2019 3:20pm
by Cedron
Nice sleuthing.

I don't know, maybe should be reported as a bug. I do know from the mailing list that qt is less "troublesome" for lack of a better word, perhaps more supported/preferred, than gtk. I do all my desktop projects as qt.

Re: Dialog save file

Posted: Wednesday 5th June 2019 7:38pm
by sadams54
nobody is missing anything. I did it with the dialog.path but it still does not work. I am using gtk which I have found to be the least troublesome.
The idea behind this is that I want to save a file from a program. I want to provide a default name for the user that includes date information in the file name, but still want the user to be able to name it as they wish and just leave a suggestion. I have discounted the idea of extra questions for default names. The user may not be all that smart and I prefer to keep it as simple as I can.

Re: Dialog save file

Posted: Thursday 6th June 2019 1:11pm
by cogier
As you want to use 'gtk' the only way I could find to do what you want is to use a FileChooser. Have a look at the attached code which is similar to the code I posted above. I hope it helps.
SaveFile.tar.gz
(13.28 KiB) Downloaded 406 times