PyGObject에 GtkSourceView 위젯이있는 Glade 파일을 사용하려고합니다.PyGObject에서 GtkSourceView를 사용하여 Glade에서 GUI로드
from gi.repository import Gtk, GtkSource
from os.path import abspath, dirname, join
WHERE_AM_I = abspath(dirname(__file__))
class MyApp(object):
def __init__(self):
self.builder = Gtk.Builder()
self.glade_file = join(WHERE_AM_I, 'test.glade')
self.builder.add_from_file(self.glade_file)
if __name__ == '__main__':
try:
gui = MyApp()
Gtk.main()
except KeyboardInterrupt:
pass
내가 그 파일 I을 실행하면 : 나는 습지 PyGObject에서 있음을로드 할 때 http://cjenkins.wordpress.com/2012/05/08/use-gtksourceview-widget-in-glade/
문제는 : 나는 습지의 새로운 GtkSourceView 3.0을 사용하여 시작하는 방법에 대한 약간의 가이드를 작성했습니다 이 오류를 가지고 :
Traceback (most recent call last):
File "test.py", line 15, in <module>
gui = MyApp()
File "test.py", line 11, in __init__
self.builder.add_from_file(self.glade_file)
File "/usr/lib/python2.7/dist-packages/gi/types.py", line 43, in function
return info.invoke(*args, **kwargs)
gi._glib.GError: Invalid object type `GtkSourceView'
숲 사이의 빈터 파일 (test.glade은) 그것을에서 GtkSourceView 위젯과 바로 창입니다 :
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtksourceview 3.0 -->
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<object class="GtkSourceView" id="gtksourceview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="tab_width">4</property>
<property name="auto_indent">True</property>
<property name="indent_on_tab">False</property>
</object>
</child>
</object>
</interface>
이 문제를 해결하는 방법은 지금 당장 알 수 없습니다. add_from_file()을 호출하기 전에 어떤 타입을 등록해야한다고 생각합니까? 어떤 생각이라도 환영합니다.
내가 사용 :
- 우분투 정밀 12.04
- 습지 3.12.0
- libgtksourceview 3.0
- GTK + 3.0
종류는 내가 생각