在哪里可以找到用于打印杯子的Pycups模块的文档?

发布于 2025-01-25 00:37:54 字数 349 浏览 2 评论 0原文

我正在使用Python杯模块列出可用目的地。一切正常。我已经使用pycups使用sudo apt-get安装pycups

import cups

conn = cups.Connection()
printers = conn.getPrinters()
for p in printers:
    print(p)
    print(printers[p],["device-uri"])

问题在于,我找不到该模块的文档,可以使用哪些方法,因此可以实现其他功能。

您有一个我可以在哪里找到文档的想法吗?

I am using the python cups module to list the available destinations. And everything work perfectly. I've installed the pycups using sudo apt-get install pycups.

import cups

conn = cups.Connection()
printers = conn.getPrinters()
for p in printers:
    print(p)
    print(printers[p],["device-uri"])

The problem is that I am not finding a documentation for this module and what are the methods that can be used so can implement other functionalities.

Do you have an idea where I can find the documentation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

蓝天白云 2025-02-01 00:37:54

I ran into the same problem. There is one example in their github and that's all I could find. You should probably poke around with a python debugger to learn how the library works.

溺孤伤于心 2025-02-01 00:37:54

您可以在Python解释器中使用内置帮助函数:

>>> import cups
>>> help(cups)
# shows auto-generated documentation for cups module

You can use built-in help function in python interpreter:

>>> import cups
>>> help(cups)
# shows auto-generated documentation for cups module
烦人精 2025-02-01 00:37:54

您可以使用上述答案中提到的内置帮助功能。
这是使用Pycups PrintFile需要4个参数打印文件的示例

 |  printFile(...)
 |      printFile(printer, filename, title, options) -> integer
 |      
 |      Print a file.
 |      
 |      @type printer: string
 |      @param printer: queue name
 |      @type filename: string
 |      @param filename: local file path to the document
 |      @type title: string
 |      @param title: title of the print job
 |      @type options: dict
 |      @param options: dict of options
 |      @return: job ID
 |      @raise IPPError: IPP problem


我通过了一个空词典,因为它是必要的,而且我正在使用第一个可用打印机

import cups
conn = cups.Connection ()
printers = conn.getPrinters ()
# printers is a dictionary containing information about all the printers available

emptyDict = {}
AvailablePrinters = list(printers.keys())
PrinterUsing = AvailablePrinters[0]
conn.printFile(PrinterUsing, "./FileName", "title", emptyDict)

You can use the built-in help function mentioned in the above answer.
Here is an example of printing a file using pycups

 |  printFile(...)
 |      printFile(printer, filename, title, options) -> integer
 |      
 |      Print a file.
 |      
 |      @type printer: string
 |      @param printer: queue name
 |      @type filename: string
 |      @param filename: local file path to the document
 |      @type title: string
 |      @param title: title of the print job
 |      @type options: dict
 |      @param options: dict of options
 |      @return: job ID
 |      @raise IPPError: IPP problem

printFile needs 4 parameters.
I passed an empty dictionary because it was necessary and also I am using the first available printer

import cups
conn = cups.Connection ()
printers = conn.getPrinters ()
# printers is a dictionary containing information about all the printers available

emptyDict = {}
AvailablePrinters = list(printers.keys())
PrinterUsing = AvailablePrinters[0]
conn.printFile(PrinterUsing, "./FileName", "title", emptyDict)
悍妇囚夫 2025-02-01 00:37:54

Pycups-1.9.51的文档: 文档

Documentation for pycups-1.9.51: Documentation

甜警司 2025-02-01 00:37:54

关于选项参数,我经常使用:
{“侧面”:“双面长边”,“ prettyprint”:“ true”}

您可以在人页面中找到其他键,“常见的作业选项”部分:
- man lpr
- localhost:631/help/help/hand man-lpr.html

About the options argument, I often use:
{"sides": "two-sided-long-edge", "prettyprint": "True"}

You can find other keys in man pages, "Common Job Options" section:
- man lpr
- localhost:631/help/man-lpr.html

萌化 2025-02-01 00:37:54

Pycups只是一座桥,您必须将其链接并使用。
创建一个Cups Conn对象,并使用带有该对象的Cups文档中可用的功能。

pycups is just a bridge, you have to link it and use.
Create a cups conn object and use the functions available in cups docs with that object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文