AnsweredAssumed Answered

Any PyQt users out there?

Question asked by jborgion Champion on Jun 24, 2020
Latest reply on Jul 1, 2020 by danretired

I'm trying to figure out how to design and implement a GUI developed in PyQt5 and then execute a query against a SQL server data base.  I'd like to take a begin date value and an end date value from two Date Edit widgets and pass those two as variables for my sql query to use in a 'Where Between' statement.


I have the python/sql queries all taken care of, and I can run them easily, but this will be for non-python, non-database users.


I can create the ui just fine, and then convert the .ui file to a .py file, which when run produces a window with the two widgets:

The Begin date has a default value of 1/1/89 and the while the Date is 1/1/21.  Here is the part of the code that defines the window and widgets:


class Ui_Form(object):
    def setupUi(self, Form):
        self.dateEditStartDate.setDateTime(QtCore.QDateTime(QtCore.QDate(1989, 1, 1), QtCore.QTime(0, 0, 0)))
        self.dateEditStartDate.setMaximumDateTime(QtCore.QDateTime(QtCore.QDate(2021, 12, 31), QtCore.QTime(23, 59, 59)))
        self.dateEditStartDate.setMaximumDate(QtCore.QDate(2021, 12, 31))
        self.dateEditStartDate.setMinimumDate(QtCore.QDate(1989, 1, 1))
        self.dateEditStartDate.setDate(QtCore.QDate(1989, 1, 1))
        self.dateEditEndDate = QtWidgets.QDateEdit(Form)
        self.dateEditEndDate.setGeometry(QtCore.QRect(290, 100, 130, 25))
        self.dateEditEndDate.setMaximumDate(QtCore.QDate(2021, 1, 1))
        self.dateEditEndDate.setMinimumDate(QtCore.QDate(1989, 1, 1))
        self.dateEditEndDate.setDate(QtCore.QDate(2021, 1, 1))

Admittedly, I'm pretty green when it comes to using classes in python, but I think there is a way to get the values from the user input for each of the two dates, but I just don't know how to do that.  Obviously there will be a bit more to my GUI, so this is just the start.