On Sat, May 30, 2020, 7:31 AM Soham Parmar <soham...@gmail.com> wrote:
> Hi, > I am trying to create scrollArea under my tabWidget. > I have already written code for creating widgets under my tab widgets but > now i wanted scrollArea. running code with scrollArea i can not se any > Widgets in my scrollArea and maya is geting crached if i move the window or > change the tab. > > Below Code is working perfectly fine WITHOUT scrollArea In my tabWidget: > > def buildTabLodUpdate(self): > # all tabs in widget > tabs = [self.buildTabWidget.tabText(index) for index in > range(self.buildTabWidget.count())] > allLod = [lod for lod in self.uiData["spModularRig"]["rig"]] > > # if lod exist deleting default tab > if len(allLod) > 0: > # deleting default tab if exists > if "spModularRig" in tabs: > self.buildTabWidget.removeTab(0) > > # creating tab for all lod and updating widgets. > for lod in allLod: > if lod.keys()[0] not in tabs: > W_lod = QtWidgets.QWidget() > VerL_lod = QtWidgets.QVBoxLayout(W_lod) > > self.buildTabWidget.addTab(W_lod, lod.keys()[0]) > self.buildTabWidget.setCurrentIndex(self.buildTabWidget.count()-1) > > # updating rig data widgets inside tab > self.buildTabSWUpdate() > > def buildTabSWUpdate(self): > self.buildTabSWRemoveAll() > > Widget = self.buildTabWidget.currentWidget() > layout = Widget.findChild(QtWidgets.QVBoxLayout) > > for num, rigData in > enumerate(self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName]): > GB_name = > self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName][num][rigData.keys()[0]]["name"] > if rigData.keys()[0] == "rigInfo": > # gathering data from dictionary. > assetName = > self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName][num][rigData.keys()[0]]["assetName"] > assetType = > self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName][num][rigData.keys()[0]]["assetType"] > assetOtherType = > self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName][num][rigData.keys()[0]]["OtherType"] > > # creating widget with above values. > rigInfoW = self.rigInfoUIFunc(Widget, layout, GB_name, assetName, > assetType, assetOtherType) > > # connecting. > rigInfoW.LE_assetName.editingFinished.connect(lambda data=[num, > rigInfoW.LE_assetName]: self.RI_assetNameUpdate(data)) > rigInfoW.LE_assetOtherType.editingFinished.connect(lambda data=[num, > rigInfoW.LE_assetOtherType]: self.RI_assetOtherTypeUpdate(data)) > > rigInfoW.ComB_assetType.currentIndexChanged.connect(self.RI_assetTypeUpdate) > rigInfoW.B_applyRigInfo.clicked.connect(self.applyRigInfo) > > > > > below is the code where i am adding scrollArea: > > def buildTabLodUpdate(self): > # all tabs in widget > tabs = [self.buildTabWidget.tabText(index) for index in > range(self.buildTabWidget.count())] > allLod = [lod for lod in self.uiData["spModularRig"]["rig"]] > > # if lod exist deleting default tab > if len(allLod) > 0: > # deleting default tab if exists > if "spModularRig" in tabs: > self.buildTabWidget.removeTab(0) > > # creating tab for all lod and updating widgets. > for lod in allLod: > if lod.keys()[0] not in tabs: > W_lod = QtWidgets.QWidget() > VerL_lod = QtWidgets.QVBoxLayout(W_lod) > > SA_buildTab = QtWidgets.QScrollArea(W_lod) > SA_buildTab.setObjectName("SA_buildTab") > > SA_W_rigData = QtWidgets.QWidget() > SA_W_rigData.setObjectName("SA_W_rigData") > VerL_SA_W_rigData = QtWidgets.QVBoxLayout(SA_W_rigData) > VerL_SA_W_rigData.setObjectName("VerL_SA_W_rigData") > > SA_buildTab.setWidget(SA_W_rigData) > VerL_lod.addWidget(SA_buildTab) > > self.buildTabWidget.addTab(W_lod, lod.keys()[0]) > self.buildTabWidget.setCurrentIndex(self.buildTabWidget.count()-1) > > # updating rig data widgets inside tab > self.buildTabSWUpdate() > > def buildTabSWUpdate(self): > self.buildTabSWRemoveAll() > > Widget = [Widget for Widget in > self.buildTabWidget.currentWidget().findChildren(QtWidgets.QWidget) if > Widget.objectName() == "SA_W_rigData"][0] > layout = Widget.findChild(QtWidgets.QVBoxLayout) > > for num, rigData in > enumerate(self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName]): > GB_name = > self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName][num][rigData.keys()[0]]["name"] > if rigData.keys()[0] == "rigInfo": > # gathering data from dictionary. > assetName = > self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName][num][rigData.keys()[0]]["assetName"] > assetType = > self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName][num][rigData.keys()[0]]["assetType"] > assetOtherType = > self.uiData["spModularRig"]["rig"][self.lodIndex][self.selectedLodName][num][rigData.keys()[0]]["OtherType"] > > # creating widget with above values. > rigInfoW = self.rigInfoUIFunc(Widget, layout, GB_name, assetName, > assetType, assetOtherType) > > # connecting. > rigInfoW.LE_assetName.editingFinished.connect(lambda data=[num, > rigInfoW.LE_assetName]: self.RI_assetNameUpdate(data)) > rigInfoW.LE_assetOtherType.editingFinished.connect(lambda data=[num, > rigInfoW.LE_assetOtherType]: self.RI_assetOtherTypeUpdate(data)) > > rigInfoW.ComB_assetType.currentIndexChanged.connect(self.RI_assetTypeUpdate) > rigInfoW.B_applyRigInfo.clicked.connect(self.applyRigInfo) > > > > What am i doing wrong here? > It is really hard to know for sure what is causing the crash just from looking at this code. Is it a complete crash of Maya or just a python exception? Your code is using an approach that is much harder to reason about, where you are using lots and lots of introspection to find a child of this or that widget with this or that type or object name. If these were properly composed as more custom classes then you could ask the widget for the thing you need. An example of a possible problem is where you are looping on the tab to find the current widget and then get the child and layout and check the name. Now that you have added a scroll widget in the middle, it would appear you aren't looking deep enough in the widget hierarchy anymore. Other issues could be not setting object names on layouts. Or the fact that you use dict.keys()[0] everywhere when a dict makes no guarantee of being ordered. So this could be a bug now, or later, and/or break when you run this in py3. There are also lots of redundant nested dictionary lookups in the same function body would could lead to a mistake. My suggestion is to try and reduce your problem to the absolute smallest amount of code. This will help isolate the difference between success and crashing. -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to python_inside_maya+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/bcadbece-a05b-4ee2-abd4-636fcd95dd8c%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/bcadbece-a05b-4ee2-abd4-636fcd95dd8c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3ajwO1rbnjV8S8k%3DB5n5%2Bud%2Bc6%3DUYhkppUQmMAi0Y%2BGQ%40mail.gmail.com.