From 90f3256999c0bb258a71e70e30ea3e2e52f7c262 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <Jacques.grelet@ird.fr>
Date: Thu, 25 Apr 2019 16:01:09 +0200
Subject: [PATCH] add combo default_value

---
 oceano.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/oceano.py b/oceano.py
index 4a843a5..95a53c1 100644
--- a/oceano.py
+++ b/oceano.py
@@ -18,6 +18,8 @@ ti = typeInstrument  # an alias
 filesBrowsePosition_row = 2
 filesBrowsePosition_column = 1
 
+# initialize filename use to save GUI configuration
+configfile = 'oceano.cfg'
 
 def processArgs():
     parser = argparse.ArgumentParser(
@@ -54,6 +56,12 @@ def processArgs():
 
 def defineGUI():
 
+    # check if GUI config file exist
+    if args.instrument != None:
+        instrument_default_value = args.instrument
+    else:
+        instrument_default_value = 'CTD'
+
     # get all devices
     devices = list(ti.keys())
 
@@ -75,7 +83,8 @@ def defineGUI():
                          enable_events=True),
                 sg.FilesBrowse(key='_HIDDEN_', initial_folder=None,                   # row 1, col 2
                                tooltip='Choose one or more files')],    
-               [sg.Combo(list(ti.keys()), enable_events=True, size=(8, 1),            # row 2
+               [sg.Combo(list(ti.keys()), enable_events = True, size=(8, 1),          # row 2
+                         default_value = instrument_default_value,                    
                          key='_COMBO_', tooltip='Select the instrument')],
                [sg.Frame(d, frameLayout[d], key='_FRAME_{:s}'.format(d) , visible=True)          # row 3
                 for d in devices],                                                    
@@ -86,7 +95,7 @@ def defineGUI():
     window = sg.Window('Oceano converter').Layout(layout)
     window.LoadFromDisk(configfile)
     window.Finalize
-    return window
+    return window 
 
 
 def updateFilesBrowseCombo(extentions, x, y):
@@ -146,9 +155,6 @@ if __name__ == "__main__":
     parser = processArgs()
     args = parser.parse_args()
 
-    # initialize filename use to save GUI configuration
-    configfile = 'oceano.cfg'
-
     # set looging mode if debug
     if args.debug:
         logging.basicConfig(
-- 
GitLab