本文整理匯總了Python中ttk.Progressbar.pack方法的典型用法代碼示例。如果您正苦於以下問題:Python Progressbar.pack方法的具體用法?Python Progressbar.pack怎麽用?Python Progressbar.pack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ttk.Progressbar
的用法示例。
在下文中一共展示了Progressbar.pack方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: splashscreen
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
def splashscreen():
root = Tk()
root.geometry("+200+200")
root.overrideredirect(True)
root.configure(bg = "white")
back = PhotoImage(file = "splashscreen.gif")
l1 = Label(root, image = back, bg = "white")
scritta = Progressbar(root, orient = "horizontal", mode = "determinate", length = 240)
scritta.start(30)
copyright = Label(root, text = "Copyright by lokk3d", bg = "white")
root.after(3000, root.destroy)
l1.pack()
scritta.pack(side = "left")
copyright.pack( side = "right")
root.mainloop()
示例2: FdaAltimeterControl
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
class FdaAltimeterControl(tk.Toplevel):
PORT_SELECTION_FRAME_HEIGHT = 80
SUB_FRAME_X_PADDING = 20
def __init__(self, parent):
tk.Toplevel.__init__(self)
self.parent = parent
# Do not let user to close this window
# is a communication with the Altimeter
# is taking place.
self.communicating = False
self.protocol("WM_DELETE_WINDOW", self.close_asked)
# Setup window content.
self.initialize()
def initialize(self):
self.title(_(u'FlyDream Altimeter - Device Controller'))
# Set fixed size.
self.minsize(640, 320)
self.resizable(False, False)
# Altimeter local device.
frame = tk.Frame(self, height=self.PORT_SELECTION_FRAME_HEIGHT)
frame.pack(fill=tk.BOTH, expand=tk.YES)
tk.Label(frame, text=_(u'Altimeter plugged on:')).pack(side=tk.LEFT)
self.detect = tk.Button(frame, text=_(u'Refresh'),
command=self.refresh_serial_ports)
self.detect.pack(side=tk.RIGHT)
self.port = tk.StringVar(self)
self.ports = tk.OptionMenu(frame, self.port,
_(u'Detecting serial ports...'))
self.ports.pack(fill=tk.X, expand=tk.YES)
# Update possible serial ports.
self.refresh_serial_ports()
# Upload altimeter flight data.
frame = tk.Frame(self, padx=self.SUB_FRAME_X_PADDING)
frame.pack(fill=tk.BOTH, expand=tk.YES)
label = tk.Label(frame, anchor=tk.W, text=_(u'Upload'))
label.pack(side=tk.TOP, fill=tk.X)
# Setup bold font for titles.
f = Font(font=label['font'])
f['weight'] = 'bold'
label['font'] = f.name
Separator(frame).pack(fill=tk.X)
self.progressbar = Progressbar(frame, orient='horizontal',
mode='determinate')
self.progressbar.pack(side=tk.BOTTOM, fill=tk.X)
# Do not show progressbar
# unless data is uploaded.
self.hide_progressbar()
self.upload_info = tk.StringVar()
self.upload_info.set('/')
self.info_label = tk.Label(frame, anchor=tk.NE, fg='darkgrey',
textvariable=self.upload_info)
self.info_label.pack(side=tk.BOTTOM, fill=tk.BOTH)
self.label = tk.Label(frame, anchor=tk.W,
text=_(u'Tell the altimeter to send flight '
'data to your computer'))
self.label.pack(side=tk.LEFT)
self.upload = tk.Button(frame, text=_(u'Upload data'),
command=self.upload)
self.upload.pack(side=tk.RIGHT)
# Erase altimeter flight data.
frame = tk.Frame(self, padx=self.SUB_FRAME_X_PADDING)
frame.pack(fill=tk.BOTH, expand=tk.YES)
label = tk.Label(frame, anchor=tk.W, text=_(u'Clear'))
label['font'] = f.name
label.pack(side=tk.TOP, fill=tk.X)
Separator(frame).pack(fill=tk.X)
label = tk.Label(frame, anchor=tk.W,
text=_(u'Delete all the flight data from your altimeter'))
label.pack(side=tk.LEFT)
self.erase = tk.Button(frame, text=_(u'Erase data'),
command=self.erase)
self.erase.pack(side=tk.RIGHT)
# Setup altimeter sampling frequency.
frame = tk.Frame(self, padx=self.SUB_FRAME_X_PADDING)
#.........這裏部分代碼省略.........
示例3: AudioJackGUI
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
class AudioJackGUI(object):
def __init__(self, master):
self.root = master
self.searching = False
self.can_download = True
audiojack.set_useragent('AudioJack', '1.0')
self.frame = ScrollableFrame(self.root)
self.frame.setconfig(bg='#0D47A1', width=1280, height=720)
self.frame.pack(side=TOP, fill=BOTH, expand=1)
self.label = Label(self.frame.mainframe, text='AudioJack', fg='#ffffff', bg=self.frame.mainframe['background'], font=('Segoe UI', 48))
self.label.pack()
self.url_entry = Entry(self.frame.mainframe, width=48, font=('Segoe UI', 20), bg='#1565C0', bd=2, highlightthickness=1, highlightcolor='#1565C0', highlightbackground='#0D47A1', fg='#ffffff', insertbackground='#ffffff', relief=FLAT, insertwidth=1)
self.url_entry.pack()
self.submit_button = Button(self.frame.mainframe, width=60, font=('Segoe UI', 16), text='Go!', bd=0, bg='#1E88E5', fg='#ffffff', activebackground='#2196F3', activeforeground='#ffffff', relief=SUNKEN, cursor='hand2', command=self.submit)
self.submit_button.pack()
self.search_progress = Progressbar(self.frame.mainframe, orient='horizontal', length=720, maximum=100 ,mode='indeterminate')
self.error_info = Label(self.frame.mainframe, fg='#ff0000', bg=self.frame.mainframe['background'])
# Use pack_forget on this to reset the view
self.contents = Frame(self.frame.mainframe, bg=self.frame.mainframe['background'])
# Contains results and custom tag options
self.select_frame = Frame(self.contents, bg=self.frame.mainframe['background'])
self.select_frame.pack()
#Search results
self.results_label = Label(self.select_frame, text='Results:', fg='#ffffff', bg=self.frame.mainframe['background'])
self.results_frame = Frame(self.select_frame, bg=self.frame.mainframe['background'])
self.results_label.pack()
self.results_frame.pack()
# Downloads
self.file_label = Label(self.contents, fg='#ffffff', bg=self.frame.mainframe['background'])
def submit(self):
self.searching = True
self.error_info.pack_forget()
self.error_info.config(text='')
self.contents.pack_forget()
self.reset_results_frame()
self.file_label.config(text='')
self.results_queue = Queue.Queue()
t = Thread(target=self.search)
t.daemon = True
t.start()
self.submit_button.pack_forget()
self.search_progress.pack()
self.search_progress.start(10)
self.root.after(100, self.handle_results)
def search(self):
url = self.url_entry.get()
try:
self.results_queue.put(audiojack.get_results(url))
except Exception as e:
self.results_queue.put([])
def handle_results(self):
try:
results = self.results_queue.get(0)
self.reset_results_frame()
self.search_progress.pack_forget()
self.submit_button.pack()
if results == []:
self.error_info.config(text='No results found.')
self.error_info.pack()
else:
for i, entry in enumerate(results):
self.get_result_box(entry).grid(row=i / 4, column=i % 4)
self.contents.pack()
self.select_frame.pack()
except Queue.Empty:
self.root.after(100, self.handle_results)
def reset_results_frame(self):
for result in self.results_frame.winfo_children():
result.destroy()
def get_result_box(self, entry):
try:
text ='%s\n%s\n%s' % (entry['title'], entry['artist'], entry['album'])
raw_image = Image.open(BytesIO(entry['img'].decode('base64')))
side = self.frame.mainframe.winfo_reqwidth() / 4
image_data = raw_image.resize((side, side), Image.ANTIALIAS)
image = ImageTk.PhotoImage(image=image_data)
frame = Frame(self.results_frame)
button = Button(frame, fg='#ffffff', text=text, image=image, compound=CENTER, bg=self.frame.mainframe['background'], command=lambda: self.select(entry))
button.image = image
button.pack(fill=BOTH, expand=1)
return frame
except Exception as e:
print e
print type(e)
def select(self, entry):
if self.can_download:
#.........這裏部分代碼省略.........
示例4: FindServer
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
class FindServer(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
self.selected = "";
self.controller = controller
label = Label(self, text="Select server", font=TITLE_FONT, justify=CENTER, anchor=CENTER)
label.pack(side="top", fill="x", pady=10)
self.button1 = Button(self, text="Next",state="disabled", command=self.callback_choose)
button2 = Button(self, text="Refresh", command=self.callback_refresh)
button3 = Button(self, text="Back", command=self.callback_start)
scrollbar = Scrollbar(self)
self.mylist = Listbox(self, width=100, yscrollcommand = scrollbar.set )
self.mylist.bind("<Double-Button-1>", self.twoClick)
self.button1.pack()
button2.pack()
button3.pack()
# create list with a scroolbar
scrollbar.pack( side = "right", fill="y" )
self.mylist.pack( side = "top", fill = "x", ipadx=20, ipady=20, padx=20, pady=20 )
scrollbar.config( command = self.mylist.yview )
# create a progress bar
label2 = Label(self, text="Refresh progress bar", justify='center', anchor='center')
label2.pack(side="top", fill="x")
self.bar_lenght = 200
self.pb = Progressbar(self, length=self.bar_lenght, mode='determinate')
self.pb.pack(side="top", anchor='center', ipadx=20, ipady=20, padx=10, pady=10)
self.pb.config(value=0)
# to select he server user must double-click on it
def twoClick(self, event):
widget = event.widget
selection=widget.curselection()
value = widget.get(selection[0])
self.selected = value
self.button1.config(state="normal")
# save the selected server in a global variable
SELECTED_SERV = SERVER_LIST[selection[0]]
set_globvar(SELECTED_SERV)
# listen for broadcasts from port 8192
def listen_broadcasts(self, port, timeout):
# Set the progress bar to 0
self.pb.config(value=0)
step_size = ((self.bar_lenght/(MAX_NR_OF_SERVERS+1))/2)
list_of_servers = []
# Initialize the listener
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.bind(('', port))
s.settimeout(LISTENING_TIMEOUT)
# Listen for a number of times to get multiple servers
for _ in range(MAX_NR_OF_SERVERS + 1):
# Update the progress bar
self.pb.step(step_size)
self.pb.update_idletasks()
try:
message, address = s.recvfrom(8192)
m_split = message.split(';')
if m_split[0] == '\HELLO':
server_id = (m_split[1], address)
# Check if the server has not yet broadcasted itself.
if server_id not in list_of_servers:
list_of_servers.append(server_id)
except:
pass
# Close the socket
s.close()
if not list_of_servers:
# If no server found, pop a warning message.
tkMessageBox.showwarning("Find Servers", "No servers found. Refresh or create a new game.")
# Set the progress bar back to 0
self.pb.config(value=0)
# Return the whole list of available servers
return list_of_servers
# service the refresh button
def callback_refresh(self):
global SERVER_LIST
self.mylist.delete(0,END)
SERVER_LIST = self.listen_broadcasts(BROADCASTING_PORT, LISTENING_TIMEOUT)
for server_el in SERVER_LIST:
self.mylist.insert(END,(" "+str(server_el[0])+" IP: "+str(server_el[1])+" Time: "+str(time.asctime())))
def callback_choose(self):
self.mylist.delete(0,END)
self.button1.config(state="disabled")
self.controller.show_frame("ChooseType")
def callback_start(self):
self.mylist.delete(0,END)
self.button1.config(state="disabled")
self.controller.show_frame("StartPage")
示例5: Checkbutton
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
keepseqs_check = Checkbutton(optionsframe, text="Keep all sequences", variable=kpseqs, onvalue=True, offvalue=False)
keeprvals_check = Checkbutton(optionsframe, text="Keep all r-values", variable=kprval, onvalue=True, offvalue=False)
keepgdata_check = Checkbutton(optionsframe, text="Keep all graphed data", variable=kpgdata, onvalue=True, offvalue=False)
keepseqs_check.grid(column=0, row=1, sticky=(W))
keeprvals_check.grid(column=0, row=2, sticky=(W))
keepgdata_check.grid(column=0, row=3, sticky=(W))
#------------------------------
defaults_bt = Button(mainframe, text="Last Settings", command=setdefault)
defaults_bt.grid(column=3, row=1)
start_bt = Button(statusframe, text="Start", width=10, command=startall)
start_bt.pack(side=LEFT)
progress = Progressbar(statusframe, orient=HORIZONTAL, length=450, mode='determinate')
progress.pack(side=LEFT)
stop_bt = Button(statusframe, text="Stop", width=10, command=stopall)
stop_bt.pack(side=LEFT)
diag = Text(dialogframe)
scroll = Scrollbar(dialogframe)
scroll.pack(side=RIGHT, fill=Y)
diag.pack(side=LEFT, fill=Y)
scroll.config(command=diag.yview)
diag.config(yscrollcommand=scroll.set)
#------------------------------
rootframe.pack(fill=BOTH)
mainframe.pack()
dialogframe.pack()
statusframe.pack()
setdefault()
示例6: createWidgets
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
def createWidgets(self):
first_row = Progressbar(self)
first_row.pack(side=TOP)
示例7: DicoGIS
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
#.........這裏部分代碼省略.........
# frames placement
self.FrPath.grid(row=3, column=1, padx=2, pady=2,
sticky="NSWE")
self.FrFilters.grid(row=4, column=1, padx=2, pady=2,
sticky="NSWE")
# tab 2: database
self.nb.add(self.tab_sgbd,
text='gui_database', padding=3)
# tab 3: webservices
self.nb.add(self.tab_webservices,
text='gui_webservices', padding=3)
## TAB 4: ISOGEO
self.nb.add(self.tab_isogeo,
text='gui_Isogeo', padding=3)
## TAB 5: ABOUT
self.nb.add(self.tab_about,
text='gui_about', padding=3)
## MAIN FRAME
# Welcome message
self.welcome = Label(self,
text='hola test',
foreground="red2")
# Progression bar
self.status = StringVar(self.FrProg, '')
# widgets
self.prog_layers = Progressbar(self.FrProg,
orient="horizontal")
Label(master=self.FrProg,
textvariable=self.status,
foreground='DodgerBlue').pack()
# widgets placement
self.prog_layers.pack(expand=1, fill='both')
# Output configuration
# widgets
self.nameoutput = Label(self.FrOutp,
text='gui_fic')
self.output = Entry(self.FrOutp, width=35)
# widgets placement
self.nameoutput.grid(row=0, column=1,
sticky="NSWE", padx=2, pady=2)
self.output.grid(row=0, column=2, columnspan=2,
sticky="NSWE", padx=2, pady=2)
# Image
self.icone = PhotoImage(file=r'../data/img/DicoGIS_logo.gif')
Label(self,
borderwidth=2,
image=self.icone).grid(row=1,
rowspan=4,
column=0,
padx=2,
pady=2,
sticky=W)
# credits
s = Style(self)
s.configure('Kim.TButton', foreground='DodgerBlue', borderwidth=0)
Button(self,
text='by @GeoJulien\nGPL3 - 2015',
style='Kim.TButton',
command=lambda: open_new('https://github.com/Guts/DicoGIS')).grid(row=4,
padx=2,
pady=2,
sticky="WE")
# language switcher
self.ddl_lang = Combobox(self,
values=['fr', 'en'],
width=5)
# grid placement
self.val = Button(self,
text='gui_go',
state=ACTIVE,
command=lambda: self.process())
self.can = Button(self, text='gui_quit',
command=lambda: self.destroy())
self.welcome.grid(row=1, column=1, columnspan=1, sticky="NS",
padx=2, pady=2)
self.ddl_lang.grid(row=1, column=1, sticky="NSE", padx=2, pady=2)
self.nb.grid(row=2, column=1)
self.FrProg.grid(row=3, column=1, sticky="NSWE", padx=2, pady=2)
self.FrOutp.grid(row=4, column=1, sticky="NSWE", padx=2, pady=2)
self.val.grid(row=5, column=1, columnspan=2,
sticky="NSWE", padx=2, pady=2)
self.can.grid(row=5, column=0, sticky="NSWE", padx=2, pady=2)
示例8: Page
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
class Page(Frame):
def __init__(self, parent, index=0):
Frame.__init__(self, parent, height=530, relief=RAISED, borderwidth=1)
self.parent = parent
if index == 0:
self.loadScriptPage()
elif index == 1:
self.scriptProcessPage()
elif index == 2:
self.sonifyProcessPage()
elif index == 3:
self.finishedPage()
else:
print "No Page here!"
def loadScriptPage(self):
# Button States
self.parent.prevButton.config(state='disabled')
if self.parent.scriptname != '':
self.parent.nextButton.config(state='normal')
explain = Label(self, text=txt.selectscript, justify=CENTER, font=root.fontH1)
explain.pack(pady=50)
self.loadedscript = Label(self, text=self.parent.scriptname, justify=CENTER, font=root.fontH1)
self.loadedscript.pack()
loadscriptBtn = Button(self, text="Load Script", command=self.getScript)
loadscriptBtn.pack(pady=10)
def scriptProcessPage(self):
self.parent.prevButton.config(state='normal')
self.parent.nextButton.config(state='normal')
explain = Label(self, text="Character Selection", justify=CENTER, font=root.fontH1)
explain.grid(row=0, columnspan=3, pady=20)
# Instance Script
self.parent.Script = ScreenPlay(normpath(self.parent.scriptpath))
actorNames = self.parent.Script.topcharacters
self.actorActive = []
self.actorGender = []
for i in range(6):
Label(self, text=actorNames[i], width=20).grid(row=i+1, padx=10, pady=8)
participateFrame = Frame(self ,relief=RAISED, borderwidth=1)
participateFrame.grid(row=i+1,column=1, padx=10, ipady=2, ipadx=5)
participate = BooleanVar()
self.actorActive.append(participate)
self.actorActive[i].set(True)
Radiobutton(participateFrame, text="ON", variable=self.actorActive[i], value=True, command=self.updateVars).pack(side=LEFT)
Radiobutton(participateFrame, text="OFF", variable=self.actorActive[i], value=False, command=self.updateVars).pack(side=LEFT)
genderFrame = Frame(self, relief=RAISED, borderwidth=1)
genderFrame.grid(row=i+1,column=2, padx=30, ipady=2)
gender = StringVar()
self.actorGender.append(gender)
self.actorGender[i].set('F')
Label(genderFrame, text="Gender:").pack(side=LEFT, padx=10)
Radiobutton(genderFrame, text="Female", variable=self.actorGender[i], value='F', command=self.updateVars).pack(side=LEFT, padx=5)
Radiobutton(genderFrame, text="Male", variable=self.actorGender[i], value='M', command=self.updateVars).pack(side=LEFT, padx=5)
Label(self, text="______________________", justify=CENTER, state='disabled').grid(row=8, columnspan=3, pady=10)
Label(self, text="Sonification Settings", justify=CENTER, font=root.fontH1).grid(row=9, columnspan=3, pady=10)
sonificationFrame = Frame(self)
sonificationFrame.grid(row=10, columnspan=3)
Label(sonificationFrame, text="Tone Length", width=22).grid(row=0, column=0)
self.tonelen = Combobox(sonificationFrame, state='readonly', values=['1/1','1/2','1/4', '1/8'])
self.tonelen.bind("<<ComboboxSelected>>", self.updateCombobox)
self.tonelen.current(1)
self.tonelen.grid(row=0, column=1, padx=10, pady=5)
Label(sonificationFrame, text="Sonification BPM", width=22).grid(row=1, column=0)
self.bpm = Combobox(sonificationFrame, state='readonly', values=[100, 120, 140, 160, 180, 200, 220, 240, 260])
self.bpm.bind("<<ComboboxSelected>>", self.updateCombobox)
self.bpm.current(4)
self.bpm.grid(row=1, column=1, padx=10, pady=5)
Label(sonificationFrame, text="Dialogue Length per Tone", justify=LEFT).grid(row=2, column=0)
self.dpt = Combobox(sonificationFrame, state='readonly', values=[1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000])
self.dpt.bind("<<ComboboxSelected>>", self.updateCombobox)
self.dpt.current(4)
self.dpt.grid(row=2, column=1, padx=10, pady=5)
self.submitSettings()
def submitSettings(self):
actorSelections = []
sonifySettings = []
#.........這裏部分代碼省略.........
示例9: Metadator
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
#.........這裏部分代碼省略.........
command=lambda: self.setpathtarg(),
takefocus=True)
self.browsetarg.focus_force() # force the focus on
self.profil = Label(self.FrPath, text=self.blabla.get('tab1_prof'))
# profiles switcher
self.ddl_profil = Combobox(self.FrPath, values=self.li_pro, width=5)
self.ddl_profil.current(0)
self.ddl_profil.bind("<<ComboboxSelected>>", self.select_profil)
# widgets placement
self.labtarg.grid(row=1, column=1, columnspan=1,
sticky=N + S + W + E, padx=2, pady=8)
self.target.grid(row=1, column=2, columnspan=1,
sticky=N + S + W + E, padx=2, pady=8)
self.browsetarg.grid(row=1, column=3,
sticky=N + S + W + E, padx=2, pady=8)
self.profil.grid(row=2, column=1,
sticky=N + S + W + E, padx=2, pady=8)
self.ddl_profil.grid(row=2, column=2, sticky=W + E + N + S,
columnspan=2, padx=2, pady=8)
# tooltips
InfoBulle(self.target, message=self.dico_help.get(30)[1])
InfoBulle(self.browsetarg, message=self.dico_help.get(30)[1])
InfoBulle(self.ddl_profil, message=self.dico_help.get(31)[1])
## Frame 2
# variables
self.status = StringVar(self.FrProg, '')
# widgets
self.prog_layers = Progressbar(self.FrProg, orient="horizontal")
self.prog_fields = Progressbar(self.FrProg, orient="horizontal")
# widgets placement
Label(self.FrProg, textvariable=self.status,
foreground='DodgerBlue').pack(expand=1)
self.prog_layers.pack(expand=1, fill=X)
# Frames placement
self.FrPath.pack(expand=1, fill='both')
self.FrProg.pack(expand=1, fill='both')
### Tab 2: options
# Export options
caz_doc = Checkbutton(self.tab_options,
text=u'HTML / Word (.doc/.docx)',
variable=self.def_doc,
command=lambda: self.catalog_dependance())
caz_xls = Checkbutton(self.tab_options,
text=u'Excel 2003 (.xls)',
variable=self.def_xls)
caz_xml = Checkbutton(self.tab_options,
text=u'XML (ISO 19139)',
variable=self.def_xml)
self.caz_cat = Checkbutton(self.tab_options,
text=self.blabla.get('tab2_merge'),
variable=self.def_cat)
caz_odt = Checkbutton(self.tab_options,
text=u'Open Document Text (.odt)',
variable=self.def_odt)
# widgets placement
caz_doc.grid(row=1,
column=0,
sticky=N + S + W + E,
padx=2, pady=2)
self.caz_cat.grid(row=2,
column=0,
sticky=N + S + W + E,
示例10: __init__
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack [as 別名]
class YoutubeScript:
def __init__(self):
self.totDownloadSize = 0
self.completedSize = 0
self.saveData = {
"url": "",
"title": "",
"selected": [],
"completed": [],
"savetype": ""
}
def initUi(self):
self.ipGui = Tk()
self.ipGui.wm_title("YtD by T90")
self.ipGui.wm_minsize(700, 150)
self.titleFrame = Frame(self.ipGui, height=100, width=500, relief=RAISED, bg="#555")
self.titleFrame.pack(fill=BOTH)
titleLabel = Label(self.titleFrame, text="Youtube Downloader Script", bg="#555", fg="#fff", font=("Arial", 16))
subTitleLabel = Label(self.titleFrame, text="By T90", bg="#555", fg="#ddd")
titleLabel.pack(fill=X, side=TOP, pady=3)
subTitleLabel.pack(fill=X, side=BOTTOM)
self.ipFrame = Frame(self.ipGui, height=200, width=500, relief=RAISED, bg="#bbb")
self.ipFrame.pack(fill=BOTH, padx=3, pady=3)
self.urlBox = Entry(self.ipFrame, relief=RAISED, fg="#777")
self.urlBox.focus()
self.urlBtn = Button(self.ipFrame, text="Download", height=2, bg="#777", fg="#eee", command=self.startDownload)
self.urlBox.pack(fill=BOTH, padx=20, pady=10)
self.urlBtn.pack(fill=BOTH, padx=50, pady=10)
# self.urlBox.insert(0, "https://www.youtube.com/playlist?list=PLYvPGplh5--N1zwtg_5-z3kVW9U92FUc2")
self.selectVidsFrame = Frame(self.ipGui, bg="#bbb")
selectLabel = Label(self.selectVidsFrame, text="Select videos to be downloaded and click on Start.", bg="#bbb")
self.vidsListBox = Listbox(self.selectVidsFrame, bg="#bbb", relief=RAISED, selectmode=EXTENDED,
selectbackground="#888", selectforeground="#fff", borderwidth=1,
highlightthickness=0, activestyle="none")
self.selectVidsBtn = Button(self.selectVidsFrame, text="Start", height=2, bg="#777", fg="#eee",
command=self.selectVids)
selectLabel.pack(fill=X, padx=3, pady=3)
self.vidsListBox.pack(fill=X, padx=10, pady=10)
self.selectVidsBtn.pack(fill=X, padx=50, pady=10)
self.progFrame = Frame(self.ipGui, height=200, width=500, relief=SUNKEN, bg="#bbb")
self.titleInProgFrame = Frame(self.progFrame, bg="#bbb")
self.status1InProgFrame = Frame(self.progFrame, bg="#bbb")
self.status2InProgFrame = Frame(self.progFrame, bg="#bbb")
self.progInProgFrame = Frame(self.progFrame, bg="#bbb")
self.vidTitleLabel = Label(self.titleInProgFrame, text="Fetching videos, please wait...", bg="#bbb", fg="#333")
self.thisVidCompletedTitle = Label(self.status1InProgFrame, text="Completed:", bg="#bbb", fg="#333",
justify="right")
self.thisVidCompletedText = Label(self.status1InProgFrame, text="0 MB", bg="#bbb", fg="#333", justify="left")
self.thisVidSizeTitle = Label(self.status1InProgFrame, text="Size:", bg="#bbb", fg="#333", justify="right")
self.thisVidSizeText = Label(self.status1InProgFrame, text="calculating", bg="#bbb", fg="#333", justify="left")
self.totVidCompletedTitle = Label(self.status1InProgFrame, text="Total downloaded:", bg="#bbb", fg="#333",
justify="right")
self.totVidCompletedText = Label(self.status1InProgFrame, text="0 MB", bg="#bbb", fg="#333", justify="left")
self.totVidSizeTitle = Label(self.status1InProgFrame, text="Total Size:", bg="#bbb", fg="#333", justify="right")
self.totVidSizeText = Label(self.status1InProgFrame, text="calculating", bg="#bbb", fg="#333", justify="left")
self.curSpeedTitle = Label(self.status2InProgFrame, text="Speed:", bg="#bbb", fg="#333", justify="right")
self.curSpeedText = Label(self.status2InProgFrame, text="0 mbps", bg="#bbb", fg="#333", justify="left")
self.vidLengthTitle = Label(self.status2InProgFrame, text="Video duration:", bg="#bbb", fg="#333",
justify="right")
self.vidLengthText = Label(self.status2InProgFrame, text="calculating", bg="#bbb", fg="#333", justify="left")
self.etaTitle = Label(self.status2InProgFrame, text="ETA:", bg="#bbb", fg="#333", justify="right")
self.etaText = Label(self.status2InProgFrame, text="calculating", bg="#bbb", fg="#333", justify="left")
self.timeTakenTitle = Label(self.status2InProgFrame, text="Time Taken:", bg="#bbb", fg="#333", justify="right")
self.timeTakenText = Label(self.status2InProgFrame, text="calculating", bg="#bbb", fg="#333", justify="left")
self.totProgLabel = Label(self.progInProgFrame, text="Total Progress", bg="#bbb", fg="#333")
s = Style()
s.theme_use('alt')
s.configure("grey.Horizontal.TProgressbar", foreground='#eee', background='#888')
self.indiProg = Progressbar(self.progInProgFrame, style="grey.Horizontal.TProgressbar", orient='horizontal',
mode='determinate', maximum=100)
self.totProg = Progressbar(self.progInProgFrame, style="grey.Horizontal.TProgressbar", orient='horizontal',
mode='determinate', maximum=100)
self.openDownloadFolderBtn = Button(self.progInProgFrame, text="Open Download Location", height=2, bg="#777",
fg="#eee", command=self.openDownloadFolder)
self.titleInProgFrame.pack(fill=BOTH, expand=1)
self.status1InProgFrame.pack(fill=BOTH, expand=1)
self.status2InProgFrame.pack(fill=BOTH, expand=1)
self.progInProgFrame.pack(fill=BOTH, expand=1)
self.vidTitleLabel.pack(fill=BOTH, expand=1, padx=50, pady=10, side=TOP)
self.thisVidCompletedTitle.pack(fill=BOTH, expand=1, side=LEFT)
self.thisVidCompletedText.pack(fill=BOTH, expand=1, side=LEFT)
self.thisVidSizeTitle.pack(fill=BOTH, expand=1, side=LEFT)
self.thisVidSizeText.pack(fill=BOTH, expand=1, side=LEFT)
self.totVidCompletedTitle.pack(fill=BOTH, expand=1, side=LEFT)
self.totVidCompletedText.pack(fill=BOTH, expand=1, side=LEFT)
#.........這裏部分代碼省略.........