8/10/2013

One-line notes organizer using Python's Tkinter, os and smtplib modules

Hello.

This is a little GUI program I coded last month to help me organize one-line notes and URL's that I find on the web. Sometimes it's a little boring to email them to myself manually so I thought why not automate the process using Python. 



* Little Preview:






* Usage:


To use noteOrganizer, go to the directory where the script is in, and simply run: python noteOrganizer.py in the terminal, and a window will just pop up. 

You have couple of options to save notes, either saving them to the directory the script is in, or email the note. [Please edit and enter your email credentials in the code]

Here is the code or -download it-:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

# Imports #
from tkinter import *
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import tkinter 
import os
import time
import smtplib

# End Imports #
# Functions # def save(): localtime = time.asctime(time.localtime(time.time())) text = '\n' + note.get() + '\t <- This note was saved on: ' + (localtime) + ' \n' txt_file = open(desired_path.get()+"txt", 'a') txt_file.write(text) txt_file.close() def email(): localtime = time.asctime(time.localtime(time.time())) text = '\n' + note.get() + '\t <- This note was saved and emailed on ' + (localtime) fromAddress = "" # Here goes the the sender's address, e.g foobar@gmail.com toAddress = "" # Here goes the the recipient's address, e.g foobar@gmail.com uname = "" # Here goes the the sender's username, e.g foobar passwd = "" # Here goes the the sender's password, e.g foobar123456 msg = MIMEMultipart() msg['From'] = fromAddress msg['To'] = toAddress msg['Subject'] = "This was sent to you by NoteOrganizer" msg.attach(MIMEText(text)) server = smtplib.SMTP('smtp.gmail.com:587') server.ehlo() server.starttls() ## Use TLS for email credntials. server.ehlo() server.login(uname, passwd) server.sendmail(fromAddress, toAddress, msg.as_string()) server.quit() # End Functions # # TkInter # window = Tk() note = StringVar() #takes input from entry field. desired_path = StringVar() #takes input for directory. #-------------------------------- #### Dimensions and title ### #-------------------------------- window.geometry("290x120+200+200") window.title("\tNotes Organizer") #-------------------------------- #### Labels ### #-------------------------------- enter_note_label = Label(window, text="Enter a note: ").place(x=20, y=50) enter_directory_label = Label(window, text="Desired Path: ").place(x=20, y=20) #-------------------------------- #### Buttons ### #-------------------------------- save_button = Button(window, text=" Save ", fg="black", command=save).place(x=75, y=90) email_button = Button(window, text=" Email me! ", fg="black", command=email).place(x=140, y=90) quit_button = Button(window, text=" Quit ", fg="black", command=window.destroy).place(x=10, y=90) #-------------------------------- #### Entry fields ### #-------------------------------- entryfield_note = Entry(window,textvariable=note, bd=3) entryfield_note.place(x=110, y=50) directory_path = Entry(window, textvariable=desired_path, bd=3) directory_path.place(x= 110 , y=20) window.mainloop() #End TkInter#






Thank you for reading and Happy Coding! @_YSaif

No comments:

Post a Comment

Note: only a member of this blog may post a comment.