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
#2
If you plan to use Ui file, you don't need to compile it to python. Doing the conversion in the script will make your workflow much easier. You can use Qt's uic utility like this:

#!/usr/bin/python3
import os
import sys
from PyQt5 import QtCore, QtGui, QtWidgets, uic
 
LOCAL_DIR = os.path.dirname(os.path.realpath(__file__))
 
 
class Main(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = uic.loadUi(LOCAL_DIR + "/foo.ui", self)
        self.show()
        print(self.ui.inputPipe_name.text())
 
if __name__== '__main__':
    app = QtWidgets.QApplication([])
    gui = Main()
    sys.exit(app.exec_())
The only downside is that it takes more time to execute, but if you plan the distribute the package, the ui files can be converted only once at install time.

If you really want to convert it, you must first import it in your script, then in __init__:

        self.ui = foo.Ui_MainWindow()  # Or .Ui_Dialog, or .Ui_Widget
        self.ui.setupUi(self)
Then access yours widgets trought the self.ui object, as in the previous example
Reply


Messages In This Thread
RE: Collect entry from textline Widget via UI file - by Alfalfa - Aug-02-2019, 08:04 PM

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