本文整理匯總了Python中ttk.Progressbar.stop方法的典型用法代碼示例。如果您正苦於以下問題:Python Progressbar.stop方法的具體用法?Python Progressbar.stop怎麽用?Python Progressbar.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ttk.Progressbar
的用法示例。
在下文中一共展示了Progressbar.stop方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MPExportApp
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import stop [as 別名]
#.........這裏部分代碼省略.........
def export(self):
if self.api_key_entry.get() == '':
print 'API Key Required!'
return
elif self.api_secret_entry.get() == '':
print 'API Secret Required!'
return
self.output_dir = askdirectory(title='Choose output directory', mustexist=True, parent=self.master)
if not self.output_dir:
return
print 'Output directory is ' + self.output_dir
self.progress_bar.start()
if self.export_type.get() == 'people':
self.export_thread = threading.Thread(target=self.export_people)
elif self.export_type.get() == 'events':
self.export_thread = threading.Thread(target=self.export_events)
self.export_thread.start()
def export_people(self):
mixpanel = Mixpanel(
api_key=self.api_key_entry.get(),
api_secret=self.api_secret_entry.get(),
endpoint=API_ENDPOINT
)
'''Here is the place to define your selector to target only the users that you're after'''
'''parameters = {'selector':'(properties["$email"] == "Albany") or (properties["$city"] == "Alexandria")'}'''
selector = self.where_entry.get()
parameters = {}
if selector:
parameters['selector'] = selector
response = mixpanel.request(['engage'], parameters)
try:
result = '\nAPI ERROR! - ' + json.loads(response)['error'] + '\n'
if result:
print result
self.progress_bar.stop()
self.progress_bar_value.set(0)
return
except KeyError, e:
pass
parameters['session_id'] = json.loads(response)['session_id']
parameters['page'] = 0
global_total = json.loads(response)['total']
if global_total == 0:
print 'Query returned 0 profiles!'
self.progress_bar.stop()
self.progress_bar_value.set(0)
return
print "Session id is %s \n" % parameters['session_id']
print "Here are the # of people %d" % global_total
filename = self.output_dir + "/people_export_"+str(int(time.time()))
jsonfile = filename + ".json"
csvfile = filename + ".csv"
has_results = True
total = 0
with tempfile.NamedTemporaryFile(delete=False) as temp:
with open(jsonfile, 'w') as j:
j.write('[')
while has_results:
responser = json.loads(response)['results']
response_count = len(responser)
total += response_count
has_results = response_count == 1000
i = 0
for data in responser:
dump = json.dumps(data)
temp.write(dump + '\n')
j.write(dump)
i += 1
if i != response_count:
j.write(',')
print "%d / %d" % (total,global_total)
parameters['page'] += 1
if has_results:
j.write(',')
response = mixpanel.request(['engage'], parameters)
else:
j.write(']')
print 'JSON saved to ' + j.name
j.close()
mixpanel.people_json_to_csv(csvfile, temp.name)
temp.close()
os.remove(temp.name)
self.progress_bar.stop()
self.progress_bar_value.set(0)
示例2: TkApplicationWindow
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import stop [as 別名]
#.........這裏部分代碼省略.........
w = event.widget
st = w.config()["text"][-1]
dialog = TkAddSynthDialog(self.root, self.app, st, False)
self.root.wait_window(dialog)
def _show_add_efx_dialog(self, event):
w = event.widget
st = w.config()["text"][-1]
dialog = TkAddSynthDialog(self.root, self.app, st, is_efx=True, is_controller=False)
self.root.wait_window(dialog)
def _show_add_controller_dialog(self, event):
w = event.widget
st = w.config()["text"][-1]
dialog = TkAddSynthDialog(self.root, self.app, st, is_efx=False, is_controller=True)
self.root.wait_window(dialog)
def _add_synth_group(self):
sh = self.app.ls_parser.synthhelper
sh.new_group()
def add_synth_group(self, name=None):
gw = GroupWindow(self.app, self.root, name)
# gw.transient(self.root) # If executed keeps main app window behind all other windows.
self.group_windows.append(gw)
self.status("Added new Synth Group Window")
return gw
def display_synth_editor(self, sid):
try:
swin = self[sid]
grpid = swin.group_index
grp = self.group_windows[grpid]
#grp.deiconify()
grp.show_synth_editor(sid)
except (KeyError, IndexError):
msg = "Can not find editor for %s" % sid
self.warning(msg)
def update_progressbar(self, count, value):
self._progressbar.config(mode="determinate", maximum=count)
self._progressbar.step()
self.root.update_idletasks()
def busy(self, flag, message=""):
if message:
self.status(message)
self._progressbar.config(mode="indeterminate")
if flag:
self._progressbar.grid(row=0, column=PROGRESSBAR_COLUMN, sticky='w', padx=8)
self._progressbar.start()
else:
self._progressbar.stop()
# self._progressbar.grid_remove()
self.root.update_idletasks()
def save_scene(self, *_):
options = {'defaultextension' : '.llia',
'filetypes' : [('Llia Scenes', '*.llia'),
('all files', '*')],
'initialfile' : self._scene_filename,
'parent' : self.root,
'title' : "Save Llia Scene"}
filename = tkFileDialog.asksaveasfilename(**options)
if filename:
try:
self.app.ls_parser.save_scene(filename)
self._scene_filename = filename
self.status("Scene saved as '%s'" % filename)
except Exception as ex:
self.warning(ex.message)
else:
self.status("Scene save canceld")
def load_scene(self, *_):
options = {'defaultextension' : '.llia',
'filetypes' : [('Llia Scenes', '*.llia'),
('all files', '*')],
'initialfile' : self._scene_filename,
'parent' : self.root,
'title' : "Load Llia Scene"}
filename = tkFileDialog.askopenfilename(**options)
if filename:
try:
self.app.ls_parser.load_scene(filename)
self.status("Scene '%s' loaded" % filename)
self._scene_filename = filename
except Exception as ex:
self.warning(ex.message)
else:
self.status("Load scene canceld")
def tabula_rasa(self):
for grp in self.group_windows:
grp.tabula_rasa()
self.group_windows = []
def _interactive_tabula_rasa(self, *_):
# ISSUE: Check config and ask user confirmation before existing
self.app.ls_parser.tabula_rasa()
示例3: QuoraAnalyticsUI
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import stop [as 別名]
#.........這裏部分代碼省略.........
if idx_clicked:
print "Tree Item Clicked - ", idx_clicked
def show_busy_dialog(self):
tkMessageBox.showerror(title="Task in Progress", message=BUSY_MSG, icon=tkMessageBox.INFO)
def thread(self, task):
print "Starting a new Thread for " + task
if self.backup_status.get() != "Ready":
self.show_busy_dialog()
else:
self.backup_status.set("Starting a new Task...")
task_ids = (
("login", self.login_crawler),
("logout", self.logout_crawler),
("update", self.update_answer_list),
("reset", self.reset_answer_list),
)
for task_relation in task_ids:
if task == task_relation[0]:
Thread(target=task_relation[1]).start()
def reset_answer_list(self):
confirm = tkMessageBox.askquestion(title="Confirm Reset", message=RESET_MSG, icon="warning")
if confirm == "yes":
self.backup_status.set("Reseting Answer List...")
self.backup_progress.start(interval=500)
self.crawler.reset_answer_list()
self.answer_count.set(len(self.crawler.answer_list))
self.populate_tree()
self.backup_status.set("Ready")
self.backup_progress.stop()
self.backup_progress["value"] = 0
def update_answer_list(self):
try:
self.backup_status.set("Checking Login Status...")
self.backup_progress.start(interval=500)
if not self.crawler.check_login(self.backup_progress, self.backup_status):
self.backup_status.set("Logged Out !! Cannot continue")
tkMessageBox.showerror(title="Login Required", message=LOGIN_REQ_MSG, icon=tkMessageBox.INFO)
else:
self.backup_progress["value"] = 10
self.backup_status.set("Updating Answer List...It may take few minutes")
self.crawler.update_answer_list(self.backup_progress, self.backup_status)
self.answer_count.set(len(self.crawler.answer_list))
self.populate_tree()
except STException:
tkMessageBox.showerror(title="Operation Aborted", message=TIMEOUT_MSG, icon=tkMessageBox.ERROR)
self.backup_status.set("Ready")
self.backup_progress.stop()
self.backup_progress["value"] = 0
def login_crawler(self):
try:
self.backup_status.set("Checking Login Status...")
self.backup_progress.start(interval=500)
self.backup_progress["value"] = 10
if self.crawler.check_login(self.backup_progress, self.backup_status):
self.backup_progress["value"] = 100
self.backup_progress.stop()
tkMessageBox.showinfo(title="Login Successful", message=ALREADY_LOGIN_MSG, icon=tkMessageBox.INFO)
self.user.set(self.crawler.get_user_name())
示例4: iface
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import stop [as 別名]
class iface():
def __init__(self):
root.title("MuBlas")
self.lab1 = Label(root, text="Music directory")
self.lab1.grid(row = 0, column = 0)
self.music_entry = Entry(root,width=50,bd=1)
self.music_entry.grid(row = 1, column = 0)
self.m_dir_but = Button(root)
self.m_dir_but["text"] = "Choose directory"
self.m_dir_but.grid(row = 1, column = 1)
self.m_dir_but.bind("<Button-1>", self.ask_mus_dir)
self.lab3 = Label(root, text="Size in MBytes")
self.lab3.grid(row = 2, column = 0)
self.size_entry = Entry(root,width=5,bd=1)
self.size_entry.grid(row = 2, column = 1)
self.lab2 = Label(root, text="Destination directory")
self.lab2.grid(row = 3, column = 0)
self.destination_entry = Entry(root,width=50,bd=1)
self.destination_entry.grid(row = 4, column = 0)
self.dest_dir_but = Button(root)
self.dest_dir_but["text"] = "Choose directory"
self.dest_dir_but.grid(row = 4, column = 1)
self.dest_dir_but.bind("<Button-1>", self.ask_out_dir)
self.process_but = Button(root)
self.process_but["text"] = "Run"
self.process_but.grid(row = 6, column = 0)
self.process_but.bind("<Button-1>", self.start)
self.exit_but = Button(root)
self.exit_but["text"] = "Exit"
self.exit_but.grid(row = 6, column = 1)
self.exit_but.bind("<Button-1>", self.exit_app)
self.pr_bar = Progressbar(root, mode='indeterminate')
self.pr_bar.grid(row = 5, column = 0, sticky = "we", columnspan = 2)
#self.pr_bar.start()
def ask_mus_dir(self, event):
dirname = tkFileDialog.askdirectory(parent = root,initialdir="/",title='Please select a directory')
self.music_entry.delete(0, END)
self.music_entry.insert(0, dirname)
def ask_out_dir(self, event):
dirname = tkFileDialog.askdirectory(parent = root,initialdir="/",title='Please select a directory')
self.destination_entry.delete(0, END)
self.destination_entry.insert(0, dirname)
def start(self, event):
self.pr_bar.start()
self.process_but["state"] = DISABLED
m_dir = self.music_entry.get()
d_dir = self.destination_entry.get()
sz = 1024000 * int(self.size_entry.get())
mbls = MuBlas.MuBlas(m_dir, d_dir, sz)
mbls.start()
self.process_but["state"] = NORMAL
self.pr_bar.stop()
def exit_app(self, event):
root.destroy()
def process(self):
示例5: Metadator
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import stop [as 別名]
#.........這裏部分代碼省略.........
self.browsetarg.config(state=DISABLED)
# Looping in folders structure
self.status.set(self.blabla.get('tab1_prog1'))
self.prog_layers.start()
for root, dirs, files in walk(unicode(foldertarget)):
self.num_folders = self.num_folders + len(dirs)
for f in files:
""" looking for files with geographic data """
try:
unicode(path.join(root, f))
full_path = path.join(root, f)
except UnicodeDecodeError:
full_path = path.join(root, f.decode('latin1'))
# Looping on files contained
if path.splitext(full_path.lower())[1].lower() == '.shp'\
and (path.isfile('{0}.dbf'.format(full_path[:-4]))
or path.isfile('{0}.DBF'.format(full_path[:-4])))\
and (path.isfile('{0}.shx'.format(full_path[:-4]))
or path.isfile('{0}.SHX'.format(full_path[:-4]))):
""" listing compatible shapefiles """
# add complete path of shapefile
self.li_shp.append(full_path)
elif path.splitext(full_path.lower())[1] == '.tab'\
and (path.isfile(full_path[:-4] + '.dat')
or path.isfile(full_path[:-4] + '.DAT'))\
and (path.isfile(full_path[:-4] + '.map')
or path.isfile(full_path[:-4] + '.MAP'))\
and (path.isfile(full_path[:-4] + '.id')
or path.isfile(full_path[:-4] + '.ID')):
""" listing MapInfo tables """
# add complete path of MapInfo file
self.li_tab.append(full_path)
# stopping the progress bar
self.prog_layers.stop()
# Lists ordering and tupling
self.li_shp.sort()
self.li_shp = tuple(self.li_shp)
self.li_tab.sort()
self.li_tab = tuple(self.li_tab)
# setting the label text and activing the buttons
self.status.set(unicode(len(self.li_shp)) + u' shapefiles - '
+ unicode(len(self.li_tab)) + u' tables (MapInfo) - '
+ unicode(self.num_folders) + self.blabla.get('log_numfold'))
self.browsetarg.config(state=ACTIVE)
self.val.config(state=ACTIVE)
# End of function
return foldertarget, self.li_shp, self.li_tab
def li_profiles(self, lang):
u"""
list profiles already existing
"""
# reseting global variable
self.li_pro = []
# Looping in folders structure
folder_profiles = path.join('locale/', lang + '/profiles/')
self.li_pro = [lg[:-4] for lg in listdir(folder_profiles)]
self.li_pro.append(self.blabla.get('tab1_new'))
# End of function
return folder_profiles, self.li_pro
def li_rekurs(self, lang):
u"""
List recurring attributes that already exist in the selected language
"""
# clearing the text dictionary
示例6: TkSynthWindow
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import stop [as 別名]
#.........這裏部分代碼省略.........
raise ValueError(msg)
b_add_vel.bind("<Button-1>", add_map_callback)
b_add_atouch.bind("<Button-1>", add_map_callback)
b_add_keynum.bind("<Button-1>", add_map_callback)
b_delete_vel.bind("<Button-1>", delete_map_callback)
b_delete_atouch.bind("<Button-1>", delete_map_callback)
b_delete_keynum.bind("<Button-1>", delete_map_callback)
def sync_map2_tab(self):
perf = self.synth.bank()[None].performance
vmaps = perf.velocity_maps
atmaps = perf.aftertouch_maps
knmaps = perf.keynumber_maps
self.list_vel_maps.delete(0, 'end')
self.list_atouch_maps.delete(0, 'end')
self.list_keynum_maps.delete(0, 'end')
for q in str(vmaps).split('\n'):
self.list_vel_maps.insert('end', q)
for q in str(atmaps).split('\n'):
self.list_atouch_maps.insert('end', q)
for q in str(knmaps).split('\n'):
self.list_keynum_maps.insert('end', q)
def status(self, msg):
self._lab_status.config(text = msg)
def warning(self, msg):
msg = "WARNING: %s" % msg
self._lab_status.config(text = msg)
def set_value(self, param, value):
for ed in self._child_editors.items():
ed.set_value(param, value)
def set_aspect(self, param, value):
for ed in self._child_editors.values():
ed.set_value(param, value)
def sync(self, *ignore):
self.sync_program_tab()
self.sync_midi_tab()
self.sync_map1_tab()
self.sync_map2_tab()
if "bank" not in ignore:
self.bank_editor.sync_no_propegate()
for key, ed in self._child_editors.items():
if key not in ignore:
ed.sync(*ignore)
def annotation_keys(self):
"""
See TkSubEditor annotation
"""
acc = []
for ed in self._child_editors.values():
acc += ed.annotation_keys()
return acc
def set_annotation(self, key, text):
"""
See TkSubEditor annotation
"""
for ed in self._child_editors.values():
ed.annotation(key, text)
def get_annotation(self, key):
"""
See TkSubEditor annotation
"""
rs = None
for ed in self._child_editors.values():
rs = ed.get_annotation(key)
if rs != None:
return rs
return None
def update_progressbar(self, count, value):
"""
Set progress bar to position value/count, where.
count - Expected number of steps.
value - Current step number.
"""
self._progressbar.config(mode="determinate", maximum=count)
self._progressbar.step()
self.update_idletasks()
def busy(self, flag, message=""):
"""
Set progress bar to 'busy'
"""
if message:
self.status(message)
self._progressbar.config(mode="indeterminate")
if flag:
self._progressbar.grid(row=0,column=PROGRESSBAR_COLUMN, sticky='w', padx=8)
self._progressbar.start()
else:
self._progressbar.stop()
self.update_idletasks()