@@ -13,27 +13,43 @@ def resetProgram():
1313
1414options = Options (resetProgram )
1515
16- # Convert the command list to a tuple list
17- updatedCommands = []
18- for command in options .commands :
19- icon = command .icon
20- if (command .icon == "" or command .icon == None ):
21- icon = None
22- else :
23- _ , extension = splitext (command .icon )
24-
25- # Ensure that the icon is valid
26- if (not (exists (command .icon ) and extension == ".ico" )):
16+ def addCommandsToTuple (commands , tuple ):
17+ for command in commands :
18+ icon = command .icon
19+ if (command .icon == "" or command .icon == None ):
2720 icon = None
21+ else :
22+ _ , extension = splitext (command .icon )
23+
24+ # Ensure that the icon is valid
25+ if (not (exists (command .icon ) and extension == ".ico" )):
26+ icon = None
27+
28+ # Recursively add items if a command list
29+ if (command .commandList != None ):
30+ tuple = tuple + ((command .name , icon , addCommandsToTuple (command .commandList , ())),)
31+
32+ else :
33+ tuple = tuple + (((
34+ command .name ,
35+ icon ,
36+ command .getActionableCommand ())),
37+ )
38+ return tuple
2839
29- updatedCommands .append ((
30- command .name ,
31- icon ,
32- command .getActionableCommand ())
33- )
40+ # Convert the command list to a tuple list
41+ updatedCommands = ()
42+ updatedCommands = addCommandsToTuple (options .commands , updatedCommands )
3443
35- # Add the options page
36- updatedCommands .append (("Options" , "icons/settings.ico" , options .showOptionsPage ))
44+ # Are there nested commands?
45+ nestedCommands = False
46+ for command in options .commands :
47+ if command .commandList != None :
48+ nestedCommands = True
49+
50+ # Add the options page if there are no nested commands as the options page currently doesn't support them
51+ if not nestedCommands :
52+ updatedCommands = updatedCommands + ((("Options" , "icons/settings.ico" , options .showOptionsPage )),)
3753
38- sysTrayIcon = SysTrayIcon ("icons/main.ico" , "Tray Script" , tuple ( updatedCommands ) , default_menu_index = len (updatedCommands )- 1 )
54+ sysTrayIcon = SysTrayIcon ("icons/main.ico" , "Tray Script" , updatedCommands , default_menu_index = len (updatedCommands )- 1 if not nestedCommands else 0 )
3955sysTrayIcon .start ()
0 commit comments