def __init__(self, *args, **kwargs): self.attr_name = "" self.type_node = "" if kwargs.has_key("attr_name"): self.attr_name = kwargs.pop("attr_name") if kwargs.has_key('type_node'): self.type_node = kwargs.pop('type_node') self.path_uiInfo = path_basedir + "/attr_name_%s.json" % self.attr_name super(Widget_TypeAttribute, self).__init__(*args, **kwargs) self.installEventFilter(self) mainLayout = QHBoxLayout(self) mainLayout.setContentsMargins(0, 0, 0, 0) checkBox = QCheckBox() checkBox.setFixedWidth(10) checkBox.setChecked(True) label = QLabel('%s ( *.%s )' % (self.type_node, self.attr_name)) mainLayout.addWidget(checkBox) mainLayout.addWidget(label) self.setFixedHeight(25) self.checkBox = checkBox self.cmds_checkEvent = [] self.load_check() QtCore.QObject.connect(checkBox, QtCore.SIGNAL("stateChanged(int)"), self.save_check)
def __init__(self, text, validator, minValue, maxValue): QWidget.__init__(self) layout = QHBoxLayout(self) checkBox = QCheckBox() checkBox.setFixedWidth(115) checkBox.setText(text) layout.addWidget(checkBox) hLayoutX = QHBoxLayout() lineEditXMin = QLineEdit() lineEditXMax = QLineEdit() hLayoutX.addWidget(lineEditXMin) hLayoutX.addWidget(lineEditXMax) lineEditXMin.setValidator(validator) lineEditXMax.setValidator(validator) lineEditXMin.setText(str(minValue)) lineEditXMax.setText(str(maxValue)) hLayoutY = QHBoxLayout() lineEditYMin = QLineEdit() lineEditYMax = QLineEdit() hLayoutY.addWidget(lineEditYMin) hLayoutY.addWidget(lineEditYMax) lineEditYMin.setValidator(validator) lineEditYMax.setValidator(validator) lineEditYMin.setText(str(minValue)) lineEditYMax.setText(str(maxValue)) hLayoutZ = QHBoxLayout() lineEditZMin = QLineEdit() lineEditZMax = QLineEdit() hLayoutZ.addWidget(lineEditZMin) hLayoutZ.addWidget(lineEditZMax) lineEditZMin.setValidator(validator) lineEditZMax.setValidator(validator) lineEditZMin.setText(str(minValue)) lineEditZMax.setText(str(maxValue)) layout.addLayout(hLayoutX) layout.addLayout(hLayoutY) layout.addLayout(hLayoutZ) self.checkBox = checkBox self.lineEditX_min = lineEditXMin self.lineEditX_max = lineEditXMax self.lineEditY_min = lineEditYMin self.lineEditY_max = lineEditYMax self.lineEditZ_min = lineEditZMin self.lineEditZ_max = lineEditZMax self.lineEdits = [ lineEditXMin, lineEditXMax, lineEditYMin, lineEditYMax, lineEditZMin, lineEditZMax ] QtCore.QObject.connect(checkBox, QtCore.SIGNAL("clicked()"), self.updateEnabled) self.updateEnabled()
def __init__(self, text, minValue, maxValue, defaultValue ): QWidget.__init__( self ) validator = QDoubleValidator(minValue, maxValue, 2, self ) mainLayout = QHBoxLayout( self ) checkBox = QCheckBox() checkBox.setFixedWidth( 115 ) checkBox.setText( text ) lineEdit = QLineEdit() lineEdit.setValidator( validator ) lineEdit.setText( str(defaultValue) ) slider = QSlider( QtCore.Qt.Horizontal ) slider.setMinimum( minValue*100 ) slider.setMaximum( maxValue*100 ) slider.setValue( defaultValue ) mainLayout.addWidget( checkBox ) mainLayout.addWidget( lineEdit ) mainLayout.addWidget( slider ) QtCore.QObject.connect( slider, QtCore.SIGNAL( 'valueChanged(int)' ), self.syncWidthLineEdit ) QtCore.QObject.connect( lineEdit, QtCore.SIGNAL( 'textChanged(QString)' ), self.syncWidthSlider ) QtCore.QObject.connect( checkBox, QtCore.SIGNAL( "clicked()" ), self.updateEnabled ) self.checkBox = checkBox self.slider = slider self.lineEdit = lineEdit self.updateEnabled()
def __init__(self, *args, **kwargs): super(Widget_referenceFiles, self).__init__(*args, **kwargs) self.installEventFilter(self) mainLayout = QVBoxLayout(self) mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.setSpacing(8) treeWidget = QTreeWidget() headerItem = treeWidget.headerItem() checkBox_allItems = QCheckBox(treeWidget) checkBox_allItems.setFixedWidth(20) checkBox_allItems.setChecked(True) checkBox_allItems.setStyleSheet("margin: 6px 6px") treeWidget.setItemWidget(headerItem, 0, checkBox_allItems) headerItem.setText(0, "") headerItem.setText(1, "Reference File Name") treeWidget.setRootIsDecorated(False) treeWidget.setStyleSheet( "QTreeWidget::item { border-left: 1px solid gray;border-bottom: 1px solid gray; padding: 3px}\ QTreeWidget{ font-size:13px;}") treeWidget.header().setStyleSheet("font-size:12px;") treeWidget.setColumnWidth(0, 22) w_buttons = QWidget() lay_buttons = QHBoxLayout(w_buttons) lay_buttons.setContentsMargins(0, 0, 0, 0) buttonReference = QPushButton("REFERENCE") buttonCleanExceptSelected = QPushButton("CLEAN EXCEPT SELECTED") lay_buttons.addWidget(buttonCleanExceptSelected) lay_buttons.addWidget(buttonReference) mainLayout.addWidget(treeWidget) mainLayout.addWidget(w_buttons) self.treeWidget = treeWidget self.treeWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) self.treeWidget.checkBox_allItems = checkBox_allItems checkBox_allItems.stateChanged.connect(self.cmd_setCheckAsset) treeWidget.itemPressed.connect(self.cmd_selectItems) buttonReference.clicked.connect(self.referenceFiles) buttonCleanExceptSelected.clicked.connect(self.cmd_cleanScene) self.cmd_loadList()
class TreeWidgetItem_file(QTreeWidgetItem, Cmds_file_control): def __init__(self, *args, **kwargs): super(TreeWidgetItem_file, self).__init__(*args, **kwargs) def setCheckState(self): allChecked = True originalCheckValues = [] for checkBox in [ self.treeWidget().topLevelItem(i).checkBox for i in range(self.treeWidget().topLevelItemCount()) ]: if not checkBox.isChecked(): allChecked = False originalCheckValues.append(checkBox.isChecked()) if allChecked: self.treeWidget().checkBox_allItems.setChecked(True) else: self.treeWidget().checkBox_allItems.setChecked(False) for i in range(self.treeWidget().topLevelItemCount()): checkBox = self.treeWidget().topLevelItem(i).checkBox checkBox.setChecked(originalCheckValues[i]) def addFilePath(self, fileName, enableValue=True): self.checkBox = QCheckBox() self.checkBox.setFixedWidth(20) self.checkBox.setChecked(True) self.lineEdit = QLineEdit() self.lineEdit.setText(fileName) self.lineEdit.setReadOnly(True) self.treeWidget().setItemWidget(self, 0, self.checkBox) self.treeWidget().setItemWidget(self, 1, self.lineEdit) self.checkBox.stateChanged.connect(self.setCheckState) self.checkBox.setEnabled(enableValue) self.lineEdit.setEnabled(enableValue)
def __init__(self, text, minValue, maxValue, defaultValue): QWidget.__init__(self) validator = QDoubleValidator(minValue, maxValue, 2, self) mainLayout = QHBoxLayout(self) checkBox = QCheckBox() checkBox.setFixedWidth(115) checkBox.setText(text) lineEdit = QLineEdit() lineEdit.setValidator(validator) lineEdit.setText(str(defaultValue)) slider = QSlider(QtCore.Qt.Horizontal) slider.setMinimum(minValue * 100) slider.setMaximum(maxValue * 100) slider.setValue(defaultValue) mainLayout.addWidget(checkBox) mainLayout.addWidget(lineEdit) mainLayout.addWidget(slider) QtCore.QObject.connect(slider, QtCore.SIGNAL('valueChanged(int)'), self.syncWidthLineEdit) QtCore.QObject.connect(lineEdit, QtCore.SIGNAL('textChanged(QString)'), self.syncWidthSlider) QtCore.QObject.connect(checkBox, QtCore.SIGNAL("clicked()"), self.updateEnabled) self.checkBox = checkBox self.slider = slider self.lineEdit = lineEdit self.updateEnabled()
def __init__(self, *args, **kwargs): self.get_csv_form_google_spreadsheets(Widget_FileTree.url, Widget_FileTree.csv) self.dict_extensionList = self.get_dictList_from_csvPath( Widget_FileTree.csv) super(Widget_FileTree, self).__init__(*args, **kwargs) self.installEventFilter(self) mainLayout = QVBoxLayout(self) mainLayout.setContentsMargins(0, 5, 0, 0) w_basePath = QWidget() lay_basePath = QHBoxLayout(w_basePath) w_basePath.setStyleSheet("font-size:12px") lay_basePath.setContentsMargins(5, 0, 3, 0) label_basePath = QLabel("Base Path : ") lineEdit_basePath = QLineEdit() lineEdit_basePath.setMinimumHeight(22) lineEdit_basePath.setReadOnly(True) lay_basePath.addWidget(label_basePath) lay_basePath.addWidget(lineEdit_basePath) w_tree = QTreeWidget() w_tree.setColumnCount(2) headerItem = w_tree.headerItem() headerItem.setText(0, "File Path") headerItem.setText(1, "Target Node") w_tree.itemExpanded.connect(self.setContentsWidth) w_tree.itemCollapsed.connect(self.setContentsWidth) w_tree.setSelectionMode(QAbstractItemView.ExtendedSelection) self.w_typeAttrList = Widget_TypeAttributeList() w_tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) QtCore.QObject.connect( w_tree, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), self.loadContextMenu) w_check = QWidget() lay_check = QHBoxLayout(w_check) lay_check.setContentsMargins(5, 5, 0, 10) lay_check.setSpacing(0) checkBox = QCheckBox() checkBox.setFixedWidth(30) label = QLabel("Show Unused files in folder") label.setStyleSheet("font-size:12px") lay_check.addWidget(checkBox) lay_check.addWidget(label) mainLayout.addWidget(w_basePath) mainLayout.addWidget(w_tree) mainLayout.addWidget(w_check) self.w_tree = w_tree self.checkBox = checkBox self.lineEdit = lineEdit_basePath self.load_checkBoxValue(checkBox, Widget_FileTree.path_uiInfo) QtCore.QObject.connect(checkBox, QtCore.SIGNAL("stateChanged(int)"), self.saveCheckBoxValue) QtCore.QObject.connect(w_tree, QtCore.SIGNAL("itemSelectionChanged()"), self.selectItem)
def __init__(self, text, validator, minValue, maxValue ): QWidget.__init__( self ) layout = QHBoxLayout( self ) checkBox = QCheckBox() checkBox.setFixedWidth( 115 ) checkBox.setText( text ) layout.addWidget( checkBox ) hLayoutX = QHBoxLayout() lineEditXMin = QLineEdit() lineEditXMax = QLineEdit() hLayoutX.addWidget( lineEditXMin ) hLayoutX.addWidget( lineEditXMax ) lineEditXMin.setValidator( validator ) lineEditXMax.setValidator( validator ) lineEditXMin.setText( str( minValue ) ) lineEditXMax.setText( str( maxValue ) ) layout.addLayout( hLayoutX ) self.checkBox = checkBox self.lineEditX_min = lineEditXMin self.lineEditX_max = lineEditXMax self.lineEdits = [ lineEditXMin, lineEditXMax ] QtCore.QObject.connect( checkBox, QtCore.SIGNAL( "clicked()" ), self.updateEnabled ) self.updateEnabled()