Python Forum
[PyQt] Collect entry from textline Widget via UI file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Collect entry from textline Widget via UI file
#1
Hi,

I would like to know how I can access a QLineEdit widget in a UI file directly from Python.
I have read some examples on the Internet but, I can't get it to work.

This is what I have:
original *.ui file: propertyDialog.ui
extracted *.py file: propertyDialog.py
QLineEdit widget name on the ui: "input_PipeName"

The script I have so far is:
from PyQt5 import QtCore, QtGui, QtWidgets
from propertyDialog import Ui_Dialog

class mainProgram(QtWidgets.QMainWindow, Ui_Dialog):
    def __init__(self, parent=None):
        self.cntPipe = 0
        self.cntLiner = 0
        self.cntCoating = 0
        self.pipeproperty = {}
        self.coating = {}
        self.liner = {}
        super(mainProgram, self).__init__(parent)
        # self.calc = Calculations()
        self.setupUi(self)
        self.response_AddPipe.clicked.connect(self.add_pipe)

    def add_pipe(self):
        self.cntPipe +=1
        self.cntLiner = 0
        self.cntCoating = 0
        self.pipeproperty[self.cntPipe]={}
        pipe_name = self.inputPipe_name.text()
        self.pipeproperty[self.cntPipe]["Name"] = pipe_name

if __name__ == "__main__":

    import sys
    app = QtWidgets.QApplication(sys.argv)
    nextGui = mainProgram()
    nextGui.show()
    sys.exit(app.exec_())
With the error:
Error:
"C:\Users\Usr\Desktop\Work Folder PPM\VirtualEnvironment\Scripts\python.exe" "C:/Users/Usr/Desktop/Work Folder PPM/VirtualEnvironment/Scripts/Total.py" Traceback (most recent call last): File "C:/Users/Usr/Desktop/Work Folder PPM/VirtualEnvironment/Scripts/Total.py", line 151, in <module> nextGui = mainProgram() File "C:/Users/Usr/Desktop/Work Folder PPM/VirtualEnvironment/Scripts/Total.py", line 15, in __init__ self.response_AddPipe.clicked.connect(self.add_pipe()) File "C:/Users/Usr/Desktop/Work Folder PPM/VirtualEnvironment/Scripts/Total.py", line 23, in add_pipe pipe_name = self.inputPipe_name.text() AttributeError: 'mainProgram' object has no attribute 'inputPipe_name' Process finished with exit code 1
Can someone help me with this? It seems to fail on:
pipe_name = self.inputPipe_name.text()
Reply


Messages In This Thread
Collect entry from textline Widget via UI file - by mart79 - Aug-02-2019, 01:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: could not convert string to float: '' fron Entry Widget russellm44 5 728 Mar-06-2024, 08:42 PM
Last Post: russellm44
  [Tkinter] entry widget DPaul 5 1,549 Jul-28-2023, 02:31 PM
Last Post: deanhystad
  [PyQt] [solved] How to display a pdf-file in a PyQt6 widget BigMan 13 16,280 May-06-2023, 09:27 AM
Last Post: Axel_Erfurt
  Tkinter Exit Code based on Entry Widget Nu2Python 6 3,022 Oct-21-2021, 03:01 PM
Last Post: Nu2Python
  [Tkinter] compare entry with value inside file rwahdan 1 2,093 Jun-19-2021, 08:01 AM
Last Post: Yoriz
  method to add entries in multi columns entry frames in self widget sudeshna24 2 2,275 Feb-19-2021, 05:24 PM
Last Post: BashBedlam
  Entry Widget issue PA3040 16 6,907 Jan-20-2021, 02:21 PM
Last Post: pitterbrayn
  Android app to collect data jehoshua 7 4,398 Dec-24-2020, 08:07 AM
Last Post: dejaolsone
  [Tkinter] password with Entry widget TAREKYANGUI 9 6,021 Sep-24-2020, 05:27 PM
Last Post: TAREKYANGUI
  [Tkinter] Get the last entry in my text widget Pedroski55 3 6,438 Jul-13-2020, 10:34 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020