From e0f3f9dbffcf636627b20f4401b78f4aae972a72 Mon Sep 17 00:00:00 2001 From: gillesvink Date: Mon, 2 Aug 2021 21:31:22 +0200 Subject: [PATCH 1/2] Fix for icons not working on Windows. --- python/tk_nuke/menu_generation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/tk_nuke/menu_generation.py b/python/tk_nuke/menu_generation.py index 2058c5c..4cb0cae 100644 --- a/python/tk_nuke/menu_generation.py +++ b/python/tk_nuke/menu_generation.py @@ -528,6 +528,7 @@ def create_menu(self, add_commands=True): """ # Create main Shotgun menu. menu_handle = nuke.menu("Nuke").addMenu(self._menu_name) + iconPath=self._shotgun_logo node_menu_handle = nuke.menu("Nodes").addMenu( self._menu_name, icon=self._shotgun_logo ) @@ -578,6 +579,8 @@ def create_menu(self, add_commands=True): if cmd.type == "node": # Get icon if specified - default to sgtk icon if not specified. icon = cmd.properties.get("icon", self._shotgun_logo) + # Fix for Windows slashes + icon = icon.replace(os.sep, '/') command_context = cmd.properties.get("context") # If the app recorded a context that it wants the command to be associated @@ -1003,6 +1006,8 @@ def add_command_to_menu(self, menu, enabled=True, icon=None, hotkey=None): for the menu command. """ icon = icon or self.properties.get("icon") + # Fix for Windows slashes + icon = icon.replace(os.sep, '/') hotkey = hotkey or self.properties.get("hotkey") # Now wrap the command callback in a wrapper (see above) From 40253925bac5a14a9178181e056974b2da42b1a3 Mon Sep 17 00:00:00 2001 From: gillesvink Date: Sat, 14 Aug 2021 22:36:45 +0200 Subject: [PATCH 2/2] Fixed icons not working on Windows. --- python/tk_nuke/menu_generation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/tk_nuke/menu_generation.py b/python/tk_nuke/menu_generation.py index 4cb0cae..7cfef7e 100644 --- a/python/tk_nuke/menu_generation.py +++ b/python/tk_nuke/menu_generation.py @@ -471,6 +471,7 @@ def create_menu(self, add_commands=True): # Get icon if specified - default to sgtk icon if not specified. icon = cmd.properties.get("icon", self._shotgun_logo) + icon = icon.replace(os.sep, '/') command_context = cmd.properties.get("context") # If the app recorded a context that it wants the command to be associated @@ -528,7 +529,6 @@ def create_menu(self, add_commands=True): """ # Create main Shotgun menu. menu_handle = nuke.menu("Nuke").addMenu(self._menu_name) - iconPath=self._shotgun_logo node_menu_handle = nuke.menu("Nodes").addMenu( self._menu_name, icon=self._shotgun_logo ) @@ -889,6 +889,7 @@ def add_command_to_menu(self, menu, enabled=True, icon=None): command. """ icon = icon or self.properties.get("icon") + icon = icon.replace(os.sep, '/') action = menu.addAction(self.name) action.setEnabled(enabled) if icon: @@ -993,6 +994,8 @@ def add_command_to_pane_menu(self, menu): :param menu: The menu object to add the new item to. """ icon = self.properties.get("icon") + # Fix for Windows slashes + icon = icon.replace(os.sep, '/') menu.addCommand(self.name, self._original_callback, icon=icon) def add_command_to_menu(self, menu, enabled=True, icon=None, hotkey=None):