代码中很少有需要注意的锚点。update_observation()每次下拉值更改时都会更新该函数。我希望图表也随着下拉列表值的变化而变化。我希望在任何时候都只需要一个图形窗口实例。我想更新图形窗口内的信息。我尝试使用动画,但我相信使用 trace 方法可以替代它。该按钮只是用于打开和关闭窗口。它没有解决任何其他目的。它一直绑定到同一个窗口没有关闭。我如何artifact_graph_window在我的update_observation()函数中使用的值。def tab_two_load(self,tab1_open_observations): def update_observation(a,b,c): proj_name,mod_name = observation_project_value.get().split(" -- ") observations_fr_project = db.query_findings_by_project(proj_name,mod_name) ##CONFIG fig = Figure(figsize=(6,6)) a = fig.add_subplot(111) ## DATA x_cat = [x[1] for x in db.query_artifact()] x_cat = x_cat[:-2] y_count = {} for i in x_cat: y_count[i] = 0 for i in observations_fr_project: y_count[i[2]] = y_count[i[2]] + 1 print(y_count) x = y_count.keys() y = y_count.values() ## PLOT a.bar(x,y,color='blue') ## SHOW a.set_title ("Artifact Breakdown", fontsize=16) a.set_ylabel("Breakdown", fontsize=14) a.set_xlabel("Artifact Type", fontsize=14) a.yaxis.set_major_locator(MaxNLocator(integer=True)) ####################################### ''' GRAPH END ''' ####################################### canvas = FigureCanvasTkAgg(fig, master=artifact_graph_window) canvas.get_tk_widget().pack() canvas.draw() def artifact_graph(): artifact_graph_window = Toplevel(self) artifact_graph_window.title('Artifact Graph') button_graph_1.config(state='disable') proj_name,mod_name = observation_project_value.get().split(" -- ") observations_fr_project = db.query_findings_by_project(proj_name,mod_name)
添加回答
举报
0/150
提交
取消