def load_gui(self): self.txtSource = tk.Entry(self.master, text='', width=52) source = self.txtSource self.txtSource.grid(row=0, column=1, padx=(30, 0), pady=(50, 0), sticky=NW) self.txtDest = tk.Entry(self.master, text='', width=52) destination = self.txtDest self.txtDest.grid(row=1, column=1, padx=(30, 0), pady=(10, 0), sticky=NW) self.btnSource = tk.Button( self.master, text='Source Directory', width=15, height=1, command=lambda: functions.openDirectory(self, source)) self.btnSource.grid(row=0, column=0, padx=(20, 0), pady=(50, 0)) self.btnDest = tk.Button( self.master, text='Destination Directory', width=15, height=1, command=lambda: functions.openDirectory(self, destination)) self.btnDest.grid(row=1, column=0, padx=(20, 0), pady=(10, 0)) self.btnCheck = tk.Button( self.master, text='Check for files...', width=15, height=3, command=lambda: functions.move_file(self, source, destination)) self.btnCheck.grid(row=2, column=0, padx=(20, 0), pady=(10, 0)) self.btnClose = tk.Button(self.master, text='Close Program', width=15, height=3, command=lambda: functions.ask_quit(self)) self.btnClose.grid(row=2, column=1, padx=(20, 0), pady=(10, 0), sticky=E) functions.create_db(self)
def main(): f.create_db() f.create_table() f.insert_data()
from functions import get_song, get_local_time, insert, get_db_song, daily_songs, create_table, create_db from datetime import datetime import csv import time import schedule create_db() create_table() def write_log(): current_date = datetime.now().strftime('%Y-%m-%d') i = (current_date + '.csv') x = daily_songs(current_date) with open(i, 'wb') as csv_file: writer = csv.writer(csv_file) writer.writerow(['artists ', 'songs ', 'time']) writer.writerows(x) schedule.every().hour.do(write_log) rest_url = 'http://www.radio21.ro/track.json' database_check = get_db_song() if database_check is None: previous_songs = get_song(rest_url) previous_song = previous_songs[0]['track'] previous_song_artist = previous_songs[0]['artist'] ro_time = get_local_time() insert(previous_song_artist, previous_song, ro_time)
def load_gui(selfie): #We start with tk to call Tkinter's class methods, which instantiates each object. Then we name it. Think of "selfie" as a key #Names for entry boxes selfie.label_user = tk.Label(selfie.master, text="User:"******"First Name:") selfie.label_FName.grid(row=0, column=0, padx=(25, 0), pady=(10, 0), sticky=NW) selfie.label_LName = tk.Label(selfie.master, text="Last Name:") selfie.label_LName.grid(row=2, column=0, padx=(25, 0), pady=(10, 0), sticky=NW) selfie.label_phone = tk.Label(selfie.master, text="Phone:") selfie.label_phone.grid(row=4, column=0, padx=(25, 0), pady=(10, 0), sticky=NW) selfie.label_email = tk.Label(selfie.master, text="Email:") selfie.label_email.grid(row=6, column=0, padx=(25, 0), pady=(10, 0), sticky=NW) #Entry boxes inserted selfie.txt_FName = tk.Entry(selfie.master, text='') selfie.txt_FName.grid(row=1, column=0, columnspan=2, padx=(10, 30), sticky=N + E + W) #NEW stretches widget both E and W, at the top selfie.txt_LName = tk.Entry(selfie.master, text='') selfie.txt_LName.grid(row=3, column=0, columnspan=2, padx=(10, 20), sticky=N + E + W) selfie.txt_phone = tk.Entry(selfie.master, text='') selfie.txt_phone.grid(row=5, column=0, columnspan=2, padx=(10, 20), sticky=N + E + W) selfie.txt_email = tk.Entry(selfie.master, text='') selfie.txt_email.grid(row=7, column=0, columnspan=2, padx=(10, 20), sticky=N + E + W) #Listbox and scrollbar inserted selfie.scroll1 = Scrollbar(selfie.master, orient=VERTICAL) selfie.List1 = Listbox( selfie.master, exportselection=0, yscrollcommand=selfie.scroll1.set) #ES = 0 disables clipboard selfie.List1.bind( '<<ListboxSelect>>', lambda event: functions.on_select(selfie, event) ) #Bind method registers an event and calls lambda function when the listbox is clicked selfie.scroll1.config(command=selfie.List1.yview) selfie.scroll1.grid(row=1, column=5, rowspan=7, sticky=N + E + S) selfie.List1.grid(row=1, column=2, columnspan=3, rowspan=7, sticky=N + E + S + W) #Buttons inserted selfie.btn_add = tk.Button(selfie.master, width=12, height=2, text='Add', command=lambda: functions.addToList(selfie)) selfie.btn_add.grid(row=8, column=0, padx=(25, 0), pady=(45, 10), sticky=W) selfie.btn_update = tk.Button(selfie.master, width=12, height=2, text='Update', command=lambda: functions.onUpdate(selfie)) selfie.btn_update.grid(row=8, column=1, padx=(15, 0), pady=(45, 10), sticky=W) selfie.btn_delete = tk.Button(selfie.master, width=12, height=2, text='Delete', command=lambda: functions.onDelete(selfie)) selfie.btn_delete.grid(row=8, column=2, padx=(15, 0), pady=(45, 10), sticky=W) selfie.btn_close = tk.Button(selfie.master, width=12, height=2, text='Close', command=lambda: functions.ask_quit(selfie)) selfie.btn_close.grid(row=8, column=4, padx=(15, 0), pady=(45, 10), sticky=E) functions.create_db(selfie) functions.onRefresh(selfie) if __name__ == "__main__": pass