Исправлен вывод элемена ComboBox + выбор файла

master-3.5
parent 336db0386f
commit 830c3f1b8f

@ -537,11 +537,11 @@ class FileOpenWgt(qt.QWidget):
def setText(self, text): def setText(self, text):
return self.lineEdit.setText(text) return self.lineEdit.setText(text)
class ComboFileWgt(qt.QWidget): class ComboFileWgt(qt.QLabel):
# textChanged = qt.Signal() # textChanged = qt.Signal()
def __init__(self, parent, type, choice = None, caption=None, \ def __init__(self, parent, type, choice = None, caption=None, \
value=None, comments = None): value=None, comments = None):
qt.QWidget.__init__(self,parent) qt.QLabel.__init__(self,parent)
self.type = type self.type = type
self.caption = caption self.caption = caption
self.value = value self.value = value
@ -560,24 +560,15 @@ class ComboFileWgt(qt.QWidget):
if self.comments: if self.comments:
self.comments.append(value) self.comments.append(value)
self.hlayout = qt.QHBoxLayout(self) self.layout = qt.QHBoxLayout(self)
self.layout.setContentsMargins(0,0,0,0)
self.ComboBox = qt.QComboBox(self) self.ComboBox = qt.QComboBox()
self.ComboBox.setDuplicatesEnabled(False) self.setContentsMargins(0,0,0,0)
self.ComboBox.currentIndexChanged.connect(self.setCursorPos)
self.ComboBox.setEditable(True) self.ComboBox.setEditable(True)
self.lineEdit = self.ComboBox.lineEdit() self.lineEdit = self.ComboBox.lineEdit()
#self.lineEdit = qt.QLineEdit(self) self.setFixedHeight(self.ComboBox.sizeHint().height()+2)
#self.ComboBox.setLineEdit(self.lineEdit) self.layout.addWidget(self.ComboBox)
#self.lineEdit.setStyleSheet('QLineEdit {background:white;margin: 1px;}')
self.ComboBox.currentIndexChanged.connect(self.setCursorPos)
# self.lineEdit.setStyleSheet("QLineEdit {border: none;}")
self.ComboWidget = qt.QLabel(self)
self.ComboWidget.setContentsMargins(0,0,0,0)
ComboLayout = qt.QVBoxLayout(self.ComboWidget)
ComboLayout.setContentsMargins(0,0,0,0)
ComboLayout.addWidget(self.ComboBox)
self.unsetErrorBorder()
self.view_value = [] self.view_value = []
if choice: if choice:
@ -610,12 +601,10 @@ class ComboFileWgt(qt.QWidget):
self.button.setIcon(icon) self.button.setIcon(icon)
else: else:
self.button.setText(_('Open')) self.button.setText(_('Open'))
# self.button.setStyleSheet("QToolButton {border: none;}")
self.button.clicked.connect(self.file_dialog) self.button.clicked.connect(self.file_dialog)
self.hlayout.addWidget(self.ComboWidget) self.layout.addWidget(self.button)
self.hlayout.addWidget(self.button) self.unsetErrorBorder()
self.hlayout.setSpacing(0)
def setCursorPos(self, num = None): def setCursorPos(self, num = None):
self.lineEdit.setCursorPosition(0) self.lineEdit.setCursorPosition(0)
@ -662,12 +651,12 @@ class ComboFileWgt(qt.QWidget):
self.ComboBox.setCurrentIndex(self.ComboBox.count()-1) self.ComboBox.setCurrentIndex(self.ComboBox.count()-1)
def setErrorBorder(self): def setErrorBorder(self):
style = ".QLabel {border: 1px solid red; margin: 0px;}" style = ".ComboFileWgt {border: 1px solid red; margin: 0px;}"
self.ComboWidget.setStyleSheet(style) self.setStyleSheet(style)
def unsetErrorBorder(self): def unsetErrorBorder(self):
style = "QLabel {border: 1px solid transparent; margin: 0px;}" style = ".ComboFileWgt {border: 1px solid transparent; margin: 0px;}"
self.ComboWidget.setStyleSheet(style) self.setStyleSheet(style)
class ReadonlyCheckBox(qt.QCheckBox): class ReadonlyCheckBox(qt.QCheckBox):
def __init__(self, parent): def __init__(self, parent):

Loading…
Cancel
Save