-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py
33 lines (27 loc) · 1.25 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
def save(widget, json_file):
d = {}
d['ipe_size'] = widget.ipe_size.currentText()
d['extend_length'] = widget.extend_length.value()
d['extend_3ipe_len_below'] = widget.extend_3ipe_len_below.value()
d['extend_plate_len_above'] = widget.extend_plate_len_above.value()
d['extend_plate_len_below'] = widget.extend_plate_len_below.value()
d['connection_ipe_length'] = widget.connection_ipe_length.value()
d['connection_ipe_above'] = widget.connection_ipe_above.value()
d['deltax'] = widget.deltax.value()
d['number'] = widget.number.value()
with open(json_file, 'w') as f:
json.dump(d, f)
def load(widget, json_file):
with open(json_file, 'r') as f:
d = json.load(f)
index = widget.ipe_size.findText(d['ipe_size'])
widget.ipe_size.setCurrentIndex(index)
widget.extend_length.setValue(d['extend_length'])
widget.extend_3ipe_len_below.setValue(d.get('extend_3ipe_len_below', .8))
widget.extend_plate_len_above.setValue(d.get('extend_plate_len_above', .8))
widget.extend_plate_len_below.setValue(d.get('extend_plate_len_below', .8))
widget.connection_ipe_length.setValue(d['connection_ipe_length'])
widget.connection_ipe_above.setValue(d['connection_ipe_above'])
widget.deltax.setValue(d['deltax'])
widget.number.setValue(d.get('number', 1))