为什么会提示NameError: global name 'gtk_entry_set_text'
#!/usr/bin/python
# coding=utf8
import sys #导入sys模块
import gtk #导入gtk模块
import gtk.glade
import pygtk
import os
class first_window_view:#定义类
def on_window_destroy(self, widget, data=None): #函数事件
gtk.main_quit() #反映
def on_imagemenuitem5_activate(self,widget,data=None):
gtk.main_quit()
def on_button1_clicked(self,widget,data=None):
print 'ok!'
gtk_entry_set_text(GTK_ENTRY(entry1),"测试!")
def on_entry1_changed(self,widget,data=None):
print "okle!"
def __init__(self):
builder = gtk.Builder()
builder.add_from_file("first_window_view.glade")
self.window = builder.get_object("window")
builder.connect_signals(self)
if __name__ == "__main__":
editor = first_window_view() #执行块
editor.window.show()# 显示
gtk.main()#执行主程序
运行挺正常,就是在点击按扭后不能执行,提示:
Traceback (most recent call last):
File "first_window_view.py", line 15, in on_button1_clicked
gtk_entry_set_text(GTK_ENTRY(entry1),"测试!")
NameError: global name 'gtk_entry_set_text' is not defined
python不会,没办法帮你了~ 控件.set_text ();
python是面向对象的
页:
[1]