Glade和弃用的gtk属性 [英] Glade and deprecated gtk properties

查看:197
本文介绍了Glade和弃用的gtk属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试运行一个软件,在那里我通过Glade构建了UI。 Glade然后在XML文件中转换UI,然后在Python中加载该文件。



但是我遇到了gtk对象的(可能)不推荐使用的属性问题。
这就是解释器所说的:

 未知属性:GtkScrolledWindow.min-content-width 
self .__ builder.add_from_file('UI2.glade')
/home/jimmy/Documenti/linguaggi_dinamici/progetto/collega_GUI.py:37:GtkWarning:未知属性:GtkScrolledWindow.min-content-height
self。 __builder.add_from_file('UI2.glade')
/home/jimmy/Documenti/linguaggi_dinamici/progetto/collega_GUI.py:37:GtkWarning:未知属性:GtkBox.margin-left
self .__ builder.add_from_file ('UI2.glade')
/home/jimmy/Documenti/linguaggi_dinamici/progetto/collega_GUI.py:37:GtkWarning:未知属性:GtkBox.margin-right
self .__ builder.add_from_file('UI2 .glade')
/home/jimmy/Documenti/linguaggi_dinamici/progetto/collega_GUI.py:37:GtkWarning:未知属性:GtkBox.margin-bottom
self .__ builder.add_from_file('UI2.glade' )

(main.py:4490):GLib-GObject-ERROR **:无法创建抽象实例(非实例化能够)类型'GtkBox'
跟踪/断点陷阱(核心转储)

我可以尝试删除GtkBox.margin-left-right-bottom,但我需要属性GtkScrolledWindow.min-content-height。



奇怪的是GtkScrolledWindow.min-content-width一直工作正常,因为我看不到任何警告。



:关于当前运行的Gtk和Glade版本的信息

  Glade:3.14.2 

collega_GUI.py

 尝试:
导入pygtk
pygtk.require(2.0)
除了:
通过

尝试:
导入gtk
导入gtk.glade
除外:
print(GTK不可用)
sys.exit(1)

我跑了此命令来检索gtk的版本:

  dpkg -l libgtk [0-9] * | grep ^我

而我得到了

  2.24.20-1ubuntu1 


解决方案

glade-3.8.x系列是支持Gtk + 2的最新版本。 glade> 3.8.x目标Gtk + 3。 Ubuntu提供了包装3.8.x版本的 glade-gtk2 包,而 glade 包将最新的Gtk所以如果你的目标是Gtk + 2,你需要安装 glade-gtk2 和使用该版本的glade。



注意:类似于Fedora, glade 包装包含Gtk + 3版本,而 glade3 (并非真正的最佳名称)发布了Gtk + 2版本。


i've been trying to run a software where i've built the UI by Glade. Glade then transform the UI in an XML file, and then in Python i just load that file.

But i've a problem with (maybe) deprecated properties of gtk objects. This is what the interpreter says:

 Unknown property: GtkScrolledWindow.min-content-width
  self.__builder.add_from_file('UI2.glade')
/home/jimmy/Documenti/linguaggi_dinamici/progetto/collega_GUI.py:37: GtkWarning: Unknown property: GtkScrolledWindow.min-content-height
  self.__builder.add_from_file('UI2.glade')
/home/jimmy/Documenti/linguaggi_dinamici/progetto/collega_GUI.py:37: GtkWarning: Unknown property: GtkBox.margin-left
  self.__builder.add_from_file('UI2.glade')
/home/jimmy/Documenti/linguaggi_dinamici/progetto/collega_GUI.py:37: GtkWarning: Unknown property: GtkBox.margin-right
  self.__builder.add_from_file('UI2.glade')
/home/jimmy/Documenti/linguaggi_dinamici/progetto/collega_GUI.py:37: GtkWarning: Unknown property: GtkBox.margin-bottom
  self.__builder.add_from_file('UI2.glade')

(main.py:4490): GLib-GObject-ERROR **: cannot create instance of abstract (non-instantiatable) type 'GtkBox'
Trace/breakpoint trap (core dumped)

I could try to remove GtkBox.margin-left-right-bottom, but i need the property GtkScrolledWindow.min-content-height.

The strange thing is that GtkScrolledWindow.min-content-width has been working corretcly, because i can't see any WARNING about that.

EDIT :: informations about Gtk and Glade versions currently running

Glade: 3.14.2

collega_GUI.py

try:  
    import pygtk  
    pygtk.require("2.0")  
except:  
    pass  

try:  
    import gtk  
    import gtk.glade  
except:  
    print("GTK Not Availible")
    sys.exit(1)

I ran this command to retrieve the version of gtk:

dpkg -l libgtk[0-9]* | grep ^i

and i got

2.24.20-1ubuntu1

解决方案

The glade-3.8.x series is the last version supporting Gtk+2. glade > 3.8.x targets Gtk+3. Ubuntu provides the glade-gtk2 package which packages the 3.8.x version, whereas the glade package packages the latest, Gtk+3 only version.

So if you are targeting Gtk+2, you need to install glade-gtk2 and use that version of glade.

Note: similarly on Fedora, the glade package ships the Gtk+3 version, whereas the glade3 (not really an optimal name) ships the Gtk+2 version.

这篇关于Glade和弃用的gtk属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆