clutter-gtk 和 clutter-gsk 的 Python 绑定

发布于 2024-12-14 04:54:23 字数 387 浏览 1 评论 0原文

我正在使用 python,想要在混乱阶段嵌入 gtk3 小部件。但是,似乎 pyclutter-gtkpyclutter-gsk 已停止一段时间。我们可以在 python 中使用任何替代绑定吗? 我尝试谷歌但没有运气。只有一个项目(http://code.google.com/p/pyclutter-widgets/)看起来很有趣,但它已经一年不活跃了......

I'm using python and want to embed gtk3 widgets in clutter stage. However, it seems pyclutter-gtk and pyclutter-gsk has been stopped for a while. Is there any alternative binding that we can use in python?
I tried google but with no luck. There's only one project(http://code.google.com/p/pyclutter-widgets/) seems interesting but it's inactive for a year...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

银河中√捞星星 2024-12-21 04:54:23

gtk3 和 clutter 的所有 python 绑定都已移至基于内省的 pygobject;您应该能够通过简单地执行以下操作来使用 pygobject >= 2.30 中的 Clutter-Gtk 和 Clutter-Gst:

from gi.repository import GtkClutter

您可以按照 IntrospectionPorting 的 Gnome wiki 条目

All python bindings for gtk3 and clutter have been moved to the introspection-based pygobject; you should be able to use Clutter-Gtk and Clutter-Gst from pygobject >= 2.30 by simply doing:

from gi.repository import GtkClutter

You can follow the documentation on the Gnome wiki entry for IntrospectionPorting.

抹茶夏天i‖ 2024-12-21 04:54:23

以下是如何使用 Clutter-gtk 1.2.x 和 python-3.x 将 GtkClutter 阶段和滚动Actor 添加到 Gtk.HBox

from gi.repository import Gtk, Gdk, GtkClutter, Clutter   

class EmbeddedGtkClutterStageWithScrollActor(Gtk.Window): 

    def __init__(self):
        super(EmbeddedGtkClutterStage, self).__init__()

        # Initialise GtkClutter
        GtkClutter.init(sys.argv)


        self.connect('destroy', lambda w: Gtk.main_quit())

        self.set_default_size(1024, 768)
        self.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 1))

        display = Gdk.Display.get_default()
        screen = display.get_default_screen()
        css_provider = Gtk.CssProvider()

        css_provider.load_from_path('style.css')
        context = Gtk.StyleContext()
        context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) 


        hbox = Gtk.HBox(False, 2)
        vbox.add(hbox)

        # Create Clutter Stage 
        embed = GtkClutter.Embed()    

        hbox.add(embed)
        embed.set_size_request(900, 500)

        stage = embed.get_stage()
        # set stage color to black
        stage.set_color(Clutter.Color.new(0, 0, 0, 255))

        # Create a Scrollable Actor and add to the Stage
        scrollActor = Clutter.ScrollActor()

        scrollActor.set_scroll_mode(Clutter.ScrollMode.HORIZONTALLY)
        stage.add_actor(scrollActor)

        # scroll the scrollActor to x/y coords 
        point = Clutter.Point()
        point.x = 50
        point.y = 100
        scrollActor.scroll_to_point(point) 

        hbox.show_all()


EmbeddedGtkClutterStageWithScrollActor()
Gtk.main()

Here's how to add a GtkClutter stage and scrollActor to a Gtk.HBox with Clutter-gtk 1.2.x and python-3.x

from gi.repository import Gtk, Gdk, GtkClutter, Clutter   

class EmbeddedGtkClutterStageWithScrollActor(Gtk.Window): 

    def __init__(self):
        super(EmbeddedGtkClutterStage, self).__init__()

        # Initialise GtkClutter
        GtkClutter.init(sys.argv)


        self.connect('destroy', lambda w: Gtk.main_quit())

        self.set_default_size(1024, 768)
        self.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0, 0, 0, 1))

        display = Gdk.Display.get_default()
        screen = display.get_default_screen()
        css_provider = Gtk.CssProvider()

        css_provider.load_from_path('style.css')
        context = Gtk.StyleContext()
        context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) 


        hbox = Gtk.HBox(False, 2)
        vbox.add(hbox)

        # Create Clutter Stage 
        embed = GtkClutter.Embed()    

        hbox.add(embed)
        embed.set_size_request(900, 500)

        stage = embed.get_stage()
        # set stage color to black
        stage.set_color(Clutter.Color.new(0, 0, 0, 255))

        # Create a Scrollable Actor and add to the Stage
        scrollActor = Clutter.ScrollActor()

        scrollActor.set_scroll_mode(Clutter.ScrollMode.HORIZONTALLY)
        stage.add_actor(scrollActor)

        # scroll the scrollActor to x/y coords 
        point = Clutter.Point()
        point.x = 50
        point.y = 100
        scrollActor.scroll_to_point(point) 

        hbox.show_all()


EmbeddedGtkClutterStageWithScrollActor()
Gtk.main()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文