Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python plugin for CLCL clipboard manager

Write your own plugin for CLCL with Python

One of the main advantages of CLCL over other other clipboard managers ist the feature to include plugins to extend CLCL's functions. But the plugin architecture is based on C, and even for experienced C developers it is a tedious work to write a new plugin.
Python on the other hand is an easy-to-learn programming language.
Most CLCL plugins are text-based:

  • A text selection within an editor window is copied to the clipboard,
  • the copied text is somehow processed/modified and copied back to the clipboard,
  • the result overwrites the selected text in the editor.

tool_python enables users of CLCL to write such plugin in python and configure them.

tool_python comes with an example module example.py:

#Python plugin functions must take string as 
#input parameter and return a string:

def main(input_text: str = ""):
    ret = "Hello Python!"
    return ret # return to CLCL

def ToLower(s: str = ""):
    return s.lower()

def ToUpper(s: str = ""):
    return s.upper()

These functions are not very fancy, but will give you the idea.

Install tool_python

You have two possibilities to install:

  • Setup program:
    • Download setup_tool_python.exe and start it. As target path choose the same folder where your clcl.exe resides.
      The installer needs permission to download the Python embeddable package from www.python.org.
  • Manual install:
    • Download and unpack tool_python.zip into the same folder as clcl.exe (Default is C:\Program Files (x86)\clcl).
    • Download Windows embeddable package (32-bit).
    • Create a subfolder python314 and unpack the zip file into that folder.
      Don't create a sub-subfolder python-3.14.5-embed-win32 when unpacking!
    • Copy python3.dll and python314.dll from the subfolder python314 into the folder of clcl.exe.

That's it. Now you are ready to write and configure plugin functions in python.

Configure python plugins

To configure these functions as tools in CLCL

  • open the Options window
  • activate the Tools tab
  • click on the button Add
  • in the new opened dialog click on Browse
  • navigate to your folder and select tool_python.dll
  • choose the one and only function cb_python0
  • you should change the title to something meaningful, e.g. "Convert to UPPERCASE".
  • click on OK
  • scroll to the bottom of the plugin list and select your newly created plugin function
  • now click on the Properties button
  • in the dialog "Select Python Module and Function" click on Browse and select your python module, e.g. example (the module must be in the same folder as tool_python.dll or in CLCL's ini folder %LOCALAPPDATA%\clcl.
  • select one of the modules functions from the combo box, e.g. "ToUpper" (function must have exactly one parameter of type str and result of type str)
  • click button OK
  • Command line now contains the module name and the function name, separated by a ":"
  • in the Tools tab of the Options you can continue to add more Python functions
  • when finished click OK in the Options dialog

Now CLCL is ready with your new Python tool functions.

A completely configured function should look similiar to this: example:ToUpper

Build the plugin

CLCL's plugin tool_python.dll can be built with the current version Python 3.14.* (32-bit). In order to build it, you need to have the python C header files and binary libraries at the appropriate places.
Python on Windows systems allows for several versions side by side as subfolders of %LOCALAPPDATA%\python.

Install the necessary version with

pymanager install 3.14-32

License

This project is licensed under the MIT License - see LICENSE.txt

Python (embedded package) is licensed under the Python Software Foundation License - see PYTHON_LICENSE.txt

About

Python plugin for CLCL clipboard manager

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages