-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontextimo.py
More file actions
60 lines (48 loc) · 1.63 KB
/
contextimo.py
File metadata and controls
60 lines (48 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# for getting the absolute path to the marimo icon
import os.path
import sys
from context_menu import menus
from context_menu.menus import ContextMenu
# adds all of the commands
def add_commands():
# commands which appear in the context menu for .py files
python_menu = ContextMenu(
"marimo", type=".py", icon_path=os.path.abspath("marimo_icon.ico")
)
edit_with_marimo = menus.ContextCommand(
"edit", command="marimo edit ?", command_vars=["FILENAME"]
)
sandboxed_edit_with_marimo = menus.ContextCommand(
"edit in a sandbox",
command="marimo edit ? --sandbox",
command_vars=["FILENAME"],
)
run_with_marimo = menus.ContextCommand(
"run", command="marimo run ?", command_vars=["FILENAME"]
)
python_menu.add_items(
[edit_with_marimo, sandboxed_edit_with_marimo, run_with_marimo]
)
python_menu.compile()
# commands which appear when in a folder or the desktop
general_menu = ContextMenu(
"marimo",
type="DIRECTORY_BACKGROUND",
icon_path=os.path.abspath("marimo_icon.ico"),
)
create_with_marimo = menus.ContextCommand(
"new notebook", command="cmd /c marimo new"
)
marimo_home = menus.ContextCommand("marimo hub", command="cmd /c marimo edit")
general_menu.add_items([create_with_marimo, marimo_home])
general_menu.compile()
# removes all the created menus
def remove_commands():
menus.removeMenu("marimo", type=".py")
menus.removeMenu("marimo", type="DIRECTORY_BACKGROUND")
if sys.argv[1] == "add":
add_commands()
elif sys.argv[1] == "remove":
remove_commands()
else:
pass