I'm going to keep this question pretty general because I feel a lot of people do the same thing and I couldn't find a consice answer.
Using PyQt (4 or 5) to make a program everyone needs mainly the following lines:
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QWidget
For each widget that someone wants to create they need to write those two lines, more or less. Is there a way to (speedily) import all those lines without having to import them for each sub-widget?
To further clarify, say I have a main class MainWindow
that calls upon it's child widget Child
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QWidget
from ChildWidget import Child
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
widget1 = Child(self)
....
The file ChildWidget
will then have a structure similar to
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QWidget
class Child(QWidget):
def __init__(self, parent):
super(Child, self).__init__(parent)
....
(And of course, imports will vary for each widget, but those two will always be there.)
I know that instead of the regular two imports in ChildWidget
I can do from MainWindow import *
to import everything in MainWindow
but I feel that's slow because it's circular importing everything?
So my question is what's the best way to import the same functions in each widget, as the number of widgets increase, if speed is a major concern?