--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProjectFlask/ServerStartOptionsDialog.py Sat Nov 14 19:56:06 2020 +0100 @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module implementing a dialog to enter parameters to start the server. +""" + +from PyQt5.QtWidgets import QDialog + +from .Ui_ServerStartOptionsDialog import Ui_ServerStartOptionsDialog + + +class ServerStartOptionsDialog(QDialog, Ui_ServerStartOptionsDialog): + """ + Class implementing a dialog to enter parameters to start the server. + """ + def __init__(self, options, parent=None): + """ + Constructor + + @param options dictionary containing the current server start options + @type dict + @param parent reference to the parent widget + @type QWidget + """ + super(ServerStartOptionsDialog, self).__init__(parent) + self.setupUi(self) + + self.developmentCheckBox.setChecked(options.get("development", False)) + self.hostEdit.setText(options.get("host", "")) + self.portSpinBox.setValue(int(options.get("port", "5000"))) + + msh = self.minimumSizeHint() + self.resize(max(self.width(), msh.width()), msh.height()) + + def getDataDict(self): + """ + Public method to get a dictionary containing the entered data. + + @return dictionary containing the entered data + @rtype dict + """ + options = {} + + options["development"] = self.developmentCheckBox.isChecked() + host = self.hostEdit.text() + if host: + options["host"] = host + port = self.portSpinBox.value() + if port != 5000: + options["port"] = str(port) + + return options