本文整理匯總了Python中ttk.Progressbar.step方法的典型用法代碼示例。如果您正苦於以下問題:Python Progressbar.step方法的具體用法?Python Progressbar.step怎麽用?Python Progressbar.step使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ttk.Progressbar
的用法示例。
在下文中一共展示了Progressbar.step方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FindServer
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import step [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")
示例2: TkApplicationWindow
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import step [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: __init__
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import step [as 別名]
#.........這裏部分代碼省略.........
self.setText(entry, fname)
def browseForProject(self, entry, save=False):
fname = tkFileDialog.askdirectory(
parent=self._root, title="Select a Project Directory",
mustexist=(not save))
self.setText(entry, fname)
def runRom(self, entry):
romFname = entry.get()
if self.getPrefsValue("Emulator") == "":
tkMessageBox.showerror(parent=self._root,
title="Error",
message="""Emulator executable not specified.
Please specify it in the Preferences menu.""")
elif romFname != "":
Popen([self.getPrefsValue("Emulator"), romFname])
def resetConsole(self):
self._console.delete(1.0, END)
self._console.see(END)
def doExport(self, romEntry, projEntry):
if (romEntry.get() != "") and (projEntry.get() != ""):
# Update the GUI
self.resetConsole()
self._exportB["state"] = DISABLED
self._importB["state"] = DISABLED
self._upgradeB["state"] = DISABLED
# Save the fields to preferences
self._prefs["export_rom"] = romEntry.get()
self._prefs["export_proj"] = projEntry.get()
self.savePrefs()
self._progBar["value"] = 0
print "Initializing CoilSnake\n"
self._cs = CoilSnake.CoilSnake()
self._progBar.step(10)
thread = Thread(target=self._doExportHelp,
args=(romEntry.get(), projEntry.get(),
time(), ))
thread.start()
def _doExportHelp(self, rom, proj, startTime):
try:
if self._cs.romToProj(rom, proj):
print "Done! (Took %0.2fs)" % (time()-startTime)
except Exception as inst:
print "\nError:", str(inst)
if self.getPrefsValue("ErrorDetails") == "1":
print_exc()
self._progBar["value"] = 0
self._exportB["state"] = NORMAL
self._importB["state"] = NORMAL
self._upgradeB["state"] = NORMAL
del(self._cs)
def doImport(self, projEntry, cleanRomEntry, romEntry):
if self.getPrefsValue("CCC") == "":
tkMessageBox.showerror(parent=self._root,
title="Error",
message="""CCScript Compiler executable not specified.
Please specify it in the Preferences menu.""")
elif ((projEntry.get() != "") and (cleanRomEntry.get() != "")
and (romEntry.get() != "")):
# Update the GUI
self.resetConsole()
self._exportB["state"] = DISABLED
self._importB["state"] = DISABLED
self._upgradeB["state"] = DISABLED
self._importRunB["state"] = DISABLED
# Save the fields to preferences
示例4: __init__
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import step [as 別名]
#.........這裏部分代碼省略.........
filetypes=[('SNES ROMs','*.smc'), ('All files','*.*')])
self.setText(entry, fname)
def browseForProject(self, entry, save=False):
fname = tkFileDialog.askdirectory(
parent=self._root, title="Select a Project Directory",
mustexist=(not save))
self.setText(entry, fname)
def runRom(self, entry):
romFname = entry.get()
if self._prefs["Emulator"] == "":
tkMessageBox.showerror(parent=self._root,
title="Error",
message="""Emulator executable not specified.
Please specify it in the Preferences menu.""")
elif romFname != "":
Popen([self._prefs["Emulator"], romFname])
def resetConsole(self):
self._console.delete(1.0, END)
self._console.see(END)
def doExport(self, romEntry, projEntry):
if (romEntry.get() != "") and (projEntry.get() != ""):
# Update the GUI
self.resetConsole()
self._exportB["state"] = DISABLED
self._importB["state"] = DISABLED
# Save the fields to preferences
self._prefs["export_rom"] = romEntry.get()
self._prefs["export_proj"] = projEntry.get()
self.savePrefs()
self._progBar["value"] = 0
print "Initializing CoilSnake\n"
self._cs = CoilSnake.CoilSnake()
self._progBar.step(10)
thread = Thread(target=self._doExportHelp,
args=(romEntry.get(), projEntry.get()+"/Project.snake",
time(), ))
thread.start()
def _doExportHelp(self, rom, proj, startTime):
try:
self._cs.romToProj(rom, proj)
print "Done! (Took %0.2fs)" % (time()-startTime)
except Exception as inst:
print "\nError! Something went wrong:"
print_exc()
self._progBar["value"] = 0
self._exportB["state"] = NORMAL
self._importB["state"] = NORMAL
del(self._cs)
def doImport(self, projEntry, cleanRomEntry, romEntry):
if self._prefs["CCC"] == "":
tkMessageBox.showerror(parent=self._root,
title="Error",
message="""CCScript Compiler executable not specified.
Please specify it in the Preferences menu.""")
elif ((projEntry.get() != "") and (cleanRomEntry.get() != "")
and (romEntry.get() != "")):
# Update the GUI
self.resetConsole()
self._exportB["state"] = DISABLED
self._importB["state"] = DISABLED
self._importRunB["state"] = DISABLED
# Save the fields to preferences
self._prefs["import_proj"] = projEntry.get()
self._prefs["import_baserom"] = cleanRomEntry.get()
self._prefs["import_rom"] = romEntry.get()
示例5: RecordFrame
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import step [as 別名]
class RecordFrame(MyFrame):
def __init__(self, parent):
MyFrame.__init__(self, parent, 'Parametrize', (100,0))
self.record_options = DataDumper.load_json_data(Constants.CONFIG_PATH)['record_options']
self.record_time.set_value(self.record_options['duration'])
self.thread = None
def init_ui(self):
MyFrame.init_ui(self)
self.columnconfigure(0, weight=2, minsize=150)
self.columnconfigure(1, weight=3, minsize=100)
self.file_name = TextEntry(self, 'Recorded file name')
self.record_time = TextEntry(self, 'Record time')
self.progress_bar = Progressbar(self, orient='horizontal', mode='determinate')
self.progress_bar.grid(columnspan=2, sticky='NESW')
Button(self, text='Record', command=self.threaded_record).grid(columnspan=2, sticky='NESW')
def threaded_record(self):
if self.thread == None or not self.thread.isAlive():
self.thread = threading.Thread(target=self.record)
self.thread.start()
def record(self):
frequency = int(self.record_options['frequency'])
record_time = int(self.record_time.get_value())
format = pyaudio.paInt16
n_channels = 2
chunk = 1024
output_filename = Constants.RAW_FILES_PATH + self.file_name.get_value() + '.wav'
splitted = self.file_name.get_value().split('/')
if len(splitted) > 1:
splitted = splitted[:-1]
acc = Constants.RAW_FILES_PATH
for el in splitted:
acc += el + '/'
if not os.path.isdir(acc):
os.mkdir(acc)
audio = pyaudio.PyAudio()
stream = audio.open(format=format, channels=n_channels,
rate=frequency, input=True,
frames_per_buffer=chunk)
frames = []
progress_step = 100. / int(frequency / chunk * record_time)
for i in range(0, int(frequency / chunk * record_time)):
data = stream.read(chunk)
frames.append(data)
self.progress_bar.step(progress_step)
stream.stop_stream()
stream.close()
audio.terminate()
waveFile = wave.open(output_filename, 'wb')
waveFile.setnchannels(n_channels)
waveFile.setsampwidth(audio.get_sample_size(format))
waveFile.setframerate(frequency)
waveFile.writeframes(b''.join(frames))
waveFile.close()
tkMessageBox.showinfo('Info', 'Finished recording')
self.progress_bar.step(-100)
示例6: LowerScrollingFrame
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import step [as 別名]
class LowerScrollingFrame(ScrollableFrame):
#self.mangaFrame ==> the MangaFrame that we get our image and updates from
def __init__(self,parent,*args,**kwargs):
self.parent=parent
ScrollableFrame.__init__(self,self.parent,*args,**kwargs)
self.disableDynamicRows() #really annoying to have it on
self.__body()
self.mangaFrame=None
self.imageNotFound=self.image=ImageTk.PhotoImage(Image.open("Image-not-found.gif"))
self.image=self.imageNotFound
self.redraw()
def __body(self):
self.BUTTONS={}
self.BUTTONS["Update"]=Button(self,text="Update",command=self.updateManga)
self.BUTTONS["CheckForUpdates"]=Button(self,text="Check Updates",command=self.updateManga_check)
self.BUTTONS["Delete"]=Button(self,text="Delete",command=self.deleteManga)
self.BUTTONS["Update"].grid(row=0,column=0,sticky=N+S+E+W)
self.BUTTONS["CheckForUpdates"].grid(row=1,column=0,sticky='nsew')
self.BUTTONS["Delete"].grid(row=2,column=0,sticky=N+S+E+W)
self.LABELS={}
self.LABELS["Status"]=Label(self,text="Status:\nUnknown")
self.LABELS["ChapterCount"]=Label(self,text="Chapters:\nUnknown")
self.LABELS["Updates"]=Label(self,text="Updates:\nUnknown")
self.LABELS["Summary"]=LabelResizing(self,text="Summary:\n")
self.LABELS["Picture"]=Label(self,image=None)
self.LABELS["UpdatingStatus"]=Label(self,text="")
self.LABELS["Status"].grid(row=0,column=1)
self.LABELS["ChapterCount"].grid(row=1,column=1)
self.LABELS["Updates"].grid(row=2,column=1)
self.LABELS["Summary"].grid(row=3,column=0,sticky='nwe')
self.LABELS["Picture"].grid(row=0,column=2,rowspan=5)
self.LABELS["UpdatingStatus"].grid(row=5,column=0,columnspan=3)
self.PROGRESSBAR=Progressbar(self)
self.PROGRESSBAR.grid(row=6,column=0,columnspan=3,sticky=E+W)
self.bindChidrenScrolling()
self.grid_columnconfigure(0,weight=1)
self.grid_columnconfigure(1,weight=2)
def setManga(self,MangaFrame):
#this should be a manga frame
self.mangaFrame=MangaFrame
self.image=self.mangaFrame.getImage()
self.redraw()
def redraw(self,*args):
try:
if self.mangaFrame.inProgress==False:self.BUTTONS["Update"].config(text="Update")
else:self.BUTTONS["Update"].config(text="Cancel")
self.LABELS["ChapterCount"].config(text="{} Chapters".format(self.mangaFrame.numberOfChapters()))
self.LABELS["Updates"].config(text="{} Updates".format(self.mangaFrame.numberOfUpdates()))
self.progressSet(self.mangaFrame.getProgress())
self.LABELS["UpdatingStatus"].config(text=self.mangaFrame.getStatus())
self.LABELS["Summary"].config(text="Summary: "+self.mangaFrame.getSummary())
except Exception as e:
print e
self.LABELS["Status"].config(text="Status:\nUnknown")
self.LABELS["ChapterCount"].config(text="Chapters:\nUnknown")
self.LABELS["Updates"].config(text="Updates:\nUnknown")
self.progressReset()
self.LABELS["UpdatingStatus"].config(text="")
self.LABELS["Summary"].config(text="Summary:\nUnknown")
self.LABELS["Picture"].config(image=self.image)
def progressSet(self,value):
self.PROGRESSBAR.config(value=value)
def progressStep(self,value):
self.PROGRESSBAR.step(value)
def progressReset(self):
self.PROGRESSBAR.config(value=0)
def updateManga(self):
if not self.mangaFrame.inProgress:self.mangaFrame.updateManga(self)
else: self.mangaFrame.cancelUpdate()
self.redraw()
def updateManga_check(self):
self.mangaFrame.updateManga_check() #look to see if there are any updates
self.redraw() #change the number we have for the number of updates
def deleteManga(self):
rmtree("files/"+self.mangaFrame.getName())
self.parent.populateLibrary()
self.mangaFrame=None
self.image=self.imageNotFound
self.redraw()
示例7: TkSynthWindow
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import step [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()