I modified an example of 3dsmax to replicate my problem.
I can’t figure out how remove a widget, actually, the instance is removed but the window display the widget
simply running the code and clicking on the button will display the problem
'''
Demonstrates how to create a QWidget with PySide2 and attach it to the 3dsmax main window.
'''
from PySide2 import QtCore
from PySide2 import QtWidgets
import MaxPlus
import pymxs
def make_cylinder():
cyl = pymxs.runtime.Cylinder(radius=10, height=30)
pymxs.runtime.redrawViews()
return
class PyMaxDialog(QtWidgets.QDialog):
def __init__(self, parent=MaxPlus.GetQMaxMainWindow()):
super(PyMaxDialog, self).__init__(parent)
self.setWindowTitle('Pyside Qt Window')
self.initUI()
def initUI(self):
self.main_layout = QtWidgets.QVBoxLayout()
self.label = QtWidgets.QLabel("Click button to create a cylinder in the scene")
self.main_layout.addWidget(self.label)
cylinder_btn = QtWidgets.QPushButton("Cylinder")
cylinder_btn.clicked.connect(self.remove_text)
self.main_layout.addWidget(cylinder_btn)
self.setLayout(self.main_layout)
self.resize(250, 100)
def remove_text(self):
self.main_layout.removeWidget(self.label)
self.main_layout.update()
time = MaxPlus.Core.GetCurrentTime()
MaxPlus.ViewportManager.RedrawViews(time)
def main():
#MaxPlus.FileManager.Reset(True)
w = PyMaxDialog()
w.show()
if __name__ == '__main__':
main()
Do you know why?
It is basic stuff, but today is not my day
Thanks