Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf595216

Browse files
committed
refactor(yasb/home): expand user paths and handle file missing case with logger
This commit refactors the `create_menu_action` method in `HomeWidget` class to expand user paths before calling `os.startfile`.
1 parentd725933 commitf595216

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎src/core/widgets/yasb/home.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
fromcore.utils.widgets.powerimportPowerOperations
1010
fromcore.utils.utilitiesimportPopupWidget
1111
fromcore.utils.widgets.animation_managerimportAnimationManager
12+
importlogging
1213

1314
classHomeWidget(BaseWidget):
1415
validation_schema=VALIDATION_SCHEMA
@@ -95,9 +96,10 @@ def process_content(content):
9596

9697

9798
defcreate_menu_action(self,path):
98-
expanded_path=os.path.expanduser(path)
99-
returnlambda:os.startfile(expanded_path)
100-
99+
path=os.path.expanduser(path)
100+
returnlambda:os.startfile(path)ifos.path.exists(path)elselogging.error(f"The system cannot find the file specified: '{path}'")
101+
102+
101103
def_create_menu(self):
102104
self._menu=PopupWidget(self,self._blur,self._round_corners,self._round_corners_type,self._border_color)
103105
self._menu.setProperty('class','home-menu')
@@ -119,6 +121,7 @@ def _create_menu(self):
119121

120122
self._add_menu_item(main_layout,self._menu_labels['system'],
121123
lambda:os.startfile("ms-settings:"))
124+
122125
self._add_menu_item(main_layout,self._menu_labels['task_manager'],
123126
lambda:subprocess.Popen("taskmgr",shell=True,creationflags=subprocess.CREATE_NO_WINDOW))
124127

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp