本文整理匯總了Python中ttk.Progressbar.grid方法的典型用法代碼示例。如果您正苦於以下問題:Python Progressbar.grid方法的具體用法?Python Progressbar.grid怎麽用?Python Progressbar.grid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ttk.Progressbar
的用法示例。
在下文中一共展示了Progressbar.grid方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FrProgres
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
class FrProgres(LabelFrame):
def __init__(self, title, txt):
LabelFrame.__init__(self, text=title)
# Bar of global progress
Label(self, text = 'Global progress').grid(row=1, column = 0)
self.proglob = Progressbar(self,
orient = HORIZONTAL,
max = 50,
length = 200,
mode = 'determinate')
# Bar of attributes progress
Label(self, text = 'Attributes progress').grid(row=3, column = 0)
self.progatt = Progressbar(self,
orient = HORIZONTAL,
max = 50,
length = 200,
mode = 'determinate')
# Widgets placement
self.proglob.grid(row=2, column = 0, sticky = N+S+W+E,
padx = 2, pady = 2)
self.progatt.grid(row=4, column = 0, sticky = N+S+W+E,
padx = 2, pady = 2)
示例2: MPExportApp
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
class MPExportApp(object):
"""docstring for MPExportApp"""
def __init__(self, master):
super(MPExportApp, self).__init__()
self.master = master
self.export_type = StringVar()
master.columnconfigure(1, weight=1)
export_type_label = Label(master, text="Data Type: ")
export_type_label.grid(row=0, column=0, sticky=E)
radio_group_frame = Frame(master)
radio_group_frame.grid(row=0, column=1, sticky=W)
self.events_radio_button = Radiobutton(radio_group_frame, text='Events', value='events', variable=self.export_type,
command=self.radio_button_changed)
self.events_radio_button.select()
self.events_radio_button.grid(row=0, column=0)
self.people_radio_button = Radiobutton(radio_group_frame, text='People', value='people', variable=self.export_type,
command=self.radio_button_changed)
self.people_radio_button.grid(row=0, column=1)
api_key_label = Label(master, text="API Key: ")
api_key_label.grid(row=1, column=0, sticky=E)
self.api_key_entry = Entry(master)
self.api_key_entry.grid(row=1, column=1, columnspan=2, sticky=(E,W))
api_secret_label = Label(master, text="API Secret: ")
api_secret_label.grid(row=2, column=0, sticky=E)
self.api_secret_entry = Entry(master)
self.api_secret_entry.grid(row=2, column=1, columnspan=2, sticky=(E, W))
self.project_token_label = Label(master, text="Project Token: ", state=DISABLED)
self.project_token_label.grid(row=3, column=0, sticky=E)
self.project_token_entry = Entry(master, state=DISABLED)
self.project_token_entry.grid(row=3, column=1, columnspan=2, sticky=(E, W))
self.events_label = Label(master, text="Events: ")
self.events_label.grid(row=4, column=0, sticky=E)
self.events_entry = Entry(master)
self.events_entry.insert(0, 'Event A,Event B,Event C')
self.events_entry.bind('<FocusIn>', partial(self.clear_placeholder_text, self.events_entry))
self.events_entry.grid(row=4, column=1, columnspan=2, sticky=(E, W))
where_label = Label(master, text="Where: ")
where_label.grid(row=5, column=0, sticky=E)
self.where_entry = Entry(master)
self.where_entry.grid(row=5, column=1, columnspan=2, sticky=(E, W))
self.from_date_label = Label(master, text="From Date: ")
self.from_date_label.grid(row=6, column=0, sticky=E)
self.from_date_entry = Entry(master)
self.from_date_entry.insert(0, 'YYYY-MM-DD')
self.from_date_entry.bind('<FocusIn>', partial(self.clear_placeholder_text, self.from_date_entry))
self.from_date_entry.grid(row=6, column=1, columnspan=2, sticky=(E, W))
self.to_date_label = Label(master, text="To Date: ")
self.to_date_label.grid(row=7, column=0, sticky=E)
self.to_date_entry = Entry(master)
self.to_date_entry.insert(0, 'YYYY-MM-DD')
self.to_date_entry.bind('<FocusIn>', partial(self.clear_placeholder_text, self.to_date_entry))
self.to_date_entry.grid(row=7, column=1, columnspan=2, sticky=(E, W))
export_button = Button(master, text="EXPORT", fg="green", command=self.export)
export_button.grid(row=8, column=1, sticky=(E, W))
self.delete_button = Button(master, text="DELETE", fg='red', state=DISABLED,
command=lambda: threading.Thread(target=self.delete_people).start())
self.delete_button.grid(row=9, column=1, sticky=(E, W))
self.progress_bar = Progressbar(master)
self.progress_bar_value = IntVar()
self.progress_bar.config(mode='determinate', orient='horizontal', variable=self.progress_bar_value)
self.progress_bar.grid(row=10, column=0, columnspan=3, sticky=(E, W))
def clear_placeholder_text(self, entry, event):
entry_text = entry.get()
if entry_text == 'Event A,Event B,Event C' or entry_text == 'YYYY-MM-DD':
entry.delete(0, END)
def make_events_string(self, events):
events = events.replace(', ', ',')
events = events.split(',')
events_string = '['
for x in range(0, len(events)):
events_string += '"' + events[x] + '"'
if x != len(events)-1:
events_string += ','
else:
events_string += ']'
#.........這裏部分代碼省略.........
示例3: Window
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
class Window(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("Network/Port Scan")
self.style = Style()
self.style.configure("TFrame", background = "#000000")
self.style.configure("TCheckbutton", background = "#000000")
self.style.configure("TButton", background = "#000000")
self.pack(fill=BOTH, expand=1)
# Configure layout
self.columnconfigure(0, weight=1)
self.columnconfigure(1, weight=1)
self.columnconfigure(2, weight=1)
self.rowconfigure(5, weight = 1)
self.rowconfigure(6, weight = 1)
# Title of program
lbl = Label(self, text="Network/Port Scan")
lbl.grid(sticky = W, pady=5, padx=5)
# Text Box
area = ScrolledText(self, height = 20)
area.grid(row=1, column=0, columnspan=3, rowspan=4, padx=3, sticky = N+S+E+W)
self.area = area
# IP Address Button
self.ip = BooleanVar()
ip_add_button = Checkbutton(self, text="IP Address",variable=self.ip, width=10)
ip_add_button.grid(row = 1, column = 3, sticky = N)
ip_add_button.config(anchor = W, activebackground = "red")
# Port Button
self.port = BooleanVar()
port_button = Checkbutton(self, text="Ports", variable=self.port, width=10)
port_button.grid(row = 1, column = 3)
port_button.config(anchor = W, activebackground = "orange")
# Host Name Button
self.host = BooleanVar()
host_name_button = Checkbutton(self, text="Host Name",variable=self.host, width=10)
host_name_button.grid(row = 1, column = 3, sticky = S)
host_name_button.config(anchor = W, activebackground = "yellow")
# Gateway Button
self.gateway = BooleanVar()
gateway_btn = Checkbutton(self, text="Gateway", variable=self.gateway, width=10)
gateway_btn.grid(row = 2, column = 3, sticky = N)
gateway_btn.config(anchor = W, activebackground = "green")
# Services Button
self.service = BooleanVar()
service_btn = Checkbutton(self, text="Services", variable = self.service, width=10)
service_btn.grid(row = 2, column = 3)
service_btn.config(anchor = W, activebackground = "blue")
# Starting IP label
ip_label = Label(self, text = "Starting IP: ")
ip_label.grid(row = 5, column = 0, pady = 1, padx = 3, sticky = W)
self.ip_from = Entry(self, width = 15)
self.ip_from.insert(0, start_ip)
self.ip_from.grid(row = 5 , column = 0, pady = 1, padx = 3, sticky = E)
# Ending IP label
ip_label_two = Label(self, text = "Ending IP: ")
ip_label_two.grid(row = 5, column = 1, pady = 1, padx = 5, sticky = W)
self.ip_to = Entry(self, width = 15)
self.ip_to.insert(0, end_ip)
self.ip_to.grid(row = 5 , column = 1, pady = 1, padx = 5, sticky = E)
# Starting Port Label
port_label = Label(self, text = "Starting Port: ")
port_label.grid(row = 5, column = 0, pady = 3, padx = 5, sticky = S+W)
self.port_from = Entry(self, width = 15)
self.port_from.insert(0, 0)
self.port_from.grid(row = 5 , column = 0, pady = 1, padx = 5, sticky = S+E)
# Ending Port Label
port_label_two = Label(self, text = "Ending Port: ")
port_label_two.grid(row = 5, column = 1, pady = 3, padx = 5, sticky = S+W)
self.port_to = Entry(self, width = 15)
self.port_to.insert(0, 1025)
self.port_to.grid(row = 5 , column = 1, pady = 1, padx = 5, sticky = S+E)
# Scan Me
self_scan_button = Button(self, text="Scan Me", command = lambda : self.onClick(1), width = 33)
self_scan_button.grid(row = 6, column = 1, sticky = N)
# Scan near me Button
scan_other_button = Button(self, text="Scan Near Me", width = 33, command = lambda : self.onClick(2))
scan_other_button.grid(row = 6, column = 0, pady=1, sticky = N)
# Clear button
clear_button = Button(self, text="Clear text", command = self.clear_text, width = 12)
clear_button.grid(row = 6, column = 3, pady=1, sticky = N)
#.........這裏部分代碼省略.........
示例4: TkApplicationWindow
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
class TkApplicationWindow(AbstractApplicationWindow):
def __init__(self, app):
self.root = Tk()
self.root.title("Llia")
self.root.config(background=factory.bg())
super(TkApplicationWindow, self).__init__(app, self.root)
self.root.withdraw()
if app.config()["enable-splash"]:
splash = TkSplashWindow(self.root, app)
self.root.deiconify()
self.root.protocol("WM_DELETE_WINDOW", self.exit_app)
self.llia_graph = None
self._main = layout.BorderFrame(self.root)
self._main.config(background=factory.bg())
self._main.pack(anchor="nw", expand=True, fill=BOTH)
self._progressbar = None
self._init_status_panel()
self._init_menu()
self._init_center_frame(self._main.center)
self.root.minsize(width=665, height=375)
self.group_windows = []
self.add_synth_group()
self._scene_filename = ""
def _init_status_panel(self):
south = self._main.south
south.configure(padx=4, pady=4)
self._lab_status = factory.label(south, "", modal=False)
b_panic = factory.panic_button(south)
b_down = factory.button(south, "-")
b_up = factory.button(south, "+")
b_panic.grid(row=0, column=0)
self._progressbar = Progressbar(south,mode="indeterminate")
self._progressbar.grid(row=0,column=PROGRESSBAR_COLUMN, sticky='w', padx=8)
self._lab_status.grid(row=0,column=4, sticky='w')
south.config(background=factory.bg())
b_down.configure(command=lambda: self.root.lower())
b_up.configure(command=lambda: self.root.lift())
self.update_progressbar(100, 0)
def _tab_change_callback(self, event):
self.llia_graph.sync()
def _init_center_frame(self, master):
nb = ttk.Notebook(master)
nb.pack(expand=True, fill="both")
frame_synths = layout.FlowGrid(nb, 6)
frame_efx = layout.FlowGrid(nb, 6)
frame_controllers = layout.FlowGrid(nb, 6)
self.llia_graph = LliaGraph(nb, self.app)
nb.add(frame_synths, text = "Synths")
nb.add(frame_efx, text = "Effects")
nb.add(frame_controllers, text = "Controllers")
nb.add(self.llia_graph, text="Graph")
nb.bind("<Button-1>", self._tab_change_callback)
def display_info_callback(event):
sp = event.widget.synth_spec
msg = "%s: %s" % (sp["format"],sp["description"])
self.status(msg)
def clear_info_callback(*_):
self.status("")
for st in con.SYNTH_TYPES:
sp = specs[st]
ttp = "Add %s Synthesizer (%s)" % (st, sp["description"])
b = factory.logo_button(frame_synths, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_synth_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_synths.add(b)
for st in con.EFFECT_TYPES:
sp = specs[st]
ttp = "Add %s Effect (%s)" % (st, sp["description"])
b = factory.logo_button(frame_efx, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_efx_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_efx.add(b)
for st in con.CONTROLLER_SYNTH_TYPES:
sp = specs[st]
ttp = "Add %s Effect (%s)" % (st, sp["description"])
b = factory.logo_button(frame_controllers, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_controller_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_controllers.add(b)
@staticmethod
def menu(master):
m = Menu(master, tearoff=0)
m.config(background=factory.bg(), foreground=factory.fg())
return m
def _init_menu(self):
#.........這裏部分代碼省略.........
示例5: __init__
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
#.........這裏部分代碼省略.........
self._prefs["title"] = 1
self.savePrefs()
menuBar = Menu(self._root)
# Preferences pulldown menu
prefMenu = Menu(menuBar, tearoff=0)
prefMenu.add_command(label="CCScript Compiler Executable",
command=self.setCccExe)
prefMenu.add_command(label="Emulator Executable",
command=self.setEmulatorExe)
prefMenu.add_command(label="Toggle Error Details",
command=self.toggleErrorDetails)
menuBar.add_cascade(label="Preferences", menu=prefMenu)
# Tools pulldown menu
toolsMenu = Menu(menuBar, tearoff=0)
toolsMenu.add_command(label="Expand ROM to 32 MBit",
command=self.expandRom)
toolsMenu.add_command(label="Expand ROM to 48 MBit",
command=self.expandRomEx)
toolsMenu.add_command(label="Add Header to ROM",
command=self.addHeaderRom)
toolsMenu.add_command(label="Remove Header from ROM",
command=self.stripHeaderRom)
menuBar.add_cascade(label="Tools", menu=toolsMenu)
# Help menu
helpMenu = Menu(menuBar, tearoff=0)
helpMenu.add_command(label="About", command=self.aboutMenu)
menuBar.add_cascade(label="Help", menu=helpMenu)
self._root.config(menu=menuBar)
# Left side: Export
a=Label(self._root, text="ROM -> New Project",justify=CENTER).grid(
row=0, column=1, columnspan=1)
# ROM file selector
Label(self._root, text="Input ROM:").grid(
row=1, column=0, sticky=E)
inRom = Entry(self._root)
inRom.grid(row=1, column=1)
self.setText(inRom, self.getPrefsValue("export_rom"))
def browseTmp():
self.browseForRom(inRom)
def runTmp():
self.runRom(inRom)
Button(self._root, text="Browse...",
command=browseTmp).grid(row=1, column=2, sticky=W)
Button(self._root, text="Run",
command=runTmp).grid(row=1, column=3, sticky=W)
# Project dir selector
Label(self._root, text="Output Directory:").grid(
row=2, column=0, sticky=E)
outProj = Entry(self._root)
outProj.grid(row=2, column=1)
self.setText(outProj, self.getPrefsValue("export_proj"))
def browseTmp():
self.browseForProject(outProj, save=True)
Button(self._root, text="Browse...",
command=browseTmp).grid(row=2, column=2, sticky=W)
# Export Button
def exportTmp():
self.doExport(inRom, outProj)
self._exportB = Button(self._root, text="Decompile", command=exportTmp)
self._exportB.grid(row=3, column=1, columnspan=1, sticky=W+E)
# Right side: Import
示例6: __init__
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
#.........這裏部分代碼省略.........
self._root = Tk()
if self._prefs["title"] == 1:
self._root.wm_title(getTitle() + " " + _version)
else:
self._root.wm_title("CoilSnake" + " " + _version)
if self._prefs["title"] == 0:
self._prefs["title"] = 1
self.savePrefs()
menuBar = Menu(self._root)
# Preferences pulldown menu
prefMenu = Menu(menuBar, tearoff=0)
prefMenu.add_command(label="CCScript Compiler Executable",
command=self.setCccExe)
prefMenu.add_command(label="Emulator Executable",
command=self.setEmulatorExe)
menuBar.add_cascade(label="Preferences", menu=prefMenu)
# Tools pulldown menu
toolsMenu = Menu(menuBar, tearoff=0)
toolsMenu.add_command(label="Expand ROM to 32 MBit",
command=self.expandRom)
toolsMenu.add_command(label="Expand ROM to 48 MBit",
command=self.expandRomEx)
menuBar.add_cascade(label="Tools", menu=toolsMenu)
# Help menu
helpMenu = Menu(menuBar, tearoff=0)
helpMenu.add_command(label="About", command=self.aboutMenu)
menuBar.add_cascade(label="Help", menu=helpMenu)
self._root.config(menu=menuBar)
# Left side: Export
a=Label(self._root, text="ROM -> New Project",justify=CENTER).grid(
row=0, column=1, columnspan=1)
# ROM file selector
Label(self._root, text="Input ROM:").grid(
row=1, column=0, sticky=E)
inRom = Entry(self._root)
inRom.grid(row=1, column=1)
self.setText(inRom, self._prefs["export_rom"])
def browseTmp():
self.browseForRom(inRom)
def runTmp():
self.runRom(inRom)
Button(self._root, text="Browse...",
command=browseTmp).grid(row=1, column=2, sticky=W)
Button(self._root, text="Run",
command=runTmp).grid(row=1, column=3, sticky=W)
# Project dir selector
Label(self._root, text="Output Directory:").grid(
row=2, column=0, sticky=E)
outProj = Entry(self._root)
outProj.grid(row=2, column=1)
self.setText(outProj, self._prefs["export_proj"])
def browseTmp():
self.browseForProject(outProj, save=True)
Button(self._root, text="Browse...",
command=browseTmp).grid(row=2, column=2, sticky=W)
# Export Button
def exportTmp():
self.doExport(inRom, outProj)
self._exportB = Button(self._root, text="Export", command=exportTmp)
self._exportB.grid(row=4, column=1, columnspan=1, sticky=W+E)
# Right side: Import
示例7: RecordFrame
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [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)
示例8: hello
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
self.running = False
def hello():
tkMessageBox.showinfo("Say Hello", "Hello World")
top = Tk()
top.title("Converter")
L1 = Label(top, text = "Hexadecimal", width=20)
L1.grid(row=0, column=0)
L2 = Label(top, text = "Binary", width=20)
L2.grid(row=0, column=1)
L3 = Label(top, text = "Decimal", width=20)
L3.grid(row=0, column=2)
progressBar = Progressbar(top, orient='horizontal', mode='determinate', length=240)
progressBar.grid(row=3, column = 1, columnspan = 2)
B1 = Button(top, text = "Say Hello", command = hello)
B1.grid(row=31, column=3)
E1 = Entry(top, bd = 3)
E1.grid(row=1, column=0)
E2 = Entry(top, bd = 3)
E2.grid(row=1, column=1)
E3 = Entry(top, bd = 3)
E3.grid(row=1, column=2)
top.mainloop()
示例9: iface
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [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):
示例10: Application
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
class Application(Frame):
def run(self):
appid = self.var_appid.get().strip()
if len(appid) == 0:
tkMessageBox.showinfo(title=u"錯誤", message="請輸入公眾賬號ID")
return
mch_id = self.var_mch_id.get().strip()
if len(mch_id) == 0:
tkMessageBox.showinfo(title=u"錯誤", message="請輸入商戶號")
return
mch_key = self.var_mch_key.get().strip()
if len(mch_key) == 0:
tkMessageBox.showinfo(title=u"錯誤", message="請輸入商戶密鑰")
return
bill_date_from = self.var_bill_date_from.get().strip()
if len(bill_date_from) == 0:
tkMessageBox.showinfo(title=u"錯誤", message="請輸入開始日期")
return
path = self.var_path.get().strip()
if len(path) == 0:
tkMessageBox.showinfo(title=u"錯誤", message="請選擇輸出目錄")
return
sub_mch_id = self.txt_sub_mch_id.get(1.0, END)
if len(sub_mch_id) > 0:
sub_mch_ids = list(set(sub_mch_id.split()))
else:
sub_mch_ids = []
# save settings
config.save(appid, mch_id, mch_key, sub_mch_id, path)
bill_date_to = self.var_bill_date_to.get().strip()
if len(bill_date_to) == 0:
bill_date_to = (datetime.now() + timedelta(days=-1)).strftime("%Y%m%d")
s = datetime.strptime(bill_date_from, "%Y%m%d")
e = datetime.strptime(bill_date_to, "%Y%m%d")
def work_proc(self, path, s, e, sub_mch_ids, event):
self.btn_run.config(state='disabled')
days = (e - s).days + 1
max = days * (len(sub_mch_ids) if len(sub_mch_ids) > 0 else 1)
self.prg_bar.config({'maximum': max})
while s <= e:
if len(sub_mch_ids) > 0:
for sub_mch_id in sub_mch_ids:
r = download_bill(mch_key, appid, mch_id, s, sub_mch_id)
self.save_bill(r, s, mch_id, sub_mch_id)
self.prg_bar.step()
else:
r = download_bill(mch_key, appid, mch_id, s)
self.save_bill(r, s, mch_id)
self.prg_bar.step()
s += timedelta(days=1)
self.btn_run.config(state='normal')
event.set()
self.running = True
work_thread = threading.Thread(target=work_proc, args=(self, path, s, e, sub_mch_ids, self.event))
work_thread.start()
def save_bill(self, text, bill_date, mch_id, sub_mch_id=None):
bill_date = bill_date.strftime("%Y%m%d")
if text.startswith('<xml>'):
f = '%s_%s_%s.xml' % (bill_date, mch_id, sub_mch_id) if sub_mch_id else '%s_%s_.xml' % (bill_date, mch_id)
else:
f = '%s_%s_%s.csv' % (bill_date, mch_id, sub_mch_id) if sub_mch_id else '%s_%s_.csv' % (bill_date, mch_id)
fullname = os.path.join(self.var_path.get().strip(), f)
with open(fullname, 'wb') as csv:
csv.write(text)
def select_path(self):
self.var_path.set(tkFileDialog.askdirectory())
def createWidgets(self, settings):
row = 0
# 公眾號ID
self.lbl_appid = Label(self, text=u"公眾帳號ID", fg='red')
self.lbl_appid.grid(column=0, row=row, sticky=(E, N))
self.var_appid = StringVar(self, value=settings.get('appid'))
self.txt_appid = Entry(self, textvariable=self.var_appid, width=60, font=self.font)
self.txt_appid.grid(column=1, row=row, columnspan=2, sticky=(W, N))
#.........這裏部分代碼省略.........
示例11: LowerScrollingFrame
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [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()
示例12: MiCall
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
class MiCall(tk.Frame):
CONFIG_FILE = os.path.expanduser("~/.micall.config")
def __init__(self, parent, *args, **kwargs):
self.pssm = Pssm(path_to_lookup=AssetWrapper('micall/g2p/g2p_fpr.txt').path,
path_to_matrix=AssetWrapper('micall/g2p/g2p.matrix').path)
tk.Frame.__init__(self, parent, *args, **kwargs)
self.parent = parent
parent.report_callback_exception = self.report_callback_exception
self.rundir = None # path to MiSeq run folder containing data
self.workdir = gettempdir() # default to temp directory
os.chdir(self.workdir)
self.line_counter = LineCounter()
self.run_info = None
self.target_files = []
self.button_frame = tk.Frame(self)
self.button_frame.pack(side='top')
self.console_frame = tk.Frame(self)
self.console_frame.pack(side='top', fill='both', expand=True)
try:
with open(MiCall.CONFIG_FILE, 'rU') as f:
self.config = json.load(f)
except:
self.config = {}
self.nthreads = self.config.get('threads', None)
if not self.nthreads:
self.nthreads = int(round(cpu_count() * 0.5))
self.config['threads'] = self.nthreads
self.write_config()
self.button_run = tk.Button(
self.button_frame, text="Run", command=self.process_files
)
self.button_run.grid(row=0, column=1, sticky='W')
self.progress_bar = Progressbar(self.button_frame, orient='horizontal', length=500, mode='determinate')
self.progress_bar.grid(row=1, columnspan=5)
scrollbar = tk.Scrollbar(self.console_frame)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
self.console = tk.Text(self.console_frame,
bg='black',
fg='white',
yscrollcommand=scrollbar.set)
self.console.pack(side=tk.LEFT, fill=tk.BOTH)
self.console.tag_configure('ERROR', foreground="red")
scrollbar.config(command=self.console.yview)
# redirect stderr to Text widget
#sys.stderr = Redirector(self.console)
self.write('Welcome to MiCall v{}, running with {} threads.\n'.format(
pipeline_version,
self.nthreads))
def write(self, msg):
"""
Write to Text widget, scroll to bottom, and then disable editing again.
:param msg:
:return:
"""
self.console.config(state=tk.NORMAL)
self.console.insert(tk.END, msg)
self.console.see(tk.END)
self.console.config(state=tk.DISABLED)
def write_config(self):
try:
with open(MiCall.CONFIG_FILE, 'w') as f:
json.dump(self.config, f, indent=4)
except:
pass # For now, we don't care if config fails
def open_files(self):
"""
Transfer FASTQ files into working folder, uncompress.
:return:
"""
fastq_files = []
setting_name = 'run_path'
run_path = self.config.get(setting_name, '')
self.rundir = tkFileDialog.askdirectory(
title='Choose a folder of FASTQ files:',
initialdir=run_path)
if not self.rundir:
return fastq_files
self.config[setting_name] = self.rundir
self.write_config()
self.write('Selected folder %s\n' % (self.rundir,))
# check for presence of FASTQ files
for root, _dirs, files in os.walk(self.rundir):
for file in files:
if len(fastq_re.findall(file)) > 0:
#.........這裏部分代碼省略.........
示例13: Metadator_GUI
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
class Metadator_GUI(Tk):
""" Main class """
def __init__(self):
# basics settings
Tk.__init__(self) # constructor of parent graphic class
self.focus_force() # put the window on foreground
self.resizable(width = False, # freeze dimensions
height = False)
self.iconbitmap('../data/images/metadator.ico') # icon
self.title(u'Choose your maps before and after')
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
# Frames
self.frmain = LabelFrame(self, text = 'General')
self.frprog = LabelFrame(self, text = 'Progression')
# GUI variables
self.nbshp = StringVar() # number of shapefiles
self.nbtab = StringVar() # number of MapInfo files
#### Main frame
# Labels
self.labglob = Label(self.frmain, text = u' Please paste or browse the path of your maps')
self.labefore = Label(self, text = u'Map before: ')
self.labafter = Label(self, text = u'Map after: ')
self.numfiles = Label(self, textvariable = self.nbshp)
# paths to image
self.pathbefore = Entry(self, width = 35)
self.pathafter = Entry(self, width = 35)
# browse buttons
self.browsebef = Button(self, text = 'Browse',
command = self.setpathbef)
self.browseaft = Button(self, text = 'Browse',
command = self.setpathaft)
# target folder
self.labtarg = Label(self, text = u'Destination folder: ')
self.target = Entry(self, width = 35)
self.browsetarg = Button(self, text = 'Browse',
command = self.setpathtarg)
# basic buttons
self.validate = Button(self, text = 'Launch',
relief= 'raised',
command = self.bell)
self.cancel = Button(self, text = 'Cancel (quit)',
relief= 'groove',
command = self.destroy)
#### Progression frame
# Progress bar
self.prog = Progressbar(self,
orient=HORIZONTAL,
max = 50,
length=200,
mode='determinate')
# widgets placement
self.labglob.grid(row = 0, column = 0, columnspan = 3)
self.labefore.grid(row = 1, column = 1, columnspan = 1)
self.labafter.grid(row = 2, column = 1, columnspan = 1)
self.labtarg.grid(row = 3, column = 1, columnspan = 1)
self.pathbefore.grid(row = 1, column = 2, columnspan = 1)
self.pathafter.grid(row = 2, column = 2, columnspan = 1)
self.target.grid(row = 3, column = 2, columnspan = 1)
self.browsebef.grid(row = 1, column = 3, columnspan = 1)
self.browseaft.grid(row = 2, column = 3, columnspan = 1)
self.browsetarg.grid(row = 3, column = 3, columnspan = 1)
self.validate.grid(row = 4, column = 1, columnspan = 2)
self.cancel.grid(row = 4, column = 3, columnspan = 1, sticky = "W")
self.numfiles.grid(row=5, column= 2, columnspan = 2)
self.prog.grid(row=6, column = 0, columnspan = 4)
# frames placement
self.frmain.grid(row=6)
def setpathbef(self):
""" ...browse and insert the path of FIRST image """
self.filename = askopenfilename(parent = self,
title = 'Select the "before" image',
filetypes = (("Images", "*.jpg;*.jpeg;*.png;*.tiff"),
("All files", "*.*")))
if self.filename:
try:
self.pathbefore.insert(0, self.filename)
except:
print 'no file indicated'
# end of function
return self.filename
def setpathaft(self):
""" ...browse and insert the path of SECOND image """
self.filename = askopenfilename(parent = self,
title = 'Select the "after" image',
filetypes = (("Images", "*.jpg;*.jpeg;*.png;*.tiff"),
("All files", "*.*")))
if self.filename:
#.........這裏部分代碼省略.........
示例14: JobList
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
#.........這裏部分代碼省略.........
output_files_list.append([output_file, job_outcome[3]])
else:
output_files_list.append([output_file])
plots_thread = PlotsThread(self.create_plots, output_files_list, self)
plots_thread.start()
def add_plot(self, args=dict()):
self.plot_args.append(args)
def finished_adding_plots(self):
self.event_generate('<<CreatePlotGUI>>', when='tail')
def create_plot_gui(self, event):
# TODO: This should be replaced with a new window that allows the user to drag and drop the icons from one frame to another
graph_names = list()
for args in self.plot_args:
graph_name = args['output_file']
graph_names.append(graph_name)
dnd_graphs_frame = Dnd.createFrame(self, 'Drag and Drop Output Plots', graph_names, self.finish_creating_plot_gui)
# This is the entry point for the
def finish_creating_plot_gui(self, plot_labels):
graph_count = 1
for plot_label in plot_labels:
for args in self.plot_args:
#print 'Looking in ' + args['plot_title'] + ' for ' + plot_label
#print 'The plot label is: ' + plot_label
#print 'The output file is: ' + args['output_file']
if plot_label == args['output_file']:
#print 'Creating graph ' + str(graph_count)
graph_count += 1
graph_window = ModelRunnerGraphGUI.GraphWindow(parent=self, title=args['window_title'], df=args['df'], plot=args['plot'], plot_title=args['plot_title'], y_label=args['y_label'], log_filename=self.log_filename)
graph_window.set_grid()
self.top_level_windows.append(graph_window)
#print 'Creating plot GUI
# Have to clear out list here instead of clear_list because clear_list() removes plot_args before this method has a chance to read
# them and create the appropriate plot graph windows
self.reinit_variables()
# Clear all the elements in the list
def clear_list(self):
# Save plot args because they are need later in this run
plot_args = self.plot_args
self.reinit_variables()
# Restore the plot args
self.plot_args = plot_args
self.job_list.delete(0, self.job_list.size())
self.progress_value.set(0)
# Update parent to refresh widget appearance
self.parent.update()
def on_add(self):
single_job = JobParameters(parent=self.parent, beginning_year=1950, ending_year=2100, job_id=self.last_job_id + 1, entry=self)
single_job.set_grid()
def on_remove(self):
selection = self.job_list.curselection()
for line_number in selection:
line_text = self.job_list.get(line_number)
job_id = int(line_text[4:line_text.index(' ', 4)])
job = self.job_params.pop(job_id)
self.job_list.delete(line_number)
示例15: QuoraAnalyticsUI
# 需要導入模塊: from ttk import Progressbar [as 別名]
# 或者: from ttk.Progressbar import grid [as 別名]
class QuoraAnalyticsUI(Notebook):
def __init__(self):
self.parent = Tkinter.Tk()
Notebook.__init__(self, self.parent)
# self.parent.title('Quora Analytics')
self.parent.title("Quora Backup and Analytics")
self.parent.wm_title("Quora Backup and Analytics")
self.parent.grid_rowconfigure(0, weight=1)
self.parent.grid_columnconfigure(0, weight=1)
self.parent.resizable(True, True)
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
self.crawler = QuoraCrawler(driver=QuoraCrawler.CHROME_DRIVER)
self._add_frames()
self.pack(fill="both", expand=True)
def _add_frames(self):
# Adding Answer Backup Frame
f1 = Frame(self)
f1.grid(column=0, row=0, sticky="NWES")
for i in range(4):
f1.grid_rowconfigure(i, weight=0, pad=5)
f1.grid_rowconfigure(4, weight=1, pad=5)
for i in range(4):
f1.grid_columnconfigure(i, weight=1, pad=5)
Label(f1, anchor="e", text="Answers Count : ").grid(column=0, row=0, sticky="EWNS")
self.answer_count = StringVar(value=len(self.crawler.answer_list))
Label(f1, anchor="w", textvariable=self.answer_count).grid(column=1, row=0, sticky="EWNS")
Label(f1, anchor="e", text="User Name : ").grid(column=2, row=0, sticky="EWNS")
self.user = StringVar(value="Unknown")
Label(f1, anchor="w", textvariable=self.user).grid(column=3, row=0, sticky="EWNS")
tf_col = "#e6e6e6"
tf = Tkinter.Frame(f1, relief=GROOVE, borderwidth="2p")
tf.grid(row=1, columnspan=2, column=0, sticky="EWNS")
Label(tf, text="Quora User Options", bg=tf_col, anchor="c").grid(column=0, row=0, columnspan=2, sticky="EWNS")
Button(tf, text="Login", command=lambda: self.thread("login"), highlightbackground=tf_col).grid(
column=0, row=1, sticky="EWNS"
)
Button(tf, text="Logout", command=lambda: self.thread("logout"), highlightbackground=tf_col).grid(
column=1, row=1, sticky="EWNS"
)
tf.grid_rowconfigure(0, weight=1, pad=5)
tf.grid_rowconfigure(1, weight=1, pad=5)
tf.grid_columnconfigure(0, weight=1, pad=5)
tf.grid_columnconfigure(1, weight=1, pad=5)
tf = Frame(f1, relief=GROOVE, borderwidth="2p")
tf.grid(row=1, columnspan=2, column=2, sticky="EWNS")
Label(tf, text="Answer List Option", bg=tf_col, anchor="c").grid(column=0, columnspan=2, row=0, sticky="EWNS")
Button(tf, text="Reset", command=lambda: self.thread("reset"), highlightbackground=tf_col).grid(
column=0, row=1, sticky="EWNS"
)
Button(tf, text="Update", command=lambda: self.thread("update"), highlightbackground=tf_col).grid(
column=1, row=1, sticky="EWNS"
)
tf.grid_rowconfigure(0, weight=1, pad=5)
tf.grid_rowconfigure(1, weight=1, pad=5)
tf.grid_columnconfigure(0, weight=1, pad=5)
tf.grid_columnconfigure(1, weight=1, pad=5)
# Add Progress Bar
self.backup_progress = Progressbar(f1, orient="horizontal", length=100, mode="determinate")
self.backup_progress.grid(row=2, columnspan=4, column=0, sticky="EWNS")
# Adding Status Pane
self.backup_status = StringVar(value="Ready")
Label(f1, textvariable=self.backup_status, anchor="w").grid(row=3, column=0, columnspan=4, sticky="EWNS")
# Adding The list of all answers
tree = Treeview(f1, columns=("sno", "date", "question"))
tree.heading("sno", text="S. No")
tree.heading("date", text="Date")
tree.heading("question", text="Question")
tree.column("#0", width=0, stretch=False)
tree.column("sno", width=40, stretch=False, anchor="center")
tree.column("date", width=120, stretch=False, anchor="center")
tree.column("question", stretch=True, anchor="w")
tree.grid(column=0, columnspan=4, row=4, sticky="EWNS")
tree.bind("<Double-1>", self.tree_item_click)
self.answer_tree = tree
self.populate_tree()
f2 = Frame(self)
self.add(f1, text="Answer Backup", underline=7)
self.add(f2, text="Analytics")
def tree_item_click(self, event):
idx_clicked = self.answer_tree.identify_row(event.y)
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":
#.........這裏部分代碼省略.........