Dialog save file

Post

Posted
Rating:
#1 (In Topic #278)
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 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?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
Cedron is in the usergroup ‘Regular’
 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!
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
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.

<IMG src="http://www.cogier.com/gambas/File_Save.png"> </IMG>

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
Cedron is in the usergroup ‘Regular’
I tested this before I replied.

Code (gambas)

  1. Dialog.Path = User.Home &/ "Pictures/test.jpg"
  2.  

This left "test.jpg" in the filename slot.

Am I misunderstanding something?

.... and carry a big stick!
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
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?
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
Cedron is in the usergroup ‘Regular’
 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!
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Enthusiast
sadams54 is in the usergroup ‘Enthusiast’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
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.

Attachment
Online now: No Back to the top
1 guest and 0 members have just viewed this.