-
Notifications
You must be signed in to change notification settings - Fork 0
Making an extension for "Extensia" update
kPad searches for files in its plugin folder found at:
-
~/Library/Application Support/kPad/pluginson Mac, -
~/.config/kpad/pluginson Linux, - and
%APPDATA%\Local\kPad\Pluginson Windows.
It"s made so creating an extension is fairly easy. You need two files in a folder:
extension_name
|_ metadata.json
|_ logic.py
The metadata.json contains all the needed metadata for a plugin. Example:
{
"name": "MyCoolKPadPlugin",
"author": "MyCoolUsername",
"version": "6.7",
"website": "https://github.com/MyCoolUsername/MyCoolKPadPlugin/",
"desc": "Makes all text uppercase."
}Fairly easy. The logic (logic.py) isn"t hard either. An example:
def action(textbox):
text_in_box = textbox.get_text_from_box() # This will return a string.
text_in_box.upper()
textbox.clear_text_from_box()
textbox.insert_text_from_start_of_box()Binds are also available, by using bind(sequence, callback). Just make sure that the command for callback is inside the action() command.
Widgets are available by using the provided commands:
Widget_Frame(parent, **kwargs)
Widget_Label(parent, label, font, **kwargs)
Widget_Button(parent, label, command, font, **kwargs)
Widget_Other(parent, widget, **kwargs)I recommend getting the actual parent like this:...
parent = editor._appinstance...and using your newly-defined parent variable as the parent for widgets. Example:
# plugins/test_plugin/logic.py
def action():
parent = editor._appinstance
hello_frame = editor.Widget_Frame(parent)
hello_world = editor.Widget_Label(parent, "Hello World!")
hello_frame.pack(padx=5, pady=5)
hello_world.pack(padx=5, pady=5)Then press the button for the respective plugin in the Plugin Info window, found under Plugins > Show Plugin Information.
For editor.Widget_Other(), the widget attribute needs to be a Tk-based widget, e.g. widget=tk.Label. However I suggest using a customtkinter widget for best look. For **kwargs, any other Tk attributes are supported. Pack widgets with the normal pack() function.
Publish it to a GitHub repo, with a name like kpad-plugin-[PLUGIN_NAME].
Look in the source code for all commands available.