【发布时间】:2018-05-03 10:01:57
【问题描述】:
使用 Python,我正在尝试创建一个将打印条形码标签的 exe。这将与 BarTender 标签软件交互。我知道这是可能的,但我是 Python 新手,不知道该怎么做。 我在 C# 中有它,但我需要转换为 Python。对于懂两种语言的人来说,这会是一个简单的转换吗?)
// Declare a BarTender application variable
BarTender.Application btApp;
// Declare two BarTender document variables
BarTender.Format btFormat1;
BarTender.Format btFormat2;
// Create a new instance of BarTender
btApp = new BarTender.Application();
// Set the BarTender application visible
btApp.Visible = true;
// Open a BarTender document
btFormat1 = btApp.Formats.Open("c:\\Format1.btw", false, "");
// Open a second BarTender document
btFormat2 = btApp.Formats.Open("c:\\Format2.btw", false, "");
// Set focus to the first opened document
btFormat1.Activate();
// End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
目前为止
import win32.com.client
btApp = win32com.client.Dispatch("BarTender.Application")
btApp.Visible = 1
btFormat = btApp.Formats.Open(r"C:\Users\kmoe\Desktop\Print-Self_Labels.btw", false, "")
第一个参数是必需的,是一个字符串,包含要打开的文档的路径和文件名。第二个参数是一个布尔值:如果为真,该方法将关闭名为“Document1”的默认空白文档,BarTender 在启动时会自动打开该文档。它不能关闭具有任何其他名称的文档。第三个参数指定要使用的打印机。
但是,这只会打开正确的标签模板,而不会打印到默认打印机
更多信息可以在这里找到
提前致谢!
【问题讨论】:
-
继续下去,看起来你没有更多的代码要写,几乎可以肯定不需要我们的帮助来完成它
-
我刚刚搜索了
python barcode,第一个结果是:pypi.org/project/python-barcode -
嗨 Samuel,我确实找到了该页面,但据我了解,这将帮助我创建新标签,但不会与 BarTender 交互。我必须能够使用新的和现有的 BarTender .btw 模板。花了一段时间,但还没有破解实际的打印部分!
标签: c# python win32com bartender