We will see in this practical tutorial, how to create a mini PyQt5 application With Qt Designer which asks the user to enter an integer N and return its double 2 * N by clicking on the Validate button:

 

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_Form(object):

def action(self):
N = int(self.lineEdit.text())
N2 = 2*N
self.lineEdit_2.setText(str(N2))

def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(20, 30, 151, 31))
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setStyleSheet("color: rgb(0, 0, 255);")
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(20, 80, 151, 31))
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setStyleSheet("color: rgb(0, 0, 255);")
self.label_2.setObjectName("label_2")
self.lineEdit = QtWidgets.QLineEdit(Form)
self.lineEdit.setGeometry(QtCore.QRect(170, 29, 191, 31))
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.lineEdit.setFont(font)
self.lineEdit.setStyleSheet("color: rgb(255, 0, 0);")
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(Form)
self.lineEdit_2.setGeometry(QtCore.QRect(170, 80, 191, 31))
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.lineEdit_2.setFont(font)
self.lineEdit_2.setStyleSheet("color: rgb(255, 0, 0);")
self.lineEdit_2.setObjectName("lineEdit_2")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.clicked.connect(self.action)
self.pushButton.setGeometry(QtCore.QRect(170, 132, 181, 31))
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.pushButton.setFont(font)
self.pushButton.setStyleSheet("background-color: rgb(255, 255, 0);")
self.pushButton.setObjectName("pushButton")

self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)

def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "Value Of N :"))
self.label_2.setText(_translate("Form", "Double 2*N :"))
self.pushButton.setText(_translate("Form", "Validate"))


if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
Younes Derfoufi
my-courses.net
3 thoughts on “Creation of a Mini Python Application with PyQt5 and Qt Designer”
  1. The platform has been operational since 2011 and is totally licensed under Curacao eGambling. In 2016, he notified the city’s Conflicts of Interest Board that he received between $5,000 and $47,999 gambling. The New York Daily News reported his annual monetary disclosure form also revealed a collection of $50,000 in 1xbet winnings from the state lottery last yr. Local racinos rake in document profits, see greenback signs forward in sports bettingThe fee also issued sports betting accredited Wednesday to the Hardrock Casino in Cincinnati and the Pro Football Hall of Fame’s Hall of Fame Village in Canton.

  2. Hi, Eric here with a quick thought about your website my-courses.net…

    I’m on the internet a lot and I look at a lot of business websites.

    Like yours, many of them have great content.

    But all too often, they come up short when it comes to engaging and connecting with anyone who visits.

    I get it – it’s hard. Studies show 7 out of 10 people who land on a site, abandon it in moments without leaving even a trace. You got the eyeball, but nothing else.

    Here’s a solution for you…

    Talk With Web Visitor is a software widget that’s works on your site, ready to capture any visitor’s Name, Email address and Phone Number. You’ll know immediately they’re interested and you can call them directly to talk with them literally while they’re still on the web looking at your site.

    CLICK HERE http://jumboleadmagnet.com to try out a Live Demo with Talk With Web Visitor now to see exactly how it works.

    It could be huge for your business – and because you’ve got that phone number, with our new SMS Text With Lead feature, you can automatically start a text (SMS) conversation – immediately… and contacting someone in that 5 minute window is 100 times more powerful than reaching out 30 minutes or more later.

    Plus, with text messaging you can follow up later with new offers, content links, even just follow up notes to keep the conversation going.

    Everything I’ve just described is extremely simple to implement, cost-effective, and profitable.

    CLICK HERE http://jumboleadmagnet.com to discover what Talk With Web Visitor can do for your business.

    You could be converting up to 100X more eyeballs into leads today!

    Eric
    PS: Talk With Web Visitor offers a FREE 14 days trial – and it even includes International Long Distance Calling.
    You have customers waiting to talk with you right now… don’t keep them waiting.
    CLICK HERE http://jumboleadmagnet.com to try Talk With Web Visitor now.

    If you’d like to unsubscribe click here http://jumboleadmagnet.com/unsubscribe.aspx?d=my-courses.net

  3. Hi, my name is Eric and I’m betting you’d like your website my-courses.net to generate more leads.

    Here’s how:
    Talk With Web Visitor is a software widget that’s works on your site, ready to capture any visitor’s Name, Email address and Phone Number. It signals you as soon as they say they’re interested – so that you can talk to that lead while they’re still there at my-courses.net.

    Talk With Web Visitor – CLICK HERE https://boostleadgeneration.com for a live demo now.

    And now that you’ve got their phone number, our new SMS Text With Lead feature enables you to start a text (SMS) conversation – answer questions, provide more info, and close a deal that way.

    If they don’t take you up on your offer then, just follow up with text messages for new offers, content links, even just “how you doing?” notes to build a relationship.

    CLICK HERE https://boostleadgeneration.com to discover what Talk With Web Visitor can do for your business.

    The difference between contacting someone within 5 minutes versus a half-hour means you could be converting up to 100X more leads today!

    Try Talk With Web Visitor and get more leads now.

    Eric
    PS: The studies show 7 out of 10 visitors don’t hang around – you can’t afford to lose them!
    Talk With Web Visitor offers a FREE 14 days trial – and it even includes International Long Distance Calling.
    You have customers waiting to talk with you right now… don’t keep them waiting.
    CLICK HERE https://boostleadgeneration.com to try Talk With Web Visitor now.

    If you’d like to unsubscribe click here http://boostleadgeneration.com/unsubscribe.aspx?d=my-courses.net

Leave a Reply