问题标签 [platypus]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - 如何让 Platypus 创建的 shell 应用程序响应键盘命令?
使用 Platypus,我创建了一个运行以下 shell 脚本的简单应用程序:
“Music.py”脚本在无限循环中运行,不断地从大约 80 个 URL 中选择一个,使用 chromedriver 在 Selenium 上加载。每个 URL 加载一首特定的歌曲,当歌曲播放完毕后,Python 脚本会在可能的歌曲 URL 数组中随机选择另一个位置并加载相应的歌曲(因此它基本上会随机播放给定的播放列表)。
可以使用命令暂停播放kill -STOP [pid]
并使用命令恢复播放kill -CONT [pid]
。但是,我希望能够通过单击 Mac 扩展坞上的“Music.app”图标(以将此应用程序置于前台并确保它接收所有击键)并使用键盘快捷键来暂停它。
经过一番试验,我发现通过运行命令:
在我的普通命令行中,我可以分别使用 Ctrl + P 和 Ctrl + R 暂停和恢复进程。但是,当我在 shell 脚本的开头添加这些行时,键盘快捷键仍然没有在应用程序中执行任何操作(击键实际上并未在 shell 脚本中注册)。虽然我可以使用我的默认命令行暂停/播放音乐,但我的目标是创建一个用户友好且完全可移植的应用程序,我希望用户可以完全操纵程序而无需与应用程序本身进行交互.
所以,我的问题是,如何将这些键盘快捷键添加到应用程序本身(由 Platypus.app 创建,基本上只是运行一个 shell 脚本)?如果这很重要,我正在使用 MacOS High Sierra 10.3.5。总的来说,我绝对是编程新手,对 shell 没有过多的经验,以前从未使用过 Platypus.app,所以我对此不熟悉,不知道我想要的是否真的可行。任何帮助表示赞赏。
谢谢!
python - Python reportLab 鸭嘴兽:底部图像
我正在使用 reportlab 库,我对使用 SimpleDocTemplate 添加图像有疑问。
我有动态内容,我不知道它占用了多少空间。发生的事情是我想在页面底部添加一个徽标(总是在同一个地方)。我这样做的方式是将内容添加到列表中:例如[文本、间隔、表格、间隔、徽标],然后构建它。徽标的位置取决于其他变量。
你能帮我完成这个行为吗?
我知道这可以使用绝对定位来完成(例如在画布类中使用 drawImage),但我不知道如何将我的操作方式与此结合起来。
提前致谢
python - 如何使用reportlab在图像顶部覆盖文本超链接?
我正在尝试创建一个包含许多页面的 pdf 文档。每个页面都包含一个图像,其顶部显示带有指向其他页面的超链接的文本。
我已经设法使用reportlab.pdfgen
矩形链接来做到这一点,不幸的是,使用的阅读器(电子阅读器)无法识别这种类型的链接。
取而代之的是,我设法创建了文本嵌入的超链接(使用如何使用 reportlab 添加到单词的链接?),我的电子阅读器可以识别这些超链接,但我没有设法将它们覆盖在图像上。
我尝试使用这篇文章中提供的解决方案(reportlab: add background image by using platypus)来使用图像作为背景,但它不起作用。当我将文档的页面大小设置为图像大小时,不会显示该段落。当我将其设置为大于图像大小时,该段落显示在图像上方而不是覆盖它。
这是我的代码:
PS:此代码不完整(不会创建多个页面等),但只是尝试在图像上覆盖文本嵌入超链接的最小示例。
python - 使用 ReportLab 处理大型 PDF 所需的时间呈指数级增长
我ReportLab
用于生成 PDF 报告,下面是相同的代码。问题是,对于 X 个页面,它需要 T 时间,但是对于 2X 个页面,它需要的时间远远超过 2T 时间。由于我需要生成可能多达 35000 页的 PDF,因此很麻烦。我能做些什么来规避这个问题。
python - 如何在 Python 中将布尔值列表转换为实际值?
我在 Python 中使用鸭嘴兽。问题是,在优化之后,当我需要查看变量时,它会以布尔格式显示它们。
当我将变量类型更改为“Real”时,变量结果显示为实数,但当我选择“Integer”类型时,它显示为布尔值。这就是其中一个人的样子:
在进入函数之前,它们是整数(我是故意这样做的),但是在进入函数之后,变量变成了整数和实数的混合体。
python - Reportlab:为什么两列输出恢复为单列?
我想在 Reportlab 中生成两列页面。附加程序(改编自各种示例)生成两列两页,然后生成单列页。
我尝试为第一页和后续页面创建多个页面模板。这不会改变输出。
我在“Story.append(p)”之后添加了以下内容,看看它是否是一种解决方法:
现在,第 1 页和第 2 页是两列,第 3 页是一列,第 4 页和第 5 页是两列。
python-3.x - Reportlab - Truncating text after specific width while writing on canvas
I am working on a project which has a PDF editor that we have built in angular. User can drag and drop dynamic fields (user defined fields) on the PDF. These fields when are filled from a user define form, the corresponding PDF (that user has edited) gets generated in the backend. We are using Python 3.7 and Reportlab to edit and write dynamic data to the PDF.
The length of the value dynamic fields is not fixed. It can be more than the field variable's length. On PDF editor, the user decides max width of the generated dynamic text. We want to write the text till the specified width only and truncate rest of the text. For example, first_name is the variable dropped on the PDF editor. It's max width is set to 10px. If the value of the variable is "Wolfeschlegelsteinhausenbergerdorff", the text should be written till 10 px and should get truncated after that.
So far, we have managed to write the full text (irrespective of width specified). Following is the code that we are using.
Above code writes full text on the PDF. However, we need a way to somehow truncate the text after specified width.
Any help is greatly appreciated.