How to import a .py file converted from a .ui to a .py project
I was with a problem to import a .py file to a new .py file, because when we import a .ui file, we need to search for the functions before to use on the file, and it is too bad to make our programs.
To solution the problem I always transform the .ui file to a .py file and them make my modifications, but when I need to add or moddify anything in the interface I need to transform the .ui file again and adapt the converted file to my actual file.
But transform the .ui file to a .py file and them import to my project is the solution, because I can use all the functions, labels, widgets and etc from my transformed file without to search for every one to use, and when I need to change anything in the interface I only need to transform the .ui file to the same .py file and preserve all of my code.
How to do.
Save the file and convert with the command "pyuic6 -x input.ui -o output.py"
Open the output.py file and copy the "if name == "main":" section and the imports to another .py file.
Add the import "import output as interface"
After import, just change the ui = Ui_MainWindow() adding the interface. before
Now the interface works from this file, and to modify the interface, create a class and a def method and call in the if name == "main":, and inside the def call the Ui_MainWindow and the setupUi from the imported file to modidy.