Python Forum
Problem with the printer function - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: Problem with the printer function (/thread-26764.html)



Printing a variable to local printer - scratchmyhead - May-12-2020

How can I print a variable to the local printer?


Problem with the printer function - scratchmyhead - May-12-2020

I'm trying to print data to the printer but get an error code: TypeError: to_printer() missing 1 required positional argument: 'text'
The code is below:


from tkinter import *
import tkinter as tk

root = Tk()
root.state('zoomed')
root.title('Hotel King Ver 1.8')


def to_printer(text):
    import subprocess
    lpr =  subprocess.Popen("/usr/bin/lpr", stdin=subprocess.PIPE)
    lpr.stdin.write(text)


print_button = tk.Button(root, text="print", command=to_printer)
print_button.pack()




root.mainloop()



RE: Printing a variable to local printer - Larz60+ - May-13-2020

google 'python printer dialog'


RE: Problem with the printer function - Larz60+ - May-13-2020

Merged with previous thread on same subject.
Please don't double post


RE: Problem with the printer function - YvonneAlsop - Oct-15-2020

Hello:) Have you solved this problem? I too have a problem with printer... I have no idea what to do, last month I wanted to buy for my family a quality home printer . I needed it for work, and the children needed it for school. I wanted to invest my money in a quality machine from a reliable brand. My boss suggested that I place an order on this service where quality office products are offered at a good price. These guys provide a wide selection of printers and cartridges. So I ordered one from , and now my family uses it every day! If you are still looking for a good printer, try checking out this website for more information!