wxPython中的焦点跟随鼠标? [英] Focus-follows-mouse in wxPython?
问题描述
我正在开发一个包含多个窗格的应用程序.请参阅情节.
wx.Panel
.我想实现焦点跟随鼠标,这样当我将鼠标移到绘图上时,我可以立即使用滚轮放大或缩小,而无需先单击绘图以使其成为焦点.
同样,当我将鼠标移到左侧 settings 、顶部 events 或底部 data 窗格上时,我希望能够立即使用滚轮滚动窗口,无需先点击窗口.
目前我定义了一个函数:
def focusFollowsMouse(window):window.Bind(wx.EVT_ENTER_WINDOW, lambda 事件: window.SetFocus())
我只想在四个顶级窗格中应用此功能:plot、settings、events 和 data.
但是,我需要为每个顶级窗格中的每个子面板或控件调用此函数才能使其工作.例如,我需要将此功能单独应用于测量设置、分析参数、查看设置等面板.
EVT_ENTER_WINDOW
事件很可能没有传播到父窗口.
有没有办法在不将 focusFollowsMouse
应用到每个子面板或控件的情况下使其工作?
谢谢
这是 Windows 的行为 - 它在 GTK 下按您的预期工作.就个人而言,为了与其他 Windows 应用程序保持一致,我会保留您的应用程序原样,并安装 WizMouse
I'm developing an application that contains a number of panes. See the screenshot:
- The left settings pane is a
wx.ScrolledPanel
that contains a number ofwx.Panels
. - The top events pane is a
wx.grid.Grid
. - The bottom data pane is a
wx.Panel
that contains awx.grid.Grid
. - The middle plot pane is a
wx.Panel
containing an enthought chaco plot. - The right detector pane is a
wx.Panel
.
I would like to implement focus follows mouse so that when I move my mouse over the plot I can immediately zoom in or out using my scroll wheel without first clicking on the plot to give it the focus.
Similarly when I move my mouse over the left settings , the top events or the bottom data panes I would like to be able to immediately scroll the window using the scroll wheel without first clicking on the window.
Currently I defined a function:
def focusFollowsMouse(window):
window.Bind(wx.EVT_ENTER_WINDOW, lambda event: window.SetFocus())
I would like to apply this function only on the four top-level panes: plot, settings, events and data.
However I need to call this function for each sub-panel or control in each of the top-level panes to get this to work. For example I need to apply this function individually to the Measurement Settings, Analysis Parameters, View Settings etc. panels.
Most likely the EVT_ENTER_WINDOW
event is not propagated to parent windows.
Is there a way to get this to work without applying focusFollowsMouse
to each and every sub-panel or control?
Thanks
This is Windows' behaviour - it works as you expect under GTK. Personally, I'd leave your app as it is, for consistency with other Windows applications, and install WizMouse
这篇关于wxPython中的焦点跟随鼠标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!