![](/img/trans.png)
[英]I am getting a syntax error on line 42(4th last line) and I cant fix it can someone please help?
[英]Can someone please edit this i keep getting a syntax error on line 13
class Tux(gtk.Window):
def __init__(self):
super(Tux, self).__init__()
combobox = gtk.combo_box_new_text()
combobox.connect("changed", self.on_changed)
for choice in choices:
combobox.append_text(choice)
self.add(combobox)
self.label = gtk.Label("No selection")
self.add(self.label)
img = gtk.Image( )
img.set_from_file(“Tux image.png”)
self.add(img)
self.connect("destroy", gtk.main_quit)
self.show_all()
def on_changed(self, widget):
self.label.set_label(widget.get_active_text())
Tux()
gtk.main()
img.set_from_file(“Tux image.png”)
像大多數編程語言一樣,Python不支持特殊引號(可能由文字處理器插入)。 而是使用"
或'
。
在線:
img.set_from_file(“Tux image.png”)
您應該使用(“)或(')符號,而不是(”)。
class Tux(gtk.Window):
def __init__(self):
super(Tux, self).__init__()
combobox = gtk.combo_box_new_text()
combobox.connect("changed", self.on_changed)
for choice in choices:
combobox.append_text(choice)
self.add(combobox)
self.label = gtk.Label("No selection")
self.add(self.label)
img = gtk.Image( )
img.set_from_file("Tux image.png")
self.add(img)
self.connect("destroy", gtk.main_quit)
self.show_all()
def on_changed(self, widget):
self.label.set_label(widget.get_active_text())
Tux()
gtk.main()
未來的注意事項:使用真實的編程編輯器來編寫代碼,而不是MS Word。 Word會改變您的輸入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.