本文整理匯總了Python中ttk.Progressbar.pack_forget方法的典型用法代碼示例。如果您正苦於以下問題:Python Progressbar.pack_forget方法的具體用法?Python Progressbar.pack_forget怎麽用?Python Progressbar.pack_forget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ttk.Progressbar
的用法示例。
在下文中一共展示了Progressbar.pack_forget方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FdaAltimeterControl
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack_forget [as 別名]
#.........這裏部分代碼省略.........
self.frequency.set('1')
self.frequencies = tk.OptionMenu(frame, self.frequency,
'1', '2', '4', '8')
self.frequencies.pack(side=tk.LEFT)
label = tk.Label(frame, text=_(u'records per second'))
label.pack(side=tk.LEFT)
self.setup = tk.Button(frame, text=_(u'Set sampling frequency'),
command=self.set_frequency)
self.setup.pack(side=tk.RIGHT)
def allow_user_interactions(self, allow=True):
state = tk.NORMAL if allow else tk.DISABLED
self.ports.configure(state=state)
self.detect.configure(state=state)
self.upload.configure(state=state)
self.erase.configure(state=state)
self.frequencies.configure(state=state)
self.setup.configure(state=state)
def close_asked(self):
if not self.communicating:
self.destroy()
return
else:
showwarning(_(u'Warning'),
_(u"""The application is communicating with the altimeter.
Please wait until communication is finished before closing this window."""))
def hide_progressbar(self):
self.progressbar.prev_pack = self.progressbar.pack_info()
self.progressbar.pack_forget()
self.update()
# Reset progressbar for next upload.
self.progressbar['value'] = 0
def show_progressbar(self):
# Well, Tkinter pack does not seem to
# make it easy to simply hide a widget...
#
# I may be missing something.
prev_info_label_packinfo = self.info_label.pack_info()
prev_label_packinfo = self.label.pack_info()
prev_upload_packinfo = self.upload.pack_info()
self.info_label.pack_forget()
self.label.pack_forget()
self.upload.pack_forget()
self.progressbar.pack(self.progressbar.prev_pack)
self.info_label.pack(prev_info_label_packinfo)
self.label.pack(prev_label_packinfo)
self.upload.pack(prev_upload_packinfo)
self.update()
def upload_progressed(self, read, total):
self.progressbar['maximum'] = total
self.progressbar['value'] = read
info = _(u'Please wait, %d bytes read out of %d') % (read, total)
示例2: AudioJackGUI
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import pack_forget [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:
#.........這裏部分代碼省略.........