wxPython中的焦点跟随鼠标? [英] Focus-follows-mouse in wxPython?

查看:27
本文介绍了wxPython中的焦点跟随鼠标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含多个窗格的应用程序.请参阅情节.

  • 右侧的检测器面板是一个wx.Panel.
  • 我想实现焦点跟随鼠标,这样当我将鼠标移到绘图上时,我可以立即使用滚轮放大或缩小,而无需先单击绘图以使其成为焦点.

    同样,当我将鼠标移到左侧 settings 、顶部 events 或底部 data 窗格上时,我希望能够立即使用滚轮滚动窗口,无需先点击窗口.

    目前我定义了一个函数:

    def focusFollowsMo​​use(window):window.Bind(wx.EVT_ENTER_WINDOW, lambda 事件: window.SetFocus())

    我只想在四个顶级窗格中应用此功能:plotsettingseventsdata.

    但是,我需要为每个顶级窗格中的每个子面板或控件调用此函数才能使其工作.例如,我需要将此功能单独应用于测量设置分析参数查看设置等面板.

    EVT_ENTER_WINDOW 事件很可能没有传播到父窗口.

    有没有办法在不将 focusFollowsMo​​use 应用到每个子面板或控件的情况下使其工作?

    谢谢

    解决方案

    这是 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 of wx.Panels.
    • The top events pane is a wx.grid.Grid.
    • The bottom data pane is a wx.Panel that contains a wx.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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆