我更新了这个问题,现在我知道(多亏了Brody CritchLow),Gtk的打印机产品已经停产了。我发现了一个名为cups
的模块,我正试图使用它来打印,但在尝试设置作业时遇到了一个错误。这是我的密码:
import cups
import cupshelpers
connection = cups.Connection()
printers = cupshelpers.getPrinters(connection)
for printer in printers:
# print(cupshelpers.Printer("asdf", "asdf").setJobSheets("Hello!", "Boodoaefrw"))
print(printer)
print(printers[printer].setJobSheets("Hello!", "Boodoaefrw"))
printers[printer].setAccepting(True)
错误是:
Traceback (most recent call last):
File "/home/sam/programs/python/testing/problem.py", line 9, in <module>
print(printers[printer].setJobSheets("Hello!", "Boodoaefrw"))
File "/usr/lib/python3/dist-packages/cupshelpers/cupshelpers.py", line 313, in setJobSheets
self.connection.setPrinterJobSheets(self.name, start, end)
cups.IPPError: (1025, 'Forbidden')
有人能告诉我我做错了什么吗?如果有帮助的话,我正在Ubuntu 20.04上使用Python 3.8
我知道了!使用
cups
模块,您可以获得可用打印机的列表,选择一个,然后将文件打印到其中!以下是一个例子:我假设你也可以打印PDF和其他东西,但是文本文件对我来说很有用。如果我在
printer.connection.printFile()
函数中找到有关options
字典的任何信息,我将更新此答案注意:不保证这在Windows上有效。如果你有一个窗口,你可能想看看Brody Critchlow的答案
你不能用win32print吗
你要做的就是
虽然如果您需要使用GTK,我认为所有的打印选项都已停止
推理:
编辑:
GTK文档上唯一有效的打印操作是https://athenajc.gitbooks.io/python-gtk-3-api/content/gtk-group/gtkprintsettings.html
相关问题 更多 >
编程相关推荐