简体   繁体   English

林间空地和pygtk(可能是字符集概率?)

[英]glade and pygtk (probably a charset prob?)

I am struggling with a problem, that is really driving me nuts. 我正在为一个问题而苦苦挣扎,那真的使我发疯。 I installed Pygtk-all-in-one Bundle version 2.24.2 for Python 2.7 [1] and Python 2.7.5 [2]. 我为Python 2.7 [1]和Python 2.7.5 [2]安装了Pygtk多合一捆绑包版本2.24.2。

Now I want to use gtk.builder to load my glade file. 现在,我想使用gtk.builder加载我的林间空地文件。

My python file looks like: 我的python文件看起来像:

#!/usr/bin/python
#-*- coding: utf-8 -*-

import sys
import gtk

import gtk.glade

class  QueryRelevanceEvaluationApp:

    def __init__(self):
        builder = gtk.Builder()
        builder.add_from_file("C:\blubb.glade")
        builder.connect_signals(self)

app = QueryRelevanceEvaluationApp()
gtk.main()

My glade file looks like: 我的林间空地文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <requires lib="gtk+" version="2.16"/>
  <!-- interface-naming-policy project-wide -->
  <object class="GtkWindow" id="window1">
    <property name="can_focus">False</property>
    <child>
      <placeholder/>
    </child>
  </object>
</interface>

If I run the application, I get the following error: 如果运行该应用程序,则会出现以下错误:

Process started >>>
Traceback (most recent call last):
  File "C:\Users\Bernhard\Documents\test\base2.py", line 16, in <module>
    app = QueryRelevanceEvaluationApp()
  File "C:\Users\Bernhard\Documents\test\base2.py", line 13, in __init__
    builder.add_from_file("C:\blubb.glade")
glib.GError: Datei ┬╗Clubb.glade┬½ konnte nicht ge├Âffnet werden: Invalid argument

However, If I rename "blubb.glade" to "hallo-welt2.ui" everyhing works fine. 但是,如果我将“ blubb.glade”重命名为“ hallo-welt2.ui”,则一切正常。 I am relatively new to Python, so I don't really know, what's causing the problem. 我是Python的新手,所以我真的不知道是什么原因引起的。 At first, I thought, that something with my Pygtk installation was wrong, but than I discovered the strange behaviour, that everything works fine, after renaming the file. 起初,我以为我的Pygtk安装有问题,但是我发现了奇怪的行为,在重命名文件后一切正常。 So I am thinking, that maybe something else (charset?) is causing the problem. 所以我在想,也许是其他原因(字符集?)引起了问题。 I am working on a Windows 7 64 bit machine (my system language is german). 我正在Windows 7 64位计算机上工作(我的系统语言是德语)。

It would be really nice, If someone could give me a hint on how I can solve this problem. 如果有人可以给我一些有关如何解决此问题的提示,那将非常好。

Thanks in advance! 提前致谢!

Greetings from Austria 来自奥地利的问候

[1] http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi [1] http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi

[2] http://www.python.org/download/releases/2.7.5/ [2] http://www.python.org/download/releases/2.7.5/

\\b is a backspace character, AFAIR; \\b是退格字符AFAIR; you should escape the backslash: 您应该避免使用反斜杠:

>>> print "C:\blubb.glade"
Clubb.glade
>>> print "C:\\blubb.glade"
C:\blubb.glade

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM