这是我的应用程序的组织方式:
def __init__(self):
gladefile = "ui/gui.ui"
builder = gtk.glade.XML(gladefile,"gtk_main_window")
gtk_main_window = builder.get_widget("gtk_main_window")
Main_Window(gtk_main_window, builder)
Tree_View(builder)
TFIDF_Tab(builder)
VSM_Tab(builder)
gtk_main_window.show_all()
这是生成图表的代码:
if len(results_tfidf) >= 1:
if len(results_tfidf) > 300:
Main_Window.dialog.display("Too much words!")
else:
results_tfidf = collections.OrderedDict(sorted(results_tfidf.items(), key=lambda x : x[1], reverse=True))
self.plot = self.tf_idf_fig.add_subplot(111)
self.plot.cla()
self.plot.bar(*zip(*zip(count(), results_tfidf.values())))
self.plot.set_title("TF IDF Chart")
self.plot.set_xticklabels(results_tfidf.keys(),rotation='vertical',horizontalalignment='left')
labels = range(len(results_tfidf.keys()))
self.plot.set_xticks(labels)
self.plot.set_xlabel("Word")
self.plot.set_ylabel("TF*IDF")
self.tf_idf_canvas.draw()
else:
self.tf_idf_fig = Figure()
self.tf_idf_fig.subplots_adjust(bottom=0.20)
self.tf_idf_canvas = FigureCanvas(self.tf_idf_fig)
self.tf_idf_chart_vbox.pack_start(self.tf_idf_canvas)
self.tf_idf_toolbar = NavigationToolbar(self.tf_idf_canvas, self.tf_idf_chart_vbox)
self.tf_idf_chart_vbox.pack_start(self.tf_idf_toolbar,False,False, 3)
图像为
这是我得到什么样的错误:
Traceback (most recent call last):
File "/home/badc0re/Desktop/magisterska/twitter_dataset/code/TextAnalyzer/core/vsm_tab.py", line 18, in on_vsm_process_button_clicked
search_query = self.vsm_search_query.get_text()
AttributeError: 'VSM_Tab' object has no attribute 'vsm_search_query'
这是当我从 VSM_Tab(向量空间模型)调用方法“on_vsm_process_button_clicked”时,我不知道为什么当我拥有每个类处理程序 self.builder.signal_autoconnect(self) 用于连接方法时我会丢失所有元素。