Created
March 24, 2011 05:36
-
-
Save ellamental/884629 to your computer and use it in GitHub Desktop.
This is a simple app to track the current episode that you are on in various TV shows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
############################################################################## | |
## If you would like to contribute, contact jacktradespublic@gmail.com | |
## | |
## tvtracker is free software: you can redistribute it and/or | |
## modify it under the terms of the GNU Affero General Public | |
## License version 3 as published by the Free Software Foundation. | |
## | |
## This program is distributed in the hope that it will be useful, | |
## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
## GNU Affero General Public License version 3 for more details. | |
## | |
## You should have received a copy of the GNU Affero General Public | |
## License version 3 along with this program. If not, see | |
## <http://www.gnu.org/licenses/>. | |
############################################################################## | |
## Known Bugs: | |
## - This needs some serious refactoring, even for this simple script | |
## - The current episode number just keeps growing and doesn't wrap | |
## around seasons. | |
## - There is no way to undo an increment. | |
## | |
## Improvements | |
## - Next episode available: Input the day of the week that the | |
## show is usually aired and the program will notify you when the | |
## next episode is available. You should also be able to enter a | |
## delay (for things like hulu or torrents). | |
############################################################################## | |
from Tkinter import * | |
import pickle | |
def loadShows(): | |
global shows | |
f = open(filename, 'r') | |
shows = pickle.load(f) | |
f.close() | |
def saveShows(): | |
f = open(filename, 'wb') | |
pickle.dump(shows, f) | |
f.close() | |
class Add_Episode: | |
def __init__(self, parent): | |
self.add_frame = Frame(parent) | |
self.name_label = Label(self.add_frame, text="Name: ") | |
self.name_entry = Entry(self.add_frame) | |
self.episode_label = Label(self.add_frame, text="Current Episode: ") | |
self.episode_entry = Entry(self.add_frame) | |
self.add_show_button = Button(self.add_frame, text="Add Show", command=self.add_show) | |
self.name_label.pack(side=LEFT) | |
self.name_entry.pack(side=LEFT) | |
self.episode_label.pack(side=LEFT) | |
self.episode_entry.pack(side=LEFT) | |
self.add_show_button.pack(side=LEFT) | |
self.add_frame.pack(side=TOP) | |
def add_show(self): | |
name = self.name_entry.get() | |
episode = int(self.episode_entry.get()) | |
shows[name] = episode | |
Show(root, name, episode) | |
saveShows() | |
class Show: | |
def __init__(self, parent, name, episode): | |
self.name = name | |
self.episode = episode | |
f = Frame(parent) | |
f.pack(side=LEFT) | |
self.label = Label(f, text=name) | |
self.entry = Label(f, text=episode) | |
self.button = Button(f, text="Increment", command=self.increment) | |
self.label.pack() | |
self.entry.pack() | |
self.button.pack() | |
def increment(self): | |
self.episode += 1 | |
self.entry.config(text = self.episode) | |
shows[self.name] += 1 | |
saveShows() | |
if __name__ == "__main__": | |
filename = "tvshows.pk" | |
try: | |
loadShows() | |
except IOError: | |
shows = {} | |
root = Tk() | |
root.title('Tv Shows') | |
Add_Episode(root) | |
for n, e in shows.items(): | |
Show(root, n, e) | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment