Skip to content

Commit f1fd9b0

Browse files
committed
kPad Release 1.2.2 "Extensia"
1 parent 2b6790b commit f1fd9b0

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ jobs:
2525
2626
- name: Build job ARM64
2727
run: |
28-
python -m nuitka --standalone --onefile --macos-create-app-bundle --macos-app-name='kPad ARM64' --macos-app-version='1.2.0' --enable-plugin=tk-inter --assume-yes-for-downloads main.py
28+
python -m nuitka --standalone --onefile --macos-create-app-bundle --macos-app-name='kPad ARM64' --macos-app-version='1.2.2' --enable-plugin=tk-inter --assume-yes-for-downloads main.py
2929
mv main.app kPad-mac_arm64.app
3030
3131
- name: Build job Intel
3232
run: |
33-
arch -x86_64 python -m nuitka --standalone --onefile --macos-create-app-bundle --macos-app-name='kPad Intel' --macos-app-version='1.2.0' --enable-plugin=tk-inter --assume-yes-for-downloads main.py
33+
arch -x86_64 python -m nuitka --standalone --onefile --macos-create-app-bundle --macos-app-name='kPad Intel' --macos-app-version='1.2.2' --enable-plugin=tk-inter --assume-yes-for-downloads main.py
3434
mv main.app kPad-mac_x86_64.app
3535
3636
- name: Create Info.plist for ARM64
@@ -47,7 +47,7 @@ jobs:
4747
<key>CFBundleIdentifier</key>
4848
<string>com.maxhatei2.kPad</string>
4949
<key>CFBundleVersion</key>
50-
<string>1.2.0</string>
50+
<string>1.2.2</string>
5151
<key>CFBundleExecutable</key>
5252
<string>main</string>
5353
<key>CFBundlePackageType</key>
@@ -70,7 +70,7 @@ jobs:
7070
<key>CFBundleIdentifier</key>
7171
<string>com.maxhatei2.kPad</string>
7272
<key>CFBundleVersion</key>
73-
<string>1.2.0</string>
73+
<string>1.2.2</string>
7474
<key>CFBundleExecutable</key>
7575
<string>main</string>
7676
<key>CFBundlePackageType</key>

main.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,29 @@
55
from tkinter import simpledialog
66
import time, threading
77
import os, json, platform
8+
import venv, sys
89

910
# ██╗░░██╗██████╗░░█████╗░██████╗░
1011
# ██║░██╔╝██╔══██╗██╔══██╗██╔══██╗
1112
# █████═╝░██████╔╝███████║██║░░██║
1213
# ██╔═██╗░██╔═══╝░██╔══██║██║░░██║
1314
# ██║░╚██╗██║░░░░░██║░░██║██████╔╝
1415
# ╚═╝░░╚═╝╚═╝░░░░░╚═╝░░╚═╝╚═════╝░
15-
# Version 1.2.1 [SOURCE CODE]
16+
# Version 1.2.2 [SOURCE CODE]
17+
1618

1719
if platform.system() == 'Darwin':
1820
config_dir = os.path.expanduser('~/Library/Application Support/kPad')
1921
plugin_dir = os.path.expanduser(f'{config_dir}/plugins')
22+
plugin_env_path = os.path.expanduser("~/Library/Application Support/kPad/plugin-env")
2023
elif platform.system() == 'Windows':
2124
config_dir = os.path.join(os.getenv('APPDATA'), 'kPad')
2225
plugin_dir = os.path.join(os.getenv('APPDATA'), 'kPad', 'Plugins')
26+
plugin_env_path = os.path.join(os.getenv('APPDATA', 'kPad', 'Plugins', 'plugin_env'))
2327
else:
2428
config_dir = os.path.expanduser('~/.config/kpad')
2529
plugin_dir = os.path.expanduser(f'{config_dir}/plugins')
30+
plugin_env_path = os.path.expanduser("~/Library/Application Support/kPad/plugin-env")
2631
os.makedirs(config_dir, exist_ok=True)
2732
os.makedirs(plugin_dir, exist_ok=True)
2833
CONFIG_PATH = os.path.join(config_dir, 'config.json')
@@ -40,6 +45,10 @@
4045
'recent_files': {'enabled': True, 'keep_recent_files_count': 5, 'recent_file_paths': []},
4146
'auto_start_plugins': []
4247
}
48+
49+
if not os.path.exists(plugin_env_path):
50+
venv.create(plugin_env_path, with_pip=True)
51+
os.environ["KPAD_PLUGIN_ENV"] = plugin_env_path
4352

4453
_fonts = ['Menlo', 'Monaco', 'Helvetica', 'Arial', 'Times New Roman', 'Georgia', 'Avenir', 'Baskerville', 'Futura', 'Verdana', 'Gill Sans', 'Courier', 'Optima', 'American Typewriter']
4554

@@ -64,7 +73,6 @@ def wrapper(event):
6473
callback(event)
6574
except TypeError:
6675
callback()
67-
return 'break'
6876
self.textbox.bind(sequence, wrapper)
6977
def get_plugin_path(self, plugin_name):
7078
return os.path.join(plugin_dir, plugin_name)
@@ -101,6 +109,32 @@ def Widget_Button(self, parent, text, cmd, font=('', 13), **kwargs):
101109
def Widget_Other(self, parent, widget, **kwargs):
102110
widg = widget(parent, **kwargs)
103111
return widg
112+
def prepare_for_external_libs(self):
113+
'Use this when external libs are required for a plugin at the top of the action() function.'
114+
ver = f"{sys.version_info.major}.{sys.version_info.minor}"
115+
env = os.getenv("KPAD_PLUGIN_ENV")
116+
sys.path.append(os.path.join(env, "lib", f"python{ver}", "site-packages"))
117+
def get_selected_text(self):
118+
try:
119+
return self.textbox.get('sel.first', 'sel.last')
120+
except:
121+
return ''
122+
def add_text_tag(self, tag_name, **options):
123+
"""Create or update a text tag (foreground, background, font, etc.)"""
124+
self.textbox.tag_config(tag_name, **options)
125+
126+
def tag_text(self, tag_name, start, end):
127+
"""Apply a tag to a range of text."""
128+
self.textbox.tag_add(tag_name, start, end)
129+
130+
def remove_tag(self, tag_name, start="1.0", end="end"):
131+
"""Remove a tag from a range."""
132+
self.textbox.tag_remove(tag_name, start, end)
133+
134+
def clear_all_tags(self):
135+
"""Remove all tags from the textbox."""
136+
for tag in self.textbox.tag_names():
137+
self.textbox.tag_remove(tag, "1.0", "end")
104138

105139

106140
class App(ctk.CTk):
@@ -448,4 +482,4 @@ def make_separator():
448482
make_separator()
449483
self.main.pack(fill='both', expand='True')
450484

451-
App('kPad - Untitled', CONFIGURATION['window_geometry']).mainloop()
485+
App('kPad - Untitled', CONFIGURATION['window_geometry']).mainloop()

0 commit comments

Comments
 (0)