当我使用键盘进行下拉选择时,滚动条不会上下移动,所以我现在无法看到选择了哪一个。当键盘上下按时,如何上下滚动。我的示例代码如下:
import PySimpleGUI as sg
class GUI():
def __init__(self):
self.data = [(10), (20), (30), (40), (50), (60), (70), (80), (90), (100)]
self.work_order_currrent_selection_index = 0
def run(self):
layout = [[sg.Listbox(values=self.data, size=(35, 3), enable_events=True, key='selected_key')]]
# Create the Window
self.testWindow = sg.Window('Test', return_keyboard_events=True).Layout(layout).Finalize()
self.testWindow.Maximize()
self.testWindow.Element('selected_key').Update(set_to_index=0)
# Event Loop to process "events"
while True:
event, values = self.testWindow.Read()
if event in('Up:111', '16777235'):
if(hasattr(self, 'testWindow')):
self.work_order_currrent_selection_index = (self.work_order_currrent_selection_index - 1) % len(self.data)
self.testWindow.Element('selected_key').Update(set_to_index=self.work_order_currrent_selection_index)
elif event in ('Down:116',' 16777237'):
if(hasattr(self, 'testWindow')):
self.work_order_currrent_selection_index = (self.work_order_currrent_selection_index + 1) % len(self.data)
self.testWindow.Element('selected_key').Update(set_to_index=self.work_order_currrent_selection_index)
self.testWindow.Close()
if __name__ == '__main__':
app = GUI()
app.run()
我按了下箭头键,然后像这样一个一个地往下选
但选择30后,在向下键上按选择移动到下一个,如40,50。。除了滚动,所以我现在不知道是哪一个被选中了。 有没有办法在滚动的同时移动所选内容?在
看到第四张图片,这里的选择移动到40,但滚动没有向下移动。按向上键时出现相同问题。在
也许这会让你更接近你想要的东西
相关问题 更多 >
编程相关推荐