Python 在热敏打印机上打印收据

Python 在热敏打印机上打印收据,python,tkinter,Python,Tkinter,我正在python上创建一个库存系统。我需要在所有销售完成后重新打印Recit。当我单击“保存”按钮时。我已经在使用mysql数据库了。它有销售和销售产品表 销售表由以下列组成–id、小计、工资、余额。 sales_products表由以下列组成–id、sales_id、item、Quantity、price、total。当我同时点击save按钮时,需要将数据保存到两个不同的表中。print recipt应该显示。我不知道如何将数据保存在多模块表中,我不知道如何将所有treeview保存在数据库

我正在python上创建一个库存系统。我需要在所有销售完成后重新打印Recit。当我单击“保存”按钮时。我已经在使用mysql数据库了。它有销售和销售产品表 销售表由以下列组成–id、小计、工资、余额。 sales_products表由以下列组成–id、sales_id、item、Quantity、price、total。当我同时点击save按钮时,需要将数据保存到两个不同的表中。print recipt应该显示。我不知道如何将数据保存在多模块表中,我不知道如何将所有treeview保存在数据库中。我在下面的save函数中得到了最后一个insert id


以下是我认为您应该如何进行接收

from tkinter import *

root = Tk()

def reciept():
    top = Toplevel()
    price1 = 3000
    qty1 = 3
    total1 = price1*qty1

    price2 = 5000
    qty2 = 4
    total2 = price1*qty2

    l = Label(top,text='---------RECIEPT----------')
    l.pack()
    heading = Label(top,text='PRICE\tQTY\tTOTAL')
    heading.pack()

    item1 = Label(top,text=f'{price1}\t{qty1}\t{total1}')
    item1.pack()

    item2 = Label(top,text=f'{price2}\t{qty2}\t{total2}')
    item2.pack()

b = Button(root,text='Print reciept',command=reciept)
b.pack(padx=10,pady=10)
root.mainloop()
\t
将在字母末尾添加4个空格

您可以将价格替换为
e1.get()
和所有内容

您也可以在此处使用
grid()
,但这可能会很麻烦,而且需要更多的行

希望你有个主意


干杯

要查看的代码太多了,发布代码区域,这是问题所必需的。现在检查我需要保存treeview数据treeview有项目、数量、价格,总计所有需要保存的行数据,然后打印receipt display for print您需要在终端中打印treeview数据作为收据,对吗?是的,人………treeview数据也需要保存在mysql数据库中。这我需要在GUI上打印tkinterget the print recipt for printya很好,谢谢。当我在打印机上自动看到打印视图打印时,我问Dim不确定如何在你的打印机上打印,也许可以问一个新的Q或谷歌它。
from tkinter import *

root = Tk()

def reciept():
    top = Toplevel()
    price1 = 3000
    qty1 = 3
    total1 = price1*qty1

    price2 = 5000
    qty2 = 4
    total2 = price1*qty2

    l = Label(top,text='---------RECIEPT----------')
    l.pack()
    heading = Label(top,text='PRICE\tQTY\tTOTAL')
    heading.pack()

    item1 = Label(top,text=f'{price1}\t{qty1}\t{total1}')
    item1.pack()

    item2 = Label(top,text=f'{price2}\t{qty2}\t{total2}')
    item2.pack()

b = Button(root,text='Print reciept',command=reciept)
b.pack(padx=10,pady=10)
root.mainloop()