Skip to content
Snippets Groups Projects
Commit 8012959a authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

add layout for devices, in test

parent 2f6eb980
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,31 @@ L[:-1]
[1, 2, 3]
L[::-1]
[4, 3, 2, 1]
L.method() avec method = append, sort,index,reverse
L.method() avec method = append, sort,index,reverse, extend
We see that extend() is semantically clearer, and that it can run much faster than append(),
when you intend to append each element in an iterable to a list.
If you only have a single element (not in an iterable) to add to the list, use append.
The following two snippets are semantically equivalent:
for item in iterator:
a_list.append(item)
and
a_list.extend(iterator)
The latter may be faster as the loop is implemented in C.
List comprehensions:
------------------------------------------
new_list = [expression for_loop_one_or_more condtions]
numbers = [1, 2, 3, 4]
squares = [n**2 for n in numbers]
print(squares) # Output: [1, 4, 9, 16]
list_a = [1, 2, 3]
square_cube_list = [ [a**2, a**3] for a in list_a]
print(square_cube_list) # Output: [[1, 1], [4, 8], [9, 27]]
Tuples:
-------
......
......@@ -44,8 +44,22 @@ def processArgs():
def defineGUI():
# get all devices
devices = list(ti.keys())
# change look and feel color scheme
sg.ChangeLookAndFeel('SandyBeach')
frameLayout = {}
deviceLayout = []
# define a frame layout for each instrument (device)
for d in devices:
keys = cfg['split'][device.lower()].keys()
frameLayout[d] = [* [[sg.Checkbox(k, key=k,
tooltip='Select the extract the physical parameter {}'.format(k))] for k in keys]]
for d in devices:
deviceLayout.append(sg.Frame(d, frameLayout[d]))
# define GUI layout
layout = ([[sg.Text('File(s) to read and convert')],
......@@ -57,8 +71,7 @@ def defineGUI():
initial_folder='data/{}'.format(ti[device][0]))],
[sg.Combo(list(ti.keys()), enable_events=True, size=(8, 1),
key='_COMBO_', tooltip='Select the instrument')],
* [[sg.Checkbox(k, key=k,
tooltip='Select the extract the physical parameter {}'.format(k))] for k in keys],
[deviceLayout],
[sg.OK(), sg.CloseButton('Cancel')]])
# [sg.CloseButton('Run'), sg.CloseButton('Cancel')]])
......@@ -131,6 +144,7 @@ if __name__ == "__main__":
# read config Toml file and get the physical parameter list (Roscop code) for the specified instrument
cfg = toml.load(args.config)
# this the select device from command line !
device = str(args.instrument) # convert one element list to str
keys = cfg['split'][device.lower()].keys()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment