diff --git a/Scripts/functions/backup.py b/Scripts/functions/backup.py index c884638a..c0e31370 100644 --- a/Scripts/functions/backup.py +++ b/Scripts/functions/backup.py @@ -131,7 +131,9 @@ def select_backup_destination(auto_select=True): return destinations[0] selection = menu_select( - 'Where are we backing up to?', destinations, actions) + title = 'Where are we backing up to?', + main_entries = destinations, + action_entries = actions) if selection == 'M': raise GenericAbort else: diff --git a/Scripts/functions/common.py b/Scripts/functions/common.py index 4cf147e7..5204b45f 100644 --- a/Scripts/functions/common.py +++ b/Scripts/functions/common.py @@ -224,6 +224,10 @@ def menu_select(title='~ Untitled Menu ~', if not main_entries and not action_entries: raise Exception("MenuError: No items given") + # Set title + if 'Title' in global_vars: + title = '{}\n\n{}'.format(global_vars['Title']) + # Build menu menu_splash = '{}\n\n'.format(title) width = len(str(len(main_entries))) @@ -361,6 +365,13 @@ def run_program(cmd, args=[], check=True, pipe=True, shell=False): return process_return +def set_title(title='~Some Title~'): + """Set title. + + Used for window title and menu titles.""" + global_vars['Title'] = title + os.system('title {}'.format(title)) + def show_info(message='~Some message~', info='~Some info~', indent=8, width=32): """Display info with formatting.""" print_standard('{indent}{message:<{width}}{info}'.format( diff --git a/Scripts/functions/disk.py b/Scripts/functions/disk.py index 3b7730c0..5ea4be45 100644 --- a/Scripts/functions/disk.py +++ b/Scripts/functions/disk.py @@ -300,7 +300,7 @@ def remove_volume_letters(keep=''): except subprocess.CalledProcessError: pass -def select_disk(prompt='Which disk?'): +def select_disk(title='Which disk?'): """Select a disk from the attached disks""" disks = get_attached_disk_info() @@ -334,7 +334,10 @@ def select_disk(prompt='Which disk?'): ] # Menu loop - selection = menu_select(prompt, disk_options, actions) + selection = menu_select( + title = title, + main_entries = disk_options, + action_entries = actions) if (selection.isnumeric()): return disk_options[int(selection)-1]['Disk'] diff --git a/Scripts/functions/windows_setup.py b/Scripts/functions/windows_setup.py index 199999a4..aa1ced35 100644 --- a/Scripts/functions/windows_setup.py +++ b/Scripts/functions/windows_setup.py @@ -180,7 +180,10 @@ def select_windows_version(): actions = [{'Name': 'Main Menu', 'Letter': 'M'},] # Menu loop - selection = menu_select('Which version of Windows are we installing?', WINDOWS_VERSIONS, actions) + selection = menu_select( + title = 'Which version of Windows are we installing?', + main_entries = WINDOWS_VERSIONS, + action_entries = actions) if selection.isnumeric(): return WINDOWS_VERSIONS[int(selection)-1] diff --git a/Scripts/functions/winpe_menus.py b/Scripts/functions/winpe_menus.py index e14c0a22..419ef08e 100644 --- a/Scripts/functions/winpe_menus.py +++ b/Scripts/functions/winpe_menus.py @@ -62,6 +62,7 @@ def menu_backup(): 'GenericAbort': 'Skipped', 'GenericRepair': 'Repaired', }} + set_title('{}: Backup Menu'.format(KIT_NAME_FULL)) # Set ticket Number os.system('cls') @@ -154,7 +155,6 @@ def menu_backup(): pause('\nPress Enter to return to main menu... ') def menu_root(): - title = '{}: Main Menu'.format(KIT_NAME_FULL) menus = [ {'Name': 'Create Backups', 'Menu': menu_backup}, {'Name': 'Setup Windows', 'Menu': menu_setup}, @@ -168,11 +168,12 @@ def menu_root(): # Main loop while True: + set_title(KIT_NAME_FULL) selection = menu_select( - title=title, - main_entries=menus, - action_entries=actions, - secret_exit=True) + title = 'Main Menu', + main_entries = menus, + action_entries = actions, + secret_exit = True) if (selection.isnumeric()): try: @@ -191,6 +192,7 @@ def menu_root(): def menu_setup(): """Format a drive, partition for MBR or GPT, apply a Windows image, and rebuild the boot files""" errors = False + set_title('{}: Setup Menu'.format(KIT_NAME_FULL)) # Set ticket ID os.system('cls') @@ -295,13 +297,16 @@ def menu_setup(): pause('\nPress Enter to return to main menu... ') def menu_tools(): - title = '{}: Tools Menu'.format(KIT_NAME_FULL) tools = [k for k in sorted(PE_TOOLS.keys())] actions = [{'Name': 'Main Menu', 'Letter': 'M'},] + set_title(KIT_NAME_FULL) # Menu loop while True: - selection = menu_select(title, tools, actions) + selection = menu_select( + title = 'Tools Menu', + main_entries = tools, + action_entries = actions) if (selection.isnumeric()): tool = tools[int(selection)-1] cmd = [PE_TOOLS[tool]['Path']] + PE_TOOLS[tool].get('Args', []) @@ -342,7 +347,9 @@ def select_minidump_path(): return None # Menu - selection = menu_select('Which BSoD / MiniDump path are we scanning?', dumps, []) + selection = menu_select( + title = 'Which BSoD / MiniDump path are we scanning?', + main_entries = dumps) return dumps[int(selection) - 1]['Name'] if __name__ == '__main__': diff --git a/Scripts/winpe_root_menu.py b/Scripts/winpe_root_menu.py index ad19b34b..4bd39aef 100644 --- a/Scripts/winpe_root_menu.py +++ b/Scripts/winpe_root_menu.py @@ -8,7 +8,7 @@ os.chdir(os.path.dirname(os.path.realpath(__file__))) sys.path.append(os.getcwd()) from functions.winpe_menus import * init_global_vars() -os.system('title {}: Root Menu'.format(KIT_NAME_FULL)) +set_title('{}: Root Menu'.format(KIT_NAME_FULL)) global_vars['LogFile'] = r'{LogDir}\WinPE.log'.format(**global_vars) if __name__ == '__main__':