Dialog save file

Post Reply
sadams54
Posts: 21
Joined: Monday 09th July 2018 3:43am

Dialog save file

Post by sadams54 » Monday 27th May 2019 8:04pm

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?

User avatar
Cedron
Posts: 87
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Dialog save file

Post by Cedron » Tuesday 28th May 2019 1:18am

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
.... and carry a big stick!

User avatar
cogier
Site Admin
Posts: 282
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Dialog save file

Post by cogier » Tuesday 28th May 2019 1:30pm

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 9 times

User avatar
Cedron
Posts: 87
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Dialog save file

Post by Cedron » Tuesday 28th May 2019 2:14pm

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?
.... and carry a big stick!

User avatar
cogier
Site Admin
Posts: 282
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Dialog save file

Post by cogier » Tuesday 28th May 2019 2:55pm

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?

User avatar
Cedron
Posts: 87
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: Dialog save file

Post by Cedron » Tuesday 28th May 2019 3:20pm

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.
.... and carry a big stick!

sadams54
Posts: 21
Joined: Monday 09th July 2018 3:43am

Re: Dialog save file

Post by sadams54 » Wednesday 05th June 2019 7:38pm

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.

User avatar
cogier
Site Admin
Posts: 282
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Dialog save file

Post by cogier » Thursday 06th June 2019 1:11pm

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 7 times

Post Reply