I need some insight about classes design
I have the GUI file called ui_smbhelper.py
class Ui_SMBWindow(object):
def setupUi(self, SMBWindow):
if not SMBWindow.objectName():
SMBWindow.setObjectName(u"SMBWindow")
SMBWindow.resize(852, 486)
self.actionQuit = QAction(SMBWindow)
self.actionQuit.setObjectName(u"actionQuit")
self.actionAbout = QAction(SMBWindow)
self.actionAbout.setObjectName(u"actionAbout")
self.centralwidget = QWidget(SMBWindow)
#More code here
This is obtained with piuic6. It is the GUI of the project.
This is smbhelper_functions.py
class SmbHelper(QMainWindow, Ui_SMBWindow):
def __init__(self, app):
super().__init__()
self.setupUi(self)
self.app = app
# Variables
self.samba_ip = self.line_samba_ip.text()
self.samba_share = self.line_samba_share.text()
self.samba_user = self.line_samba_user.text()
# More imports
# SLOTS
self.button_apply.clicked.connect(self.apply_clicked)
self.button_cancel.clicked.connect(self.close_clicked)
self.actionQuit.triggered.connect(self.close_clicked)
I want it to work as a sort of controller for other 2 classes I have: FstabConfig
and SambaConfig
class SambaConfig:
def __init__(self, smb_helper):
# Folder creation
def check_credentials_folder(self):
# more methods here
class FstabConfig(SmbHelper):
def fstab_create_temp(self):
fstab_tmp = self.fstab_read()
# more methods here
The problem is those are sons of SmbHelper, but, I need that functions to be called in SmbHelper, but it’s not good to instantiate sons on father, but I can’t break inheritance because I need the variables in order the functions in SambaConfig and FstabConfig work, and I am in a catch 22 here.
How can I design my classes: hierarchy and relationships?