import PySimpleGUI as sg
sg.theme('DefaultNoMoreNagging')
layout = [
[sg.Text('Select a file to upload:', font=('Arial', 12))],
[sg.Input(key='file_path', size=(40, 1)), sg.FileBrowse('Browse', file_types=(("Text Files", "*.txt"), ("All Files", "*.*")))],
[sg.Text('Select a destination folder:', font=('Arial', 12))],
[sg.Input(key='folder_path', size=(40, 1)), sg.FolderBrowse('Browse')],
[sg.Text('Select an upload method:', font=('Arial', 12))],
[sg.Radio('FTP', 'upload_method', key='ftp', default=True), sg.Radio('HTTP', 'upload_method', key='http')],
[sg.Text('Enter FTP server address:', font=('Arial', 12))],
[sg.Input(key='ftp_address', size=(40, 1))],
[sg.Text('Enter FTP username:', font=('Arial', 12))],
[sg.Input(key='ftp_username', size=(40, 1))],
[sg.Text('Enter FTP password:', font=('Arial', 12))],
[sg.Input(key='ftp_password', password_char='*', size=(40, 1))],
[sg.Text('Enter HTTP server address:', font=('Arial', 12))],
[sg.Input(key='http_address', size=(40, 1))],
[sg.Text('Enter HTTP username:', font=('Arial', 12))],
[sg.Input(key='http_username', size=(40, 1))],
[sg.Text('Enter HTTP password:', font=('Arial', 12))],
[sg.Input(key='http_password', password_char='*', size=(40, 1))],
[sg.Button('Upload', size=(10, 1)), sg.Button('Cancel', size=(10, 1))]
]
window = sg.Window('File Uploader', layout, size=(500, 700), element_justification='center', font=('Arial', 12))
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Cancel':
break
elif event == 'Upload':
file_path = values['file_path']
folder_path = values['folder_path']
upload_method = 'FTP' if values['ftp'] else 'HTTP'
server_address = values['ftp_address'] if upload_method == 'FTP' else values['http_address']
username = values['ftp_username'] if upload_method == 'FTP' else values['http_username']
password = values['ftp_password'] if upload_method == 'FTP' else values['http_password']
sg.popup(f'File: {file_path}\nFolder: {folder_path}\nMethod: {upload_method}\nServer: {server_address}\nUsername: {username}\nPassword: {password}')
window.close()