Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import PySimpleGUI as sg
- import pandas as pd
- sg.theme('DarkGreen4') #Dari Library PySimpleGUI
- EXCEL_FILE = 'Pendaftaran.xlsx'
- df = pd.read_excel(EXCEL_FILE) #Dari library pandas
- #----------------DARI LIBRARY "PySimpleGUI"--------------------
- layout=[
- [sg.Text('Masukan Data Kamu')],
- [sg.Text('Nama',size=(15,1)), sg.InputText(key='Nama')],
- [sg.Text('Nomor',size=(15,1)), sg.InputText(key='Nomor')],
- [sg.Text('Alamat',size=(15,1)), sg.Multiline(key='Alamat')],
- [sg.Text('Tanggal Lahir',size=(15,1)), sg.InputText(key='Tanggal Lahir'),
- sg.CalendarButton('Kalender', target='Tanggal Lahir', format=('%d-%m-%y'))],
- [sg.Text('Jenis Kelamin',size=(15,1)), sg.Combo(['Pria','Wanita'],key='Jenis Kelamin')],
- [sg.Text('Hobby',size=(15,1)), sg.Checkbox('Belajar',key='Belajar'),
- sg.Checkbox('Menonton',key='Menonton'),
- sg.Checkbox('Music',key='Music')],
- [sg.Submit(), sg.Button('clear'), sg.Exit()]
- ]
- #---------------------------------------------------------------
- window=sg.Window('Form pendaftaran',layout)
- def clear_input():
- for key in values:
- window[key]('')
- return None
- while True :
- event, values = window.read()
- if event == sg.WIN_CLOSED or event == 'EXIT':
- break
- if event == 'Clear':
- clear_input()
- if event == 'Submit':
- df =df._append(values, ignore_index=True)
- df.to_excel(EXCEL_FILE, index=False)
- sg.popup('Data Berhasil di Simpan')
- clear_input()
- window.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement