From: jimmy Date: Fri, 28 Jun 2024 01:31:40 +0000 (-0500) Subject: early learning in mu editor X-Git-Url: https://vault307.fbx.one/gitweb/mu_code.git/commitdiff_plain/HEAD early learning in mu editor --- 806f6364faa87a070f99beb2c745970d8bcd3475 diff --git a/GPIO/blinkLED.py b/GPIO/blinkLED.py new file mode 100644 index 0000000..b336eb9 --- /dev/null +++ b/GPIO/blinkLED.py @@ -0,0 +1,12 @@ +import RPi.GPIO as GPIO +import time + +GPIO.setwarnings(False) +GPIO.setmode(GPIO.BCM) +GPIO.setup(18, GPIO.OUT) + +while True: + GPIO.output(18, True) + time.sleep(1) + GPIO.output(18, False) + time.sleep(1) \ No newline at end of file diff --git a/GPIO/buttonLED.py b/GPIO/buttonLED.py new file mode 100644 index 0000000..a01c18d --- /dev/null +++ b/GPIO/buttonLED.py @@ -0,0 +1,13 @@ +import RPi.GPIO as GPIO +import time + +GPIO.setwarnings(False) +GPIO.setmode(GPIO.BCM) +GPIO.setup(18, GPIO.OUT) +GPIO.setup(25, GPIO.IN) + +while True: + if GPIO.input(25): + GPIO.output(18, False) + else: + GPIO.output(18, True) \ No newline at end of file diff --git a/GPIO/gpio0LED.py b/GPIO/gpio0LED.py new file mode 100644 index 0000000..80c42be --- /dev/null +++ b/GPIO/gpio0LED.py @@ -0,0 +1,8 @@ +from gpiozero import LED +from time import sleep +led=LED(18) +while True: + led.on() + sleep(1) + led.off() + sleep(1) \ No newline at end of file diff --git a/__pycache__/calendarQstrt.cpython-37.pyc b/__pycache__/calendarQstrt.cpython-37.pyc new file mode 100644 index 0000000..ed6f328 Binary files /dev/null and b/__pycache__/calendarQstrt.cpython-37.pyc differ diff --git a/__pycache__/readDocx.cpython-37.pyc b/__pycache__/readDocx.cpython-37.pyc new file mode 100644 index 0000000..aff40df Binary files /dev/null and b/__pycache__/readDocx.cpython-37.pyc differ diff --git a/__pycache__/sheetsAuth.cpython-37.pyc b/__pycache__/sheetsAuth.cpython-37.pyc new file mode 100644 index 0000000..87a604e Binary files /dev/null and b/__pycache__/sheetsAuth.cpython-37.pyc differ diff --git a/__pycache__/vcnlCounter.cpython-39.pyc b/__pycache__/vcnlCounter.cpython-39.pyc new file mode 100644 index 0000000..ca5133c Binary files /dev/null and b/__pycache__/vcnlCounter.cpython-39.pyc differ diff --git a/calendarQstrt.py b/calendarQstrt.py new file mode 100644 index 0000000..ca87786 --- /dev/null +++ b/calendarQstrt.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +from __future__ import print_function +import datetime +import os.path + +import tkinter as tk + +from google.auth.transport.requests import Request +from google.oauth2.credentials import Credentials +from google_auth_oauthlib.flow import InstalledAppFlow +from googleapiclient.discovery import build +from googleapiclient.errors import HttpError + +SCOPES=['https://www.googleapis.com/auth/calendar.readonly'] + +def main(): + + """Shows basic usage of the Google Calendar API. + Prints the start and name of the next 10 events on the user's calendar + """ + creds=None + if os.path.exists('token.json'): + creds=Credentials.from_authorized_user_file('token.json', SCOPES) + if not creds or not creds.valid: + if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) + else: + flow=InstalledAppFlow.from_client_secrets_file( + 'credentials-sheets.json',SCOPES) + creds=flow.run_local_server(port=0) + with open('token.json','w') as token: + token.write(creds.to_json()) + try: + service=build('calendar','v3',credentials=creds) + + # Call the Calendar API + now=datetime.datetime.utcnow().isoformat()+'Z' + print('Getting the upcoming 10 events') + events_result=service.events().list(calendarId='primary', + timeMin=now,maxResults=10,singleEvents=True, + orderBy='startTime').execute() + events=events_result.get('items',[]) + + if not events: + print('No upcoming events found.') + return + + for event in events: + start=event['start'].get('dateTime',event['start'].get('date')) + description=event.get('description','') + print(start, event['summary'], description) + + except HttpError as error: + print('An error occurred: %s' % error) + +if __name__=='__main__': + main() \ No newline at end of file diff --git a/calendarWeek.py b/calendarWeek.py new file mode 100644 index 0000000..11fb27b --- /dev/null +++ b/calendarWeek.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python3 +# display events for next 7 days +from __future__ import print_function +import datetime +import os.path +#import collections +from collections import ChainMap +import tkinter as tk +from tkinter.scrolledtext import ScrolledText + +from google.auth.transport.requests import Request +from google.oauth2.credentials import Credentials +from google_auth_oauthlib.flow import InstalledAppFlow +from googleapiclient.discovery import build +from googleapiclient.errors import HttpError + +SCOPES=['https://www.googleapis.com/auth/calendar.readonly'] + +"""Shows basic usage of the Google Calendar API. +Prints the start and name of the next 7 days on the user's calendar +""" +creds=None +if os.path.exists('token.json'): + creds=Credentials.from_authorized_user_file('token.json', SCOPES) +if not creds or not creds.valid: + if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) + else: + flow=InstalledAppFlow.from_client_secrets_file( + 'credentials-sheets.json',SCOPES) + creds=flow.run_local_server(port=0) + with open('token.json','w') as token: + token.write(creds.to_json()) + +try: + service=build('calendar','v3',credentials=creds) + + # Call the Calendar API + now=datetime.datetime.utcnow().isoformat()+'Z' #datetime in crrct frmt + today=datetime.datetime.now() + max=(today+datetime.timedelta(days=7)).isoformat()+'Z' + print("Getting the week's events") + events_result=service.events().list(calendarId='primary', + timeMin=now,timeMax=max,singleEvents=True, + orderBy='startTime',prettyPrint=True).execute() + events=events_result.get('items',[]) #list of dict (event=dict) + + #dont use events_result. dictionary, then list of dictionaries + eventsJ=([kind["summary"] for kind in events])+(([kind["start"] for kind in events])) + #for eventJ in eventsJ: + #print(events_result) + print(eventsJ) + + + #second calendar + events_result2=service.events().list(calendarId='greendaygirl0123@gmail.com', + timeMin=now,timeMax=max,singleEvents=True, + orderBy='startTime').execute() + events2=events_result2.get('items',[]) + + if not events: + print('No upcoming events found.') + + if not events2: + print('No upcoming events2 found.') + + for event in events: + start=datetime.datetime.fromisoformat( + event['start'].get('dateTime',event['start'].get('date'))) + description=event.get('description','') + + for event2 in events2: + start2=datetime.datetime.fromisoformat( + event2['start'].get('dateTime',event2['start'].get('date'))) + description2=event2.get('description','') + + print(start, event['summary'], description,"\n", + start2, event2['summary'], description2,"\n") + +except HttpError as error: + print('An error occurred: %s' % error) + +window=tk.Tk() +window.title("Next 7 days") +#window.geometry('600x400+50+50') +#window.columnconfigure(0, weight=1) +#window.columnconfigure(2, weight=3) +#window.rowconfigure(0, weight=1) +#window.rowconfigure(1, weight=5) +#window.rowconfigure(2, weight=5) + +idLbl1=tk.Label(window, text="Calendar User", relief="sunken") +idLbl1.grid(column=0,row=0, sticky="nsew") + +idLblJ=tk.Label(window,text="Jimmy", relief="sunken") +idLblJ.grid(column=0,row=1, sticky="nsew") + +idLblK=tk.Label(window,text="Katie", relief="sunken") +idLblK.grid(column=0,row=2, sticky="nsew") + +strtLbl1=tk.Label(window,text="start date/time in UTC", relief="sunken") +strtLbl1.grid(column=1,row=0, sticky="nsew") + +strtLblJ=tk.Label(window,text=start,relief="sunken") +strtLblJ.grid(column=1,row=1, sticky="nsew") + +strtLblK=tk.Label(window,text=start2, relief="sunken",) +strtLblK.grid(column=1,row=2, sticky="nsew") + +sumLbl1=tk.Label(window,text="summary", relief="sunken") +sumLbl1.grid(column=2,row=0, sticky="nsew") + +sumLblJ=tk.Label(window,text=event['summary'],relief="sunken") +sumLblJ.grid(column=2,row=1,sticky="nsew") + +"""sclTeventj=tk.scrolledtext.ScrolledText(window,height=2,width=30,wrap='word', +relief="sunken") +sclTeventj.insert(tk.INSERT,([kind["summary"] for kind in events])) +sclTeventj.grid(column=2,row=1,sticky="nsew")""" + +"""sumTxtJ=tk.Text(window,height=10,wrap="word",relief="sunken") +sumTxtJ.grid(column=2,row=1, sticky="nsew") +sumTxtJ.insert(tk.END,eventsJ) +sumTxtJ.configure(state='disabled') +scrlBrJ=tk.Scrollbar(sumTxtJ) +scrlBrJ.pack(side="right",fill='y') +sumTxtJ.config(yscrollcommand=scrlBrJ.set) +scrlBrJ.config(command=sumTxtJ.yview)""" + +sumLblK=tk.Label(window,text=event2['summary'], relief="sunken") +sumLblK.grid(column=2,row=2, sticky="nsew") + +dscLbl1=tk.Label(window,text="description", relief="sunken") +dscLbl1.grid(column=3,row=0, sticky="nsew") + +dscLblJ=tk.Label(window,text=description, relief="sunken") +dscLblJ.grid(column=3,row=1, sticky="nsew") + +dscLblK=tk.Label(window,text=description2, relief="sunken") +dscLblK.grid(column=3,row=2, sticky="nsew") + +dateLbl1=tk.Label(window,text="WEEK", relief="sunken") +dateLbl1.grid(column=0,columnspan=2, row=4, sticky="nsew") + +dateLblMin=tk.Label(window,text=now,relief="sunken") +dateLblMin.grid(column=2,row=4, sticky="nsew") + +dateLblmax=tk.Label(window,text=max,relief="sunken") +dateLblmax.grid(column=3,row=4,stick="nsew") +window.mainloop() \ No newline at end of file diff --git a/checkListfromList.py b/checkListfromList.py new file mode 100755 index 0000000..349039f --- /dev/null +++ b/checkListfromList.py @@ -0,0 +1,229 @@ +#!/usr/bin/env python3 +import tkinter as tk +from tkinter import ttk +import datetime +import re +import shelve + +entries=[] # updated by user +buttons=[] +count=0 +kount=0 + +window=tk.Tk() +window.title((datetime.date.today()).strftime("%B")) +window.minsize(width=240, height=50) +window.maxsize(width=240,height=365) +window.resizable(width=True,height=True) +window.columnconfigure(0,weight=1) +window.columnconfigure(1,weight=1) + + +uframe=tk.Frame(window) #entry widget, add and delete button +uframe.columnconfigure(0,weight=1) +uframe.columnconfigure(1,weight=1) +uframe.grid(row=0,column=0,columnspan=2,sticky='nsew') + +scrollframe=tk.Frame(window, height=283, width=240) +scrollframe.grid_columnconfigure(0,weight=1) +scrollframe.grid_rowconfigure(0,weight=1) +scrollframe.grid(row=1,column=0,sticky='nsew') +scrollframe.grid_propagate(0) + +kanvas=tk.Canvas(scrollframe) +rScroll=ttk.Scrollbar(scrollframe,orient='vertical', + command=kanvas.yview) +rScroll.grid(row=0,column=1,sticky='ns') +kanvas.configure(yscrollcommand=rScroll.set,borderwidth=0, + bg='medium purple') +kanvas.configure(scrollregion=kanvas.bbox('all')) +kanvas.grid(row=0,column=0,sticky='nsew') + +rframe=tk.Frame(kanvas) # buttons created from input +kanvas.create_window((0,0),window=rframe,anchor='nw') +rframe.columnconfigure(0, minsize=225) + + +# reset/configure inner frame (rframe) to be scrollregion +def updateScrollRegion(kanvas): + kanvas.update_idletasks() + kanvas.configure(scrollregion=kanvas.bbox('all')) + +# set scrollwheel +def MouseWheelHandler(event): + direction=0 + if event.num==5 or event.delta==-120: + direction=1 + if event.num==4 or event.delta==120: + direction=-1 + kanvas.yview_scroll(direction,'units') +window.bind("",MouseWheelHandler) +window.bind("",MouseWheelHandler) +window.bind("",MouseWheelHandler) + +rframe.bind("", lambda event, kanvas=kanvas: updateScrollRegion(kanvas)) + +style=ttk.Style() +style2=ttk.Style() +style3=ttk.Style() + +style.theme_use('default') +style.configure('todo.TButton',foreground='blue4', + background='medium purple') +style.map('todo.TButton', + foreground=[('pressed','maroon'),('disabled','medium purple')], + background=[('active','slate blue'),('disabled','blue4')]) +style2.configure('admin.TButton',forgeground='deep pink', + background='MediumPurple4') +style2.map('admin.TButton', + foreground=[('pressed','DeepPink2'),('focus','hot pink'),('!focus','deep pink')], + background=[('active','DeepPink4'),('focus','MediumOrchid4')]) +style3.configure('admin.TEntry',forgeground='deep pink', + fieldbackground='MediumPurple4') +style3.map('admin.TEntry', + foreground=[('focus','hot pink'),('!focus','deep pink')], + fieldbackground=[('active','DeepPink4'),('focus','MediumOrchid4')]) + +content=tk.StringVar() + +def clear_entry(): + inPut.delete(0,'end') + +def add(): + cOntent=content.get() + entries.append(cOntent) + clear_entry() + count=len(entries) + for entry in entries: + btn=ttk.Button(rframe,text=entry,style='todo.TButton', + command=lambda :done()) + btn.grid(row=(count),column=0,sticky='ew') + if btn['text'].endswith(" DONE"): + btn['state']='disabled' + buttons.append(btn) + for children in rframe.winfo_children(): + if children.winfo_class() =='TButton': + if children not in buttons: + children.destroy() + inPut.focus_set() + updateScrollRegion(kanvas) + kanvas.yview('moveto',1) + + def done(): + btn.configure(text=btn['text']+" DONE",state='disabled') + return btn + +def reset(x): + remove=r'\sDONE' + for btn in buttons: + btn['state']='normal' + btn['text']=re.sub(remove,'',(btn['text'])) + +def save(): + saveData=[] + for button in buttons: + saveData.append(button['text']) + + shelfFile=shelve.open('/home/Jimmy/mu_code/savedButtons') + shelfFile['saveData']=saveData + shelfFile.close() + +def load(): + a=len(entries) + if a==0: + shelfFile=shelve.open('/home/Jimmy/mu_code/savedButtons') + saveData=shelfFile['saveData'] + for item in saveData: + inPut.insert(0,item) + add() + +def delete(): + entries.clear() + for button in buttons: + entries.append(button['text']) + + new=tk.Toplevel(window) + new.title('delete') + new.minsize(width=240, height=50) + new.resizable(width=True,height=True) + new.columnconfigure(0,weight=1) + new.columnconfigure(1,weight=1) + new.transient(window) + + + newFrame=tk.Frame(new) + newFrame.columnconfigure(0,weight=1) + newFrame.grid(row=0,column=0,columnspan=2,sticky='nsew') + +# listbox with vertical(y) scroll + lb=tk.Listbox(newFrame,bg='peach puff',fg='DeepPink2', + selectbackground='maroon3',selectforeground='DarkOrchid4') + lb.grid(column=0,row=0, columnspan=2,sticky='nsew') + yScroll=ttk.Scrollbar(new, orient='vertical') + yScroll.grid(column=2, row=0, sticky='ns') + yScroll['command']=lb.yview + lb.configure(yscrollcommand=yScroll.set) + + reMove=ttk.Button(newFrame,text='remove',style='admin.TButton', + command=lambda :remove()) + reMove.grid(column=0,row=1,sticky='ew') + + for entry in entries: + lb.insert(tk.END,entry) + + def remove(): + rmvdTxt=lb.get(tk.ANCHOR) + lb.delete(tk.ANCHOR) + entries.remove(rmvdTxt) + new.destroy() + reload=[] + for button in buttons: + if button['text']==rmvdTxt: + buttons.remove(button) + entries.clear() + for button in buttons: + entries.append(button['text']) + for entry in entries: + reload.append(entry) + entries.clear() + buttons.clear() + for widget in rframe.winfo_children(): + widget.destroy() + for item in reload: + inPut.insert(0,item) + add() + +def hitenter(event): + add() + +inPut=ttk.Entry(uframe,textvariable=content,style='admin.TEntry') +inPut.grid(row=0,column=0,columnspan=2,sticky='ew') +inPut.focus_set() + +inPut.bind('',hitenter) +aDd=ttk.Button(uframe,text='add',command=add,style='admin.TButton') +aDd.grid(row=1,column=0,sticky='nsew') + +deLete=ttk.Button(uframe,text='delete', +command=delete,style='admin.TButton') +deLete.grid(row=1,column=1,sticky='nsew') + +# make menu bar and drop down items +menubar=tk.Menu(window, background='SlateBlue2', + activebackground='slate blue',disabledforeground='blue4') +optionsmenu=tk.Menu(window,tearoff=0) +optionsmenu.add_command(background='SlateBlue2', + activebackground='slate blue',label='reset ALL',command=lambda x=buttons :reset(x)) +optionsmenu.add_command(background='SlateBlue2', + activebackground='slate blue',label='load',command=load) +optionsmenu.add_command(background='SlateBlue2', + activebackground='slate blue',label='save',command=save) +optionsmenu.add_command(background='SlateBlue2', + activebackground='slate blue',label='exit',command=window.destroy) +menubar.add_cascade(label='options',menu=optionsmenu) +datemenu=tk.Menu(window,tearoff=0) +menubar.add_cascade(label=((datetime.date.today()).strftime("%d-%m-%Y")), + state='disabled',menu=datemenu) +window.config(background='medium purple',menu=menubar) + +window.mainloop() \ No newline at end of file diff --git a/credentials-drive.json b/credentials-drive.json new file mode 100644 index 0000000..7501cc5 --- /dev/null +++ b/credentials-drive.json @@ -0,0 +1 @@ +{"installed":{"client_id":"383597059543-t1vbec53p6cm97rp8qdi8nep80mpkkud.apps.googleusercontent.com","project_id":"eminent-bond-333015","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}} \ No newline at end of file diff --git a/credentials-sheets.json b/credentials-sheets.json new file mode 100644 index 0000000..648cf1c --- /dev/null +++ b/credentials-sheets.json @@ -0,0 +1 @@ +{"installed":{"client_id":"383597059543-c3gpqitjek4c2tockq267f0vigl9ciii.apps.googleusercontent.com","project_id":"eminent-bond-333015","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}} \ No newline at end of file diff --git a/credentials.json b/credentials.json new file mode 100644 index 0000000..d9b8ccf --- /dev/null +++ b/credentials.json @@ -0,0 +1 @@ +{"web":{"client_id":"383597059543-nogj55vuhj9ci01sqbh2qcfe0f0fej8j.apps.googleusercontent.com","project_id":"eminent-bond-333015","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost:8080/"],"javascript_origins":["http://localhost:8080"]}} \ No newline at end of file diff --git a/data_capture/20220511-131832.csv b/data_capture/20220511-131832.csv new file mode 100644 index 0000000..e69de29 diff --git a/data_capture/20220513-111448.csv b/data_capture/20220513-111448.csv new file mode 100644 index 0000000..e69de29 diff --git a/data_capture/20220726-213605.csv b/data_capture/20220726-213605.csv new file mode 100644 index 0000000..e69de29 diff --git a/goodText.py b/goodText.py new file mode 100644 index 0000000..2c9b0a1 --- /dev/null +++ b/goodText.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 +# goodText.py-send sms via email (gmail) + +import ezgmail, ezsheets, random + +# who will be texted (1 recipient at a time) +#recipient='6059295681@vtext.com' #testing +recipient='6055954622@vtext.com' #Katie (LIVE) + +# leave blank, will send text as (subject)body if text here +subject='' + +# spreadsheet title=goodMessage +spreadsheetID='1cEviBnbCudweCIVYzHa1GX9l8feFwXMSdqkpDIX-E-A' +ss=ezsheets.Spreadsheet(spreadsheetID) +sheet=ss[0] + +# message to send +goodMessage=sheet[1,(random.randint(1,(int(sheet['B1']))))] +#print(goodMessage) + +body=goodMessage +# send message to recipient +ezgmail.send(recipient, subject, body) \ No newline at end of file diff --git a/images/alien.png b/images/alien.png new file mode 100644 index 0000000..7900bb8 Binary files /dev/null and b/images/alien.png differ diff --git a/images/alien_hurt.png b/images/alien_hurt.png new file mode 100644 index 0000000..250e6e8 Binary files /dev/null and b/images/alien_hurt.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..32778b4 --- /dev/null +++ b/index.html @@ -0,0 +1,33 @@ + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+

Cat is {state}

+

Red is {Rstate}

+

Green is {Gstate}

+ + \ No newline at end of file diff --git a/lightLog.txt b/lightLog.txt new file mode 100644 index 0000000..59b43d4 --- /dev/null +++ b/lightLog.txt @@ -0,0 +1,3 @@ +Ambient Light: 28 17:8:30 5/28/2023 +Ambient Light: 28 17:9:31 5/28/2023 +Ambient Light: 28 17:10:31 5/28/2023 diff --git a/loopButton.py b/loopButton.py new file mode 100644 index 0000000..b8f0ce4 --- /dev/null +++ b/loopButton.py @@ -0,0 +1,23 @@ +import tkinter as tk +from tkinter import ttk + +class App(tk.Tk): + def __init__(self): + super().__init__() + + self.geometry('300x100') + + button=ttk.Button(self,text='Save') + button.pack(expand=True) + + style=ttk.Style(self) + style.configure('TButton',font=('Helvetica',16)) + style.map('TButton', + foreground=[('pressed','blue'), + ('active','red')]) + + print(style.layout('TButton')) + +if __name__== "__main__": + app=App() + app.mainloop() \ No newline at end of file diff --git a/loopCalWeek.py b/loopCalWeek.py new file mode 100644 index 0000000..a5731c9 --- /dev/null +++ b/loopCalWeek.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +# display events for next 7 days +from __future__ import print_function +import datetime +import os.path + +import tkinter as tk +from tkinter import ttk + +from google.auth.transport.requests import Request +from google.oauth2.credentials import Credentials +from google_auth_oauthlib.flow import InstalledAppFlow +from googleapiclient.discovery import build +from googleapiclient.errors import HttpError + +SCOPES=['https://www.googleapis.com/auth/calendar.readonly'] + +"""Shows basic usage of the Google Calendar API. +Prints the start and name of the next 7 days on the user's calendar +""" +creds=None +if os.path.exists('token.json'): + creds=Credentials.from_authorized_user_file('token.json', SCOPES) +if not creds or not creds.valid: + if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) + else: + flow=InstalledAppFlow.from_client_secrets_file( + 'credentials-sheets.json',SCOPES) + creds=flow.run_local_server(port=0) + with open('token.json','w') as token: + token.write(creds.to_json()) + +try: + service=build('calendar','v3',credentials=creds) + window=tk.Tk() + window.title('next 7 days') + + # Call the Calendar API + now=datetime.datetime.utcnow().isoformat()+'Z' #datetime in crrct frmt + today=datetime.datetime.now() + max=(today+datetime.timedelta(days=7)).isoformat()+'Z' + print("Getting the week's events") + events_result=service.events().list(calendarId='primary', + timeMin=now,timeMax=max,singleEvents=True, + orderBy='startTime',prettyPrint=True).execute() + events=events_result.get('items',[]) #list of dict (event=dict) + #second calendar + events_result2=service.events().list(calendarId='greendaygirl0123@gmail.com', + timeMin=now,timeMax=max,singleEvents=True, + orderBy='startTime').execute() + events2=events_result2.get('items',[]) + + if not events: + print('No upcoming events found.') + + if not events2: + print('No upcoming events2 found.') + + + + for event in events: + start=datetime.datetime.fromisoformat( + event['start'].get('dateTime',event['start'].get('date'))) + Start=start.strftime("%a %m-%d %I:%M %p") + description=event.get('description','') + eventLblJ=tk.Label(window,text=(Start, event['summary'], description), + fg='cyan',bg='black',relief='sunken') + eventLblJ.grid(stick='nsew') + + keyLblJ=tk.Label(window,text="Jimmy",bg='black',fg='cyan', + relief='sunken') + keyLblJ.grid(sticky='nsew') + keyLblK=tk.Label(window,text="Katie",bg='cyan',relief='sunken') + keyLblK.grid(sticky='nsew') + + for event2 in events2: + start2=datetime.datetime.fromisoformat( + event2['start'].get('dateTime',event2['start'].get('date'))) + Start2=start2.strftime("%a %m-%d %I:%M %p") + description2=event2.get('description','') + eventLblK=tk.Label(window,text=(Start2, event2['summary'], description2), + bg='cyan',relief='sunken') + eventLblK.grid(sticky='nsew') + + print(Start, event['summary'], description,"\n", + Start2, event2['summary'], description2,"\n") + + + window.mainloop() +except HttpError as error: + print('An error occurred: %s' % error) \ No newline at end of file diff --git a/loopTest.py b/loopTest.py new file mode 100644 index 0000000..f2a6ac5 --- /dev/null +++ b/loopTest.py @@ -0,0 +1,34 @@ +from tkinter import * + +root=Tk() + +files=['bill1','bill2'] +btn=[] +content=StringVar() +"""for i in range(3): + files.append("Button"+str(i))""" + +def clear_entry(): + tYpe.delete(0,'end') + +def addTofiles(): + cOntent=content.get() + files.append(cOntent) + clear_entry() + + +for i in range(len(files)): + btn.append(Button(root,text=files[i], + command=lambda c=i: print(btn[c].cget("text")))) + btn[i].pack() + +tYpe=Entry(root,textvariable=content) +tYpe.pack() +filebtn=Button(root,text='add',command=addTofiles) +filebtn.pack() +menubar=Menu(root) +optionsmenu=Menu(root,tearoff=0) +optionsmenu.add_command(label='exit',command=root.quit) +menubar.add_cascade(label='options',menu=optionsmenu) +root.config(menu=menubar) +root.mainloop() \ No newline at end of file diff --git a/loopToLabelS.py b/loopToLabelS.py new file mode 100644 index 0000000..597e128 --- /dev/null +++ b/loopToLabelS.py @@ -0,0 +1,17 @@ +import tkinter as tk +import datetime +events=[{'kind': 'calendar#event', 'etag': '"3283203974568000"', 'id': 'n9tmirpipd7arjg8k72bnvr66q_20220117T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=bjl0bWlycGlwZDdhcmpnOGs3MmJudnI2NnFfMjAyMjAxMTdUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-16T21:37:44.000Z', 'updated': '2022-01-08T00:33:07.387Z', 'summary': 'Lifescape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-17T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-17T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'n9tmirpipd7arjg8k72bnvr66q_R20220117T203000', 'originalStartTime': {'dateTime': '2022-01-17T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'n9tmirpipd7arjg8k72bnvr66q_R20220117T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}, {'kind': 'calendar#event', 'etag': '"3283204004964000"', 'id': 'o70jch4k13ma7escsbl97esvs5_20220119T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=bzcwamNoNGsxM21hN2VzY3NibDk3ZXN2czVfMjAyMjAxMTlUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-10T21:37:34.000Z', 'updated': '2022-01-08T00:33:22.654Z', 'summary': 'LifeScape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-19T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-19T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'o70jch4k13ma7escsbl97esvs5_R20220119T203000', 'originalStartTime': {'dateTime': '2022-01-19T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'o70jch4k13ma7escsbl97esvs5_R20220119T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}, {'kind': 'calendar#event', 'etag': '"3283204024001000"', 'id': 'i611bn6sae4skpt1s5845jc4ph_20220120T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=aTYxMWJuNnNhZTRza3B0MXM1ODQ1amM0cGhfMjAyMjAxMjBUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-16T21:38:42.000Z', 'updated': '2022-01-08T00:33:32.068Z', 'summary': 'Lifescape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-20T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-20T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'i611bn6sae4skpt1s5845jc4ph_R20220120T203000', 'originalStartTime': {'dateTime': '2022-01-20T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'i611bn6sae4skpt1s5845jc4ph_R20220120T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}] +[{'kind': 'calendar#event', 'etag': '"3283203974568000"', 'id': 'n9tmirpipd7arjg8k72bnvr66q_20220117T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=bjl0bWlycGlwZDdhcmpnOGs3MmJudnI2NnFfMjAyMjAxMTdUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-16T21:37:44.000Z', 'updated': '2022-01-08T00:33:07.387Z', 'summary': 'Lifescape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-17T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-17T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'n9tmirpipd7arjg8k72bnvr66q_R20220117T203000', 'originalStartTime': {'dateTime': '2022-01-17T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'n9tmirpipd7arjg8k72bnvr66q_R20220117T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}, {'kind': 'calendar#event', 'etag': '"3283204004964000"', 'id': 'o70jch4k13ma7escsbl97esvs5_20220119T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=bzcwamNoNGsxM21hN2VzY3NibDk3ZXN2czVfMjAyMjAxMTlUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-10T21:37:34.000Z', 'updated': '2022-01-08T00:33:22.654Z', 'summary': 'LifeScape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-19T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-19T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'o70jch4k13ma7escsbl97esvs5_R20220119T203000', 'originalStartTime': {'dateTime': '2022-01-19T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'o70jch4k13ma7escsbl97esvs5_R20220119T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}, {'kind': 'calendar#event', 'etag': '"3283204024001000"', 'id': 'i611bn6sae4skpt1s5845jc4ph_20220120T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=aTYxMWJuNnNhZTRza3B0MXM1ODQ1amM0cGhfMjAyMjAxMjBUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-16T21:38:42.000Z', 'updated': '2022-01-08T00:33:32.068Z', 'summary': 'Lifescape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-20T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-20T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'i611bn6sae4skpt1s5845jc4ph_R20220120T203000', 'originalStartTime': {'dateTime': '2022-01-20T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'i611bn6sae4skpt1s5845jc4ph_R20220120T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}] +[{'kind': 'calendar#event', 'etag': '"3283203974568000"', 'id': 'n9tmirpipd7arjg8k72bnvr66q_20220117T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=bjl0bWlycGlwZDdhcmpnOGs3MmJudnI2NnFfMjAyMjAxMTdUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-16T21:37:44.000Z', 'updated': '2022-01-08T00:33:07.387Z', 'summary': 'Lifescape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-17T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-17T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'n9tmirpipd7arjg8k72bnvr66q_R20220117T203000', 'originalStartTime': {'dateTime': '2022-01-17T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'n9tmirpipd7arjg8k72bnvr66q_R20220117T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}, {'kind': 'calendar#event', 'etag': '"3283204004964000"', 'id': 'o70jch4k13ma7escsbl97esvs5_20220119T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=bzcwamNoNGsxM21hN2VzY3NibDk3ZXN2czVfMjAyMjAxMTlUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-10T21:37:34.000Z', 'updated': '2022-01-08T00:33:22.654Z', 'summary': 'LifeScape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-19T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-19T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'o70jch4k13ma7escsbl97esvs5_R20220119T203000', 'originalStartTime': {'dateTime': '2022-01-19T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'o70jch4k13ma7escsbl97esvs5_R20220119T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}, {'kind': 'calendar#event', 'etag': '"3283204024001000"', 'id': 'i611bn6sae4skpt1s5845jc4ph_20220120T203000Z', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=aTYxMWJuNnNhZTRza3B0MXM1ODQ1amM0cGhfMjAyMjAxMjBUMjAzMDAwWiBqaW1pcHVuazg4QG0', 'created': '2020-02-16T21:38:42.000Z', 'updated': '2022-01-08T00:33:32.068Z', 'summary': 'Lifescape Shift', 'description': 'work', 'colorId': '2', 'creator': {'email': 'jimipunk88@gmail.com', 'self': True}, 'organizer': {'email': 'jimipunk88@gmail.com', 'self': True}, 'start': {'dateTime': '2022-01-20T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'end': {'dateTime': '2022-01-20T23:00:00-06:00', 'timeZone': 'America/Chicago'}, 'recurringEventId': 'i611bn6sae4skpt1s5845jc4ph_R20220120T203000', 'originalStartTime': {'dateTime': '2022-01-20T14:30:00-06:00', 'timeZone': 'America/Chicago'}, 'iCalUID': 'i611bn6sae4skpt1s5845jc4ph_R20220120T203000@google.com', 'sequence': 1, 'reminders': {'useDefault': False}, 'eventType': 'default'}] +window=tk.Tk() +window.title('loop to labels') + +for event in events: + start=datetime.datetime.fromisoformat( + event['start'].get('dateTime',event['start'].get('date'))) + description=event.get('description','') + eventLbl=tk.Label(window,text=(start, event['summary'], description), + relief='sunken') + eventLbl.pack() + +window.mainloop() \ No newline at end of file diff --git a/luxLog.py b/luxLog.py new file mode 100755 index 0000000..66cf48a --- /dev/null +++ b/luxLog.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +import time +import datetime +import board + +import adafruit_veml7700 +import adafruit_bh1750 + +i2c = board.I2C() + +veml7700=adafruit_veml7700.VEML7700(i2c) +bh1750=adafruit_bh1750.BH1750(i2c) + + +logFile=open('lightLog.txt','w') +while True: + tH=time.strftime('%H', time.localtime()) + time.sleep(1) + while int(tH) <= 7: + ti=datetime.datetime.now() + logFile.write("Ambient Light: %d lux\n" % veml7700.light) + logFile.write("Light: %d lux\n" % bh1750.lux) + logFile.write(ti.strftime("%I:%M %p %d/%m/%y\n")) + logFile.flush() + print("Ambient Light: %d lux" % veml7700.light) # print statements are for debugging + print("Light: %d lux" % bh1750.lux) + print(ti.strftime("%I:%M %p %d/%m/%y\n")) + time.sleep(60.0) + else: + logFile.close() + print("out of time") + quit("after 7 am") \ No newline at end of file diff --git a/menubarDemo.py b/menubarDemo.py new file mode 100644 index 0000000..82bd7b2 --- /dev/null +++ b/menubarDemo.py @@ -0,0 +1,18 @@ +import tkinter as tk + +def donothing(): + x=0 + +window=tk.Tk() + +menubar=tk.Menu(window) +filemenu=tk.Menu(menubar,tearoff=0) +"""filemenu.add_command(label='New',command=donothing) +filemenu.add_command(label='Open',command=donothing) +filemenu.add_command(label='Save',command=donothing) +filemenu.add_separator()""" +menubar.add_command(label='exit',command=window.quit) +menubar.add_cascade(label='file',menu=filemenu) + +window.config(menu=menubar) +window.mainloop() \ No newline at end of file diff --git a/monthlyCheckList2.py b/monthlyCheckList2.py new file mode 100644 index 0000000..3f88f08 --- /dev/null +++ b/monthlyCheckList2.py @@ -0,0 +1,43 @@ +import tkinter as tk +from tkinter import ttk +import datetime + +month=(datetime.date.today()).strftime("%B") # get current MONTH + +window=tk.Tk() +window.title(month) # title is current MONTH +content=tk.StringVar() + +btn=[] # button list +entries=[] # list to fill from entry widget +count=len(entries) +entry=ttk.Entry(window, textvariable=content) +entry.grid(row=0,column=0) + +def clear_entry(): + entry.delete(0,'end') + +def add(): + global content + cOntent=content.get() + entries.append(cOntent) + global count + for i in range(len(entries)): + btn.append(ttk.Button(window,text=cOntent, + command=lambda i=i :done())) + + def done(): + btn.append(ttk.Button(window,text=cOntent+" DONE", + state='disabled')) + btn[-1].grid(row=count+1,column=0,sticky='nsew') + + btn[-1].grid(row=count+2,column=0,sticky='nsew') + count += 1 + clear_entry() + print(entries[0:(len(entries))],len(entries)) + #print(window.grid_slaves(),cOntent) + + +add=tk.Button(window,text='Add',command=add) +add.grid(row=1,column=0) +window.mainloop() \ No newline at end of file diff --git a/monthlyChecklist.py b/monthlyChecklist.py new file mode 100644 index 0000000..ecfebdc --- /dev/null +++ b/monthlyChecklist.py @@ -0,0 +1,48 @@ +import tkinter as tk +from tkinter import ttk +import datetime + +month=(datetime.date.today()).strftime("%B") # get current MONTH + +window=tk.Tk() +window.title(month) # title is current MONTH +content=tk.StringVar() +reminder=[] # button list +item=[] # list of input from entry +cOntent=content.get() +count=0 +style=ttk.Style() +style.theme_use('default') +style.configure('styled.TButton',foreground='blue',background='yellow') +style.map('styled.TButton', + foreground=[('pressed','red'),('focus','green'),('disabled','yellow')], + background=[('active','yellow'),('disabled','blue')]) + +reminderEntry=ttk.Entry(window, textvariable=content) +reminderEntry.grid(row=0,column=0) + +def clear_entry(): + reminderEntry.delete(0,'end') +def add(): + global content + cOntent=content.get() + global count + reminder.append(ttk.Button(window,text=cOntent,command=lambda :done(), + style='styled.TButton')) + + def done(): + for i in range(len(cOntent)): + reminder[i].configure(text=reminder[i]['text']+" DONE", + state='disabled') + print((reminder[i]).configure()) + + reminder[-1].grid(row=count+2,column=0,sticky='nsew') + count += 1 + clear_entry() + + + +add=tk.Button(window,text='Add',command=add) +add.grid(row=1,column=0) +print(window.grid_slaves(),cOntent) +window.mainloop() \ No newline at end of file diff --git a/msfinstall b/msfinstall new file mode 100755 index 0000000..9cea684 --- /dev/null +++ b/msfinstall @@ -0,0 +1,175 @@ +#!/bin/sh + +print_pgp_key() { + cat <<-EOF +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBFDAy/0BEAC8I5bw5gLQqHKx5JCacYcXFL6AZowl3qIOTxo5yfBl8CepNpWY +OOERvIUJb17WehhhbWOo9WjpBalDXBRtI1NvfArewOT8fLm7BdhYe8U45moBfkYi +xFtNrPw3pdIltHQISrB8PufhliN8obQuq0rcxYV8NblvYo4gIGNjBfO1QGvBNmp7 +kBtjlAuZguScZmUTdPOwfv8fqN52X9tCv1ahQk1hg8XG9YwW0vXb5z93jkLXBb5b +sRCnou4m9IV6vOv2HVNRyMKT7uht3z4FqflP9NkySl4daCdZgmXbf169vvLdwLrC +lVymwAbwvuyILZv4JW1w0Kx8nWiTuK5A886882i83lxnkh1vC9jInva4/5hTrbRw +XJb7qOyh7sxa5GOfgq1NwVfLkrvVCMystrPu18sF1ORfg1UTFcz86RYdxpmoZvk7 +EeABiLCQDZKOf0fV3U9CxLj8gXPjPY1Lu6udZUN6NG1ALJjsPkGnbpQEqEJlKNAG ++rF+tp73TrG0PW8C/THL7fN93ET3wn5tfNu86Liui9wd8ZLuPJNEYeE6eyPAgXJ4 +p69Yb4ou5um5jWnzaVameECBZvtc4HOhy3nTEiVMDcKv/o8XxKOCLpjW1RSDirKl +ZRIsJYPx2yuJSVMCsN5Sghp5+OCsQ+On4OFWxCskemvy97ftkv/fwUI7mQARAQAB +tCJNZXRhc3Bsb2l0IDxtZXRhc3Bsb2l0QHJhcGlkNy5jb20+iQJUBBMBCAA+AhsD +BQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAFiEECeVfr094Ys1tVYmXzftfpSAHuVQF +Al1xL2oFCR98Zm0ACgkQzftfpSAHuVTPlg/9H++FCAMEoQxxWeQ1e7RkQbplrjmA ++w1hqto1YnJDB3RFpvEubS45h/36Lgs1SmcgGx1dw2uzjSAtWS/4MWtvnyWXFV3K +ZjhyJAlNw7bZLcrJHqpGFdVJvRuPmf6dYvPgSaqZQv0HP2fwSwu/msGJ8u1E7kDW +KpTg5LeQlJ3F3eePSAIa47Y0H6AaNuiW1lUz4YTboRKfDRYQizfKKi/9ssqAXNI5 +eAPLhj9i3t/MVSGtV2G6xldEQLM7A0CI4twrIplyPlYt5tCxdA225cRclRYbqaQX +AcE34YJWAWCgGxw98wxQZwtk8kXSwPdpMyrHadaAHiTzqPBlTrSes8sTDoJxfg8P +k73ILgBIey4FD7US5V46MZrKtduFmL9OvqTvZl17r6xaoScrH4oK690VHmdkfM2P +KOkgRU8PumlIjGvTDavm5afh6LkD75XDLPF5n9Om7F+Sc+2Ul+SPYV8kQaFHX1XD +QuHBeJRT9VdO9T/SI2YHkCnatC50nr9V/gK2ecui+ri8gto29jaAmz7IhdNlMU9k +EPfAbnG6Mu6DLlpjsTBYEyuAnmKVWvNBDlgC4d42WQMGleeSXCZzC0Wh3t9FbBOc +3+OB1aEdUrx1dE0elWyrzUFHmd/EOCXpLSE4RYcN6TuCIkEI0TyXYmDRQWGofK0G +S8CxmfmppfGI92C5Ag0EUMDL/QEQALkDKrnosJ5erN/ot2WiaM82KhI30J6+LZUL +9sniuA1a16cfoQfwXTnFpcd48O41aT2BNp0jpGjDo49rRC8yB7HjCd1lM+wRRm/d +0Et/4lBgycaa63jQtG+GK9gN+sf4LkiDgJYkXX2wEOilvZw9zU2VLTGhOUB+e7vR +P2LpnA4nSkvUGNKvaWcF+k/jeyP2o7dorXumfXfjGBAYiWCF6hDiy8XT5G2ruMDD +lWafoleGSVeuB0onijqzRU5BaN+IbMIzGWLRP6yvhYmmO1210IGZBF3/gJLR3OaU +m82AV5Eg4FslzBViv620hDuVsEoeRne2uN/qiEtYjSLJWYn5trtApQkk/1i+OK6c +/lqtT+CyQ/IS69E5+fJYkAYkCgHJBdcJmDXSHKycarDDihPSPuN131kgyt/wZLE9 +oV6eeH5ay9ruto9NYELNjmGVrZyZyAYRo6duN/ZyUBbczIaaWVCkEYgO04rwamkT +wOdWGEzj24gNMcXYCKQyW2OrDN3odX3f1UDvsiZqX88o0fI5YQB2YhGBjAfH5wSP +MkBBJCR3Qbc9J8ksFp//RWjWcFq/yr1WOCqEQVo1PMSPkeqfqV3ApS6XhVv4ChKL +PlnV27fa6XUK1yjNQlNxYkv15tnxhtKrLs6XiyVJbe6Q1obq0FOpBhv2WIh291BQ +bqgmGbNvABEBAAGJAjwEGAEIACYCGwwWIQQJ5V+vT3hizW1ViZfN+1+lIAe5VAUC +XXEvjgUJH3xmkQAKCRDN+1+lIAe5VJueD/4+6ldtpXYin+lWcMyHM8487GczLi8S +XgxZJu/2GzEpgdke8xoQWv6Jsk2AQaPLciIT7yU7/gTWsOiY7Om+4MGqZY+KqZ/X +eI8nFsGQx2yI7TDUQasN4uB5y6RnMGSH8DbAIWydVP2XWNVCHcVNMbeAoW7IiOOh +I2wT4bCmzrjfVsJRo8VvpykPhm7+svsU2ukMW0Ua77bA1gzdvPpRzN2I1MY/6lJk +x7BwtYsiAZt0+jII31IdCNpz4BlU3eadG+QbEH/q5FrHPBtkRWmziJpKXZDWdAg/ +I7yim36xfxjMtcv8CI3YKmy5jYcGKguA2SGApQpPEUkafLZc62v8HVmZZFKmLyXR +XM9YTHz4v4jhruJ80M6YjUtfQv0zDn2HoyZuPxAW4HCys1/9+iAhuFqdt1PnHBs/ +AmTFlQPAeMu++na4uc7vmnDwlY7RDPb0uctUczhEO4gT5UkLk5C9hcOKVAfmgF4n +MNgnOoSZO2orPKh3mejj+VAZsr1kfEWMoFeHPrWdxgRmjOhUfy6hKhJ1H306aaSQ +gkE3638Je/onWmnmZrDEZq7zg0Qk3aOOhJXugmRnIjH341y/whxvAdJIyXrjLN4z +qCU0JkA1rVqS6PXZabKb9DOqYa4pr9thGS5rU+Gn3GWiSq2PtVW6Hh83WOFcEsMk +2vTa24LE0J2DQg== +=Qa/n +-----END PGP PUBLIC KEY BLOCK----- +EOF +} + +install_deb() { + LIST_FILE=/etc/apt/sources.list.d/metasploit-framework.list + PREF_FILE=/etc/apt/preferences.d/pin-metasploit.pref + echo -n "Adding metasploit-framework to your repository list.." + echo "deb $DOWNLOAD_URI/apt lucid main" > $LIST_FILE + print_pgp_key | apt-key add - + if [ ! -f $PREF_FILE ]; then + mkdir -p /etc/apt/preferences.d/ + cat > $PREF_FILE < /dev/null + echo "OK" + echo "Checking for and installing update.." + apt-get install -y --allow-downgrades metasploit-framework +} + +install_rpm() { + echo "Checking for and installing update.." + REPO_FILE=/etc/yum.repos.d/metasploit-framework.repo + GPG_KEY_FILE=/etc/pki/rpm-gpg/RPM-GPG-KEY-Metasploit + echo -n "Adding metasploit-framework to your repository list.." + + cat > /etc/yum.repos.d/metasploit-framework.repo < ${GPG_KEY_FILE} + yum install -y metasploit-framework +} + +install_suse() { + echo "Checking for and installing update.." + GPG_KEY_FILE_DIR=/etc/pki/rpm-gpg + GPG_KEY_FILE=${GPG_KEY_FILE_DIR}/RPM-GPG-KEY-Metasploit + echo -n "Adding metasploit-framework to your repository list.." + if [ ! -d $GPG_KEY_FILE_DIR ]; then + mkdir -p $GPG_KEY_FILE_DIR + fi + zypper ar -f $DOWNLOAD_URI/rpm metasploit + print_pgp_key > ${GPG_KEY_FILE} + rpmkeys --import ${GPG_KEY_FILE} + zypper install -y metasploit-framework +} + +install_pkg() +{ + ( + cd ~/Downloads + + echo "Downloading package..." + curl -O "$DOWNLOAD_URI/osx/metasploitframework-latest.pkg" + + echo "Checking signature..." + + if pkgutil --check-signature metasploitframework-latest.pkg; then + echo "Installing package..." + installer -pkg metasploitframework-latest.pkg -target / + fi + + echo "Cleaning up..." + rm -fv metasploitframework-latest.pkg + ) +} + +DOWNLOAD_URI=http://downloads.metasploit.com/data/releases/metasploit-framework +PKGTYPE=unknown +ID=`id -u` + +if [ -f /etc/redhat-release ] ; then + PKGTYPE=rpm +elif [ -f /etc/system-release ] ; then + # If /etc/system-release is present, this is likely a distro that uses RPM. + PKGTYPE=rpm +else + if uname -sv | grep 'Darwin' > /dev/null; then + PKGTYPE=pkg + elif [ -f /usr/bin/zypper ] ; then + PKGTYPE=sus + else + PKGTYPE=deb + fi +fi + +if [ "$ID" -ne 0 ]; then + if ! hash sudo 2>/dev/null; then + echo "This script must be executed as the 'root' user or with sudo" + exit 1 + else + echo "Switching to root user to update the package" + sudo -E $0 $@ + exit 0 + fi +fi + +case $PKGTYPE in + deb) + install_deb + ;; + sus) + install_suse + ;; + rpm) + install_rpm + ;; + *) + install_pkg +esac diff --git a/newGT.py b/newGT.py new file mode 100755 index 0000000..4156205 --- /dev/null +++ b/newGT.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +import os.path +import random +import itertools +import base64 +from email.mime.text import MIMEText +from google.auth.transport.requests import Request +from google.oauth2.credentials import Credentials +from google_auth_oauthlib.flow import InstalledAppFlow +from googleapiclient.discovery import build + + +SCOPES=['https://www.googleapis.com/auth/spreadsheets.readonly', +'https://mail.google.com/'] +SPREADSHEET='1cEviBnbCudweCIVYzHa1GX9l8feFwXMSdqkpDIX-E-A' +RANGE='goodMessages!A:A' + +# authorization from credentials to token +creds=None +"""the file token-gt.json stores access/refresh tokens, and is +created automatically when auth flow completes first time""" +if os.path.exists('token-gt.json'): + creds=Credentials.from_authorized_user_file('token-gt.json',SCOPES) +# If there are no (valid) credentials available, let the user log in +if not creds or not creds.valid: + if creds and creds.expired and creds.refresh_token: + creds.refresh(Request()) + else: + flow=InstalledAppFlow.from_client_secrets_file( + 'credentials-sheets.json', SCOPES) + creds=flow.run_local_server(port=0) + # Save credentials for next run + with open('token-gt.json','w') as token: + token.write(creds.to_json()) + +# build sheets +sheetsServ=build('sheets','v4', credentials=creds) +result=sheetsServ.spreadsheets().values().get(spreadsheetId=SPREADSHEET,\ +range=RANGE).execute() +rows=result.get('values',[]) +texts=list(itertools.chain(*rows)) +text=texts[(random.randint(0,(len(texts)-1)))] +#print(text) + +# build gmail +mailServ=build('gmail','v1', credentials=creds) + +def create_message(sender,to, subject, message_text): + """Create a message for an email. + Args: + sender: Email address of sender + to: Email address of receiver + subject: The subject of the email message + message_text: the text of the email message + + returns: + an object containing a base64url encoded email object + """ + message=MIMEText(message_text) + message['to']=to + message['from']=sender + message['subject']=subject + return{'raw':base64.urlsafe_b64encode(message.as_string().encode()). + decode()} + +LIVE='6055954622@vtext.com' #KATIE +TESTING='6059295681@vtext.com' #JIMMY +message=create_message(sender='me',to=LIVE, +subject='',message_text=text) +#print(message) +eMessage=(mailServ.users().messages(). +send(userId='me', body=message).execute()) \ No newline at end of file diff --git a/octoStatus.py b/octoStatus.py new file mode 100755 index 0000000..0f19efe --- /dev/null +++ b/octoStatus.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python3 +# octoStatus-ping octoCams and light LED to show status + +from gpiozero import LED +from time import sleep +import os + +ledg0=LED(4) #1 +ledr0=LED(17) #3 +ledg1=LED(27) #5 +ledr1=LED(22) #7 +ledg2=LED(23) #9 +ledr2=LED(6) #11 +ledg3=LED(21) #13 +ledr3=LED(20) #15 +ledg4=LED(19) #17 +ledr4=LED(13) #19 +ledg5=LED(18) #21 +ledr5=LED(24) #23 +ledg6=LED(12) #25 +ledr6=LED(16) #27 + +octoCam0='192.168.0.60' +octoCam1='192.168.0.34' +octoCam2='192.168.0.32' +octoCam3='192.168.0.33' +octoCam4='192.168.0.36' +octoCam5='192.168.0.37' +octoCam6='192.168.0.38' + +while True: + # octoCam0 + response=os.system('ping -c1 '+octoCam0) + if response==0: + ledg0.on() + ledr0.off() + sleep(0.1) + else: + ledg0.off() + ledr0.on() + sleep(0.1) + + # octoCam1 + response=os.system('ping -c1 '+octoCam1) + if response==0: + ledg1.on() + ledr1.off() + sleep(0.1) + else: + ledg1.off() + ledr1.on() + sleep(0.1) + + # octoCam2 + response=os.system('ping -c1 '+octoCam2) + if response==0: + ledg2.on() + ledr2.off() + sleep(0.1) + + else: + ledg2.off() + ledr2.on() + sleep(0.1) + + # octoCam3 + response=os.system('ping -c1 '+octoCam3) + if response==0: + ledg3.on() + ledr3.off() + sleep(0.1) + else: + ledg3.off() + ledr3.on() + sleep(0.1) + + # octoCam4 + response=os.system('ping -c1 '+octoCam4) + if response==0: + ledg4.on() + ledr4.off() + sleep(0.5) + else: + ledg4.off() + ledr4.on() + sleep(0.5) + + # octoCam5 + response=os.system('ping -c1 '+octoCam5) + if response==0: + ledg5.on() + ledr5.off() + sleep(0.5) + else: + ledg5.off() + ledr5.on() + sleep(0.5) + + # octoCam6 + response=os.system('ping -c1 '+octoCam6) + if response==0: + ledg6.on() + ledr6.off() + sleep(0.5) + else: + ledg6.off() + ledr6.on() + sleep(0.5) +# sleep(23) diff --git a/pcfText.py b/pcfText.py new file mode 100644 index 0000000..384869c --- /dev/null +++ b/pcfText.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +import time +import board + +import adafruit_pcf8591.pcf8591 as PCF +from adafruit_pcf8591.analog_in import AnalogIn +from adafruit_pcf8591.analog_out import AnalogOut + +i2c=board.I2C() +pcf=PCF.PCF8591(i2c) + +pcf_in_0=AnalogIn(pcf,PCF.A0) +pcf_out=AnalogOut(pcf,PCF.OUT) + +pcf_out.value=65535 +raw_value=pcf_in_0.value +scaled_value=(raw_value/65535)*pcf_in_0.reference_voltage +print("Pin 0: %0.2fV" % (scaled_value)) +print("") \ No newline at end of file diff --git a/pyportalTEST.py b/pyportalTEST.py new file mode 100644 index 0000000..d98de1c --- /dev/null +++ b/pyportalTEST.py @@ -0,0 +1,20 @@ +import board, time, adafruit_touchscreen +from adafruit_pyportal import PyPortal + +ts = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR, board.TOUCH_YD, board.TOUCH_YU) + +meals=["/breakfastTime.bmp","/lunchTime.bmp","/dinnerTime.bmp"] + +pyportal = PyPortal() + +mealtime=0 + +while True: + tou=ts.touch_point + if tou: + # TODO: do something when touch is detected + pyportal.set_background(meals[mealtime]) + mealtime=mealtime+1 + if mealtime==3: + mealtime=0 + time.sleep(3) \ No newline at end of file diff --git a/savedButtons.db b/savedButtons.db new file mode 100644 index 0000000..5f350d3 Binary files /dev/null and b/savedButtons.db differ diff --git a/search5.py b/search5.py new file mode 100644 index 0000000..4ba47e6 --- /dev/null +++ b/search5.py @@ -0,0 +1,17 @@ +#! /usr/bin/python3 +# search5.py-search by command line and open 5 tabs + +import requests,sys,webbrowser,bs4 +print('Searching...') +res=requests.get('https://pypi.org/search?q='+ ' '.join(sys.argv[1:])) +res.raise_for_status() + +# Retrieve top search result links +soup=bs4.BeautifulSoup(res.text,'lxml') +# Open a browser tab for each result +linkElems=soup.select('.package-snippet') +numOpen=min(5,len(linkElems)) +for i in range(numOpen): + urlToOpen='https://pypi.org/search?q='+linkElems[i].get('href') + print('Opening',urlToOpen) + webbrowser.open(urlToOpen) \ No newline at end of file diff --git a/searchKeloland.py b/searchKeloland.py new file mode 100644 index 0000000..3949c83 --- /dev/null +++ b/searchKeloland.py @@ -0,0 +1,13 @@ +#!/usr/bin/python3 +# search keloland-open multiple articles from homepage +import requests, webbrowser, bs4 + +res=requests.get('https://keloland.com') +res.raise_for_status() +kelosoup=bs4.BeautifulSoup(res.text,'lxml') +linkElems=kelosoup.select('article-list') +numOpen=min(5,len(linkElems)) +for i in range(numOpen): + urlToOpen='https://keloland.com'+linkElems[i].get('href') + print('Opening',urlToOpen) + webbrowser.open(urlToOpen) \ No newline at end of file diff --git a/senseTemp.py b/senseTemp.py new file mode 100644 index 0000000..324f87c --- /dev/null +++ b/senseTemp.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +# use senseHat to get temp and display on LED matrix +from sense_hat import SenseHat +from time import sleep +sense=SenseHat() +# set rotation (0 is pwr port) +sense.set_rotation(180) +sense.low_light=True +cels=sense.get_temperature() +temp=(cels*1.8)+32 +print('%s F' % temp) +while True: + sense.show_message('%s C' % temp, text_colour=[255,128,0],back_colour=[0,0,255]) \ No newline at end of file diff --git a/styledBtn.py b/styledBtn.py new file mode 100644 index 0000000..e56fc3f --- /dev/null +++ b/styledBtn.py @@ -0,0 +1,23 @@ +import tkinter as tk +from tkinter import ttk + +win=tk.Tk() +def click(): + btn['text']='click' +def click2(): + btn2['text']='click2' + +style=ttk.Style() +style.theme_use('default') +style.configure('styled.TButton',foreground='deep pink',background='purple3') +style.map('styled.TButton', + foreground=[('pressed','DeepPink2'),('focus','hot pink'),('!focus','deep pink')], + background=[('active','DeepPink4'),('focus','MediumOrchid4')]) + +btn=ttk.Button(win,text='Styled Button',command=click, style='styled.TButton') +btn.pack(fill='both') +#btn['state']='disabled' +btn2=ttk.Button(win,text='Styled Button2',command=click2, style='styled.TButton') +btn2.pack(fill='both') + +win.mainloop() \ No newline at end of file diff --git a/test2.py b/test2.py new file mode 100644 index 0000000..828f6d8 --- /dev/null +++ b/test2.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +# use this script inside other script to perform function + +import requests,sys,webbrowser,bs4 +print('Searching...') +res=requests.get('https://pypi.org/search?q='+ ' '.join(sys.argv[1:])) +res.raise_for_status() + +# Retrieve top search result links +soup=bs4.BeautifulSoup(res.text,'lxml') +# Open a browser tab for each result +linkElems=soup.select('.package-snippet') +exec(open("testExec.py").read()) \ No newline at end of file diff --git a/testExec.py b/testExec.py new file mode 100644 index 0000000..44547b2 --- /dev/null +++ b/testExec.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +import requests,sys,webbrowser,bs4 +numOpen=min(5,len(linkElems)) +for i in range(numOpen): + urlToOpen='https://pypi.org/search?q='+linkElems[i].get('href') + print('Opening',urlToOpen) + webbrowser.open(urlToOpen) \ No newline at end of file diff --git a/themeDemo.py b/themeDemo.py new file mode 100644 index 0000000..342c118 --- /dev/null +++ b/themeDemo.py @@ -0,0 +1,27 @@ +import tkinter as tk +from tkinter import ttk + +root=tk.Tk() + +s=ttk.Style() +s.configure('Wild.TButton', + background='black', + foreground='white', + highlightthickness='20', + font=('Helvetica', 18, 'bold')) +s.map('Wild.TButton', + foreground=[('disabled','yellow'), + ('pressed','red'), + ('active','blue')], + background=[('disabled','magenta'), + ('pressed','!focus','cyan'), + ('active','green')], + highlightcolor=[('focus','green'), + ('!focus','red')], + relief=[('pressed','groove'), + ('!pressed','ridge')]) + +button=ttk.Button(text='test', style="Wild.TButton") +button.pack(expand=True) + +root.mainloop() \ No newline at end of file diff --git a/thermistorTest.py b/thermistorTest.py new file mode 100644 index 0000000..de1407e --- /dev/null +++ b/thermistorTest.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +import time +import board +import math +import datetime + +import adafruit_pcf8591.pcf8591 as PCF +from adafruit_pcf8591.analog_in import AnalogIn + +i2c=board.I2C() +pcf=PCF.PCF8591(i2c) + +thermistor=AnalogIn(pcf,PCF.A0) +R=10000/(65535/thermistor.value - 1) +def steinhart_temperature_C(r,Ro=10000.0,To=25.0,beta=3950.0): + steinhart=math.log(r/Ro)/beta + steinhart+=1.0/(To + 273.15) + steinhart=(1.0/steinhart) - 273.15 + return steinhart +while True: + print(steinhart_temperature_C(R),(datetime.datetime.now())) + time.sleep(60) \ No newline at end of file diff --git a/tikTakToe.py b/tikTakToe.py new file mode 100755 index 0000000..5153336 --- /dev/null +++ b/tikTakToe.py @@ -0,0 +1,67 @@ +#!/usr/bin/env pythyon3 +from tkinter import * +from tkinter import messagebox +import random as r + +# Button function: function to define a button +def button(frame): + b=Button(frame,padx=1,bg="indianred4",activebackground="tomato3", + width=3,text=" ",font=('arial',60,'bold'), relief="sunken",bd=10) + return b + +# Change function: change operand for next player (X or O) +def change_a(): + global a + for i in ['O','X']: + if not (i==a): + a=i + break + +# Reset function: reset game (reset buttons to normal & clear text) +def reset(): + global a + for i in range(3): + for j in range(3): + b[i][j]["text"]=" " + b[i][j]["state"]=NORMAL + +# Check function: checks for Victory or Draw +def check(): + for i in range(3): + # left/right/up/down + if(b[i][0]["text"]==b[i][1]["text"]==b[i][2]["text"]==a or + b[0][i]["text"]==b[1][i]["text"]==b[2][i]["text"]==\ + b[2][i]["text"]==a): + messagebox.showinfo("Congrats!!","'"+a+"' has won") + reset() + # diagnols + if(b[0][0]["text"]==b[1][1]["text"]==b[2][2]["text"]==a or + b[0][2]["text"]==b[1][1]["text"]==b[2][0]["text"]==a): + messagebox.showinfo("Congrats!!","'"+a+"' has won") + reset() + elif(b[0][0]["state"]==b[0][1]["state"]==b[0][2]["state"]==\ + b[1][0]["state"]==b[1][1]["state"]==b[1][2]["state"]==\ + b[2][0]["state"]==b[2][1]["state"]==b[2][2]["state"]==DISABLED): + messagebox.showinfo("Tied!!","The match ended in a draw") + reset() + +# Click function: handle clicks on board +def click(row,col): + b[row][col].config(text=a,state=DISABLED,disabledforeground=color[a]) + check() + change_a() + label.config(text=a+"'s Chance") +############## Main Program ########################################## +root=Tk() #Window defined +root.title("Tic-Tac-Toe") # Title given +a=r.choice(['O','X']) # 2 operators (operands) defined +color={'O':"deep sky blue",'X':"lawn green"} +b=[[],[],[]] +for i in range(3): + for j in range(3): + b[i].append(button(root)) + b[i][j].config(command= lambda row=i,col=j:click(row,col)) + b[i][j].grid(row=i,column=j) +label=Label(text=a+"'s Chance",font=('arial',20,'bold'),bg="rosy brown") +label.grid(row=3,column=0,columnspan=3,sticky="nsew") +root.mainloop() \ No newline at end of file diff --git a/tkScrolledText101.py b/tkScrolledText101.py new file mode 100644 index 0000000..e23e6bb --- /dev/null +++ b/tkScrolledText101.py @@ -0,0 +1,31 @@ +import tkinter as tk +import tkinter.scrolledtext as tkst + +root=tk.Tk() +root.title("ScrolledText") +frame=tk.Frame(root,bg='brown') +frame.pack(fill='both',expand='yes') + +edit_space=tkst.ScrolledText( + master=frame, + wrap='word', # wrap text at full words only + width=25, # characters + height=10, # text lines + bg='beige', # background color of edit area +) +# the padx/pady space will form a frame +edit_space.pack(fill='both',expand=True,padx=8,pady=8) + +mytext='''\ +Man who drive like hell, bound to get there. + +Man who run in front of tire, get tired. + +Man who run behind car, get exhausted. + +The Internet: where men are men, women are men, and children are FBI agents. +''' + +edit_space.insert('insert',mytext) + +root.mainloop() \ No newline at end of file diff --git a/tkinter3.py b/tkinter3.py new file mode 100644 index 0000000..3a5ce16 --- /dev/null +++ b/tkinter3.py @@ -0,0 +1,25 @@ +import tkinter as tk + +def increase(): + value=int(lbl_value["text"]) + lbl_value["text"]=f"{value+1}" + +def decrease(): + value=int(lbl_value["text"]) + lbl_value["text"]=f"{value-1}" + +window=tk.Tk() +window.title("TEST") +window.rowconfigure(0, minsize=50, weight=1) +window.columnconfigure([0,1,2], minsize=50, weight=1) + +btn_decrease=tk.Button(master=window, text="-", command=decrease) +btn_decrease.grid(row=0, column=0, sticky="nsew") + +lbl_value=tk.Label(master=window, text="0") +lbl_value.grid(row=0, column=1) + +btn_increase=tk.Button(master=window, text="+", command=increase) +btn_increase.grid(row=0, column=2, sticky="nsew") + +window.mainloop() \ No newline at end of file diff --git a/tkinterClock.py b/tkinterClock.py new file mode 100644 index 0000000..f137db3 --- /dev/null +++ b/tkinterClock.py @@ -0,0 +1,22 @@ +from tkinter import * +import time + +class App(Frame): + def __init__(self,master=None): + Frame.__init__(self,master) + self.master=master + self.label=Label(text="",fg="Green",bg="Black",font=("Helvetica",18)) + self.label.place(x=50,y=80) + self.update_clock() + + def update_clock(self): + now=time.strftime("%H:%M:%S") + self.label.configure(text=now) + self.after(1000, self.update_clock) + +root=Tk() +app=App(root) +root.wm_title("Tkinter clock") +root.geometry("200x200") +root.after(1000, app.update_clock) +root.mainloop() \ No newline at end of file diff --git a/tkinterDice.py b/tkinterDice.py new file mode 100644 index 0000000..1936281 --- /dev/null +++ b/tkinterDice.py @@ -0,0 +1,18 @@ +import tkinter as tk +import random + +def roll(): + lbl_result["text"]=str(random.randint(1,6)) + +window=tk.Tk() +window.title("") +window.columnconfigure(0, minsize=150) +window.rowconfigure([0,1], minsize=50) + +btn_roll=tk.Button(master=window,text="Roll",fg="RED",bg="ORANGE",command=roll) +btn_roll.grid(row=0, column=0, sticky="nsew") + +lbl_result=tk.Label(fg="GREEN",bg="BLACK") +lbl_result.grid(row=1, column=0, sticky="nsew") + +window.mainloop() \ No newline at end of file diff --git a/tkinterFrame.py b/tkinterFrame.py new file mode 100644 index 0000000..9d6ac79 --- /dev/null +++ b/tkinterFrame.py @@ -0,0 +1,26 @@ +from tkinter import * + +def say_hi(): + print("hello!") + +root=Tk() + +frame1=Frame(root) +frame2=Frame(root) +root.title("tkinter frame") + +label=Label(frame1,text="LABEL",justify=LEFT) +label.pack(side=LEFT) + +photo=PhotoImage(file="/home/pi/mu_code/images/alien.png") +imgLabel=Label(frame1,image=photo) +imgLabel.pack(side=RIGHT) + +hi_there=Button(frame2,text="say hi",command=say_hi) +hi_there.pack() + +frame1.pack(padx=1,pady=1) +frame2.pack(padx=10,pady=10) + +root.geometry("150x150") +root.mainloop() \ No newline at end of file diff --git a/tkinterMenu.py b/tkinterMenu.py new file mode 100644 index 0000000..0041d96 --- /dev/null +++ b/tkinterMenu.py @@ -0,0 +1,35 @@ +from tkinter import * + +class Window(Frame): + def __init__(self, master=None): + Frame.__init__(self, master,bg="peach puff") + self.master=master + self.pack(fill=BOTH, expand=1) + + text=Label(self,text="Just do it", bg='red') + text.place(x=70,y=90) + #text.pack() + label1=Label(master,text="Tkinter",fg="red") + label1=Label(master,text="Helvetica",font=("Helvetica",81)) + + menu=Menu(self.master, bg='violet red') + self.master.config(menu=menu) + + fileMenu=Menu(menu) + fileMenu.add_command(label='Item') + fileMenu.add_command(label='Exit', command=self.exitProgram) + menu.add_cascade(label='File',menu=fileMenu) + + editMenu=Menu(menu) + editMenu.add_command(label='Undo') + editMenu.add_command(label='Redo') + menu.add_cascade(label='Edit',menu=editMenu) + + def exitProgram(self): + exit() + +root=Tk() +app=Window(root) +root.wm_title("Tkinter window") +root.geometry("200x200") +root.mainloop() \ No newline at end of file diff --git a/tkinterTestUrKnow.py b/tkinterTestUrKnow.py new file mode 100644 index 0000000..1b1a898 --- /dev/null +++ b/tkinterTestUrKnow.py @@ -0,0 +1,60 @@ +import tkinter as tk + +window=tk.Tk() +window.title("Address Entry Form") + +frm_form=tk.Frame(relief=tk.SUNKEN, borderwidth=3) +frm_form.pack() + +#First name +lbl_fname=tk.Label(master=frm_form,text="First Name:") +ent_fname=tk.Entry(master=frm_form, width=50) +#pack to grid +lbl_fname.grid(row=0, column=0, sticky="e") +ent_fname.grid(row=0,column=1) +#Last name +lbl_lname=tk.Label(master=frm_form, text="Last Name:") +ent_lname=tk.Entry(master=frm_form, width=50) +lbl_lname.grid(row=1, column=0, sticky="e") +ent_lname.grid(row=1, column=1) +#Address Line 1 +lbl_add1=tk.Label(master=frm_form, text="Address Line 1:") +ent_add1=tk.Entry(master=frm_form, width=50) +lbl_add1.grid(row=2, column=0, sticky="e") +ent_add1.grid(row=2, column=1) +#Address Line 2 +lbl_add2=tk.Label(master=frm_form, text="Address Line 2:") +ent_add2=tk.Entry(master=frm_form, width=50) +lbl_add2.grid(row=3, column=0, sticky="e") +ent_add2.grid(row=3, column=1) +#City +lbl_city=tk.Label(master=frm_form, text="City:") +ent_city=tk.Entry(master=frm_form, width=50) +lbl_city.grid(row=4, column=0, sticky="e") +ent_city.grid(row=4, column=1) +#State/Province +lbl_state=tk.Label(master=frm_form, text="State/Province:") +ent_state=tk.Entry(master=frm_form, width=50) +lbl_state.grid(row=5, column=0, sticky="e") +ent_state.grid(row=5, column=1) +#Postal Code +lbl_post=tk.Label(master=frm_form, text="Postal Code:") +ent_post=tk.Entry(master=frm_form, width=50) +lbl_post.grid(row=6, column=0, sticky="e") +ent_post.grid(row=6, column=1) +#Country +lbl_country=tk.Label(master=frm_form, text="Country:") +ent_country=tk.Entry(master=frm_form, width=50) +lbl_state.grid(row=7, column=0, sticky="e") +ent_state.grid(row=7, column=1) + +frm_buttons=tk.Frame() +frm_buttons.pack(fill=tk.X, ipadx=5, ipady=5) + +btn_submit=tk.Button(master=frm_buttons, text="Submit") +btn_submit.pack(side=tk.RIGHT, padx=10, ipadx=10) + +btn_clear=tk.Button(master=frm_buttons, text="Clear") +btn_clear.pack(side=tk.RIGHT, ipadx=10) + +window.mainloop() \ No newline at end of file diff --git a/tkinterTutorial.py b/tkinterTutorial.py new file mode 100644 index 0000000..f5de5fc --- /dev/null +++ b/tkinterTutorial.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 + +from tkinter import * +from tkinter import ttk +# define calculate function +def calculate(*args): + try: + value=float(feet.get()) + meters.set(int(0.3048 * value * 10000.0 + 0.5)/1000.0) + except ValueError: + pass +# Set up Main Application Window +root=Tk() +root.title("Feet to Meters") + +# Create Content Frame +mainframe=ttk.Frame(root, padding="3 3 12 12") +# Put grid in Content Frame +mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) +root.columnconfigure(0, weight=1) +root.rowconfigure(0, weight=1) +# Create entry widget +feet=StringVar() +feet_entry=ttk.Entry(mainframe, width=7, textvariable=feet) +feet_entry.grid(column=2, row=1, sticky=(W, E)) +# Create remaining widgets +meters=StringVar() +ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, +sticky=(W,E)) + +ttk.Button(mainframe, text='Calculate', command=calculate).grid(column =3, +row=3, sticky=W) + +ttk.Label(mainframe, text="feet").grid(column=3, row=1, sticky=W) +ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E) +ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W) +# finishing touches +for child in mainframe.winfo_children(): + child.grid_configure(padx=5, pady=5) + +feet_entry.focus() +root.bind("", calculate) +# Tkinter event loop +root.mainloop() \ No newline at end of file diff --git a/tlvMag.py b/tlvMag.py new file mode 100644 index 0000000..1021e3c --- /dev/null +++ b/tlvMag.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +import time +import board +import adafruit_tlv493d + +i2c = board.I2C() +tlv=adafruit_tlv493d.TLV493D(i2c) + +while True: + print("X: %s, Y: %s, Z: %s mT" % tlv.magnetic) + time.sleep(1) \ No newline at end of file diff --git a/toDoBox.py b/toDoBox.py new file mode 100644 index 0000000..846c9c0 --- /dev/null +++ b/toDoBox.py @@ -0,0 +1,73 @@ +from tkinter import * +from tkinter import messagebox + +def newTask(): + task=my_entry.get() + if task !="": + lb.insert(END, task) + my_entry.delete(0, "end") + else: + messagebox.showwarning("warning","please enter some task.") + +def deleteTask(): + lb.delete(ANCHOR) + +ws=Tk() +ws.geometry('500x450+500+200') +ws.title('PythonGuides') +ws.config(bg='#223441') +ws.resizable(width=True,height=True) + +frame=Frame(ws) +frame.pack(pady=10) + +lb=Listbox( + frame, + width=25, + height=8, + font=('Times',18), + bd=0, + fg='#464646', + highlightthickness=0, + selectbackground='#a6a6a6', + activestyle='none', +) +lb.pack(side=LEFT,fill=BOTH) + +task_list=[] +for item in task_list: + lb.insert(END,item) + +sb=Scrollbar(frame) +sb.pack(side=RIGHT,fill=BOTH) + +lb.config(yscrollcommand=sb.set) +sb.config(command=lb.yview) + +my_entry=Entry( + ws, + font=('times',24)) +my_entry.pack(pady=20) + +button_frame=Frame(ws) +button_frame.pack(pady=20) + +addTask_btn=Button( + button_frame, + text='Add Task', + font=('times', 14), + bg='#c5f776', + padx=20, + pady=10, + command=newTask) +addTask_btn.pack(fill=BOTH,expand=True, side=LEFT) + +delTask_btn=Button(button_frame, text='Delete Task', + font=('times',14), + bg='#ff8b61', + padx=20, + pady=10, + command=deleteTask) +delTask_btn.pack(fill=BOTH,expand=True,side=LEFT) + +ws.mainloop() \ No newline at end of file diff --git a/token-drive.pickle b/token-drive.pickle new file mode 100644 index 0000000..2663955 Binary files /dev/null and b/token-drive.pickle differ diff --git a/token-gt.json b/token-gt.json new file mode 100644 index 0000000..818a229 --- /dev/null +++ b/token-gt.json @@ -0,0 +1 @@ +{"token": "ya29.a0AWY7CklDbcS20P6HAtmGjOYKSkGI7c4OujYak7FSynLw7LKteuIwo1ObYsnhLf5Hnkw4oy6CN7z3iRO6Z5D5foHWwCUYqQTeYjz-rP1HRF7pijHdX6b4QtL-Ve5U5nrWDpO-pwo861w3MHGBR3XeM2LmF7SyaCgYKAZQSARMSFQG1tDrp9cf2P2U4dwxbozEX7F3H4g0163", "refresh_token": "1//04EapuvogyFeWCgYIARAAGAQSNwF-L9IrtP8AVoC9Jy_hz5SxoNf9DMe56GwQIwc8r2jejbWivsmyVdqWUfCiZOdjYXRdDqjMhkE", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "383597059543-c3gpqitjek4c2tockq267f0vigl9ciii.apps.googleusercontent.com", "client_secret": "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", "scopes": ["https://www.googleapis.com/auth/spreadsheets.readonly", "https://mail.google.com/"], "expiry": "2023-06-29T15:32:12.505499Z"} \ No newline at end of file diff --git a/token-sheets.json b/token-sheets.json new file mode 100644 index 0000000..3ace863 --- /dev/null +++ b/token-sheets.json @@ -0,0 +1 @@ +{"token": "ya29.a0ARrdaM-HkQaOfNNrjaUCvxh7O-bHCNsmyl323LgxFKG9DRnjgRzfr7E7rrK8T-Y7Lp4ovVFP_TKubW3cRAszy0GkdcARKuogPT31TRP8CB5_O4k_M9py-FeoKh9TtHsXkHWEJ2rAjkiQFZ-eQZ5TnyHBUocM", "refresh_token": "1//041BOs7_LiCe3CgYIARAAGAQSNwF-L9IrU-7XwjXNvN_CQwtoNkY5_6kDn6C48qCbL5_AMZg5rMQ6Aw9ui5cQJMbkCRUeoRQShqk", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "383597059543-c3gpqitjek4c2tockq267f0vigl9ciii.apps.googleusercontent.com", "client_secret": "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", "scopes": ["https://www.googleapis.com/auth/spreadsheets.readonly"], "expiry": "2021-12-20T17:19:59.500696Z"} \ No newline at end of file diff --git a/token-sheets.pickle b/token-sheets.pickle new file mode 100644 index 0000000..68628e8 Binary files /dev/null and b/token-sheets.pickle differ diff --git a/token.json b/token.json new file mode 100644 index 0000000..810c1ec --- /dev/null +++ b/token.json @@ -0,0 +1 @@ +{"token": "ya29.A0ARrdaM8LfNgPEblmpHzcHgeOMxntZKuD0CvH-o3aThmUQA8HUOu9HKDg0FKcPOR3dCqcjnwb7E7CdtemQLViNvlg7yl2mXhCYy7eSNj39MBbjEEVtuw0oUYtskhhLYOlAj7jGwdYa_ya44XF2CZZ6b9gaHrJFkg", "refresh_token": "1//04_gG0Ce3LrzTCgYIARAAGAQSNwF-L9IrRvAD1TnhMTquSsDTBN3mW57DTI6IYQq3nsvvz3ctfk00mtFKxkzpOMl3qXRhi6puyLI", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "383597059543-c3gpqitjek4c2tockq267f0vigl9ciii.apps.googleusercontent.com", "client_secret": "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", "scopes": ["https://www.googleapis.com/auth/calendar.readonly"], "expiry": "2022-03-31T17:18:21.171843Z"} \ No newline at end of file diff --git a/uart.py b/uart.py new file mode 100644 index 0000000..b551674 --- /dev/null +++ b/uart.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +import serial, time + +ser=serial.Serial('/dev/ttyACM0', 9600,timeout=.5) # serial connection + +logFile=open('lightLog.txt','w') # open and write to lightLog.txt + +while True: + now = time.localtime() # year[0], month[1], day[2], hour[3], minute[4], second[5], weekday[6], yearday[7] + timestamp=(str(now[3])+":"+str(now[4])+":"+str(now[5])+" "+str((now[1]))+"/"+str(now[2])+"/"+str(now[0])) + if int(now[3]) == 7: # if hour is 7 am or greater, STOP collecting data + logFile.close() + exit() # no error message, or breaks crontab + else: + data=ser.readline() + light=str(data).encode("utf-8") + a=light.strip(b"b'") # remove beginning empty space + Light=int(float(a[:-4])) # remove last 4 bits, leaving only float->int of light_val + logFile.write("Ambient Light: "+str(Light)+" "+timestamp+"\n") + logFile.flush() + print((Light),timestamp) + time.sleep(60) # how often to sample data line \ No newline at end of file diff --git a/vcnlCounter.py b/vcnlCounter.py new file mode 100644 index 0000000..eb7c668 --- /dev/null +++ b/vcnlCounter.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +import time +import datetime +import board +import adafruit_vcnl4040 + +i2c = board.I2C() +sensor = adafruit_vcnl4040.VCNL4040(i2c) +logFile=open('lightLog.txt','w') +while True: + ti=datetime.datetime.now() + logFile.write("Light: %d lux\n" % sensor.lux) + logFile.write(ti.strftime("%I:%M %p\n")) + logFile.flush() + print("Light: %d lux" % sensor.lux) + print(ti.strftime("%I:%M %p")) + time.sleep(60.0) \ No newline at end of file diff --git a/vemlLuxtest.py b/vemlLuxtest.py new file mode 100644 index 0000000..2c0adbb --- /dev/null +++ b/vemlLuxtest.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 +import time +import board +import adafruit_veml7700 +i2c=board.I2C() +veml7700=adafruit_veml7700.VEML7700(i2c) +while True: + print("ambient light:",veml7700.light) + time.sleep(60) \ No newline at end of file diff --git a/warHammer.py b/warHammer.py new file mode 100644 index 0000000..b3cefbb --- /dev/null +++ b/warHammer.py @@ -0,0 +1,64 @@ +from machine import Pin, PWM +import time +import _thread + +red=PWM(Pin(15)) +red.freq(5000) +red.duty_u16(65535) +blue=PWM(Pin(14)) +blue.freq(5000) +blue.duty_u16(0) +green=PWM(Pin(13)) +green.freq(5000) +green.duty_u16(0) + +led0=Pin(16,Pin.OUT) #BR1 +led1=Pin(17,Pin.OUT) #BR2 +led2=Pin(18,Pin.OUT) #BR3 +led3=Pin(19,Pin.OUT) #BR4 +led4=Pin(20,Pin.OUT) #BR5 +br=[led0,led1,led2,led3,led4] #br[i].toggle() + +ledD=Pin(22,Pin.OUT) #blue LED +ledD.value(0) +ledA=Pin(21,Pin.OUT) #red LED +ledA.value(1) + +button0=Pin(12,Pin.IN,Pin.PULL_DOWN) #control ledD&ledA +global button0_pressed +button0_pressed=False +def button0_reader_thread(): + global button0_pressed + while True: + if button0.value()==1: + button0_pressed=True + time.sleep(0.01) +_thread.start_new_thread(button0_reader_thread,()) +while True: + if button0_pressed==True: + ledA.toggle() + ledD.toggle() + time.sleep(1) + button0_pressed=False + +button1=Pin(11,Pin.IN,Pin.PULL_DOWN) #control RGB and phases +global button1_pressed +global i +global p +button1_pressed=False +i=0 +p=0 +def button1_reader_thread(): + global button1_pressed + while True: + if button1.value()==1: + button1_pressed=True + time.sleep(0.01) +while True: + if button1_pressed==True: + + +# button0 will handle switching ledD(blue) and ledA(red) to indicate player turn +# led0-4 indicate battle round (1-5), light when command phase starts +# RGB indicates battle phase (command, movement, psychic, shooting, charge, fight, morale) +# button1 change battle phase, loop through 7 phases;start start new command phase=new battle round \ No newline at end of file