Okay let us say we wrote a Class with all its imports it needs such as this
from PyQt5.Widgets import QWidget, QLabel
class Exterior(QWidget):
def __init__(self):
QWidget.__init__(self)
self.lblTest = QLabel(Test)
***************************************************
Okay that is our class (called Test.py) outside our main program (called Main.py) we are writing now to import we need to do a few things (note the sub-directory is not necessary but it makes things cleaner)
Create a subfolder within your Main area call it say Utils so we have the following folder/file structure:
Main
Utils
Test.py
Main.py
Now we have our Main program and our Test class that we want to import but just importing it will not work but why? Well because python requires this interesting little additive which we implement by creating an empty text file and renaming it to "__init__.py" then placing one within our Main folder and one within our Utils folder as follows:
Main
Utils
__init__.py
Test.py
__init__.py
Main.py
Now within Main.py we can add the following code and import Test into Main
import Utils.Exterior as Ext
And reference its contents (with using the above import) like this:
Ext.lblTest.setText('My Test')
Now that above bit of code will appear to do nothing if implemented as designed since we never show lblTest anywhere but that will set the value you just wont be able to see it. Still what the above does do is show you how to set up and import an exterior class into your current code base.