1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| import sys
import PySimpleGUI as sg
sg.theme('Light Green 5')
copy_layout = [
[sg.Text('This is to copy file or folder',background_color='lightslateblue',font=('Bold'))],
[sg.Radio('Copy Folder ', "Radio_Copy", default=True, size=(10,1),enable_events=True,key='kCopy_folder',background_color='lightslateblue'), sg.Radio('Copy file', "Radio_Copy",enable_events=True,key='kCopy_files',background_color='lightslateblue')],
[sg.Text('Liste instances', size=(15, 1),key='kListe_instances_copy_txt',background_color='lightslateblue'),sg.InputText(key='kListe_instances_input_copy',background_color='lightslateblue'), sg.FileBrowse(key='kListe_instances_selected_file_copy')],
[sg.Text('Folder to copy', size=(15, 1),key='kFolder_to_copy_txt',background_color='lightslateblue'),sg.InputText(key='kFolder_to_copy_input',background_color='lightslateblue'), sg.FolderBrowse(key='kFolder_to_copy_selected_folder')],
[sg.Text('File to copy', size=(15, 1),key='kFile_to_copy_txt',background_color='lightslateblue'),sg.InputText(key='kFile_to_copy_input',background_color='lightslateblue'), sg.FileBrowse(key='kFile_to_copy_selected_file')]
]
remove_layout = [
[sg.Text('This is to remover folder in Staging or patchs',background_color='lightslateblue')],
[sg.Radio('Remove all in Staging ', "Radio_Remove", default=True,enable_events=True,key='kRemove_All_in_Staging',background_color='lightslateblue'),sg.Radio('Remove one folder in Staging ', "Radio_Remove",enable_events=True,key='kRemove_One_Folder_in_Staging',background_color='lightslateblue'), sg.Radio('Remove All Patchs', "Radio_Remove",enable_events=True,key='kRemove_All_Patches',background_color='lightslateblue'),sg.Radio('Remove one Patch', "Radio_Remove",enable_events=True,key='kRemove_One_Patch',background_color='lightslateblue')],
[sg.Text('Liste Instances', size=(15, 1),key='kListe_instances_remove_txt',background_color='lightslateblue'),sg.InputText(key='kListe_instances_input_remove',background_color='lightslateblue'), sg.FileBrowse(key='kListe_instances_selected_file_remove')],
[sg.Text('Folder to Remove', size=(15, 1),key='kFolder_to_remove_txt',background_color='lightslateblue'),sg.InputText(key='kFolder_to_remove_input',background_color='lightslateblue'), sg.FolderBrowse(key='kFolder_to_remove_selected_folder')],
[sg.Text('Patch to remove', size=(15, 1),key='kPatch_to_remove_txt',background_color='lightslateblue'),sg.InputText(key='kPatch_to_remove_input',background_color='lightslateblue'), sg.FileBrowse(key='kPatch_to_remove_selected_file')]
]
compare_layout = [
[sg.Text('This is to compare folders or patch',background_color='tan2')],
[sg.Text('List Server or Instances', size=(15, 1),key='kListe_Server_or_Instance_compare_txt',background_color='tan2'),sg.InputText(key='kListe_Server_or_Instance_compare_input',background_color='tan2'), sg.FileBrowse(key='-selected_file-c-')],
[sg.Text('Folder Source', size=(15, 1),key='foldertext',background_color='tan2'),sg.InputText(key='-folder1-',background_color='tan2'), sg.FolderBrowse(key='-selected_folder_c-')],
[sg.Text('Folder ', size=(15, 1),key='folder2text',background_color='tan2'),sg.InputText(key='-folder2-',background_color='tan2'), sg.FolderBrowse(key='-selected_folder_c2-')] ]
reboot_layout = [
[sg.Text('This is to restart services or servers')],
[sg.Radio('Restart Services ', "RADIO1", default=True,enable_events=True,key='Restart_Services'), sg.Radio('Reboot Servers', "RADIO1",enable_events=True,key='Reboot_Servers')],
[sg.Text('File 1', size=(15, 1),key='remfiletext',background_color='lightslateblue'),sg.InputText(key='-file3-',background_color='lightslateblue'), sg.FileBrowse(key='-remselected_file-')]
]
layout = [[sg.TabGroup([[sg.Tab(' Copy ', copy_layout, background_color='darkslateblue', key='-mykey-'),sg.Tab(' Compare ', compare_layout, background_color='tan1'),sg.Tab(' Remove ', remove_layout, background_color='tan1'),sg.Tab(' Reboot ', reboot_layout)]],key='-group2-', title_color='red',selected_title_color='green', tab_location='top'),
],
[sg.Button('Run')]]
window = sg.Window('ECM Tools', layout,).finalize()
window.Element('kFile_to_copy_txt').Update(visible = False)
window.Element('kFile_to_copy_input').Update(visible = False)
window.Element('kFile_to_copy_selected_file').Update(visible = False)
window.Element('kFolder_to_remove_txt').Update(visible = False)
window.Element('kFolder_to_remove_input').Update(visible = False)
window.Element('kFolder_to_remove_selected_folder').Update(visible = False)
window.Element('kPatch_to_remove_txt').Update(visible = False)
window.Element('kPatch_to_remove_input').Update(visible = False)
window.Element('kPatch_to_remove_selected_file').Update(visible = False)
while True:
event, values = window.read()
#sg.popup_non_blocking(event, values)
print(event, values)
if event == sg.WIN_CLOSED: # always, always give a way out!
break
if values["kCopy_folder"] == True:
window.Element('kFile_to_copy_txt').Update(visible = False)
window.Element('kFile_to_copy_input').Update(visible = False)
window.Element('kFile_to_copy_selected_file').Update(visible = False)
window.Element('kFolder_to_copy_txt').Update(visible = True)
window.Element('kFolder_to_copy_input').Update(visible = True)
window.Element('kFolder_to_copy_selected_folder').Update(visible = True)
else:
window.Element('kFile_to_copy_txt').Update(visible = True)
window.Element('kFile_to_copy_input').Update(visible = True)
window.Element('kFile_to_copy_selected_file').Update(visible = True)
window.Element('kFolder_to_copy_txt').Update(visible = False)
window.Element('kFolder_to_copy_input').Update(visible = False)
window.Element('kFolder_to_copy_selected_folder').Update(visible = False)
#########################################################################
if values['kRemove_One_Folder_in_Staging'] == True:
window.Element('kFolder_to_remove_txt').Update(visible = True)
window.Element('kFolder_to_remove_input').Update(visible = True)
window.Element('kFolder_to_remove_selected_folder').Update(visible = True)
window.Element('kPatch_to_remove_txt').Update(visible = False)
window.Element('kPatch_to_remove_input').Update(visible = False)
window.Element('kPatch_to_remove_selected_file').Update(visible = False)
if values['kRemove_One_Patch'] == True:
window.Element('kFolder_to_remove_txt').Update(visible = False)
window.Element('kFolder_to_remove_input').Update(visible = False)
window.Element('kFolder_to_remove_selected_folder').Update(visible = False)
window.Element('kPatch_to_remove_txt').Update(visible = True)
window.Element('kPatch_to_remove_input').Update(visible = True)
window.Element('kPatch_to_remove_selected_file').Update(visible = True)
if values['kRemove_All_in_Staging'] == True or values['kRemove_All_Patches'] == True:
window.Element('kFolder_to_remove_txt').Update(visible = False)
window.Element('kFolder_to_remove_input').Update(visible = False)
window.Element('kFolder_to_remove_selected_folder').Update(visible = False)
window.Element('kPatch_to_remove_txt').Update(visible = False)
window.Element('kPatch_to_remove_input').Update(visible = False)
window.Element('kPatch_to_remove_selected_file').Update(visible = False)
window.close() |
Partager