for i in range(5): for j in range(len(menu[i])): labels.append(Label(days[i])) labels[len(labels) - 1].pack(fill = BOTH, expand = 1) labels[len(labels) - 1].config(text = menu[i][j], background = colors[((i+j)%2)+(i%2)*2]) if j == 2: labels.append(Label(days[i])) labels[len(labels) - 1].pack(fill = BOTH) labels[len(labels) - 1].config(text = "Dinner: ", background = "#a6a6a6") # Create option buttons weatherBut = Button(selectionBar, relief = RAISED, text = " Weather ", command = lambda: initWeather()) weatherBut.pack(side = LEFT, fill = X, padx = 15, expand = 1) weatherBut.config(background = '#80ffff') revmenuBut = Button(selectionBar, relief = RAISED, text = " REVelations Cafe ", command = lambda: initMenu(1)) revmenuBut.pack(side = LEFT, fill = X, padx = 15, expand = 1) revmenuBut.config(background = '#ff944d') v1But = Button(selectionBar, relief = RAISED, text = " Village 1 Cafe ", command = lambda: initMenu(0)) v1But.pack(side = LEFT, fill = X, padx = 15, expand = 1) v1But.config(background = '#ffff80') infoBut = Button(selectionBar, relief = RAISED, text = " Information Sessions ", command = lambda: initInfo()) infoBut.pack(side = LEFT, fill = X, padx = 15, expand = 1) infoBut.config(background = '#b3ffcc') print(uw.infosessions()) mainloop()
return update_id API_KEY = apikeys.UWApiKey uw = UWaterlooAPI(api_key=API_KEY) todays_sessions = [] day = int(time.strftime("%d")) todaysDate = time.strftime("%Y") + time.strftime("-%m-") + str(day) #get all sessions for today for event in uw.infosessions(): if "CANCELLED" in event["employer"].upper(): continue if event["date"] == todaysDate: todays_sessions.append( (event["employer"], event["start_time"], event["end_time"], event["id"])) #sort session by ascending time todays_sessions.sort(key=lambda tup: tup[1]) # sorts in place message = "" #create the message for session in todays_sessions: message = message + session[0] + " at " + \ session[1] + " ends at " + session[2] + "\n"
23 January 2016 ''' import time import os rows, columns = os.popen('stty size', 'r').read().split() from termcolor import colored, cprint # keep the api key private f = open(os.path.dirname(__file__) + '/data/uw-api.txt', 'r') api_key = f.readline().strip() from uwaterlooapi import UWaterlooAPI uw = UWaterlooAPI(api_key=api_key) infosessions = uw.infosessions() previousDate = "" today = time.strftime("%B %-d, %Y") start = -1 counter = 0 for infosession in infosessions: if (today == infosession["date"]): start = counter counter += 1 if (start == -1): today = time.strftime("%B") + " " + str((int(time.strftime("%-d"))-2) % 30) + ", " + time.strftime("%Y") counter = 0 for infosession in infosessions: if (today == infosession["date"]):
return update_id API_KEY = apikeys.getUWApiKey() uw = UWaterlooAPI(api_key=API_KEY) todays_sessions = [] day = int(time.strftime("%d")) todaysDate = time.strftime("%B ") + str(day) + time.strftime(", %Y") for event in uw.infosessions(): if "CANCELLED" in event["employer"].upper(): continue if event["date"] == todaysDate: event["start_time"] = time.strftime("%H:%M", time.strptime(event["start_time"], "%I:%M %p")) event["end_time"] = time.strftime("%H:%M", time.strptime(event["end_time"], "%I:%M %p")) todays_sessions.append((event["employer"], event["start_time"], event["end_time"], event["id"])) todays_sessions.sort(key=lambda x: x[1]) print "TODAYS SESSIONS" print "---------------" print todays_sessions weekday = time.strftime("%A").upper()