From 1935af6a0e15966000333f9a59cb8e657422b9c8 Mon Sep 17 00:00:00 2001 From: K-DawG007 Date: Mon, 11 Nov 2013 17:52:42 +0530 Subject: [PATCH] Added GUI entry point --- courseradownloader/gui.py | 37 +++++++++++++++++++++---------------- setup.py | 3 ++- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/courseradownloader/gui.py b/courseradownloader/gui.py index d4fdb98..b2737c1 100644 --- a/courseradownloader/gui.py +++ b/courseradownloader/gui.py @@ -12,9 +12,11 @@ except ImportError: try: + #In python 3 the module Tkinter was renamed to tkinter import tkinter as Tk + except ImportError: - print_('Error: Tkinter module not found: Please use command line version instead') + raise Exception("Error: Tkinter module not found: Please use command line version instead") import courseradownloader as CS @@ -149,13 +151,11 @@ def sort_to_send(self): # should we be trimming paths? #TODO: this is a simple hack, something more elaborate needed mppl = None - if self.mppl_entry.get(): - if platform.system() == "Windows": - mppl = 90 - print_("Maximum length of a path component set to %s" % mppl) - else: - # linux max path length is typically around 4060 so assume thats ok - pass + if platform.system() == "Windows": + mppl = 90 + else: + # linux max path length is typically around 4060 so assume thats ok + pass self.Init_data['max_path_part_len'] = mppl @@ -206,6 +206,8 @@ def download(): " Warning: built-in 'html.parser' may cause problems on Python < 2.7.3") print_("Coursera-dl v%s (%s)" % (_version.__version__, html_parser)) + print_("Maximum length of a path component set to %s" % queue[1]['max_path_part_len']) + d = CS.CourseraDownloader(*queue[0],**queue[1]) print_("Logging in as '%s'..." % queue[0][0]) @@ -217,13 +219,16 @@ def download(): reverse_sections=queue[2][1], gzip_courses=queue[2][2]) +def main(): + root = Tk.Tk() + root.title('Coursera-dl') + root.geometry("350x280") + app = Interface(root) + app.mainloop() -root = Tk.Tk() -root.title('Coursera-dl') -root.geometry("350x280") -app = Interface(root) -app.mainloop() + # In case a user just closes the Tkinter window, It is vital that the download function isn't called and the program itself quits + if data_collected: + download() -# In case a user just closes the Tkinter window, It is vital that the download function isn't called and the program itself quits -if data_collected: - download() \ No newline at end of file +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 5717e2b..02e1158 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,8 @@ url="https://github.com/dgorissen/coursera-dl", license="GPLv3", packages=["courseradownloader"], - entry_points = { "console_scripts" : [ "coursera-dl = courseradownloader.courseradownloader:main"]}, + entry_points = { "console_scripts" : [ "coursera-dl = courseradownloader.courseradownloader:main", + "coursera-dl-gui = courseradownloader.gui:main" ]}, install_requires=requirements )