Set Selection support in Input.Update. Detecting ENTER key in auto complete demo
This commit is contained in:
parent
7e8e120fa1
commit
8abca2ea6e
|
@ -1,6 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
QT = False
|
QT = True
|
||||||
if QT:
|
if QT:
|
||||||
import PySimpleGUIQt as sg
|
import PySimpleGUIQt as sg
|
||||||
else:
|
else:
|
||||||
|
@ -49,6 +49,7 @@ while True: # Event Loop
|
||||||
if event is None or event == 'Exit':
|
if event is None or event == 'Exit':
|
||||||
break
|
break
|
||||||
if event != sg.TIMEOUT_KEY:
|
if event != sg.TIMEOUT_KEY:
|
||||||
|
# print(f'ev1 {event}')
|
||||||
in_val = values['_INPUT_']
|
in_val = values['_INPUT_']
|
||||||
prediction_list = predict_text(str(in_val), choices)
|
prediction_list = predict_text(str(in_val), choices)
|
||||||
if prediction_list:
|
if prediction_list:
|
||||||
|
@ -67,9 +68,9 @@ while True: # Event Loop
|
||||||
sel_item = sel_item - (sel_item>0)
|
sel_item = sel_item - (sel_item>0)
|
||||||
list_elem.Update(set_to_index=sel_item)
|
list_elem.Update(set_to_index=sel_item)
|
||||||
skip_event = True
|
skip_event = True
|
||||||
if event == '\r':
|
if event == '\r' or event.startswith('special 16777220'):
|
||||||
chosen = vals2['_FLOATING_LISTBOX_']
|
chosen = vals2['_FLOATING_LISTBOX_']
|
||||||
window.Element('_INPUT_').Update(vals2['_FLOATING_LISTBOX_'], select=True)
|
window.Element('_INPUT_').Update(vals2['_FLOATING_LISTBOX_'][0], select=True)
|
||||||
fwindow.Close()
|
fwindow.Close()
|
||||||
sel_item = -1
|
sel_item = -1
|
||||||
if event.startswith('Escape') or event.startswith('special 16777216'):
|
if event.startswith('Escape') or event.startswith('special 16777216'):
|
||||||
|
@ -80,6 +81,7 @@ while True: # Event Loop
|
||||||
if ev2 == '_FLOATING_LISTBOX_' and skip_event and QT:
|
if ev2 == '_FLOATING_LISTBOX_' and skip_event and QT:
|
||||||
skip_event = False
|
skip_event = False
|
||||||
elif ev2 != sg.TIMEOUT_KEY and ev2 is not None:
|
elif ev2 != sg.TIMEOUT_KEY and ev2 is not None:
|
||||||
|
# print(f'ev2 {ev2}')
|
||||||
fwindow.Close()
|
fwindow.Close()
|
||||||
window.Element('_INPUT_').Update(vals2['_FLOATING_LISTBOX_'][0], select=True)
|
window.Element('_INPUT_').Update(vals2['_FLOATING_LISTBOX_'][0], select=True)
|
||||||
sel_item = -1
|
sel_item = -1
|
||||||
|
|
|
@ -548,7 +548,7 @@ class InputText(Element):
|
||||||
self.QT_QLineEdit.setText(str(value))
|
self.QT_QLineEdit.setText(str(value))
|
||||||
self.DefaultText = value
|
self.DefaultText = value
|
||||||
if select:
|
if select:
|
||||||
self.QT_QLineEdit.setSelection()
|
self.QT_QLineEdit.setSelection(0,QtGui.QTextCursor.End )
|
||||||
|
|
||||||
def Get(self):
|
def Get(self):
|
||||||
return self.QT_QLineEdit.text()
|
return self.QT_QLineEdit.text()
|
||||||
|
|
Loading…
Reference in New Issue