【问题标题】:Is there a function that can send event to other window in pygtk or other libry是否有可以将事件发送到 pygtk 或其他库中的其他窗口的功能
【发布时间】:2016-03-18 07:49:57
【问题描述】:

我正在尝试编写一个可以控制其他窗口的应用程序,例如linux 上的terminal。我发现xlib 的send_event 函数可以做到这一点,但xlib 是X 窗口服务器的低级API,不太好用。

我看过PyGTK的api,知道是基于xlib的,但是没找到send_event这样的函数,可能是我漏掉了。是否有可以将event 发送到PyGTK 或其他库中的其他窗口的功能?

【问题讨论】:

    标签: python pygtk xlib


    【解决方案1】:

    如果你有窗口 id,你可以这样做:

    from gtk import gdk
    
    window = gdk.window_foreign_new(0x...) # Replace ... with the hexadecimal ID
    window.move(0, 0) # Moves window to the top-left corner
    window.fullscreen()
    

    玩得开心!

    【讨论】:

      猜你喜欢
      • 2021-02-26
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 2023-02-03
      • 2014-02-06
      • 1970-01-01
      • 2013-08-20
      • 1970-01-01
      相关资源
      最近更新 更多