2011-11-07 48 views
1

我正在使用python並希望在雜亂的階段中嵌入gtk3小部件。但是,看起來pyclutter-gtkpyclutter-gsk已停止了一段時間。有什麼替代綁定,我們可以在Python中使用? 我試過谷歌,但沒有運氣。只有一個項目(http://code.google.com/p/pyclutter-widgets/)看起來很有趣,但它一年內沒有活動...Python綁定雜波-gtk和雜波-gsk

回答

1

所有針對gtk3和雜亂的python綁定已被移到內省 - 基於pygobject;你應該能夠使用整潔的GTK和整潔的消費稅從pygobject> = 2.30簡單地做:

from gi.repository import GtkClutter

您可以按照在Gnome wiki entry for IntrospectionPorting的文檔。

+0

感謝您的答覆Gtk.HBox。它適用於Clutter,但是當導入ClutterGtk時我得到了ImportError。僅供參考,我使用GNOME3和Python 2.7的Ubuntu 11.10。我已經安裝了libclutter-gtk-1.0 *。任何線索? –

+0

呃... ** GtkClutter **有效,但不是_ClutterGtk_。我想我已經安裝了gir1.2-gtkclutter-1.0。 –

0

下面是如何在GtkClutter階段,scrollActor添加到與雜波-GTK的1.2.x和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()