for col in range(3): radio_button = ttk.Radiobutton( mighty2, text=colors[col], value=col, variable=color_var, command=radio_callback, ) radio_button.grid(row=1, column=col, sticky='E') # progress bar button_frame = ttk.LabelFrame(mighty2, text="ProgressBar") button_frame.grid(row=2, column=0, columnspan=2) progress_bar = ttk.Progressbar(tab2, orient=tk.HORIZONTAL, length=256, mode='determinate') progress_bar.grid(row=3, column=0, pady=2) def run_progressbar(): progress_bar['maximum'] = 100 for i in range(101): sleep(0.05) progress_bar['value'] = i # increment progressbar progress_bar.update() progress_bar['value'] = 0 def start_progressbar(): progress_bar.start()
def gameMainWindow(set_language): # menuWindowに戻るボタン def back_button(): root.destroy() menuWindow() # gameResultWindowへ進むボタン # デバック用? # 本来はタイピングがクリア出来たらgameResultWindowへ行く def result_button(): root.destroy() gameResultWindow() # もしtext[count]がコメントならば次のコメンドじゃないところまでcountをすすめて返す comment = {"Ruby": ("#"), "Python": ("#", "'''", '"""'), "swift": ("//")} def overComment(text, count, set_language): puls = 0 for c in comment[set_language]: print("コメントチェック:{0}".format(c)) # print(text[count:]) if text[count:].startswith(c): print("発見") if comment[set_language].index(c) == 0: while not text[count + puls:].startswith(os.linesep): puls += 1 return puls + count else: puls = text[count + 3:].find(c) # print("{0}文字目で終わり".format(count)) return puls + count + (len(c) * 2) return count # 入力時に正しいかどうか判定する # 入力した時に何かしたいときは個々に書く def check_input(event): global enemyCount print("pressed", repr(event.char)) true_text = trueStr_buff.get() your_text = yourStr_buff.get() your_over = len(your_text) enemyHP = EnemyHP.get() enemyX = EnemyPoseX.get() enemyY = EnemyPoseY.get() print("len(true_text):{0}".format(len(true_text))) print("your_over:{0}".format(your_over)) if len(true_text) <= your_over + 1: print("終わり") result_button() return while True: next_over = overComment(true_text, your_over, set_language) if your_over < next_over: for i in range(your_over, next_over): your_text += true_text[your_over] your_over += 1 else: break if true_text[your_over:].startswith(os.linesep): # 改行があったときは飛ばす your_over += len(os.linesep) your_text += os.linesep while true_text[your_over] == " " or true_text[your_over] == "\t": # 更に行頭の空白を飛ばす if true_text[your_over] == " ": your_over += 1 your_text += " " elif true_text[your_over] == "\t": your_over += 1 your_text += "\t" while True: next_over = overComment(true_text, your_over, set_language) if your_over < next_over: for i in range(your_over, next_over): your_text += true_text[your_over] your_over += 1 else: break if true_text[your_over] == event.char: # キー入力が正しいとき your_text += true_text[your_over] your_over += 1 enemyHP -= 10 / (enemyCount + 1) if enemyHP <= 0: # 新しい敵生成enemyHP enemyCount += 1 EnemyImg = PhotoImage(file=enemy_list[enemyCount % 2][0]) EnemyName.text = enemy_list[enemyCount % 2][1] enemyHP = 100 EnemyCanvas.image = EnemyImg enemyX = EnemyPoseX.get() enemyY = EnemyPoseY.get() enemyX += random.randint(-10, 10) enemyY += random.randint(-10, 10) with closing(sqlite3.connect(dbname)) as conn: c = conn.cursor() print(user) count_sql = "update users set count = count + 1 where name = '{0}';".format( user) c.execute(count_sql) conn.commit() conn.close() yourStr_buff.set(your_text) EnemyHP.set(enemyHP) # EnemyPoseX.set(enemyX) # EnemyPoseY.set(enemyY) EnemyCanvas.place(x=enemyX, y=enemyY) # --------------------------------- # GUI作成 root = Tk() root.title("gameMainWindow") root.resizable(0, 0) # ウインドウサイズの変更不可設定 root.geometry(windowSize) trueStr = """if __name__ == "__main__": print("Hello World!") i = input(">>> ") for n in range(int(i)): print(n)""" def select_source(ext): with closing(sqlite3.connect((dbname))) as conn: c = conn.cursor() sql = "select * from files where extension like '%{0}' order by random() asc;".format( ext) c.execute(sql) return c.fetchone() def load_source(path): f = open(path, encoding='utf-8') source = f.read() f.close() print(source) return source print(set_language) row = select_source(ext_dir[set_language]) print(row) # set_language = "Python" # trueStr = load_source("./debug.py") trueStr = load_source(row[1]) # フレームの装飾設定 cnf = {"bg": "white", "bd": 5, "relief": GROOVE} # 正解を表示するフレームの生成 trueFrame = Frame(root, cnf, width=390, height=310) trueStr_buff = StringVar() trueStr_buff.set(trueStr) trueLabel = Label(trueFrame, textvariable=trueStr_buff, justify='left') # 入力していくフレームの生成 yourFrame = Frame(root, cnf, width=390, height=310) yourStr_buff = StringVar() yourStr_buff.set("") yourLabel = Label(yourFrame, textvariable=yourStr_buff, bg="red", justify='left') yourLabel.focus_set() yourLabel.bind("<Key>", check_input) # 戦闘画面のフレーム生成 battleFrame = Frame(root, cnf, width=785, height=245) battleLabel = Label(battleFrame, text="てき が あらわれた !!") enemy_list = [("python-icon_128.png", "ニショクヘビ"), ("ruby.png", "るび")] EnemyCanvas = Canvas(battleFrame, width=128, height=128) EnemyImg = PhotoImage(file=enemy_list[enemyCount % 2][0]) EnemyCanvas.create_image(0, 0, image=EnemyImg, anchor=NW) EnemyName = Label(battleFrame, text=enemy_list[enemyCount % 2][1]) EnemyPoseX = IntVar() EnemyPoseX.set(325) EnemyPoseY = IntVar() EnemyPoseY.set(80) EnemyHP = IntVar() EnemyHP.set(110) EnemyHPGauge = ttk.Progressbar(battleFrame, orient="horizontal", length=500, variable=EnemyHP) class Dummy_event: char = "" dummy = Dummy_event() check_input(dummy) # ボタンの装飾の設定 buttonCnf = {"bg": "white", "bd": 3, "relief": RAISED} # 戻るボタンの生成 backButton = Button(root, buttonCnf, text="もどる", command=back_button) resultButton = Button(root, buttonCnf, text="すすむ", command=result_button) battleFrame.place(x=10, y=10) battleLabel.place(x=10, y=10) EnemyName.place(x=50, y=50) EnemyCanvas.place(x=EnemyPoseX.get(), y=EnemyPoseY.get()) EnemyHPGauge.place(x=120, y=50) trueFrame.place(x=10, y=260) trueLabel.place(x=10, y=10) yourFrame.place(x=405, y=260) yourLabel.place(x=10, y=10) backButton.place(x=700, y=570) resultButton.place(x=750, y=570) # GUIの表示 root.mainloop()
import tkinter as tk import tkinter.ttk as ttk import time root = tk.Tk() pb = ttk.Progressbar(root, length=100) pb.pack() pb.step(75) # pb.start(75) # pb.stop(75) root.mainloop()
def ok(): nick = str(CaixaDeEntrada1.get()) sobrenome = str(CaixaDeEntrada2.get()) genero = str(getGenero.get()) pele = str(getPele.get()) especie = str(getEspecie.get()) Linha_Entry_1 = nick Linha_Entry_2 = sobrenome Linha_Entry_3 = genero Linha_Entry_4 = pele Linha_Entry_5 = especie print(Linha_Entry_1) print(Linha_Entry_2) print(Linha_Entry_3) print(Linha_Entry_4) print(Linha_Entry_5) if nick in ' ': CaixaDeEntrada1['bg'] = 'pink' erro['text'] = 'Preencha todos os campos!' else: CaixaDeEntrada1['bg'] = 'white' if sobrenome in ' ': CaixaDeEntrada2['bg'] = 'pink' erro['text'] = 'Preencha todos os campos!' else: CaixaDeEntrada2['bg'] = 'white' if genero in ' ': erro['text'] = 'Preencha todos os campos!' elif genero != "feminino" and genero != "masculino": erro2['text'] = 'Selecione feminino ou masculino!' if pele in ' ': erro['text'] = 'Preencha todos os campos!' elif pele != 'clara' and pele != 'escura': erro3['text'] = 'Selecione tom de pele!' if especie in ' ': erro['text'] = 'Preencha todos os campos!' elif especie != 'vampir@' and especie != 'brux@' and especie != "lobisomem" and especie != "elf@": erro4['text'] = 'Selecione uma espécie válida!' if nick != '' and sobrenome != '' and genero != '' and ( genero == 'feminino' or genero == 'masculino') and (pele == 'clara' or pele == 'escura') and ( especie == 'vampir@' or especie == 'elf@' or especie == "lobisomem" or especie == 'brux@'): janela.destroy() #DESTRÓI JANELA INICIAL E CRIA A PRÓXIMA global root root = Tk() # geometry root.geometry('850x730+350+2') root.resizable(width=False, height=False) #SETANDO AS INFORMAÇOES QUE JÁ ESTAO DISPONIVELS DO PERSONAGEM logo = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\logo.jpeg') logo = logo.resize((100, 30)) global logoarcadia logoarcadia = ImageTk.PhotoImage(logo) global personagem personagem = Personagem() personagem.set_nome(nick.upper()) personagem.set_genero(genero) personagem.set_sobrenome(sobrenome.upper()) personagem.set_pele(pele) personagem.set_especie(especie) personagem.set_aliancas() personagem.set_profissoes() personagem.set_origem() personagem.set_poderes_raciais() # SETANDO A APARÊNCIA DO PERSONAGEM personagem.set_imagem_personagem() vc = personagem.get_imagem_personagem() vc = vc.resize((250, 250)) global you you = ImageTk.PhotoImage(vc) global pb #TIMESLEEP NAS COISAS DA PROPRIA TELA pb = ttk.Progressbar(root, orient="horizontal", length=200, mode="determinate") #IMPORTANDO A IMAGEM DO LOBO #COLOCAR LOBO NA GALERIA if personagem.get_especie() == "lobisomem": animal = personagem.get_lobo() animal = animal.resize((250, 250)) global lobo lobo = ImageTk.PhotoImage(animal) #TELA INICIAL t1 = Tela(root, 'Criar Personagem') t1.telas("Criar Personagem") color = personagem.get_color() root.configure(bg=color) t1.configure(bg=color, pady=30) t1.pack(fill=BOTH, expand=1, anchor=CENTER) x = 250 y = 250 #VAMPIROS im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Assassina.png') im1 = im1.resize((x, y)) global assassina assassina = ImageTk.PhotoImage(im1) im2 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Assassino.png') im2 = im2.resize((x, y)) global assassino assassino = ImageTk.PhotoImage(im2) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\CavaleiraSanguinária.png' ) im1 = im1.resize((x, y)) global cavaleira_sanguinaria cavaleira_sanguinaria = ImageTk.PhotoImage(im1) im2 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\CavaleiroSanguinário.png' ) im2 = im2.resize((x, y)) global cavaleiro_sanguinario cavaleiro_sanguinario = ImageTk.PhotoImage(im2) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\CaçadoraDaNoite.png' ) im1 = im1.resize((x, y)) global cacadora_vampira cacadora_vampira = ImageTk.PhotoImage(im1) im2 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\CaçadorDaNoite.png' ) im2 = im2.resize((x, y)) global cacador_vampiro cacador_vampiro = ImageTk.PhotoImage(im2) #ELFOS im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Sacerdotisa.png') im1 = im1.resize((x, y)) global sacerdotisa sacerdotisa = ImageTk.PhotoImage(im1) im2 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Sacerdote.png') im2 = im2.resize((x, y)) global sacerdote sacerdote = ImageTk.PhotoImage(im2) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\paladina.png') im1 = im1.resize((x, y)) global paladina paladina = ImageTk.PhotoImage(im1) im2 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Paladino.png') im2 = im2.resize((x, y)) global paladino paladino = ImageTk.PhotoImage(im2) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Arqueira.png') im1 = im1.resize((x, y)) global arqueira arqueira = ImageTk.PhotoImage(im1) im2 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Arqueiro.png') im2 = im2.resize((x, y)) global arqueiro arqueiro = ImageTk.PhotoImage(im2) #LOBOS im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Sentinela.png') im1 = im1.resize((x, y)) global sentinela sentinela = ImageTk.PhotoImage(im1) im2 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Rastreador.png') im2 = im2.resize((x, y)) global rastreador rastreador = ImageTk.PhotoImage(im2) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Caçador.png') im1 = im1.resize((x, y)) global cacador cacador = ImageTk.PhotoImage(im1) #BRUXAS im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Alquimista.png') im1 = im1.resize((x, y)) global alquimista alquimista = ImageTk.PhotoImage(im1) im2 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Necromanço.png') im2 = im2.resize((x, y)) global necromancer necromancer = ImageTk.PhotoImage(im2) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\LadrãoDeAlmas.png' ) im1 = im1.resize((x, y)) global ladrao ladrao = ImageTk.PhotoImage(im1) #ARMAS im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Assassinoarma.png' ) im1 = im1.resize((x, y)) global adagas adagas = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\CaçadorDaNoitearma.png' ) im1 = im1.resize((x, y)) global pistola pistola = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\CavaleiroSanguinárioarma.png' ) im1 = im1.resize((x, y)) global foice foice = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\armasacerdote.png' ) im1 = im1.resize((x, y)) global cetro cetro = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\arqueiroarma.png' ) im1 = im1.resize((x, y)) global arco arco = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\paladinoarma.png' ) im1 = im1.resize((x, y)) global martelo martelo = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Necromançoarma.png' ) im1 = im1.resize((x, y)) global varinha varinha = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\alquimistaarma.png' ) im1 = im1.resize((x, y)) global livro livro = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Perseguidorarma.png' ) im1 = im1.resize((x, y)) global besta besta = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Rastreadorarma.png' ) im1 = im1.resize((x, y)) global garras garras = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\Sentinelaarma.png' ) im1 = im1.resize((x, y)) global espada espada = ImageTk.PhotoImage(im1) #SÍMBOLOS DOS EXÉRCITOS x = 100 y = 100 im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\arcana.png') im1 = im1.resize((x, y)) global arcana arcana = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\tenebris.png') im1 = im1.resize((x, y)) global tenebris tenebris = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\magicae.png') im1 = im1.resize((x, y)) global magicae magicae = ImageTk.PhotoImage(im1) im1 = Image.open( r'C:\Users\Rebeca\PycharmProjects\arcadia\img\lycan.png') im1 = im1.resize((x, y)) global lycan lycan = ImageTk.PhotoImage(im1) root.mainloop()
ttk.Button(master=buttons_frame2, text='Clear plot', command=clear, style='clear.TButton').pack(side=BOTTOM) ttk.Button(master=buttons_frame2, text='Parameters', command=plot_parameters, style='parameters.TButton').pack(side=BOTTOM) ttk.Button(master=buttons_frame2, text='CSD', command=csd_guess, style='parameters.TButton').pack(side=BOTTOM) scale_var = StringVar(value='Linear') OptionMenu(buttons_frame2, scale_var, 'Linear', 'Log', command=scale).pack(side=BOTTOM) choice_var = StringVar(value='Sim.') OptionMenu(buttons_frame2, choice_var, 'Sim.', 'Stick', command=lambda choice_var: ask_plot()).pack(side=BOTTOM) progressbar = ttk.Progressbar(buttons_frame5, variable=progress_var, maximum=100) progressbar.pack(fill=X, expand=1) sim.mainloop()
def __init__(self, parent, mode, system_user): tk.Canvas.__init__(self, parent) self.parent = parent container = tk.Frame(self) self.frame_id = self.create_window((0, 0), window=container, anchor=tk.NW) # self.container.config(width=1500) # self.container.grid_propagate(False) self.bind("<Configure>", lambda e: self.configure_frame_width(self, self.frame_id)) button_list = [] delete_button_list = [] self.label_frames = [] self.event_titles = [] conn = sqlite3.connect("database.db") c = conn.cursor() if mode == 0: c.execute("SELECT eventname, date, type, max_participant, participant_num, event_pic FROM event ORDER BY date(DATE) ASC") else: c.execute("SELECT eventname, date, type, max_participant, participant_num FROM event WHERE owner = ? ORDER BY date(DATE) ASC",(system_user,)) result = c.fetchall() i = 0 for r in result: # list events by displaying widgets by loop self.event_titles.append(r[0]) if mode == 0: self.label_frames.append(tk.LabelFrame(container, width=700, height=550)) else: self.label_frames.append(tk.LabelFrame(container, width=700, height=150)) self.label_frames[i].grid_propagate(False) self.label_frames[i].pack(padx=10, pady=10, side=tk.TOP, expand=True) self.label_frames[i].columnconfigure(0, weight=3) self.label_frames[i].columnconfigure(1, weight=7) if mode == 0: # mode 0 is event podium 1 is my events windowe. canvas_for_image = tk.Canvas(self.label_frames[i], bg='green', height=420, width=720, borderwidth=0, highlightthickness=0) canvas_for_image.grid(row=0, column=0, sticky='nesw', columnspan=2) with open("temporary.png", 'wb') as file: file.write(r[5]) image = Image.open('temporary.png') canvas_for_image.image = ImageTk.PhotoImage(image.resize((720, 420), Image.ANTIALIAS)) canvas_for_image.create_image(0, 0, image=canvas_for_image.image, anchor='nw') os.remove("temporary.png") l_eventname = tk.Label(self.label_frames[i], text="", font=("Calibri", 15)) l_eventname.grid(column=0, row=1, sticky=tk.W, columnspan=2) l_date = tk.Label(self.label_frames[i], text="", font=("Calibri", 15)) l_date.grid(column=0, row=2, sticky=tk.W) l_participation = tk.Label(self.label_frames[i], text="", font=("Calibri", 15)) l_participation.grid(column=0, row=3, sticky=tk.W) l_type = tk.Label(self.label_frames[i], text="", font=("Calibri", 15)) l_type.grid(column=0, row=4, sticky=tk.W) l_eventname["text"] = r[0] l_date["text"] = r[1] l_type["text"] = "Event type: " + r[2] l_participation["text"] = str(r[4]) + "/" + str(r[3]) progress_bar = ttk.Progressbar(self.label_frames[i], orient="horizontal", length=400, mode="determinate") progress_bar.grid(column=1, row=3, sticky=tk.E) progress_bar["maximum"] = r[3] progress_bar["value"] = r[4] button_list.append( tk.Button(self.label_frames[i], text="Check Event", command=lambda event_name=r[0]: self.show_details(system_user, event_name))) button_list[i].grid(column=1, row=4, sticky=tk.E) if mode == 1: delete_button_list.append( tk.Button(self.label_frames[i], text="Delete Event", command=lambda event_name=r[0]: self.delete(event_name))) delete_button_list[i].grid(column=1, row=5, sticky=tk.E) i += 1 conn.close()
def auto_update(self): # last_version = self.lybhttp.get_version() # self.patch_urls = self.lybhttp.get_update_file() # self.logger.info('DEBUG-1') last_version = self.rest.get_version() # self.logger.info('DEBUG-2') self.logger.info(last_version) self.patch_urls = self.rest.get_update_file() # self.logger.info('DEBUG-3') self.logger.debug('last_version: ' + last_version + ', ' + lybconstant.LYB_VERSION) if (last_version == lybconstant.LYB_VERSION or len(self.patch_urls) < 1): self.main_frame = ttk.Frame(self.master) frame = ttk.Frame(self.main_frame) s = ttk.Style(frame) s.configure('blue_label.TLabel', foreground='blue') label = ttk.Label(master=frame, text='업데이트 정보가 없습니다.', wraplength=320, style='blue_label.TLabel') label.pack() frame.pack() self.main_frame.pack(expand=True) self.master.after(100, self.start_gui) else: self.main_frame = ttk.Frame(self.master) self.progress_bar = ttk.Progressbar(self.main_frame, orient="horizontal", length=300, mode="determinate") self.progress_bar.pack() self.download_label = tkinter.StringVar(self.main_frame) label = ttk.Label( master=self.main_frame, textvariable=self.download_label, ) label.pack(expand=True) self.download_file_label = tkinter.StringVar(self.main_frame) label = ttk.Label( master=self.main_frame, textvariable=self.download_file_label, ) label.pack(expand=True) self.main_frame.pack(expand=True) self.logger.debug('GoogleDrive file list: ' + str(self.patch_urls)) self.waiting_queue = queue.Queue() self.worker_thread = LYBUpdateWorker('Update', self.configure, self.waiting_queue, self.rest, self.patch_urls, self.progress_bar, self.download_label, self.download_file_label) self.worker_thread.daemon = True self.worker_thread.start() self.master.after(100, self.check_update)
def init_window(): window = tk.Tk() window.title("Mi primera aplicacion") window.geometry("400x250") label = tk.Label(window, text="Calculadora", font=("Arial bold", 15)) label.grid(column=0, row=0) entrada1 = tk.Entry(window, width=10) entrada2 = tk.Entry(window, width=10) entrada1.grid(column=1, row=1) entrada2.grid(column=1, row=2) label_entrada1 = tk.Label(window, text="Ingrese primer numero:", font=("Arial bold", 10)) label_entrada1.grid(column=0, row=1) label_entrada2 = tk.Label(window, text="Ingrese segundo numero:", font=("Arial bold", 10)) label_entrada2.grid(column=0, row=2) label_operador = tk.Label(window, text="Escoja un operador", font=("Arial bold", 10)) label_operador.grid(column=0, row=3) combo_operadores = ttk.Combobox(window) combo_operadores["values"] = ["+", "-", "*", "/", "pow"] combo_operadores.current(0) combo_operadores.grid(column=1, row=3) label_resultado = tk.Label(window, text="Resultado:", font=("Arial bold", 15)) label_resultado.grid(column=0, row=5) chk_state = tk.BooleanVar() chk_state.set(False) chk = tk.Checkbutton(window, text='¿Desea redondear su cifra a un entero?', var=chk_state) chk.grid(column=0, row=6) label_spin = tk.Label(window, text="Agrega un multiplicador al resultado", font=("Arial bold", 10)) label_spin.grid(column=0, row=7) var = tk.IntVar() var.set(1) spin = tk.Spinbox(window, from_=-100, to=100, width=5, textvariable=var) spin.grid(column=1, row=7) style = ttk.Style() style.theme_use('default') style.configure("black.Horizontal.TProgressbar", background='black') bar = ttk.Progressbar(window, length=200, style='black.Horizontal.TProgressbar') bar['value'] = 0 bar.grid(column=0, row=8) def calculadora(num1, num2, operador, mult): if operador == "+": resultado = int(mult) * (num1 + num2) elif operador == "-": resultado = int(mult) * (num1 - num2) elif operador == "*": resultado = int(mult) * (num1 * num2) elif operador == "/": resultado = int(mult) * (round(num1 / num2, 2)) else: resultado = int(mult) * (num1**num2) return resultado def click_calcular(label, num1, num2, operador, redondeo, mult, bar): valor1 = float(num1) valor2 = float(num2) res = calculadora(valor1, valor2, operador, mult) if redondeo: res = round(res) bar['value'] = 100 label.configure(text="Resultado:" + str(res)) boton = tk.Button( window, command=lambda: click_calcular(label_resultado, entrada1.get(), entrada2.get(), combo_operadores.get(), chk_state.get(), spin.get(), bar), text="Calcular", bg="purple", fg="white") boton.grid(column=1, row=4) window.mainloop()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # images self.img_properties_d = tkinter.PhotoImage(name='properties-dark', file='assets/icons8_settings_24px.png') self.img_properties_l = tkinter.PhotoImage(name='properties-light', file='assets/icons8_settings_24px_2.png') self.img_addtobackup_d = tkinter.PhotoImage(name='add-to-backup-dark', file='assets/icons8_add_folder_24px.png') self.img_addtobackup_l = tkinter.PhotoImage(name='add-to-backup-light', file='assets/icons8_add_book_24px.png') self.img_stopbackup_d = tkinter.PhotoImage(name='stop-backup-dark', file='assets/icons8_cancel_24px.png') self.img_stopbackup_l = tkinter.PhotoImage(name='stop-backup-light', file='assets/icons8_cancel_24px_1.png') self.img_play = tkinter.PhotoImage(name='play', file='assets/icons8_play_24px_1.png') self.img_refresh = tkinter.PhotoImage(name='refresh', file='assets/icons8_refresh_24px_1.png') self.img_stop_d = tkinter.PhotoImage(name='stop-dark', file='assets/icons8_stop_24px.png') self.img_stop_l = tkinter.PhotoImage(name='stop-light', file='assets/icons8_stop_24px_1.png') self.img_opened_folder = tkinter.PhotoImage(name='opened-folder', file='assets/icons8_opened_folder_24px.png') self.img_logo = tkinter.PhotoImage(name='logo', file='assets/backup.png') # ----- buttonbar buttonbar = ttk.Frame(self, style='primary.TFrame') buttonbar.pack(fill='x', pady=1, side='top') ## new backup bb_new_backup_btn = ttk.Button(buttonbar, text='New backup set', image='add-to-backup-light', compound='left') bb_new_backup_btn.configure(command=lambda: showinfo(message='Adding new backup')) bb_new_backup_btn.pack(side='left', ipadx=5, ipady=5, padx=(1, 0), pady=1) ## backup bb_backup_btn = ttk.Button(buttonbar, text='Backup', image='play', compound='left') bb_backup_btn.configure(command=lambda: showinfo(message='Backing up...')) bb_backup_btn.pack(side='left', ipadx=5, ipady=5, padx=0, pady=1) ## refresh bb_refresh_btn = ttk.Button(buttonbar, text='Refresh', image='refresh', compound='left') bb_refresh_btn.configure(command=lambda: showinfo(message='Refreshing...')) bb_refresh_btn.pack(side='left', ipadx=5, ipady=5, padx=0, pady=1) ## stop bb_stop_btn = ttk.Button(buttonbar, text='Stop', image='stop-light', compound='left') bb_stop_btn.configure(command=lambda: showinfo(message='Stopping backup.')) bb_stop_btn.pack(side='left', ipadx=5, ipady=5, padx=0, pady=1) ## settings bb_settings_btn = ttk.Button(buttonbar, text='Settings', image='properties-light', compound='left') bb_settings_btn.configure(command=lambda: showinfo(message='Changing settings')) bb_settings_btn.pack(side='left', ipadx=5, ipady=5, padx=0, pady=1) # ----- left panel left_panel = ttk.Frame(self, style='bg.TFrame') left_panel.pack(side='left', fill='y') ## ----- backup summary (collapsible) bus_cf = CollapsingFrame(left_panel) bus_cf.pack(fill='x', pady=1) ## container bus_frm = ttk.Frame(bus_cf, padding=5) bus_frm.columnconfigure(1, weight=1) bus_cf.add(bus_frm, title='Backup Summary', style='secondary.TButton') ## destination ttk.Label(bus_frm, text='Destination:').grid(row=0, column=0, sticky='w', pady=2) ttk.Label(bus_frm, textvariable='destination').grid(row=0, column=1, sticky='ew', padx=5, pady=2) self.setvar('destination', 'd:/test/') ## last run ttk.Label(bus_frm, text='Last Run:').grid(row=1, column=0, sticky='w', pady=2) ttk.Label(bus_frm, textvariable='lastrun').grid(row=1, column=1, sticky='ew', padx=5, pady=2) self.setvar('lastrun', '14.06.2021 19:34:43') ## files Identical ttk.Label(bus_frm, text='Files Identical:').grid(row=2, column=0, sticky='w', pady=2) ttk.Label(bus_frm, textvariable='filesidentical').grid(row=2, column=1, sticky='ew', padx=5, pady=2) self.setvar('filesidentical', '15%') ## section separator bus_sep = ttk.Separator(bus_frm, style='secondary.Horizontal.TSeparator') bus_sep.grid(row=3, column=0, columnspan=2, pady=10, sticky='ew') ## properties button bus_prop_btn = ttk.Button(bus_frm, text='Properties', image='properties-dark', compound='left') bus_prop_btn.configure(command=lambda: showinfo(message='Changing properties'), style='Link.TButton') bus_prop_btn.grid(row=4, column=0, columnspan=2, sticky='w') ## add to backup button bus_add_btn = ttk.Button(bus_frm, text='Add to backup', image='add-to-backup-dark', compound='left') bus_add_btn.configure(command=lambda: showinfo(message='Adding to backup'), style='Link.TButton') bus_add_btn.grid(row=5, column=0, columnspan=2, sticky='w') # ----- backup status (collapsible) status_cf = CollapsingFrame(left_panel) status_cf.pack(fill='x', pady=1) ## container status_frm = ttk.Frame(status_cf, padding=10) status_frm.columnconfigure(1, weight=1) status_cf.add(status_frm, title='Backup Status', style='secondary.TButton') ## progress message status_prog_lbl = ttk.Label(status_frm, textvariable='prog-message', font='Helvetica 10 bold') status_prog_lbl.grid(row=0, column=0, columnspan=2, sticky='w') self.setvar('prog-message', 'Backing up...') ## progress bar status_prog = ttk.Progressbar(status_frm, variable='prog-value', style='success.Horizontal.TProgressbar') status_prog.grid(row=1, column=0, columnspan=2, sticky='ew', pady=(10, 5)) self.setvar('prog-value', 71) ## time started ttk.Label(status_frm, textvariable='prog-time-started').grid(row=2, column=0, columnspan=2, sticky='ew', pady=2) self.setvar('prog-time-started', 'Started at: 14.06.2021 19:34:56') ## time elapsed ttk.Label(status_frm, textvariable='prog-time-elapsed').grid(row=3, column=0, columnspan=2, sticky='ew', pady=2) self.setvar('prog-time-elapsed', 'Elapsed: 1 sec') ## time remaining ttk.Label(status_frm, textvariable='prog-time-left').grid(row=4, column=0, columnspan=2, sticky='ew', pady=2) self.setvar('prog-time-left', 'Left: 0 sec') ## section separator status_sep = ttk.Separator(status_frm, style='secondary.Horizontal.TSeparator') status_sep.grid(row=5, column=0, columnspan=2, pady=10, sticky='ew') ## stop button status_stop_btn = ttk.Button(status_frm, text='Stop', image='stop-backup-dark', compound='left') status_stop_btn.configure(command=lambda: showinfo(message='Stopping backup'), style='Link.TButton') status_stop_btn.grid(row=6, column=0, columnspan=2, sticky='w') ## section separator status_sep = ttk.Separator(status_frm, style='secondary.Horizontal.TSeparator') status_sep.grid(row=7, column=0, columnspan=2, pady=10, sticky='ew') # current file message ttk.Label(status_frm, textvariable='current-file-msg').grid(row=8, column=0, columnspan=2, pady=2, sticky='ew') self.setvar('current-file-msg', 'Uploading file: d:/test/settings.txt') # logo ttk.Label(left_panel, image='logo', style='bg.TLabel').pack(side='bottom') # ---- right panel right_panel = ttk.Frame(self, padding=(2, 1)) right_panel.pack(side='right', fill='both', expand='yes') ## file input browse_frm = ttk.Frame(right_panel) browse_frm.pack(side='top', fill='x', padx=2, pady=1) file_entry = ttk.Entry(browse_frm, textvariable='folder-path') file_entry.pack(side='left', fill='x', expand='yes') open_btn = ttk.Button(browse_frm, image='opened-folder', style='secondary.Link.TButton', command=self.get_directory) open_btn.pack(side='right') ## Treeview tv = ttk.Treeview(right_panel, show='headings') tv['columns'] = ('name', 'state', 'last-modified', 'last-run-time', 'size') tv.column('name', width=150, stretch=True) for col in ['last-modified', 'last-run-time', 'size']: tv.column(col, stretch=False) for col in tv['columns']: tv.heading(col, text=col.title(), anchor='w') tv.pack(fill='x', pady=1) ## scrolling text output scroll_cf = CollapsingFrame(right_panel) scroll_cf.pack(fill='both', pady=1) output_container = ttk.Frame(scroll_cf, padding=1) self.setvar('scroll-message', 'Log: Backing up... [Uploading file: D:/sample_file_35.txt]') st = ScrolledText(output_container) st.pack(fill='both', expand='yes') scroll_cf.add(output_container, textvariable='scroll-message') # ----- seed with some sample data ----------------------------------------------------------------------------- ## starting sample directory file_entry.insert('end', 'D:/text/myfiles/top-secret/samples/') ## treeview and backup logs for x in range(20, 35): result = choices(['Backup Up', 'Missed in Destination'])[0] st.insert('end', f'19:34:{x}\t\t Uploading file: D:/text/myfiles/top-secret/samples/sample_file_{x}.txt\n') st.insert('end', f'19:34:{x}\t\t Upload {result}.\n') timestamp = datetime.now().strftime('%d.%m.%Y %H:%M:%S') tv.insert('', 'end', x, values=(f'sample_file_{x}.txt', result, timestamp, timestamp, f'{int(x // 3)} MB')) tv.selection_set(20)
def begin_seamcarve(self, src_w): src_w.destroy() carve_window = tkinter.Tk() self.src_w = carve_window carve_window.protocol("WM_DELETE_WINDOW", self.on_exit) # ###重写×控件#### screenwidth = carve_window.winfo_screenwidth() screenheight = carve_window.winfo_screenheight() carve_window.geometry('%dx%d+%d+%d' % (900, 600, (screenwidth - 900 - 150) / 2, (screenheight - 600 - 150) / 2)) carve_window.title('Seam Carve for Image Retargeting') ### Source Imaeg 原图存放 ### s_image = tkinter.StringVar(carve_window) s_image.set('Source Image') src_label = tkinter.Label(textvariable=s_image, fg='black', font=('Times', 15)) src_label.place(x=150, y=250) photo, _, _ = self.get_img_obj('resources/11.jpg', self.first_width) photo = ImageTk.PhotoImage(image=photo) img_label = tkinter.Label(carve_window, imag=photo) img_label.place(x=50, y=300) ### Source Imaeg 水平图存放 ### hon_label = tkinter.Label(text='Honrizontal Seams', fg='black', font=('Times', 15)) hon_label.place(x=440, y=250) photo1, _, _ = self.get_img_obj('resources/11.jpg', self.second_width) photo1 = ImageTk.PhotoImage(image=photo1) hon_img = tkinter.Label(carve_window, imag=photo1) hon_img.place(x=410, y=300) ### Source Imaeg 竖直图存放 ### ver_label = tkinter.Label(text='Vertical Seams', fg='black', font=('Times', 15)) ver_label.place(x=660, y=250) ver_img = tkinter.Label(carve_window, imag=photo1) ver_img.place(x=610, y=300) btn1 = tkinter.Button(carve_window, text='Choose Image', fg='black', font=('Times', 15)) btn1.bind( '<Button-1>', lambda event: self.get_image( img_label, hon_img, ver_img, s_pbar, p1, s_image)) btn1.place(x=30, y=60) ### 进度条 ### p1 = ttk.Progressbar(carve_window, length=600, mode='determinate', orient=HORIZONTAL) p1.place(x=200, y=65) p1['maximum'] = 100 p1['value'] = 0 ### 显示进度条的信息 ### s_pbar = tkinter.StringVar(carve_window) s_pbar.set('Progress Will Be Shown Here...') pbar_label = tkinter.Label(carve_window, textvariable=s_pbar, font=('Times', 15)) pbar_label.place(x=400, y=20) btn2 = tkinter.Button(carve_window, text='Resize Image to (H,W)', fg='black', font=('Times', 15)) btn2.bind( '<Button-1>', lambda event: self.resize_image(input_H, input_W, s_pbar, p1)) btn2.place(x=50, y=120) input_H = tkinter.Entry(carve_window, font=('Times', 12), width=5) input_H.place(x=90, y=165, height=50) input_W = tkinter.Entry(carve_window, font=('Times', 12), width=5) input_W.place(x=150, y=165, height=50) btn_result = tkinter.Button(carve_window, text='View Result', fg='black', font=('Times', 16)) btn_result.bind('<Button-1>', lambda event: self.view_result()) btn_result.place(x=300, y=120) btn_src = tkinter.Button(carve_window, text='View Raw Image', fg='black', font=('Times', 16)) btn_src.bind('<Button-1>', lambda event: self.view_src()) btn_src.place(x=300, y=200) btn3 = tkinter.Button(carve_window, text='Remove Object', fg='black', font=('Times', 15)) btn3.bind('<Button-1>', lambda event: self.remove_obj()) btn3.place(x=500, y=120) ##########主菜单是menu################## menu = tkinter.Menu(carve_window) carve_window.config(menu=menu) first_menu = tkinter.Menu(menu, tearoff=False) menu.add_cascade(label='SeamCarving使用说明', menu=first_menu) first_menu.add_command(label='SeamCarving使用说明', command=self.how_to_use) second_menu = tkinter.Menu(menu, tearoff=False) menu.add_cascade(label='开发者', menu=second_menu) second_menu.add_command(label='关于开发者', command=developer) carve_window.mainloop()
def begin_decomposition(self, src_w): src_w.destroy() demo_window = tkinter.Tk() self.src_w = demo_window demo_window.protocol("WM_DELETE_WINDOW", self.on_exit) # ###重写×控件#### screenwidth = demo_window.winfo_screenwidth() screenheight = demo_window.winfo_screenheight() demo_window.geometry('%dx%d+%d+%d' % (700, 400, (screenwidth - 500 - 150) / 2, (screenheight - 400 - 150) / 2)) demo_window.title('Edge-Preserving Filter') ### Source Imaeg 原图存放 ### s_image = tkinter.StringVar(demo_window) s_image.set('Source Image') src_label = tkinter.Label(textvariable=s_image, fg='black', font=('Times', 15)) src_label.place(x=140, y=150) photo, _, _ = get_img_obj('resources/11.jpg', self.first_width) photo = ImageTk.PhotoImage(image=photo) img_label = tkinter.Label(demo_window, imag=photo) img_label.place(x=50, y=200) ### Target Imaeg 目标图存放 ### t_image = tkinter.StringVar(demo_window) t_image.set('Target Image') tar_label = tkinter.Label(textvariable=t_image, fg='black', font=('Times', 15)) tar_label.place(x=450, y=150) t_label = tkinter.Label(demo_window, imag=photo) t_label.place(x=350, y=200) choose_src = tkinter.Button(demo_window, text='Choose Src Image', fg='black', font=('Times', 12)) choose_src.bind('<Button-1>', lambda event: self.get_image(img_label, s_image)) choose_src.place(x=130, y=110) choose_tar = tkinter.Button(demo_window, text='Show Result', fg='black', font=('Times', 12)) choose_tar.bind('<Button-1>', lambda event: self.show()) choose_tar.place(x=440, y=110) choose_tar1 = tkinter.Button(demo_window, text='Show Boosted', fg='black', font=('Times', 12)) choose_tar1.bind('<Button-1>', lambda event: self.show_boost()) choose_tar1.place(x=540, y=110) begin = tkinter.Button(demo_window, text='Begin EP Filter', fg='black', font=('Times', 12)) begin.bind('<Button-1>', lambda event: self.begin(s_pbar, p1, t_label)) begin.place(x=300, y=100) show = tkinter.Button(demo_window, text='Detail Enhance', fg='black', font=('Times', 12)) show.bind('<Button-1>', lambda event: self.enhance()) show.place(x=300, y=140) ### 进度条 ### p1 = ttk.Progressbar(demo_window, length=600, mode='determinate', orient=HORIZONTAL) p1.place(x=50, y=65) p1['maximum'] = 100 p1['value'] = 0 ### 显示进度条的信息 ### s_pbar = tkinter.StringVar(demo_window) s_pbar.set('Progress Will Be Shown Here...') pbar_label = tkinter.Label(demo_window, textvariable=s_pbar, font=('Times', 12)) pbar_label.place(x=250, y=20) ##########主菜单是menu################## menu = tkinter.Menu(demo_window) demo_window.config(menu=menu) first_menu = tkinter.Menu(menu, tearoff=False) menu.add_cascade(label='Edge Preserving Filter使用说明', menu=first_menu) first_menu.add_command(label='Edge Preserving Filter使用说明', command=self.how_to_use) second_menu = tkinter.Menu(menu, tearoff=False) menu.add_cascade(label='开发者', menu=second_menu) second_menu.add_command(label='关于开发者', command=developer) demo_window.mainloop()
checkbox.pack() spam = StringVar() spam.set("SPAM!") checkbox.config(variable=spam, onvalue="SPAM please", offvalue="nospam") #hooks variable into the button variableLabel = ttk.Label(root, textvariable=spam).pack( ) #ties label to the StringVar and updates it on change ##Entry elements typedWords = StringVar() entry = ttk.Entry(root, width=30, textvariable=typedWords).pack() variableLabel = ttk.Label(root, textvariable=typedWords).pack( ) #ties label to the StringVar and updates it on change ##Progress bar progress = ttk.Progressbar(root, orient=HORIZONTAL, length=200) progress.config(mode="indeterminate") progress.pack() progress.start() dProgress = ttk.Progressbar(root, orient=HORIZONTAL, length=200) dProgress.pack() value = DoubleVar() dProgress.config(mode="determinate", maximum=100, value=52, variable=value) scale = ttk.Scale(root, orient=HORIZONTAL, length=200, variable=value, from_=0, to=100).pack() ttk.Label(root, textvariable=value).pack()
Add_Button, Analyse_Button, Clear_Button, Single_Peak_Mode_Only_CB), (None), (Progress_Bar)), font=(text_font, text_size)) Analyse_Button.place(x=x, y=y, height=36, width=58) Single_Peak_Mode_Only = tk.BooleanVar() Single_Peak_Mode_Only.set(False) Single_Peak_Mode_Only_CB = tk.Checkbutton(root, command=Mode_Switch, text="Single Peak Only", variable=Single_Peak_Mode_Only, state=tk.DISABLED) Single_Peak_Mode_Only_CB.place(x=x, y=y + 80) Progress_Bar = ttk.Progressbar(root, length=100, orient=tk.HORIZONTAL, mode='determinate') Progress_Bar.place(x=x, y=y + 50) Adc_Calibration = tk.Entry(root, width=10) Adc_Calibration.place(x=x + 45, y=y + 120) Adc_Calibration.insert(1, string='40') Adc_Calibration_l = tk.Label(root, text='ADC:', font=(text_font, text_size)) Adc_Calibration_l.place(x=x, y=y + 120) y = y + 50 Electronic_Gain = tk.Entry(root, width=10) Electronic_Gain.place(x=x + 45, y=y + 120) Electronic_Gain.insert(1, string='32') Electronic_Gain_l = tk.Label(root, text='Electronic Gain:',
# read all lines of the process log file in as a list (of lines) list_of_process_log_lines = processlog.readlines() #print("List of lines from process log:\n",list_of_process_log_lines) # capture the LAST log entry index value as an integer last_log_number_created = int(list_of_process_log_lines[-1].split(";")[0]) #print(" -- Last log entry was: ",last_log_number_created,file=eventlog,flush="TRUE") printing("\n -- Last log entry was: " + str(last_log_number_created), eventlog) processlog.write( "\n") # create whitespace in the process log between events progressbar_root = tkinter.Tk() progressbar_value = 0 progressbar = ttk.Progressbar(progressbar_root, orient='horizontal', length="10c", mode='determinate', maximum=number_of_cp_files + 1, variable=progressbar_value) progressbar.pack(expand=1) progressbar.start() progressbar.update() ########################################################################################## # MAIN LOOP TO PROCESS ALL C73.CP FILES FOUND IN THE DATA FOLDER SELECTED ABOVE ########################################################################################## # FOR loop to parse all files in data folder. The range is from # 0 up to the total number of data files in the data folder for current_cp_file_no in range(0, number_of_cp_files): # IF LOG FILES DON'T EXIST CREATE THEM NOW, THESE LOG FILES WILL # BE UPDATED AFTER EACH RESULT FILE GETS PROCESSED # Run the following code if this is the first C73.cp file
# Type 1 # def step(): # progress['value'] += 20 # progress = ttk.Progressbar(root, orient=HORIZONTAL, # length = 300, mode = 'determinate') # Type 2 def step(): progress.start(20) def stop(): progress.stop() # progress = ttk.Progressbar(root, orient=HORIZONTAL, # length=300, mode='indeterminate') progress = ttk.Progressbar(root, orient=HORIZONTAL, length=300, mode='determinate') progress.pack() Button(root, text='Progress', command=step).pack() Button(root, text='Stop', command=stop).pack() root.mainloop()
finishMessage = tk.Label(window, text="Finished Segregation", bd=5, font=("Helvetica", 13)) #Getting source and location from use Label_Source = tk.Label(window, text="Source Location", bd=5, font=("Helvetica", 13), justify="left", anchor="nw") Label_Source.grid(column=1, row=3, padx=20) txt1 = tk.Entry(window,width=40) txt1.grid(column=2, row=3) Label_Dest = tk.Label(window, text="Destination", bd=5, font=("Helvetica", 13)) Label_Dest.grid(column=1, row=4, padx=20) txt2 = tk.Entry(window,width=40) txt2.grid(column=2, row=4) #Initializing Progress bar for separation progress = tkk.Progressbar(window, orient="horizontal", length=410, mode='determinate') progress.grid(column=1, row=7, padx=20, columnspan=4) #Creating start button button_Start = tk.Button(window, text="Start", command=lambda: retrieve_input(), width=10, height=1, bg="#00C68C", fg="Black", font=("Arial Bold", 12), relief="flat" ) button_Start.grid(column=1, row=5, pady=20) print(source+destination) # tk.Button(window, text='Start', command=bar).pack(pady=10) Label_Intro = tk.Label(window, text=" \n ", bd=5, font=("Helvetica", 13), justify="left", anchor="nw") Label_Intro.grid(column=1, row=6, padx=20) #Help link to WIki link1 = tk.Label(window, text="Need help? Read Wiki Documentation here.", fg="blue", cursor="hand2") link1.grid(column=2, row=5, padx=20) link1.bind("<Button-1>", lambda e: callback("https://wiki.ok.ubc.ca/libokhist/Creating_Zipped_Bundles"))
forward = PhotoImage(file="assets/forward.png") back = PhotoImage(file="assets/back.png") search = PhotoImage(file="assets/search.png") ref = PhotoImage(file="assets/refresh.png") goback = PhotoImage(file="assets/goback.png") img = Image.open("temp.jpg") img = img.resize((300, 300), Image.ANTIALIAS) img.save("temp.jpg") img = ImageTk.PhotoImage(Image.open("temp.jpg")) lpic = Label(root, image=img) s = ttk.Style() s.configure("red.Horizontal.TProgressbar", foreground='red', background='red') progress = ttk.Progressbar(root, style="red.Horizontal.TProgressbar", orient='horizontal', length=400, maximum=(config.songLength * 20), mode='determinate', value=0) BtPlay = Button(root, border='0', image=playimg, command=lambda: play(config.i, config.sound_file)) BtNext = Button(root, border='0', image=forward, command=lambda: next(config.sound_file)) BtPrev = Button(root, border='0', image=back, command=lambda: prev(config.sound_file))
state_label.grid(column=2, row=4, sticky=W) ttk.Label(mainframe, text="Answer").grid(column=1, row=5, sticky=(N, E)) ttk.Label(mainframe, textvariable=answer, wraplength=wrap).grid(column=2, row=5, sticky=(W, E)) ttk.Label(mainframe, text="Mitigation").grid(column=1, row=6, sticky=(N, E)) ttk.Label(mainframe, textvariable=mitigation, wraplength=wrap).grid(column=2, row=6, sticky=(W, E)) ttk.Label(mainframe, text="Risk ID").grid(column=1, row=7, sticky=(N, E)) ttk.Label(mainframe, textvariable=risk, wraplength=wrap).grid(column=2, row=7, sticky=(W, E)) status = Frame(root) progressbar = ttk.Progressbar( status, orient="horizontal", length=w, mode="determinate", style="LabeledProgressbar", ) status.pack(side=BOTTOM, fill=X, expand=False) progressbar.pack(side=BOTTOM, ipady=10) progressbar["maximum"] = len(data) for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) switch_to_next() judgement_widget.focus() root.mainloop()
# create root window top_win = tk.Tk() # naming root window top_win.title('Hello World Window') # resize root window win_size_pos = '800x600' #win_size_pos = '360x60' top_win.geometry(win_size_pos) #------------------------------ prog_total = 100 p = ttk.Progressbar(top_win, orient='horizontal', length=prog_total * 3, mod='determinate', maximum=prog_total) p.pack() def prog_start(): p.start() return btn_start_auto = tk.Button(top_win, text="Auto start progress", command=prog_start) btn_start_auto.pack()
global flag,value flag = not flag if flag: btn2["text"] = "暂停动画" p2.start(10) else: btn2["text"] = "开始动画" value = p2["value"] p2.stop() p2["value"] = value root = Tk() root.title("Progressbar组件") sg = ttk.Sizegrip(root).grid(row=99,column=99,sticky="se") # 定量进度条 p1 = ttk.Progressbar(root, length=200, mode="determinate", orient=HORIZONTAL) p1.grid(row=1,column=1) p1["maximum"] = 100 p1["value"] = 0 # 通过指定变量,改变进度条位置 # n = IntVar() # p1["variable"] = n # 通过指定步长,改变进度条位置 # p1.step(2) btn = ttk.Button(root,text="开始动画",command=manu_increment) btn.grid(row=1,column=0) # 非定量进度条
def build(self): # handle the exe try: self.spinrite_path = self.fname.name try: self.exe_error.destroy() except AttributeError as err: print(err) except AttributeError: self.exe_error = ttk.Label(self, font=("Helvetica", 12)) self.exe_error['text'] = "No Sinrite.exe selected!" self.exe_error.grid(column=1, row=11, rowspan=1, columnspan=1, sticky='N', padx=5, pady=5) # handle the bootable device path if str(self.var.get()): device_path = self.var.get().split()[0] try: self.device_error.destroy() except AttributeError as err: print(err) else: self.device_error = ttk.Label(self, font=("Helvetica", 12)) self.device_error['text'] = "No device selected!" self.device_error.grid(column=1, row=12, rowspan=1, columnspan=1, sticky='N', padx=5, pady=5) if self.spinrite_path and device_path: self.prog_bar = ttk.Progressbar( self, style="orange.Horizontal.TProgressbar", orient="horizontal", length=400, mode="determinate") self.prog_bar.grid(column=0, row=12, rowspan=1, columnspan=3, sticky='N', padx=5, pady=5) if not os.path.isdir('dos'): os.mkdir('dos') if not os.path.isdir('mnt'): os.mkdir('mnt') self.browse_files.config(state='disabled') self.build_button.config(state='disabled') self.exit_button['text'] = 'Stop' self.build_thread = UsbBuild(self.queue, self.device, self.fname.name) self.build_thread.start() self.periodiccall()
def loadingBar(self): self.progressbar = ttk.Progressbar(self, orient='horizontal', length=340, mode='determinate') self.progressbar.place(x=3, y=225)
def _parse_progressbar(master, node): widget = ttk.Progressbar(master) return widget, [WidgetGeometryConfig.default(widget, node)]
def create_widgets(self): toplevel_frame = ttk.Frame(self, padding='0.1i') (self.toolslist, selected_item) = self.get_tools_list() self.tools_frame = ttk.LabelFrame(toplevel_frame, text="{} Available Tools".format( len(self.toolslist)), padding='0.1i') self.toolnames = tk.StringVar(value=self.toolslist) self.tools_listbox = tk.Listbox(self.tools_frame, height=22, listvariable=self.toolnames) self.tools_listbox.bind("<<ListboxSelect>>", self.update_tool_help) self.tools_listbox.grid(row=0, column=0, sticky=tk.NSEW) self.tools_listbox.columnconfigure(0, weight=10) self.tools_listbox.rowconfigure(0, weight=1) s = ttk.Scrollbar(self.tools_frame, orient=tk.VERTICAL, command=self.tools_listbox.yview) s.grid(row=0, column=1, sticky=(tk.N, tk.S)) self.tools_listbox['yscrollcommand'] = s.set self.tools_frame.grid(row=0, column=0, sticky=tk.NSEW) self.tools_frame.columnconfigure(0, weight=10) self.tools_frame.columnconfigure(1, weight=1) self.tools_frame.rowconfigure(0, weight=1) overall_frame = ttk.Frame(toplevel_frame, padding='0.1i') # json_str = '{"default_value": null, "description": "Directory containing data files.", "flags": ["--wd"], "name": "Working Directory", "optional": true, "parameter_type": "Directory"}' # self.wd = FileSelector(json_str, overall_frame) # self.wd.grid(row=0, column=0, sticky=tk.NSEW) current_tool_frame = ttk.Frame(overall_frame, padding='0.1i') self.current_tool_lbl = ttk.Label( current_tool_frame, text="Current Tool: {}".format(self.tool_name), justify=tk.LEFT) # , font=("Helvetica", 12, "bold") self.current_tool_lbl.grid(row=0, column=0, sticky=tk.W) self.view_code_button = ttk.Button(current_tool_frame, text="View Code", width=12, command=self.view_code) self.view_code_button.grid(row=0, column=1, sticky=tk.E) current_tool_frame.grid(row=1, column=0, sticky=tk.NSEW) current_tool_frame.columnconfigure(0, weight=1) current_tool_frame.columnconfigure(1, weight=1) tool_args_frame = ttk.Frame(overall_frame, padding='0.0i') self.tool_args_frame = ttk.Frame(overall_frame, padding='0.0i') self.tool_args_frame.grid(row=2, column=0, sticky=tk.NSEW) self.tool_args_frame.columnconfigure(0, weight=1) # args_frame = ttk.Frame(overall_frame, padding='0.1i') # self.args_label = ttk.Label(args_frame, text="Tool Arguments:", justify=tk.LEFT) # self.args_label.grid(row=0, column=0, sticky=tk.W) # args_frame2 = ttk.Frame(args_frame, padding='0.0i') # self.args_value = tk.StringVar() # self.args_text = ttk.Entry(args_frame2, width=45, justify=tk.LEFT, textvariable=self.args_value) # self.args_text.grid(row=0, column=0, sticky=tk.NSEW) # self.args_text.columnconfigure(0, weight=1) # self.clearButton = ttk.Button(args_frame2, text="Clear", width=4, command=self.clear_args_box) # self.clearButton.pack(pady=10, padx=10) # self.clearButton.grid(row=0, column=1, sticky=tk.E) # self.clearButton.columnconfigure(0, weight=1) # args_frame2.grid(row=1, column=0, sticky=tk.NSEW) # args_frame2.columnconfigure(0, weight=10) # args_frame2.columnconfigure(1, weight=1) # args_frame.grid(row=2, column=0, sticky=tk.NSEW) # args_frame.columnconfigure(0, weight=1) # # Add the bindings # if _platform == "darwin": # self.args_text.bind("<Command-Key-a>", self.args_select_all) # else: # self.args_text.bind("<Control-Key-a>", self.args_select_all) buttonsFrame = ttk.Frame(overall_frame, padding='0.1i') self.run_button = ttk.Button(buttonsFrame, text="Run", width=8, command=self.run_tool) # self.run_button.pack(pady=10, padx=10) self.run_button.grid(row=0, column=0) self.quitButton = ttk.Button(buttonsFrame, text="Cancel", width=8, command=self.cancel_operation) self.quitButton.grid(row=0, column=1) buttonsFrame.grid(row=3, column=0, sticky=tk.E) output_frame = ttk.Frame(overall_frame, padding='0.1i') outlabel = ttk.Label(output_frame, text="Output:", justify=tk.LEFT) outlabel.grid(row=0, column=0, sticky=tk.NW) k = wbt.tool_help(self.tool_name) self.out_text = ScrolledText(output_frame, width=63, height=10, wrap=tk.NONE, padx=7, pady=7) self.out_text.insert(tk.END, k) self.out_text.grid(row=1, column=0, sticky=tk.NSEW) self.out_text.columnconfigure(0, weight=1) output_frame.grid(row=4, column=0, sticky=tk.NSEW) output_frame.columnconfigure(0, weight=1) # Add the binding if _platform == "darwin": self.out_text.bind("<Command-Key-a>", self.select_all) # self.out_text.bind("<Command-Key-A>", self.select_all) else: self.out_text.bind("<Control-Key-a>", self.select_all) progress_frame = ttk.Frame(overall_frame, padding='0.1i') self.progress_label = ttk.Label(progress_frame, text="Progress:", justify=tk.LEFT) self.progress_label.grid(row=0, column=0, sticky=tk.E, padx=5) self.progress_var = tk.DoubleVar() self.progress = ttk.Progressbar(progress_frame, orient="horizontal", variable=self.progress_var, length=200, maximum=100) self.progress.grid(row=0, column=1, sticky=tk.E) progress_frame.grid(row=5, column=0, sticky=tk.E) overall_frame.grid(row=0, column=1, sticky=tk.NSEW) overall_frame.columnconfigure(0, weight=1) toplevel_frame.columnconfigure(0, weight=1) toplevel_frame.columnconfigure(1, weight=4) # self.pack(fill=tk.BOTH, expand=1) # toplevel_frame.columnconfigure(0, weight=1) # toplevel_frame.rowconfigure(0, weight=1) toplevel_frame.grid(row=0, column=0, sticky=tk.NSEW) # Select the appropriate tool, if specified, otherwise the first tool self.tools_listbox.select_set(selected_item) self.tools_listbox.event_generate("<<ListboxSelect>>") self.tools_listbox.see(selected_item) menubar = tk.Menu(self) filemenu = tk.Menu(menubar, tearoff=0) filemenu.add_command(label="Set Working Directory", command=self.set_directory) filemenu.add_command(label="Locate WhiteboxTools exe", command=self.select_exe) filemenu.add_command(label="Refresh Tools", command=self.refresh_tools) filemenu.add_separator() filemenu.add_command(label="Exit", command=self.quit) menubar.add_cascade(label="File", menu=filemenu) editmenu = tk.Menu(menubar, tearoff=0) editmenu.add_command( label="Cut", command=lambda: self.focus_get().event_generate("<<Cut>>")) editmenu.add_command( label="Copy", command=lambda: self.focus_get().event_generate("<<Copy>>")) editmenu.add_command( label="Paste", command=lambda: self.focus_get().event_generate("<<Paste>>")) menubar.add_cascade(label="Edit ", menu=editmenu) helpmenu = tk.Menu(menubar, tearoff=0) helpmenu.add_command(label="About", command=self.help) helpmenu.add_command(label="License", command=self.license) menubar.add_cascade(label="Help ", menu=helpmenu) self.master.config(menu=menubar)
def create_widgets(self): tabControl = ttk.Notebook(self.win) # Create Tab Control tab1 = ttk.Frame(tabControl) # Create a tab tabControl.add(tab1, text='Tab 1') # Add the tab tab2 = ttk.Frame(tabControl) # Add a second tab tabControl.add(tab2, text='Tab 2') # Make second tab visible tabControl.pack(expand=1, fill="both") # Pack to make visible # LabelFrame using tab1 as the parent mighty = ttk.LabelFrame(tab1, text=' Mighty Python ') mighty.grid(column=0, row=0, padx=8, pady=4) # Modify adding a Label using mighty as the parent instead of win a_label = ttk.Label(mighty, text="Enter a name:") a_label.grid(column=0, row=0, sticky='W') # Adding a Textbox Entry widget self.name = tk.StringVar() self.name_entered = ttk.Entry(mighty, width=24, textvariable=self.name) self.name_entered.grid(column=0, row=1, sticky='W') # Adding a Button self.action = ttk.Button(mighty, text="Click Me!", command=self.click_me) self.action.grid(column=2, row=1) ttk.Label(mighty, text="Choose a number:").grid(column=1, row=0) number = tk.StringVar() self.number_chosen = ttk.Combobox(mighty, width=14, textvariable=number, state='readonly') self.number_chosen['values'] = (1, 2, 4, 42, 100) self.number_chosen.grid(column=1, row=1) self.number_chosen.current(0) # Adding a Spinbox widget self.spin = Spinbox(mighty, values=(1, 2, 4, 42, 100), width=5, bd=9, command=self._spin) # using range self.spin.grid(column=0, row=2, sticky='W') # align left # Using a scrolled Text control scrol_w = 40 scrol_h = 10 # increase sizes self.scrol = scrolledtext.ScrolledText(mighty, width=scrol_w, height=scrol_h, wrap=tk.WORD) self.scrol.grid(column=0, row=3, sticky='WE', columnspan=3) for child in mighty.winfo_children( ): # add spacing to align widgets within tabs child.grid_configure(padx=4, pady=2) #===================================================================================== # Tab Control 2 ---------------------------------------------------------------------- self.mighty2 = ttk.LabelFrame(tab2, text=' The Snake ') self.mighty2.grid(column=0, row=0, padx=8, pady=4) # Creating three checkbuttons chVarDis = tk.IntVar() check1 = tk.Checkbutton(self.mighty2, text="Disabled", variable=chVarDis, state='disabled') check1.select() check1.grid(column=0, row=0, sticky=tk.W) chVarUn = tk.IntVar() check2 = tk.Checkbutton(self.mighty2, text="UnChecked", variable=chVarUn) check2.deselect() check2.grid(column=1, row=0, sticky=tk.W) chVarEn = tk.IntVar() check3 = tk.Checkbutton(self.mighty2, text="Enabled", variable=chVarEn) check3.deselect() check3.grid(column=2, row=0, sticky=tk.W) # trace the state of the two checkbuttons chVarUn.trace('w', lambda unused0, unused1, unused2: self.checkCallback()) chVarEn.trace('w', lambda unused0, unused1, unused2: self.checkCallback()) # First, we change our Radiobutton global variables into a list colors = ["Blue", "Gold", "Red"] # create three Radiobuttons using one variable self.radVar = tk.IntVar() # Next we are selecting a non-existing index value for radVar self.radVar.set(99) # Now we are creating all three Radiobutton widgets within one loop for col in range(3): curRad = tk.Radiobutton(self.mighty2, text=colors[col], variable=self.radVar, value=col, command=self.radCall) curRad.grid(column=col, row=1, sticky=tk.W) # row=6 # And now adding tooltips ToolTip(curRad, 'This is a Radiobutton control') # Add a Progressbar to Tab 2 self.progress_bar = ttk.Progressbar(tab2, orient='horizontal', length=286, mode='determinate') self.progress_bar.grid(column=0, row=3, pady=2) # Create a container to hold buttons buttons_frame = ttk.LabelFrame(self.mighty2, text=' ProgressBar ') buttons_frame.grid(column=0, row=2, sticky='W', columnspan=2) # Add Buttons for Progressbar commands ttk.Button(buttons_frame, text=" Run Progressbar ", command=self.run_progressbar).grid(column=0, row=0, sticky='W') ttk.Button(buttons_frame, text=" Start Progressbar ", command=self.start_progressbar).grid(column=0, row=1, sticky='W') ttk.Button(buttons_frame, text=" Stop immediately ", command=self.stop_progressbar).grid(column=0, row=2, sticky='W') ttk.Button(buttons_frame, text=" Stop after second ", command=self.progressbar_stop_after).grid(column=0, row=3, sticky='W') for child in buttons_frame.winfo_children(): child.grid_configure(padx=2, pady=2) for child in self.mighty2.winfo_children(): child.grid_configure(padx=8, pady=2) # Creating a Menu Bar menu_bar = Menu(self.win) self.win.config(menu=menu_bar) # Add menu items file_menu = Menu(menu_bar, tearoff=0) file_menu.add_command(label="New") file_menu.add_separator() file_menu.add_command(label="Exit", command=self._quit) menu_bar.add_cascade(label="File", menu=file_menu) # Display a Message Box def _msgBox(): msg.showinfo( 'Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2019.') # Add another Menu to the Menu Bar and an item help_menu = Menu(menu_bar, tearoff=0) help_menu.add_command( label="About", command=_msgBox) # display messagebox when clicked menu_bar.add_cascade(label="Help", menu=help_menu) # Change the main windows icon self.win.iconbitmap('pyc.ico') # It is not necessary to create a tk.StringVar() # strData = tk.StringVar() strData = self.spin.get() # call function self.usingGlobal() self.name_entered.focus() # Add Tooltips ----------------------------------------------------- # Add a Tooltip to the Spinbox ToolTip(self.spin, 'This is a Spinbox control') # Add Tooltips to more widgets ToolTip(self.name_entered, 'This is an Entry control') ToolTip(self.action, 'This is a Button control') ToolTip(self.scrol, 'This is a ScrolledText control')
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) global label_cropped_folder global label_selected_folder global entry_nth_number global progress_select global label_progress_select font_page_title = ('Helvetica', 16, 'bold') font_label = ("Verdana", 10) croppedPath = "" selectedPath = "" label = tk.Label(self, text="Select Page", font=font_page_title) label_cropped_folder = Label(self, text="Cropped Image Directory ", width=55, height=4, font=font_label, wraplength=500, justify='left', anchor=W, fg='grey') button_cropped_explorer = ttk.Button( self, text="Browse", command=lambda: self.browseFiles(label_cropped_folder)) label_selected_folder = Label(self, text="Selected Image Directory ", width=55, height=4, font=font_label, wraplength=500, justify='left', anchor=W, fg='grey') button_selected_explorer = ttk.Button( self, text="Browse", command=lambda: self.browseFiles(label_selected_folder)) label_nth_number = Label(self, text="Nth number: ", font=font_label) entry_nth_number = ttk.Entry(self, width=5) label_progress_select = Label(self, text="Standby", fg='orange') progress_select = ttk.Progressbar(self, orient='horizontal', length=100, mode='determinate') button_select_execute = ttk.Button(self, text='Select', command=self.selectFunction) label.grid(column=0, row=0) label_cropped_folder.grid(sticky=W, column=1, row=1, columnspan=10) button_cropped_explorer.grid(column=12, row=1) label_selected_folder.grid(sticky=W, column=1, row=2, columnspan=10) button_selected_explorer.grid(column=12, row=2) label_nth_number.grid(column=1, row=3, sticky=W) entry_nth_number.grid(column=2, row=3) label_progress_select.grid(column=1, row=4) progress_select.grid(column=1, row=5) button_select_execute.grid(column=10, row=6)
root.title("kkyu GUI") root.geometry("640x480") # progressbar = ttk.Progressbar(root, maximum=100, mode="indeterminate") # progressbar = ttk.Progressbar(root, maximum=100, mode="determinate") # progressbar.start(10) # Move by 10 ms # progressbar.pack() # def btncmd(): # progressbar.stop() # btn = Button(root, text="Stop!", command=btncmd) # btn.pack() p_var2 = DoubleVar() progressbar2 = ttk.Progressbar(root, maximum=100, length=200, variable=p_var2) progressbar2.pack() def btncmd2(): for i in range(1, 101): # 1 ~ 100 time.sleep(0.01) # wait 0.01 second p_var2.set(i) # set value of progress bar progressbar2.update() # UI update print(p_var2.get()) btn = Button(root, text="Start!", command=btncmd2) btn.pack()
def __init__(self, top=None): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#ececec' # Closest X11 color: 'gray92' font11 = "-family {Avenir Next Cyr Medium} -size 23 -weight " \ "normal -slant roman -underline 0 -overstrike 0" font12 = "-family {Avenir Next Cyr} -size 9 -weight bold " \ "-slant roman -underline 0 -overstrike 0" font13 = "-family {Vivaldi} -size 22 -weight " \ "bold -slant roman -underline 0 -overstrike 0" self.style = ttk.Style() if sys.platform == "win32": self.style.theme_use('winnative') self.style.configure('.',background=_bgcolor) self.style.configure('.',foreground=_fgcolor) self.style.configure('.',font="TkDefaultFont") self.style.map('.',background= [('selected', _compcolor), ('active',_ana2color)]) top.geometry("687x526+558+155") top.title("New Toplevel") top.configure(background="#fff") self.top=top self.songName = tk.Label(top) self.songName.place(relx=0.437, rely=0.038, height=44, width=281) self.songName.configure(background="#fff") self.songName.configure(disabledforeground="#a3a3a3") self.songName.configure(font=font13) self.songName.configure(foreground="#000000") self.songName.configure(text='''MY MUSIC''') self.songProgress = ttk.Progressbar(top) self.songProgress.place(relx=0.393, rely=0.209, relwidth=0.495 , relheight=0.0, height=7) self.songTotalDuration = ttk.Label(top) self.songTotalDuration.place(relx=0.844, rely=0.171, height=19, width=29) self.songTotalDuration.configure(background="#fff") self.songTotalDuration.configure(foreground="#3399ff") self.songTotalDuration.configure(font=font12) self.songTotalDuration.configure(relief='flat') self.songTimePassed = ttk.Label(top) self.songTimePassed.place(relx=0.393, rely=0.171, height=19, width=29) self.songTimePassed.configure(background="#ffffff") self.songTimePassed.configure(foreground="#000000") self.songTimePassed.configure(font=font12) self.songTimePassed.configure(relief='flat') self.pauseButton = tk.Button(top) self.pauseButton.place(relx=0.568, rely=0.266, height=34, width=34) self.pauseButton.configure(activebackground="#ececec") self.pauseButton.configure(activeforeground="#000000") self.pauseButton.configure(background="#fff") self.pauseButton.configure(borderwidth="0") self.pauseButton.configure(disabledforeground="#a3a3a3") self.pauseButton.configure(foreground="#000000") self.pauseButton.configure(highlightbackground="#d9d9d9") self.pauseButton.configure(highlightcolor="black") self._img1 = tk.PhotoImage(file="./icons/pause.png") self.pauseButton.configure(image=self._img1) self.pauseButton.configure(pady="0") self.pauseButton.configure(text='''Button''') self.playButton = tk.Button(top) self.playButton.place(relx=0.64, rely=0.266, height=34, width=34) self.playButton.configure(activebackground="#ececec") self.playButton.configure(activeforeground="#000000") self.playButton.configure(background="#fff") self.playButton.configure(borderwidth="0") self.playButton.configure(disabledforeground="#a3a3a3") self.playButton.configure(foreground="#000000") self.playButton.configure(highlightbackground="#d9d9d9") self.playButton.configure(highlightcolor="black") self._img2 = tk.PhotoImage(file="./icons/play.png") self.playButton.configure(image=self._img2) self.playButton.configure(pady="0") self.playButton.configure(text='''Button''') self.stopButton = tk.Button(top) self.stopButton.place(relx=0.713, rely=0.266, height=34, width=34) self.stopButton.configure(activebackground="#ececec") self.stopButton.configure(activeforeground="#000000") self.stopButton.configure(background="#fff") self.stopButton.configure(borderwidth="0") self.stopButton.configure(disabledforeground="#a3a3a3") self.stopButton.configure(foreground="#000000") self.stopButton.configure(highlightbackground="#d9d9d9") self.stopButton.configure(highlightcolor="black") self._img3 = tk.PhotoImage(file="./icons/stop.png") self.stopButton.configure(image=self._img3) self.stopButton.configure(pady="0") self.stopButton.configure(text='''Button''') self.vinylRecordImage = tk.Label(top) self.vinylRecordImage.place(relx=0.0, rely=0.0, height=204, width=204) self.vinylRecordImage.configure(background="#d9d9d9") self.vinylRecordImage.configure(disabledforeground="#a3a3a3") self.vinylRecordImage.configure(foreground="#000000") self._img4 = tk.PhotoImage(file="./icons/vinylrecord.png") self.vinylRecordImage.configure(image=self._img4) self.vinylRecordImage.configure(text='''Label''') self.playList = ScrolledListBox(top) self.playList.place(relx=0.0, rely=0.38, relheight=0.532, relwidth=0.999) self.playList.configure(background="white") self.playList.configure(disabledforeground="#a3a3a3") self.playList.configure(font="TkFixedFont") self.playList.configure(foreground="black") self.playList.configure(highlightbackground="#d9d9d9") self.playList.configure(highlightcolor="#d9d9d9") self.playList.configure(selectbackground="#c4c4c4") self.playList.configure(selectforeground="black") self.playList.configure(width=10) self.previousButton = tk.Label(top) self.previousButton.place(relx=0.509, rely=0.285, height=16, width=16) self.previousButton.configure(background="#fff") self.previousButton.configure(borderwidth="0") self.previousButton.configure(disabledforeground="#a3a3a3") self.previousButton.configure(foreground="#000000") self._img5 = tk.PhotoImage(file="./icons/previous.png") self.previousButton.configure(image=self._img5) self.previousButton.configure(text='''Label''') self.bottomBar = ttk.Label(top) self.bottomBar.place(relx=0.0, rely=0.913, height=49, width=686) self.bottomBar.configure(background="#d9d9d9") self.bottomBar.configure(foreground="#000000") self.bottomBar.configure(font="TkDefaultFont") self.bottomBar.configure(relief='flat') self.bottomBar.configure(width=686) self.bottomBar.configure(state='disabled') self.vol_scale = ttk.Scale(top) self.vol_scale.place(relx=0.015, rely=0.932, relwidth=0.146, relheight=0.0 , height=26, bordermode='ignore') self.vol_scale.configure(takefocus="") self.addSongsToPlayListButton = tk.Button(top) self.addSongsToPlayListButton.place(relx=0.961, rely=0.323, height=17 , width=17) self.addSongsToPlayListButton.configure(activebackground="#ececec") self.addSongsToPlayListButton.configure(activeforeground="#d9d9d9") self.addSongsToPlayListButton.configure(background="#fff") self.addSongsToPlayListButton.configure(borderwidth="0") self.addSongsToPlayListButton.configure(disabledforeground="#a3a3a3") self.addSongsToPlayListButton.configure(foreground="#000000") self.addSongsToPlayListButton.configure(highlightbackground="#d9d9d9") self.addSongsToPlayListButton.configure(highlightcolor="black") self._img6 = tk.PhotoImage(file="./icons/add.png") self.addSongsToPlayListButton.configure(image=self._img6) self.addSongsToPlayListButton.configure(pady="0") self.addSongsToPlayListButton.configure(text='''Button''') self.deleteSongsFromPlaylistButton = tk.Button(top) self.deleteSongsFromPlaylistButton.place(relx=0.917, rely=0.323 , height=18, width=18) self.deleteSongsFromPlaylistButton.configure(activebackground="#ececec") self.deleteSongsFromPlaylistButton.configure(activeforeground="#000000") self.deleteSongsFromPlaylistButton.configure(background="#fff") self.deleteSongsFromPlaylistButton.configure(borderwidth="0") self.deleteSongsFromPlaylistButton.configure(disabledforeground="#a3a3a3") self.deleteSongsFromPlaylistButton.configure(foreground="#000000") self.deleteSongsFromPlaylistButton.configure(highlightbackground="#d9d9d9") self.deleteSongsFromPlaylistButton.configure(highlightcolor="black") self._img7 = tk.PhotoImage(file="./icons/delete.png") self.deleteSongsFromPlaylistButton.configure(image=self._img7) self.deleteSongsFromPlaylistButton.configure(pady="0") self.deleteSongsFromPlaylistButton.configure(text='''Button''') self.Button9 = tk.Button(top) self.Button9.place(relx=0.932, rely=0.913, height=42, width=42) self.Button9.configure(activebackground="#ececec") self.Button9.configure(activeforeground="#000000") self.Button9.configure(background="#d9d9d9") self.Button9.configure(borderwidth="0") self.Button9.configure(disabledforeground="#a3a3a3") self.Button9.configure(foreground="#000000") self.Button9.configure(highlightbackground="#d9d9d9") self.Button9.configure(highlightcolor="black") self._img8 = tk.PhotoImage(file="./icons/like.png") self.Button9.configure(image=self._img8) self.Button9.configure(pady="0") self.Button9.configure(text='''Button''') self.Button9.configure(width=42) self.Button10 = tk.Button(top) self.Button10.place(relx=0.873, rely=0.913, height=42, width=42) self.Button10.configure(activebackground="#ececec") self.Button10.configure(activeforeground="#000000") self.Button10.configure(background="#d9d9d9") self.Button10.configure(borderwidth="0") self.Button10.configure(disabledforeground="#a3a3a3") self.Button10.configure(foreground="#000000") self.Button10.configure(highlightbackground="#d9d9d9") self.Button10.configure(highlightcolor="black") self._img9 = tk.PhotoImage(file="./icons/broken-heart.png") self.Button10.configure(image=self._img9) self.Button10.configure(pady="0") self.Button10.configure(text='''Button''') self.Button10.configure(width=48) self.Button11 = tk.Button(top) self.Button11.place(relx=0.83, rely=0.932, height=26, width=26) self.Button11.configure(activebackground="#ececec") self.Button11.configure(activeforeground="#000000") self.Button11.configure(background="#d9d9d9") self.Button11.configure(borderwidth="0") self.Button11.configure(disabledforeground="#a3a3a3") self.Button11.configure(foreground="#000000") self.Button11.configure(highlightbackground="#d9d9d9") self.Button11.configure(highlightcolor="black") self._img10 = tk.PhotoImage(file="./icons/refresh.png") self.Button11.configure(image=self._img10) self.Button11.configure(pady="0") self.Button11.configure(text='''Button''') self.setup_player()
# 3. 파일 포맷 옵션 # 파일 포맷 옵션 레이블 lbl_format = Label(frame_option, text="간격", width=8) lbl_format.pack(side="left", padx=5, pady=5) # 파일 포맷 옵션 콤보 opt_format=["PNG", "JPG", "BMP"] cmb_format = ttk.Combobox(frame_option, state="readonly", values=opt_format, width=10) cmb_format.current(0) cmb_format.pack(side="left", padx=5, pady=5) # 진행 상황 Progress Bar frame_progress = LabelFrame(root, text="진행상황") frame_progress.pack(fill="x", padx=5, pady=5, ipady=5) p_var = DoubleVar() progress_bar = ttk.Progressbar(frame_progress, maximum=100, variable=p_var) progress_bar.pack(fill="x", padx=5, pady=5) # 실행 프레임 frame_run = Frame(root) frame_run.pack(fill="x", padx=5, pady=5) btn_close = Button(frame_run, padx=5, pady=5, text="닫기", width=12, command=root.quit) btn_close.pack(side="right", padx=5, pady=5) btn_start = Button(frame_run, padx=5, pady=5, text="시작", width=12, command=start) btn_start.pack(side="right", padx=5, pady=5) root.resizable(False, False) root.mainloop()
def __init__(self, master): self.master = master # executes self.on_closing on program exit master.protocol('WM_DELETE_WINDOW', self.on_closing) master.resizable(False, False) master.minsize(width=400, height=380) master.title('The RSE-Simulator') self.rolling_shutter = None self.files = [] self.file_output = '' self.tk_speed_val = tk.IntVar() self.tk_speed_val.set(1) self.tk_progress_val = tk.DoubleVar() self.tk_progress_val.set(0.0) # <- FRAME SECTION -> self.frame_main = tk.Frame(master) self.frame_main.pack(fill='both', expand=True) self.frame_footer = tk.Frame(master) self.frame_footer.pack(fill='both', anchor='s') # <- WIDGET SECTION -> self.label_title = ttk.Label(self.frame_main, text='Rolling-Shutter-Simulator', font=('Tahoma', 18)) self.label_title.pack(pady=(8, 20)) self.btn_input = ttk.Button(self.frame_main, text='Select Input', command=self.select_input, takefocus=0) self.btn_input.pack(fill='both', padx=40, expand=True, pady=10) self.btn_output = ttk.Button(self.frame_main, text='Select Output File', command=self.select_output, state='disabled', takefocus=0) self.btn_output.pack(fill='both', padx=40, expand=True) self.speed_scale = ttk.Scale(self.frame_main, variable=self.tk_speed_val, command=self.update_speed, from_=1, to=MAX_SPEED, length=310, takefocus=0) self.speed_scale.pack(pady=(8, 0)) self.speed_scale.state(['disabled']) self.label_speed = ttk.Label(self.frame_main, text='Shutter Speed: 1', font=('Tahoma', 13)) self.label_speed.pack(pady=(0, 8)) self.progress_bar = ttk.Progressbar(self.frame_main, orient='horizontal', mode='determinate', variable=self.tk_progress_val) self.progress_bar.pack(fill='x', padx=20, pady=(30, 0)) self.progress_bar.state(['disabled']) self.btn_start = ttk.Button(self.frame_main, text='Give it a go!', command=self.start, state='disabled', takefocus=0) self.btn_start.pack(fill='both', padx=140, pady=(8, 0), expand=True) self.label_version = tk.Label(self.frame_footer, text='Version '+__version__, font=('Tahoma', 10), fg='grey60') self.label_version.pack(anchor='e', padx=(0, 5))