【发布时间】:2021-12-03 15:57:06
【问题描述】:
我正在尝试制作一个 python 项目,它是一个员工管理系统,我在其中使用各种 python 库,如 tkinter、sqlite3(连接数据库)、matplotlib。在提议的项目中,我们可以为员工添加、查看、更新、删除和绘制图表。我面临的问题是图表。图表代码如下
from tkinter import *
from tkinter.messagebox import *
from tkinter.scrolledtext import *
from sqlite3 import *
import matplotlib.pyplot as plt
def graphback():
graph_window.deiconify()
main_window.withdraw
def graph():
con = None
try:
con = connect(project.db)
cursor = con.cursor()
sql = "select * from employee"
cursor.execute(sql)
data = cursor.fetchall()
name = []
salary = []
plt.plot(name, salary)
plt.title("Highest Salaried Employee")
plt.show
except Exception as e:
showerror("issue ", e)
con.rollback()
finally:
if con is not None:
con.close()
def mgraph():
main_window.deiconify()
graph_window.withdraw()
我在运行代码时无法获取图表。我应该怎么做才能运行代码?
【问题讨论】:
-
您可能想查看official docs,了解如何将
matplotlib嵌入tkinter。
标签: python sqlite matplotlib tkinter