77
88from constants .log import LOG
99from constants .resources import UI_ADD_PROCESS_RULE , UI_ADD_SERVICE_RULE , UI_COPY , UI_SERVICE , \
10- UI_PROCESS
10+ UI_PROCESS , UI_OPEN_FOLDER
1111from constants .threads import THREAD_PROCESS_LIST_ICONS
1212from constants .ui import CMENU_ADD_PROCESS_RULE_LABEL , CMENU_ADD_SERVICE_RULE_LABEL , COLUMN_WIDTH_WITH_ICON , \
13- CMENU_COPY_LABEL , ERROR_TRYING_UPDATE_TERMINATED_TKINTER_INSTANCE
13+ CMENU_COPY_LABEL , ERROR_TRYING_UPDATE_TERMINATED_TKINTER_INSTANCE , CMENU_OPEN_PROCESS_FOLDER
1414from enums .filters import FilterByProcessType
1515from enums .rules import RuleType
1616from enums .selector import SelectorType
1717from model .process import Process
1818from ui .widget .common .treeview .pydantic import PydanticTreeviewLoader
1919from ui .widget .common .treeview .sortable import SortableTreeview
20+ from util .files import explore
2021from util .scheduler import TaskScheduler
2122from util .ui import load_img , trim_cmenu_label
2223from util .utils import get_icon_from_exe
@@ -62,6 +63,7 @@ def _setup_context_menu(self):
6263 CMENU_ADD_PROCESS_RULE_LABEL : load_img (UI_ADD_PROCESS_RULE ),
6364 CMENU_ADD_SERVICE_RULE_LABEL : load_img (UI_ADD_SERVICE_RULE ),
6465 CMENU_COPY_LABEL : load_img (UI_COPY ),
66+ CMENU_OPEN_PROCESS_FOLDER : load_img (UI_OPEN_FOLDER ),
6567 }
6668 self ._context_menu = menu = Menu (self , tearoff = 0 )
6769 self ._process_menu = Menu (menu , tearoff = 0 )
@@ -90,8 +92,24 @@ def _setup_context_menu(self):
9092 compound = LEFT
9193 )
9294
95+ menu .add_command (
96+ label = CMENU_OPEN_PROCESS_FOLDER ,
97+ command = self ._open_process_folder ,
98+ image = icons [CMENU_OPEN_PROCESS_FOLDER ],
99+ compound = LEFT
100+ )
101+
93102 self .bind ("<Button-3>" , self ._show_context_menu , '+' )
94103
104+ def _open_process_folder (self ):
105+ selected_item = self .selection ()
106+
107+ if not selected_item :
108+ return
109+
110+ row = self .as_model (selected_item [0 ])
111+ explore (row .bin_path )
112+
95113 def _show_context_menu (self , event ):
96114 context_menu = self ._context_menu
97115 process_list = self
@@ -105,6 +123,8 @@ def _show_context_menu(self, event):
105123
106124 self ._context_menu .entryconfig (CMENU_ADD_PROCESS_RULE_LABEL , state = NORMAL if process_exists else DISABLED )
107125 self ._context_menu .entryconfig (CMENU_ADD_SERVICE_RULE_LABEL , state = NORMAL if row .service else DISABLED )
126+ self ._context_menu .entryconfig (CMENU_OPEN_PROCESS_FOLDER ,
127+ state = NORMAL if os .path .isfile (row .bin_path or '' ) else DISABLED )
108128
109129 context_menu .post (event .x_root , event .y_root )
110130
0 commit comments