是否可以使用python制作xfce面板小程序?大多数(如果不是全部)面板小程序似乎都使用 C,所以我怀疑我是否能够这样做。
答案1
是的你可以。检查例如使用 Python/Javascript 开发 XFCE-PANEL-PLUGIN
这是 GtkSocket 和 GtkPlug 的示例:
#!/usr/bin/python
"""
General flow of program
Entry widget -> GtkPlug -> GtkSocket -> Window
"""
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import sys
def perform_embed_event(widget):
print("This will get called when plug will emit embedded signal")
# initialize GtkWindow
window = Gtk.Window()
# initialize GtkSocket
socket = Gtk.Socket()
# store socket id in socket_id variable
socket_id = socket.get_id()
print("socket", socket_id)
window.add(socket)
window.show()
# initialize GtkPlug
plug = Gtk.Plug.new(socket_id)
# Different Plug signals
plug.connect("embedded", perform_embed_event)
plug.connect("destroy", Gtk.main_quit)
print("Plug ID:", plug.get_id())
# Entry Widget
entry = Gtk.Entry()
entry.set_text("Xfce GSoC 2021")
# Add entry widget into plug
plug.add(entry)
plug.show_all()
Gtk.main()