ProjectFlask/ServerStartOptionsDialog.py

changeset 9
79094fb72c18
child 10
506c78268b18
equal deleted inserted replaced
8:cfbd3a2757fd 9:79094fb72c18
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter parameters to start the server.
8 """
9
10 from PyQt5.QtWidgets import QDialog
11
12 from .Ui_ServerStartOptionsDialog import Ui_ServerStartOptionsDialog
13
14
15 class ServerStartOptionsDialog(QDialog, Ui_ServerStartOptionsDialog):
16 """
17 Class implementing a dialog to enter parameters to start the server.
18 """
19 def __init__(self, options, parent=None):
20 """
21 Constructor
22
23 @param options dictionary containing the current server start options
24 @type dict
25 @param parent reference to the parent widget
26 @type QWidget
27 """
28 super(ServerStartOptionsDialog, self).__init__(parent)
29 self.setupUi(self)
30
31 self.developmentCheckBox.setChecked(options.get("development", False))
32 self.hostEdit.setText(options.get("host", ""))
33 self.portSpinBox.setValue(int(options.get("port", "5000")))
34
35 msh = self.minimumSizeHint()
36 self.resize(max(self.width(), msh.width()), msh.height())
37
38 def getDataDict(self):
39 """
40 Public method to get a dictionary containing the entered data.
41
42 @return dictionary containing the entered data
43 @rtype dict
44 """
45 options = {}
46
47 options["development"] = self.developmentCheckBox.isChecked()
48 host = self.hostEdit.text()
49 if host:
50 options["host"] = host
51 port = self.portSpinBox.value()
52 if port != 5000:
53 options["port"] = str(port)
54
55 return options

eric ide

mercurial