May-23-2020, 06:56 PM
Does anyone know how to make your program print data from my program to the printer?
[Tkinter] How to print data to the printer
|
May-23-2020, 06:56 PM
Does anyone know how to make your program print data from my program to the printer?
May-23-2020, 09:37 PM
As an example you could use the following:
printText = your_widget_namet.get("1.0", END) print(printText) filename = tempfile.mktemp(".txt") open(filename, "w").write(printText) # Bellow is call to print text from your_widget_name textbox win32api.ShellExecute(0,"printto", filename, '"%s"' % win32print.GetDefaultPrinter(), ".", 0)
"Often stumped... But never defeated."
May-23-2020, 09:50 PM
OK. I'll try thanks.
May-26-2020, 12:56 PM
That didn't work.
May-26-2020, 01:43 PM
Please show your complete code and any errors received in the appropriate tags so it can be analysed, that will make it easier to see what you have done and what might be your issue.
"Often stumped... But never defeated."
May-27-2020, 04:58 PM
I get the following error code: NameError: name 'tempfile' is not defined
printText =Label(root, text="hello") print(printText) filename = tempfile.mktemp(".txt") open(filename, "w").write(printText) # Bellow is call to print text from your_widget_name textbox win32api.ShellExecute(0,"printto", filename, '"%s"' % win32print.GetDefaultPrinter(), ".", 0)
May-27-2020, 10:19 PM
Might be worth a look.
https://pypi.org/project/python-printer-escpos/
I welcome all feedback.
The only dumb question, is one that doesn't get asked. My Github How to post code using bbtags Download my project scripts
May-28-2020, 01:28 AM
I'm getting closer but still not working. I went to that link and installed all components. But when I try running the following code, I get this error: ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
printer = getNetworkPrinter()(host='192.168.0.1', port=8080) printer.text("Hello World") printer.lf()
May-28-2020, 04:46 AM
Are you going through a router? If so you may have to open a port to the printer.
I welcome all feedback.
The only dumb question, is one that doesn't get asked. My Github How to post code using bbtags Download my project scripts
May-28-2020, 12:07 PM
Yes the printer goes through a router.
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Problem with the printer function | scratchmyhead | 4 | 4,496 |
Oct-15-2020, 12:14 PM Last Post: YvonneAlsop |
|
setup epson lq350 dot matrix printer by python-printer-escpos | gray | 10 | 11,177 |
Jun-05-2017, 01:20 PM Last Post: sparkz_alot |
|
the rs232 printer is not working | gray | 10 | 10,901 |
May-17-2017, 09:21 AM Last Post: gray |