Python Forum
Problem with the printer function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with the printer function
#2
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()
Reply


Messages In This Thread
RE: Problem with the printer function - by Larz60+ - May-13-2020, 01:23 AM
Problem with the printer function - by scratchmyhead - May-12-2020, 09:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] How to print data to the printer scratchmyhead 11 8,090 Aug-20-2020, 08:12 PM
Last Post: StevenLee
  setup epson lq350 dot matrix printer by python-printer-escpos gray 10 9,181 Jun-05-2017, 01:20 PM
Last Post: sparkz_alot
  the rs232 printer is not working gray 10 8,857 May-17-2017, 09:21 AM
Last Post: gray

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020