Skip to content

maycon2-0/Import-.py-file-with-pyqt6-interface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Import-.py-file-with-pyqt6-interface

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.

Create a .ui file image

Save the file and convert with the command "pyuic6 -x input.ui -o output.py" image

Open the output.py file and copy the "if name == "main":" section and the imports to another .py file. image image

Add the import "import output as interface" image

After import, just change the ui = Ui_MainWindow() adding the interface. before image

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.

image

gitInterface.zip

About

How to import a .py file converted from a .ui to a .py project

Resources

License

Stars

Watchers

Forks

Packages

No packages published