-2

I'm trying to access the widget names from my QT Designer but pycharm doesn't recognise the buttons. I don't like having warnings and I don't also like explicitly removing them. I don't also want to define each widget in the init function, but I saw that converting from .UI to .py could do the trick since the file would be of the same extension.

But my question is:

  1. Would it have any bad side effect?
  2. Would I need to do the same process each time I edit my original.ui file?

Thanks for your response

  • I found all 3 of those with a simple google search..... – Alexander Oct 11 '22 at 07:25
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 11 '22 at 07:42

1 Answers1

0

The only problem with pyuic5 is that you have to freshly make the python file every time you change the ui file.

You can also the load the ui file, so that you don't have start freshly every time you make a change.

from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QLineEdit
from PyQt5 import uic
import sys


class UI(QMainWindow):
    def __init__(self):
        super(UI, self).__init__()

        # Load the ui file
        uic.loadUi("test_UI.ui", self)

        # Define our widgets
        self.btn = self.findChild(QPushButton, "submitBtn")
        self.lineEdit = self.findChild(QLineEdit, "lineEdit")
        

        
        # Show the app
        self.show()

app = QApplication(sys.argv)
UIWindow = UI()
app.exec_()

Image reference