2016-11-07 59 views
0

我編寫了一個PyGtk應用程序來控制Pi3上的某些特定功能。這個全屏GUI(通過2.8「TFT觸摸屏)是用戶必須與設備交互的所有設備,沒有鼠標,鍵盤,SSH,VNC等等,因爲需要用戶輸入I需要實現一種方式,當文本框獲得焦點時出現虛擬鍵盤,然後在焦點丟失時消失。我研究了許多虛擬鍵盤,並且唯一似乎提供Gtk支持的功能是佛羅倫薩。不能讓它自動顯示/隱藏在輸入文本框獲取/失去焦點。Python PyGtk虛擬鍵盤支持at-spi

佛羅倫薩依靠在-SPI框架來獲取事件通知。據「佛羅倫薩模式」(http://florence.sourceforge.net/english/usage.html

You should make sure your applications support at-spi if you intend to use Florence in hidden mode. 

The auto hide mode requires accessibility to be activated, which means the at-spi registry daemon is running and applications are using it. 

此外,根據FAQ(http://florence.sourceforge.net/english/how-to.html)的環境變量需要被設置。

export GTK_MODULES=gail:atk-bridge 

所以我配置佛羅倫薩自動隱藏模式,在-SPI下載,運行註冊表守護程序和設置環境變量,但沒有骰子。當GUI上的文本框聚焦時,鍵盤不會出現。

我想我有兩個問題。首先,我不以任何方式與佛羅倫薩聯繫,所以如果有另一個解決方案,我願意實施它。但其次,有一點我不清楚的是我如何讓PyGtk應用程序「支持at-spi」。除了環境變量,我如何確保我的應用使用at-spi?在這一點上,沒有任何文件是清楚的。

回答

0

我還沒有樹莓派(RPi),所以這個答案可能無法在RPi上運行。

它在Linux上工作,所以你可能想要在RPi上測試它。

我安裝了OnBoard(另一個支持DBus的虛擬鍵盤)。

確保您的OnBoard正在運行,但隱藏了虛擬鍵盤。

下面的代碼將控制虛擬鍵盤的可視性:

import dbus 

# initialize session bus, you can put the following lines into 
# your initialization block, or something or use a class 
sess_bus = dbus.SessionBus() 

# get the object proxy for the virtual keyboard, 
# won't work if OnBoard is not already running 
kbd = sess_buss.get_object('org.onboard.Onboard', 
          '/org/onboard/Onboard/Keyboard') 


# display virtual keyboard 
kbd.Show() 

# hide virtual keyboard 
kbd.Hide()