![我在编写我的第一个应用程序时遇到错误,如开发人员入门教程中所示](https://linux22.com/image/963310/%E6%88%91%E5%9C%A8%E7%BC%96%E5%86%99%E6%88%91%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E6%97%B6%E9%81%87%E5%88%B0%E9%94%99%E8%AF%AF%EF%BC%8C%E5%A6%82%E5%BC%80%E5%8F%91%E4%BA%BA%E5%91%98%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B%E4%B8%AD%E6%89%80%E7%A4%BA.png)
我正在尝试学习在 ubuntu 中开发应用程序,目前正在经历本教程。
如视频所示,我正在编写以下给定的代码:
self.refreshbutton = self.builder.get_object("refreshbutton")
def on_refreshbutton_clicked(self, widget):
print "Refresh"
当我尝试运行我的应用程序时,它给出了一个错误:
我输入此命令来运行我的应用程序:quickly run
(trickybrowser:4418): Gtk-WARNING **: Theme parsing error: gtk-widgets.css:1971:11: Not using units is deprecated. Assuming 'px'.
(trickybrowser:4418): Gtk-WARNING **: Failed to parse /usr/share/themes/mac-os-lion-theme-v2/gtk-3.0/settings.ini: Key file contains line '/* ' which is not a key-value pair, group, or comment
Traceback (most recent call last):
File "bin/trickybrowser", line 32, in <module>
import trickybrowser
File "/home/tricky/trickybrowser/trickybrowser/__init__.py", line 14, in <module>
from trickybrowser import TrickybrowserWindow
File "/home/tricky/trickybrowser/trickybrowser/TrickybrowserWindow.py", line 32
print "Refresh"
^
IndentationError: expected an indented block
答案1
记住缩进:
self.refreshbutton = self.builder.get_object("refreshbutton")
def on_refreshbutton_clicked(self, widget):
print "Refresh"
答案2
(trickybrowser:4418): Gtk-WARNING **: Theme parsing error: gtk-widgets.css:1971:11: Not using units is deprecated. Assuming 'px'.
(trickybrowser:4418): Gtk-WARNING **: Failed to parse /usr/share/themes/mac-os-lion-theme-v2/gtk-3.0/settings.ini: Key file contains line '/* ' which is not a key-value pair, group, or comment
这 2 个 Gtk-WARNINGS 是由于 mac-os-lion 主题的 settings.ini 文件和 gtk-widgets.css 中存在一些错误造成的。
为了纠正这些问题,
sudo gedit /usr/share/themes/mac-os-lion-theme-v2/gtk-3.0/settings.ini
.
用于#
评论,而不是\* .. */
# # 作者:mbossg # 网站:http://mbossg.deviantart.com # 许可证:GPL # 描述:专为 gtk3 应用程序制作的简约且实用的主题。 #
sudo gedit /usr/share/themes/mac-os-lion-theme-v2/gtk-3.0/gtk-widgets.css
.
转到第 1971 行并替换padding: 8;
为padding: 8px;
就是这样。Gtk 不再发出警告。祝您使用 mac-os-lion-theme 愉快!