Skip to content

Commit

Permalink
Merge pull request #12 from RasPiPkr/pkrBranch
Browse files Browse the repository at this point in the history
Set a font and size for all text
  • Loading branch information
swapnanildutta authored Nov 22, 2020
2 parents 1b4c3e7 + 78973f7 commit e65a05f
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
light = '#bcbcbc'
dark = '#23272a'
startupMode = dark
titleFont=('Verdana', 28)
titleFont = ('Verdana', 28) # Used only on the about page for YouTube Downloader
textFont = ('Verdana', 9) # Used everywhere, change font or size to test on your machine.


def downloader(event=None):
Expand Down Expand Up @@ -57,11 +58,14 @@ def clearData():
def getVideo():
global saveAs
ytTitle = yt.title
saveAs = filedialog.asksaveasfilename(initialfile=ytTitle, filetypes=[('mp4', '*.mp4')])
filename = saveAs.split('/')[-1]
i = saveAs.index(filename)
path = saveAs[:i]
yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution')[-1].download(output_path=path, filename=filename)
try:
saveAs = filedialog.asksaveasfilename(initialfile=ytTitle, filetypes=[('mp4', '*.mp4')])
filename = saveAs.split('/')[-1]
i = saveAs.index(filename)
path = saveAs[:i]
yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution')[-1].download(output_path=path, filename=filename)
except AttributeError:
downloadBtn.config(text='Download Cancelled', state='disabled')


def updateImg():
Expand Down Expand Up @@ -108,17 +112,17 @@ def aboutMode(bgMode, txtMode):
def about(bgMode, txtMode):
global rootFrame, menu, filemenu, helpmenu, title, line1
# Menu Tabs
menu = tk.Menu(root, bg=bgMode, fg=txtMode)
menu = tk.Menu(root, bg=bgMode, fg=txtMode, font=textFont)
root.config(menu=menu)
filemenu = tk.Menu(menu, bg=bgMode, fg=txtMode, tearoff=0)
menu.add_cascade(label='File', menu=filemenu)
filemenu = tk.Menu(menu, bg=bgMode, fg=txtMode, font=textFont, tearoff=0)
menu.add_cascade(label='File', menu=filemenu, font=textFont)
filemenu.add_command(label='Downloader', command=lambda: main(bgMode, txtMode))
filemenu.add_command(label='Exit', command=root.destroy)
filemenu.add_separator()
filemenu.add_command(label='Light Mode', command=lambda: about(light, dark))
filemenu.add_command(label='Dark Mode', command=lambda: about(dark, light))
helpmenu = tk.Menu(menu, bg=bgMode, fg=txtMode, tearoff=0)
menu.add_cascade(label='Help', menu=helpmenu)
helpmenu = tk.Menu(menu, bg=bgMode, fg=txtMode, font=textFont, tearoff=0)
menu.add_cascade(label='Help', menu=helpmenu, font=textFont)
helpmenu.add_command(label='About', command=about)
# layout
rootFrame.destroy()
Expand All @@ -127,61 +131,61 @@ def about(bgMode, txtMode):
title = tk.Label(rootFrame, text='YouTube Downloader', bg=bgMode, fg=txtMode, font=titleFont)
title.pack(pady=100)
# If you want to add to this about page, copy the next 2 lines above and paste below and change the line1 to line2 etc.
line1 = tk.Label(rootFrame, text='created by Swapnanil Dutta', bg=bgMode, fg=txtMode)
line1 = tk.Label(rootFrame, text='created by Swapnanil Dutta', bg=bgMode, fg=txtMode, font=textFont)
line1.pack()


def main(bgMode, txtMode):
global rootFrame, info, infoText, clearBtn, urlEntry, spacerL, downloadBtn, spacerR, filemenu, helpmenu
global getDesc, url, title, getTitle, views, getViews, length, getLength, desc, menu, descFrame, dispFrame
# Menu Tabs
menu = tk.Menu(root, bg=bgMode, fg=txtMode)
root.config(menu=menu)
filemenu = tk.Menu(menu, bg=bgMode, fg=txtMode, tearoff=0)
menu.add_cascade(label='File', menu=filemenu)
menu = tk.Menu(root, bg=bgMode, fg=txtMode, font=textFont)
root.config(menu=menu)
filemenu = tk.Menu(menu, bg=bgMode, fg=txtMode, font=textFont, tearoff=0)
menu.add_cascade(label='File', menu=filemenu, font=textFont)
filemenu.add_command(label='Downloader', command=lambda: main(bgMode, txtMode))
filemenu.add_command(label='Exit', command=root.destroy)
filemenu.add_separator()
filemenu.add_command(label='Light Mode', command=lambda: mainMode(light, dark))
filemenu.add_command(label='Dark Mode', command=lambda: mainMode(dark, light))
helpmenu = tk.Menu(menu, bg=bgMode, fg=txtMode, tearoff=0)
menu.add_cascade(label='Help', menu=helpmenu)
helpmenu = tk.Menu(menu, bg=bgMode, fg=txtMode, font=textFont, tearoff=0)
menu.add_cascade(label='Help', menu=helpmenu, font=textFont)
helpmenu.add_command(label='About', command=lambda: about(bgMode, txtMode))
# Layout
rootFrame.destroy()
rootFrame = tk.Frame(root, bg=bgMode)
rootFrame.pack(fill='both', expand=True)
infoText = tk.StringVar(value='Enter the link below:')
info = tk.Label(rootFrame, textvariable=infoText, bg=bgMode, fg=txtMode)
info = tk.Label(rootFrame, textvariable=infoText, bg=bgMode, fg=txtMode, font=textFont)
info.grid(row=0, column=0, padx=12, pady=10, sticky='w')
clearBtn = tk.Button(rootFrame, text='Clear Data', width=14, bg=bgMode, fg=txtMode, command=clearData)
clearBtn = tk.Button(rootFrame, text='Clear Data', width=14, bg=bgMode, fg=txtMode, font=textFont, command=clearData)
clearBtn.grid(row=0, column=7, columnspan=2, padx=8)
url = tk.StringVar()
urlEntry = tk.Entry(rootFrame, textvariable=url, width='55', borderwidth='5', bg=bgMode, fg=txtMode)
urlEntry = tk.Entry(rootFrame, textvariable=url, width='55', borderwidth='5', bg=bgMode, fg=txtMode, font=textFont)
urlEntry.grid(row=1, column=0, columnspan=5, padx=15)
root.bind('<Return>', downloader)
spacerL = tk.Label(rootFrame, width=4, bg=bgMode, fg=txtMode)
spacerL = tk.Label(rootFrame, width=4, bg=bgMode, fg=txtMode, font=textFont)
spacerL.grid(row=1, column=6)
downloadBtn = tk.Button(rootFrame, text='Download Video', width=14, bg=bgMode, fg=txtMode, command=downloader)
downloadBtn = tk.Button(rootFrame, text='Download Video', width=14, bg=bgMode, fg=txtMode, font=textFont, command=downloader)
downloadBtn.grid(row=1, column=7, columnspan=2, padx=8)
spacerR = tk.Label(rootFrame, width=4, bg=bgMode, fg=txtMode)
spacerR = tk.Label(rootFrame, width=4, bg=bgMode, fg=txtMode, font=textFont)
spacerR.grid(row=1, column=9)
getTitle = tk.StringVar(value='Title:')
title = tk.Label(rootFrame, textvariable=getTitle, bg=bgMode, fg=txtMode)
title = tk.Label(rootFrame, textvariable=getTitle, bg=bgMode, fg=txtMode, font=textFont)
title.grid(row=2, column=0, columnspan=10, padx=12, pady=5, sticky='w')
getViews = tk.StringVar(value='Views:')
views = tk.Label(rootFrame, textvariable=getViews, bg=bgMode, fg=txtMode)
views = tk.Label(rootFrame, textvariable=getViews, bg=bgMode, fg=txtMode, font=textFont)
views.grid(row=3, column=0, columnspan=2, padx=12, pady=5, sticky='w')
getLength = tk.StringVar(value='Length:')
length = tk.Label(rootFrame, textvariable=getLength, bg=bgMode, fg=txtMode)
length = tk.Label(rootFrame, textvariable=getLength, bg=bgMode, fg=txtMode, font=textFont)
length.grid(row=4, column=0, columnspan=2, padx=12, pady=5, sticky='w')
desc = tk.Label(rootFrame, text='Description:', bg=bgMode, fg=txtMode)
desc = tk.Label(rootFrame, text='Description:', bg=bgMode, fg=txtMode, font=textFont)
desc.grid(row=5, column=0, padx=12, pady=5, sticky='w')
descFrame = tk.Frame(rootFrame, bg=bgMode)
descFrame.grid(row=6, rowspan=6, column=0, columnspan=2, padx=12, sticky='w')
descScroll = tk.Scrollbar(descFrame)
descScroll.pack(side='right', fill='both', expand=True)
getDesc = tk.Text(descFrame, width=35, height=10, wrap='word', bg=bgMode, fg=txtMode)
getDesc = tk.Text(descFrame, width=35, height=10, wrap='word', bg=bgMode, fg=txtMode, font=textFont)
getDesc.pack()
getDesc.config(yscrollcommand=descScroll.set)
descScroll.config(command=getDesc.yview)
Expand Down

0 comments on commit e65a05f

Please sign in to comment.