config.py 1.43 KB
Newer Older
Yan's avatar
Yan committed
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import QtPrintSupport


def settings():
    settings = QtCore.QSettings("Yansoft","Prasopes")
    return settings


def tmp_dial(tmp_text, config):
    filename = QtWidgets.QFileDialog.getExistingDirectory()
    if filename is not '':
        tmp_text.setText(filename)
        config.setValue("tmp_location", filename)



def dial(parent):
    """constructs a dialog window"""
    dialog = QtWidgets.QDialog(
        parent, windowTitle='Settings')
    dialog.resize(600,-1)

    config = settings()

    tmp_text = QtWidgets.QLineEdit(config.value("tmp_location"))
    tmp_text.editingFinished.connect(lambda: config.setValue(
        "tmp_location", tmp_text.text()))

    browse_button = QtWidgets.QPushButton("Browse..")
    browse_button.clicked.connect(lambda: tmp_dial(tmp_text, config))
    close_button = QtWidgets.QPushButton("Close")
    close_button.clicked.connect(dialog.close)

    layout = QtWidgets.QVBoxLayout(dialog)
    butt_layout = QtWidgets.QHBoxLayout()
    tmp_layout = QtWidgets.QHBoxLayout()

    tmp_layout.addWidget(QtWidgets.QLabel("Acquisition temp folder:"))
    tmp_layout.addWidget(tmp_text)
    tmp_layout.addWidget(browse_button)

    butt_layout.addWidget(close_button)
    butt_layout.addStretch(1)

    layout.addLayout(tmp_layout)
    layout.addStretch(1)
    layout.addLayout(butt_layout)

    dialog.show()