Way to call NiceLabel 2019 from Python 3 scripts?

Label printing integration (NiceWatch middleware and ActiveX programming interface)

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
declark
Newcomer
Posts: 2
Joined: Fri Nov 19, 2021 10:27 pm

Way to call NiceLabel 2019 from Python 3 scripts?

Post by declark » Fri Nov 19, 2021 11:19 pm

We have been using NiceLabel5 on a system running a Python 2.7 program for a long time.
I need to upgrade to Windows 10 and because Python 2.7 is no longer supported, we are going to move to Python 3.9.
Unfortunately, the code uses win32com which works fine with NiceLabel5, but not with NiceLabel 2019. I'd like to use one of our NiceLabel 2019 licenses to move this system to a supported version too.
The easiest way would be if NiceLabelPrint could print a label from a command line call using standard Python modules on a Windows box. I see that was proposed several years ago as a wishlist item. Did that ever come about? Being able to run a JOB file from command line would be great.
This program talks to more than just a printer and IronPython as distributed looks like it is for NiceLabel to use for scripting, not as a standalone interpreter. Do I read that correctly?
There is a Python library, pythonnet that gives CLR .NET support. Will that suffice to use the .NET API for NiceLabel 2019? If so, do you have any implementation examples or advice?

Sorry for the volume of questions, I have worked with a lot of systems, but Windows .NET isn't one of them, yet.

Be well,
DLC

User avatar
Mytch
NiceLabel Support
NiceLabel Support
Posts: 262
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin
Contact:

Re: Way to call NiceLabel 2019 from Python 3 scripts?

Post by Mytch » Wed Nov 24, 2021 6:54 pm

declark,

NiceLabel 2019.3.1 includes IronPython 2.7.9 implementation which can be used for additional scripting logic within NiceLabel files using .NET Framework or Python libraries (standard or external). It's not intended to be used for interfacing with NiceLabel files from external sources like some third-party command-line tool. I recommend checking this article for some basic information about our Python implementation and common usage:
https://help.nicelabel.com/hc/en-001/ar ... -NiceLabel

If you want to know about IronPython and .NET integration, it's best to check directly from the source:
https://ironpython.net/documentation/dotnet/
https://github.com/IronLanguages/ironpython2

If you still wish to initiate NiceLabel print jobs from an external application, please consider looking into NiceLabel Automation:
https://www.nicelabel.com/designer-and- ... /integrate
https://www.nicelabel.com/label-managem ... d-printing
https://help.nicelabel.com/hc/en-001/ar ... Automation

You can send some signal (Serial, TCP, SQL, File, HTTP, and others..) to NiceLabel Automation and print any label to any printer with any data you need. You can execute any other Python/.NET function from Automation or complete other actions like record print history, check print status, send response back, etc.

Hope this helps.

Mytch

declark
Newcomer
Posts: 2
Joined: Fri Nov 19, 2021 10:27 pm

Re: Way to call NiceLabel 2019 from Python 3 scripts?

Post by declark » Tue Nov 30, 2021 4:43 pm

Mytch,

Thank you for the information.

The Python program calling NiceLabel handles other instruments and database access, some tools are Python release specific so running IronPython within NiceLabel is not going to work.
Our site does not license NiceLabel Automation so that presents a support problem.
The Pythonnet (.NET) package currently does not work with Python 3.9 and newer so that path is closed as well.

Computers! The simplest things get complicated quickly.
So, it looks like I'll be taking a roundabout path and craft a C# command line app for NiceLable .NET that I can call from our Python app. Based upon some of your example .NET apps for C#, that seems like the path of least resistance right now.

be well,
DLC

Post Reply