[chirp_devel] [PATCH] [ui] Default file name to include model and date. #3753
Tom Hayward
Wed Jun 15 17:18:46 PDT 2016
# HG changeset patch
# User Tom Hayward <tom at tomh.us>
# Date 1466036303 25200
# Wed Jun 15 17:18:23 2016 -0700
# Node ID 975df4b3f7b6d94280d7dc1800aab841772b80e6
# Parent cd4630e4151a435810e1eb3089f63927dfe2c626
[ui] Default file name to include model and date. #3753
During Save As, default the filename to {vendor}_{model}_{date}.img. The user
is free to edit the field to their liking before saving.
In case you don't like {vendor}_{model}_{date}.img, a new configuration
variable "default_filename" is provided. By setting this variable in your
config file, you can reorder or omit parts of the default format.
Example:
[global]
default_filename = {vendor}_{model}
This omits the date.
Example:
[global]
default_filename = Tom's_{vendor}_{model}_{date}
This begins each filename with my name.
diff -r cd4630e4151a -r 975df4b3f7b6 chirp/ui/mainapp.py
--- a/chirp/ui/mainapp.py Tue Jun 14 12:05:41 2016 -0400
+++ b/chirp/ui/mainapp.py Wed Jun 15 17:18:23 2016 -0700
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from datetime import datetime
import os
import tempfile
import urllib
@@ -433,6 +434,13 @@
vendor=eset.radio.VENDOR,
model=eset.radio.MODEL)
+ defname_format = CONF.get("default_filename", "global") or \
+ "{vendor}_{model}_{date}"
+ defname = defname_format.format(
+ vendor=eset.radio.VENDOR,
+ model=eset.radio.MODEL,
+ date=datetime.now().strftime('%Y%m%d'))
+
types = [(label + " (*.%s)" % eset.radio.FILE_EXTENSION,
eset.radio.FILE_EXTENSION)]
@@ -445,7 +453,8 @@
types += [(_("VX5 Commander") + " (*.vx5)", "vx5")]
while True:
- fname = platform.get_platform().gui_save_file(types=types)
+ fname = platform.get_platform().gui_save_file(default_name=defname,
+ types=types)
if not fname:
return
More information about the chirp_devel
mailing list