我正在尝试学习在 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 愉快!