ProjectFlask/ServerStartOptionsDialog.py

Sat, 14 Nov 2020 19:56:06 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 14 Nov 2020 19:56:06 +0100
changeset 9
79094fb72c18
child 10
506c78268b18
permissions
-rw-r--r--

Continued implementing various flask actions.

# -*- 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

eric ide

mercurial