Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Python QT designer Updating Label and Other stuff in python code issue and error
Forum Updated to NodeBB v4.3 + New Features

Python QT designer Updating Label and Other stuff in python code issue and error

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    scientist1995
    wrote on 17 Feb 2019, 04:04 last edited by
    #1

    hello everyone i am a user interface that is designed in QT designer and have converted the.UI File into python file i need help and if anyone can assist me that would be really great. what i am trying to do is when i click the button i want to update the label similarly when i click button i want the slider value to be displayed on LCD i have already written the function inside which i am printing value of slide now i just need to display when i press button i went through lot of post on stack overflow and documentation i know label can be updated by using commands
    self.l_username.setText("hello world")

    since i am new i don't know i tried all solutions and now looking for someone who can assist me

    the code is attached below

    //# -*- coding: utf-8 -*-
    
    # Form implementation generated from reading ui file 'TEST.ui'
    #
    # Created by: PyQt5 UI code generator 5.12
    #
    # WARNING! All changes made in this file will be lost!
    
    from PyQt5 import QtCore, QtGui, QtWidgets
    
    
    class Ui_Form(object):
    
        def setupUi(self, Form):
    
            Form.setObjectName("Form")
            Form.resize(549, 429)
            self.btn_submit = QtWidgets.QPushButton(Form)
            self.btn_submit.setGeometry(QtCore.QRect(150, 170, 113, 32))
            self.btn_submit.setObjectName("btn_submit")
    
            self.textEdit = QtWidgets.QTextEdit(Form)
            self.textEdit.setGeometry(QtCore.QRect(20, 10, 481, 31))
            self.textEdit.setObjectName("textEdit")
    
            self.l_username = QtWidgets.QLabel(Form)
            self.l_username.setGeometry(QtCore.QRect(50, 80, 60, 16))
            self.l_username.setObjectName("l_username")
    
            self.l_password = QtWidgets.QLabel(Form)
            self.l_password.setGeometry(QtCore.QRect(50, 120, 60, 16))
            self.l_password.setObjectName("l_password")
    
            self.txt_username = QtWidgets.QLineEdit(Form)
            self.txt_username.setGeometry(QtCore.QRect(150, 80, 251, 21))
            self.txt_username.setObjectName("txt_username")
    
            self.txt_password = QtWidgets.QLineEdit(Form)
            self.txt_password.setGeometry(QtCore.QRect(150, 120, 251, 21))
            self.txt_password.setObjectName("txt_password")
    
            self.radioButton = QtWidgets.QRadioButton(Form)
            self.radioButton.setGeometry(QtCore.QRect(270, 170, 151, 20))
            self.radioButton.setObjectName("radioButton")
    
            self.btn_newuser = QtWidgets.QPushButton(Form)
            self.btn_newuser.setGeometry(QtCore.QRect(150, 200, 113, 32))
            self.btn_newuser.setObjectName("btn_newuser")
            self.time_value = QtWidgets.QTimeEdit(Form)
            self.time_value.setGeometry(QtCore.QRect(30, 260, 118, 24))
            self.time_value.setObjectName("time_value")
            self.date_value = QtWidgets.QDateEdit(Form)
            self.date_value.setGeometry(QtCore.QRect(170, 260, 110, 24))
            self.date_value.setObjectName("date_value")
    
            self.slider_x = QtWidgets.QSlider(Form)
            self.slider_x.setGeometry(QtCore.QRect(160, 330, 160, 22))
            self.slider_x.setOrientation(QtCore.Qt.Horizontal)
            self.slider_x.setObjectName("slider_x")
    
    
            self.lcd_output = QtWidgets.QLCDNumber(Form)
            self.lcd_output.setGeometry(QtCore.QRect(330, 260, 64, 23))
            self.lcd_output.setObjectName("lcd_output")
    
            self.retranslateUi(Form)
            QtCore.QMetaObject.connectSlotsByName(Form)
    
        def retranslateUi(self, Form):
            _translate = QtCore.QCoreApplication.translate
            Form.setWindowTitle(_translate("Form", "Form"))
            self.btn_submit.setText(_translate("Form", "Submit"))
            self.textEdit.setHtml(_translate("Form", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
    "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
    "p, li { white-space: pre-wrap; }\n"
    "</style></head><body style=\" font-family:\'.SF NS Text\'; font-size:13pt; font-weight:400; font-style:normal;\">\n"
    "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Login Page</p></body></html>"))
            self.l_username.setText(_translate("Form", "username"))
            self.l_password.setText(_translate("Form", "password"))
            self.radioButton.setText(_translate("Form", "Keep me Signed in"))
            self.btn_newuser.setText(_translate("Form", "New User"))
            self.btn_submit.clicked.connect(self.btn_submit_handler)
    
    
        def update_label(self):
    
            print("Inside")
            
            self.Ui_Form.l_username.setText("Hello")
    
    
        def update_LCD(self):
            val = self.slider_x.value()
            print("SLIDER VALUE IS ", val)
            self.lcd_output.display(val)
    
    
        def btn_submit_handler(self):
            self.update_label()
    
            print("Button clicked ")
            print(self.time_value.text())
            print(self.date_value.text())
            print(self.slider_x.value())
    
    
    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_())
    
    
    1 Reply Last reply
    0

    1/1

    17 Feb 2019, 04:04

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved