Skip to content

Commit

Permalink
Added GUI entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
K-DawG007 committed Nov 11, 2013
1 parent 2e8ab24 commit 1935af6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
37 changes: 21 additions & 16 deletions courseradownloader/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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])
Expand All @@ -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()
if __name__ == '__main__':
main()
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 1935af6

Please sign in to comment.