#!/bin/bash
from tkinter import *
from tkinter import ttk
from tkinter import font
import RPi.GPIO as GPIO
import subprocess, time, os
from picamera import PiCamera
import smtplib
from email.mime.text import MIMEText
GPIO.setmode(GPIO.BCM)
#define GPIO / pins
PUSHBUTTON = 24
PRINT_LED = 22
POSE_LED = 18
READY_LED = 23
#set up pins
GPIO.setup(PUSHBUTTON, GPIO.IN)
GPIO.setup(PRINT_LED, GPIO.OUT)
GPIO.setup(POSE_LED, GPIO.OUT)
GPIO.setup(READY_LED, GPIO.OUT)
GPIO.output(PRINT_LED, True)
GPIO.output(POSE_LED, True)
GPIO.output(READY_LED, True)
#setup the main window as "win"
root = Tk()
root.title("LRP Photo Booth")
root.option_add("tearOff", False)
menubar = Menu(root)
root['menu'] = menubar
menu_file = Menu(menubar)
menu_edit = Menu(menubar)
menubar.add_cascade(menu=menu_ file, label='File')
menu_file.add_command(label=" Exit", command=root.quit)
menubar.add_cascade(menu=menu_ edit, label='Edit')
#add options here to open text editors for the email file and such
ttk.Style().configure(" TButton", padding=10, font='helvetica 34')
ttk.Style().configure("TEntry" , padding=10, font='helvetica 34')
g_name = "Tell us your name"
g_email = "youraddress@mail.com"
myFont = font.Font(family = "Helvetica", size = 34, weight = "bold")
mainframe=ttk.Frame(root, padding="12 12 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=2)
mainframe.rowconfigure(0, weight=2)
ttk.Label(mainframe, text=" Press Here and Get Ready! ", font = myFont).grid(column=1, row=1, columnspan = 3)
#set up the camera
camera = PiCamera()
camera.resolution = (1275, 767)
camera.hflip = False
camera.vflip = False
#define functions
def TakePicture():
l_photoName = time.strftime("%Y%m%d_%H%M%S")
snaponePhoto('TL')
snaponePhoto('TR')
snaponePhoto('BL')
snaponePhoto('BR')
subprocess.call( ['montage', '-tile', '2x2', '-geometry', '+5+5', '*.jpg', '/home/pi/Pictures/'+l_ photoName+'.jpg'] )
sendorDelete(l_photoName)
def snaponePhoto(photoName):
camera.start_preview()
time.sleep(2)
camera.capture(photoName +".jpg")
camera.stop_preview()
def send(l_name, l_email, l_photoName):
#send the photo to email
subject = 'LiningerRoodPhotography'
mutt = "mutt -s "+subject+" "+l_email.get()+" john.r.rood@gmail.com < /home/pi/GUI/body_text -a /home/pi/Pictures/"+l_ photoName+".jpg"
ml = subprocess.Popen([mutt], shell = True)
ml.communicate()
mutt = "mutt -s "+subject+" "+l_email.get()+" john.r.rood.update@blogger.com < /home/pi/GUI/body_text -a /home/pi/Pictures/"+l_ photoName+".jpg"
ml = subprocess.Popen([mutt], shell = True)
ml.communicate()
#print the photo to the local printer
printer = "lpr -d SELPHY /home/pi/Pictures/"+l_ photoName+".jpg"
#subprocess.Popen([printer], shell = True)
def sendorDelete(l_photoName):
global myFont
l_name = StringVar()
l_name.set(g_name)
l_email = StringVar()
l_email.set(g_email)
photoName = l_photoName
def sendButtonAction():
send(l_name, l_email, photoName)
contactBox.destroy()
contactBox = Toplevel(root)
contactBox.title("Enter Your Contact Info")
contactFrame=ttk.Frame( contactBox, padding="3 3 12 12")
contactFrame.grid(column=0, row=0, sticky=(N, W, E, S))
nameBox=ttk.Entry( contactFrame, textvariable= l_name, font = 30, width = 40).grid(column=2, row=1, columnspan =2)
emailBox=ttk.Entry( contactFrame, textvariable= l_email, font = 30, width = 40).grid(column=2, row=2, columnspan =2)
ttk.Label(contactFrame, text="Your Name:", font= myFont).grid(column=1, row=1, sticky=S)
ttk.Label(contactFrame, text="Your e-Mail:", font= myFont).grid(column=1, row=2, sticky=S)
sendButton = ttk.Button(contactFrame, text = "Send It!", command = sendButtonAction).grid(column= 2, row=3)
deleteButton = ttk.Button(contactFrame, text = "Start Over!", command = contactBox.destroy).grid( column=3, row=3)
for child in contactFrame.winfo_children(): child.grid_configure(padx=5, pady=5)
def exitProgram():
GPIO.cleanup()
root.quit()
pictureButton = ttk.Button(mainframe, text = "Touch Here To Start!", command = TakePicture).grid(column=1, row=2, columnspan = 3)
exitButton = ttk.Button(mainframe, text = "Exit", command = exitProgram).grid(column=3, row=3, sticky=E)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
mainloop()
from tkinter import *
from tkinter import ttk
from tkinter import font
import RPi.GPIO as GPIO
import subprocess, time, os
from picamera import PiCamera
import smtplib
from email.mime.text import MIMEText
GPIO.setmode(GPIO.BCM)
#define GPIO / pins
PUSHBUTTON = 24
PRINT_LED = 22
POSE_LED = 18
READY_LED = 23
#set up pins
GPIO.setup(PUSHBUTTON, GPIO.IN)
GPIO.setup(PRINT_LED, GPIO.OUT)
GPIO.setup(POSE_LED, GPIO.OUT)
GPIO.setup(READY_LED, GPIO.OUT)
GPIO.output(PRINT_LED, True)
GPIO.output(POSE_LED, True)
GPIO.output(READY_LED, True)
#setup the main window as "win"
root = Tk()
root.title("LRP Photo Booth")
root.option_add("tearOff", False)
menubar = Menu(root)
root['menu'] = menubar
menu_file = Menu(menubar)
menu_edit = Menu(menubar)
menubar.add_cascade(menu=menu_
menu_file.add_command(label="
menubar.add_cascade(menu=menu_
#add options here to open text editors for the email file and such
ttk.Style().configure("
ttk.Style().configure("TEntry"
g_name = "Tell us your name"
g_email = "youraddress@mail.com"
myFont = font.Font(family = "Helvetica", size = 34, weight = "bold")
mainframe=ttk.Frame(root, padding="12 12 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=2)
mainframe.rowconfigure(0, weight=2)
ttk.Label(mainframe, text=" Press Here and Get Ready! ", font = myFont).grid(column=1, row=1, columnspan = 3)
#set up the camera
camera = PiCamera()
camera.resolution = (1275, 767)
camera.hflip = False
camera.vflip = False
#define functions
def TakePicture():
l_photoName = time.strftime("%Y%m%d_%H%M%S")
snaponePhoto('TL')
snaponePhoto('TR')
snaponePhoto('BL')
snaponePhoto('BR')
subprocess.call( ['montage', '-tile', '2x2', '-geometry', '+5+5', '*.jpg', '/home/pi/Pictures/'+l_
sendorDelete(l_photoName)
def snaponePhoto(photoName):
camera.start_preview()
time.sleep(2)
camera.capture(photoName +".jpg")
camera.stop_preview()
def send(l_name, l_email, l_photoName):
#send the photo to email
subject = 'LiningerRoodPhotography'
mutt = "mutt -s "+subject+" "+l_email.get()+" john.r.rood@gmail.com < /home/pi/GUI/body_text -a /home/pi/Pictures/"+l_
ml = subprocess.Popen([mutt], shell = True)
ml.communicate()
mutt = "mutt -s "+subject+" "+l_email.get()+" john.r.rood.update@blogger.com < /home/pi/GUI/body_text -a /home/pi/Pictures/"+l_
ml = subprocess.Popen([mutt], shell = True)
ml.communicate()
#print the photo to the local printer
printer = "lpr -d SELPHY /home/pi/Pictures/"+l_
#subprocess.Popen([printer], shell = True)
def sendorDelete(l_photoName):
global myFont
l_name = StringVar()
l_name.set(g_name)
l_email = StringVar()
l_email.set(g_email)
photoName = l_photoName
def sendButtonAction():
send(l_name, l_email, photoName)
contactBox.destroy()
contactBox = Toplevel(root)
contactBox.title("Enter Your Contact Info")
contactFrame=ttk.Frame(
contactFrame.grid(column=0, row=0, sticky=(N, W, E, S))
nameBox=ttk.Entry(
emailBox=ttk.Entry(
ttk.Label(contactFrame, text="Your Name:", font= myFont).grid(column=1, row=1, sticky=S)
ttk.Label(contactFrame, text="Your e-Mail:", font= myFont).grid(column=1, row=2, sticky=S)
sendButton = ttk.Button(contactFrame, text = "Send It!", command = sendButtonAction).grid(column=
deleteButton = ttk.Button(contactFrame, text = "Start Over!", command = contactBox.destroy).grid(
for child in contactFrame.winfo_children():
def exitProgram():
GPIO.cleanup()
root.quit()
pictureButton = ttk.Button(mainframe, text = "Touch Here To Start!", command = TakePicture).grid(column=1, row=2, columnspan = 3)
exitButton = ttk.Button(mainframe, text = "Exit", command = exitProgram).grid(column=3, row=3, sticky=E)
for child in mainframe.winfo_children():
mainloop()
No comments:
Post a Comment