2016-07-05 100 views
1

我想在我的RPi上创建图形用户界面,这样我就可以在我的iPhone中像滚动一样滚动Listbox,而无需使用滚动条。换句话说,只需触摸列表框并上下滑动手指,我就能够滚动。有没有可能滚动Tkinter ListBoxes没有滚动条?

这个滚动方法可以用TKinter或RPi的任何GUI来完成吗?

+1

我建议你看看[Kivy](https://kivy.org/#home)。 Tkinter更适合于基础的老式桌面应用程序。 –

回答

1

是的。

看看滚动条的绑定是如何工作的。

如何达到预期的效果? Bin Mouse-Move事件(触摸移动不是别的),并根据您想要的滚动方式将它连接到yview/xview。

(例如检查方向的鼠标移动你的回调中,并使用该信息来触发滚动事件。)

如果需要进一步的帮助,让我们知道。

编辑:

这里是一些“伪码” ......

# this is your callback bound to mouse-move event 
def mouse_move_callback(event): 
    # use event.y with a previous remembered y value to determine 
    # directions 
    directions = 1 # just as an example, could also be -1 

    # scroll the listbox vertically. 
    # to increase scrolling speed, either multiply counter by some value >1 
    # or replace 'units' which means scroll 1 character in the current setting 
    # by 'pages' for larger steps. 'pages' should scroll the visible 
    # area of the listbox further. 
    listbox.yview_scroll(1, 'units') 

你也可以使用鼠标中键按下鼠标按钮释放触发动作。然后鼠标按钮将存储一个y值(滚动开始)并且鼠标按钮释放将被绑定到上述回调。

+0

是否有可能分享示例代码? – 3kstc

+0

虚拟代码实施添加 – R4PH43L

+0

如果这解决了您的问题,请通过接受答案让其他用户知道。 – R4PH43L