Custom QT widget for QStackedWidget
name = "First Page": you retrieve the content of this variable from an other function. Functions returns values vary so from a design principle, we can not assign them to class variables which are supposed to be constant/static.
When you instantiate MainWidget, you need to inject 3 arguments into it because of the way you defined its __init__(). Arguments are a different level of abstraction, so you must use them with parsimony. In your case, there is a better way to get rid of sidebarWidget and customModulesLen described in the next bullet.
You must keep the __init__() clean and outsource the creation of the widegets to an other function that you can call from __init__(). In that function, you can refer to the previous __init__()'s argument which are sidebarWidget and customModulesLen.
You forgot to attach the widget to its parent in lay = QVBoxLayout(self). I mean you must code it this way instead: lay = QVBoxLayout(self.parent). Because objects must own their data members, you should write self.lay = QVBoxLayout(self.master)