-
Notifications
You must be signed in to change notification settings - Fork 0
PluginAPI
maxhatei2 edited this page Nov 1, 2025
·
1 revision
PluginAPI is a class of commands used to configure kPad or to add widgets which are based on Tkinter.
Interacting is easy: use the editor variable alongside the command you would like to use, like editor.get_text_from_box(). That automatically uses the PluginAPI command to interact with kPad.
There are currently 25 commands for plugins to use:
-
get_text_from_box():- Get text from the edit box, returned as a string.
-
get_specific_text_from_box(start, end):- Get some specific text from the edit box, where
startis the position start, andendis the position end. Returned as a string.
- Get some specific text from the edit box, where
-
clear_text_from_box():- Clear text from the edit box.
-
insert_text_to_start_of_box(text):- Inserts text to the start of the box, where
textis a string or integer to insert.
- Inserts text to the start of the box, where
-
insert_text_to_end_of_box(text):- Same as
insert_text_to_start_of_box(text), but more like an append.
- Same as
-
get_selected_text():- Gets the current selected text. If there is none, it returns an empty string.
-
get_selected_text_indexes():- Gets the current selected text indexes in a tuple. If there isn't anything selected, it returns a None object.
-
get_plugin_path(plugin_name):- Gets the current plugin location path.
-
get_current_file_path():- Gets the currently opened file path in kPad. Returns
Noneif new file.
- Gets the currently opened file path in kPad. Returns
-
get_current_theme_mode():- Gets the current theme mode:
darkorlight.
- Gets the current theme mode:
-
set_current_theme_mode(mode):- Sets the current theme mode. Accepts
darkorlight.
- Sets the current theme mode. Accepts
-
set_theme_mode(json_path):- Sets a theme based on a JSON file. Refer to CustomTkinter documentation.
-
showinfo(text):- Shows a message in a messagebox, where
textis the text to show.
- Shows a message in a messagebox, where
-
showerror(text):- Shows an error message in a messagebox, where
textis the text to show.
- Shows an error message in a messagebox, where
-
log(text):- Shows a log in the terminal, without disturbing the user.
-
Widget_Frame(parent, **kwargs):- Creates a frame to use for widgets, where
parentcan be the editor appinstance (you can define it witheditor._appinstance) and**kwargscan be other arguments that the CTkFrame support.
- Creates a frame to use for widgets, where
-
Widget_Label(parent, text, font=('', 13), **kwargs):- Creates a label to use inside a parent or a frame, where parent can be the editor appinstance (you can define it with editor._appinstance) and **kwargs can be other arguments that the CTkLabel support,
textis the text that the label will contain,fontis a tuple where''is the font family, and the integer is the font size.
- Creates a label to use inside a parent or a frame, where parent can be the editor appinstance (you can define it with editor._appinstance) and **kwargs can be other arguments that the CTkLabel support,
-
Widget_Button(parent, text, cmd, font=('', 13))- Creates a button; everything is provided in the upper widget descriptions.
-
Widget_Other(self, parent, widget, **kwargs):- Creates a widget which is based on Tcl/Tk roots and supports **kwargs, where parent can be the editor appinstance (you can define it with editor._appinstance) and **kwargs can be other arguments that the widget supports.
widgetcan be the chosen widget (e.g.tkwebview.HtmlLabel).
- Creates a widget which is based on Tcl/Tk roots and supports **kwargs, where parent can be the editor appinstance (you can define it with editor._appinstance) and **kwargs can be other arguments that the widget supports.
-
add_text_tag(tag_name, **options):- Adds (or updates) a text tag (fg, bg, font, etc.)
-
tag_text(tag_name, start, end):- Apply a tag to a range of text.
-
remove_tag(tag_name, start="1.0", end="end"):- Remove a tag from a range.
-
clear_all_tags():- Remove all tags from the edit box.
-
bind(sequence, callback): - Binds a key or a specific shortcut (
sequence) to a function (callback). The function must be into theactionfunction and should have a parameter (event=None). Refer to this page to see using sequences. -
run_async(cmd, withdaemon):- Runs a command which could take some time in a separate thread to not freeze the UI.
cmdis the function to run, andwithdaemonis a boolean for to use or not a daemon.
- Runs a command which could take some time in a separate thread to not freeze the UI.
-
prepare_for_external_libs():- Use this when external libraries (needed to be installed) are required to use. This activates the created env.