New feature - Drag and Drop for Text Input field. Drop a file onto input and get the filename automatically entered
This commit is contained in:
parent
f9b249d43c
commit
6a20e318d4
|
@ -517,6 +517,17 @@ class InputText(Element):
|
|||
font=font, tooltip=tooltip, visible=visible, size_px=size_px)
|
||||
|
||||
|
||||
def dragEnterEvent(self, e):
|
||||
if e.mimeData().hasText():
|
||||
e.accept()
|
||||
else:
|
||||
e.ignore()
|
||||
|
||||
def dropEvent(self, e):
|
||||
self.QT_QLineEdit.setText(e.mimeData().text())
|
||||
|
||||
|
||||
|
||||
class InputTextWidget(QWidget):
|
||||
def __init__(self, qt_qlineedit, element):
|
||||
self.QT_QLineEdit = qt_qlineedit
|
||||
|
@ -530,8 +541,9 @@ class InputText(Element):
|
|||
return QWidget.eventFilter(self, widget, event)
|
||||
|
||||
|
||||
|
||||
def QtCallbackFocusInEvent(self,value):
|
||||
print('Got focus!')
|
||||
return
|
||||
|
||||
|
||||
def QtCallbackTextChanged(self, value):
|
||||
|
@ -618,6 +630,8 @@ class Combo(Element):
|
|||
self.QT_ComboBox.addItems(self.Values)
|
||||
|
||||
|
||||
|
||||
|
||||
def Update(self, value=None, values=None, set_to_index=None, disabled=None, readonly=None, background_color=None, text_color=None, font=None, visible=None):
|
||||
if values is not None:
|
||||
self.Values = values
|
||||
|
@ -4539,6 +4553,10 @@ def PackFormIntoFrame(window, containing_frame, toplevel_win):
|
|||
default_text = element.DefaultText
|
||||
element.QT_QLineEdit = qlineedit = QLineEdit()
|
||||
|
||||
qlineedit.setAcceptDrops(True)
|
||||
qlineedit.dragEnterEvent = element.dragEnterEvent
|
||||
qlineedit.dropEvent = element.dropEvent
|
||||
|
||||
if element.Justification[0] == 'c':
|
||||
element.QT_QLineEdit.setAlignment(Qt.AlignCenter)
|
||||
elif element.Justification[0] == 'r':
|
||||
|
|
Loading…
Reference in New Issue