def export_all_stress_graphs(stress_calcul, analyze_1D, run_program): location = askdirectory(title="Please choose a directory") if location is not None and location is not '': for widget in analyze_1D.Frame1_2.winfo_children(): widget.destroy() Label(analyze_1D.Frame1_2, text="Export").pack(side=LEFT) progress = Progressbar(analyze_1D.Frame1_2, orient="horizontal", mode='determinate') progress.pack(side=LEFT) progress["value"] = 0 progress["maximum"] = len(stress_calcul.liste_phi) for i in range(len(stress_calcul.liste_phi)): progress["value"] = progress["value"] + 1 progress.update() fig = plt.figure(figsize=(10, 10), dpi=100) ax = fig.add_subplot(111) plt.plot(stress_calcul.matrix_sin_psi_i_2[i], stress_calcul.matrix_displacement[i], 'ro', label='Experimental') for j in range(len(stress_calcul.matrix_psi_i[i])): plt.annotate(str("%0.1f" % stress_calcul.matrix_psi_i[i][j]), xy=(stress_calcul.matrix_sin_psi_i_2[i][j], stress_calcul.matrix_displacement[i][j])) if stress_calcul.stress_valid >= 1: plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[i], stress_calcul.matrix_F_linear[i], 'b', label='Linear fit') plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[i], stress_calcul.matrix_F_elliptic[i], 'k', label='Eliptic fit') if stress_calcul.stress_valid == 1: plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[0], stress_calcul.e_uniaxial, 'm', label='Uniaxial') plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[0], stress_calcul.e_uniaxial_shear, 'y', label='Uniaxial+shear') if stress_calcul.sigma12_valid == False and stress_calcul.stress_valid >= 2: plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[i], stress_calcul.e_biaxial_simple[i], 'm', label='Biaxial') plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[i], stress_calcul.e_biaxial_simple_shear[i], 'y', label='Biaxial+shear') if stress_calcul.sigma12_valid == True: plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[i], stress_calcul.e_biaxial[i], 'm', label='Biaxial') plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[i], stress_calcul.e_biaxial_shear[i], 'y', label='Biaxial+shear') if stress_calcul.stress_valid >= 3: plt.plot(stress_calcul.matrix_sin_psi_i_2_sorted[i], stress_calcul.e_triaxial[i], 'r', label='Triaxial') plt.xlabel(r"$sin^{2}\psi$") plt.ylabel('Strain') plt.title("phi=" + str(stress_calcul.liste_phi[i]) + "") plt.legend(loc='upper left', bbox_to_anchor=(0.0, -0.3, 1, 0), ncol=3, mode="expand", borderaxespad=0., fontsize='x-small') plt.subplots_adjust(bottom=0.4) plt.savefig(str(location) + "/stress_phi=" + str(float(stress_calcul.liste_phi[i])) + ".png", bbox_inches="tight") plt.close() for widget in analyze_1D.Frame1_2.winfo_children(): widget.destroy() run_program.fenetre.mainloop()
frmPlaylist = tk.Frame(master=window) playlistLabel = tk.Label(master=frmPlaylist, text="Playlist Link", justify="center", anchor="center") playlist = tk.Entry(master=frmPlaylist) submitButton = tk.Button( master=frmPlaylist, text="Download", command=dl, ) playlist.grid(row=1, column=1, sticky="") playlistLabel.grid(row=0, column=1, sticky="", padx=(5, 5)) submitButton.grid(row=1, column=2, sticky="", padx=(5, 5)) #status hooks frmHooks = tk.Frame(master=window) statusLabel = tk.Label(master=frmHooks, text="Press 'Download' to begin...") bar = Progressbar(frmHooks, length=100, mode='determinate') statusLabel.grid(row=0, column=1, sticky="") bar.grid(row=1, column=1, sticky="") #grid setup frmPath.grid(row=0, column=1) frmPlaylist.grid(row=1, column=1) frmHooks.grid(row=2, column=1) window.grid_rowconfigure(0, weight=1) window.grid_rowconfigure(3, weight=1) window.grid_columnconfigure(0, weight=1) window.grid_columnconfigure(3, weight=1) window.mainloop()
def _init_ui(self): ws = self.master.winfo_screenwidth() hs = self.master.winfo_screenheight() h = hs - 100 w = int(h / 1.414) + 100 x = (ws / 2) - (w / 2) y = (hs / 2) - (h / 2) self.master.geometry('%dx%d+%d+%d' % (w, h, x, y)) self.master.maxsize(w, h) self.master.minsize(w, h) self.master.title("InvoiceNet - Trainer") self.pack(fill=BOTH, expand=True) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=0) self.rowconfigure(1, weight=1) self.rowconfigure(2, weight=0) self.rowconfigure(3, weight=1) self.configure(bg=self.background, bd=0) logo_frame = Frame(self, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=1) param_frame = Frame(self, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=1) progress_frame = Frame(self, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=0) main_frame = Frame(self, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=1) logo_frame.grid(row=0, column=0, sticky='news') param_frame.grid(row=1, column=0, sticky='news') progress_frame.grid(row=2, column=0, sticky='news', padx=50, pady=(0, 20)) main_frame.grid(row=3, column=0, sticky='news') # Logo Frame logo_frame.columnconfigure(0, weight=1) logo_frame.columnconfigure(1, weight=0) logo_frame.columnconfigure(2, weight=0) logo_frame.columnconfigure(3, weight=1) logo_frame.rowconfigure(0, weight=1) self.logo_img = ImageTk.PhotoImage(Image.open(r'widgets/logo.png')) Label(logo_frame, bg=self.background, image=self.logo_img).grid(row=0, column=1, sticky='news', pady=10) Label(logo_frame, text="InvoiceNet", bg=self.background, fg="white", font=("Arial", 24, "bold")).grid(row=0, column=2, sticky='news', padx=20, pady=10) # Param Frame param_frame.columnconfigure(0, weight=1) param_frame.columnconfigure(1, weight=0) param_frame.columnconfigure(2, weight=0) param_frame.columnconfigure(3, weight=1) param_frame.rowconfigure(0, weight=1) param_frame.rowconfigure(1, weight=0) param_frame.rowconfigure(2, weight=0) param_frame.rowconfigure(3, weight=0) param_frame.rowconfigure(4, weight=1) data_param = Frame(param_frame, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=0) out_param = Frame(param_frame, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=0) field_param = Frame(param_frame, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=0) batch_param = Frame(param_frame, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=0) data_param.grid(row=1, column=1, pady=(0, 20), padx=20) out_param.grid(row=2, column=1, pady=20, padx=20) field_param.grid(row=1, column=2, pady=(0, 20), padx=20) batch_param.grid(row=2, column=2, pady=20, padx=20) df = Frame(data_param, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=0) df.pack(side=TOP, fill=BOTH) Label(df, text="Data Folder:", bg=self.background, fg="white", font=("Arial", 8, "bold"), anchor='w').pack(side=LEFT, fill=BOTH) HoverButton(df, image_path=r'widgets/open_dir_small.png', command=lambda: self._open_dir("data_dir"), width=18, height=18, bg=self.background, bd=0, highlightthickness=0, activebackground='#558de8').pack(side=RIGHT) self.textboxes["data_dir"] = Text(data_param, height=1, width=20) self.textboxes["data_dir"].insert('1.0', self.args["data_dir"]) self.textboxes["data_dir"].pack(side=BOTTOM) of = Frame(out_param, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=0) of.pack(side=TOP, fill=BOTH) Label(of, text="Processed Data Folder:", bg=self.background, anchor='w', fg="white", font=("Arial", 8, "bold")).pack(side=LEFT, fill=BOTH) HoverButton(of, image_path=r'widgets/open_dir_small.png', command=lambda: self._open_dir("prepared_data"), width=18, height=18, bg=self.background, bd=0, highlightthickness=0, activebackground='#558de8').pack(side=RIGHT) self.textboxes["prepared_data"] = Text(out_param, height=1, width=20) self.textboxes["prepared_data"].insert('1.0', self.args["prepared_data"]) self.textboxes["prepared_data"].pack(side=BOTTOM) Label(field_param, text="Field:", bg=self.background, anchor='w', fg="white", font=("Arial", 8, "bold")).pack(side=TOP, fill=BOTH) self.field_text = StringVar(field_param) self.field_text.set(list(FIELDS.keys())[0]) keys = list(FIELDS.keys()) field_list = OptionMenu(field_param, self.field_text, *keys) field_list.configure(highlightthickness=0, width=20, bg='#ffffff') field_list.pack(side=BOTTOM) for key in keys: field_list['menu'].entryconfigure(key, state="normal") Label(batch_param, text="Batch Size:", bg=self.background, anchor='w', fg="white", font=("Arial", 8, "bold")).pack(side=TOP, fill=BOTH) self.batch_text = StringVar(batch_param) self.batch_text.set("4") batch_list = OptionMenu(batch_param, self.batch_text, *[str(2**i) for i in range(8)]) batch_list.configure(highlightthickness=0, width=20, bg='#ffffff') batch_list.pack(side=BOTTOM) HoverButton(param_frame, image_path=r'widgets/prepare.png', command=self._prepare_data, text='Prepare Data', compound='center', font=("Arial", 10, "bold"), bg=self.background, bd=0, highlightthickness=0, activebackground=self.background).grid(row=3, column=1, columnspan=2, padx=20, pady=(20, 0), sticky='news') # Progress Frame self.progress_label = Label(progress_frame, text="Preparing data:", bg=self.background, anchor='w', fg="white", font=("Arial", 8, "bold"), bd=0, highlightthickness=0) self.progress_label.pack(side=TOP, expand=True, fill=X, pady=(10, 5)) self.progressbar = Progressbar(progress_frame, orient=HORIZONTAL, length=100, mode='determinate') self.progressbar.pack(side=BOTTOM, expand=True, fill=X) # Main Frame main_frame.columnconfigure(0, weight=1) main_frame.rowconfigure(0, weight=1) main_frame.rowconfigure(1, weight=1) button_frame = Frame(main_frame, bg=self.background, bd=0, relief=SUNKEN, highlightbackground=self.border_color, highlightthickness=0) button_frame.grid(row=0, column=0, sticky='news') button_frame.rowconfigure(0, weight=1) button_frame.columnconfigure(0, weight=1) button_frame.columnconfigure(1, weight=0) button_frame.columnconfigure(2, weight=1) self.start_button = HoverButton(button_frame, image_path=r'widgets/begin.png', command=self._start, text='Start', compound='center', font=("Arial", 10, "bold"), bg=self.background, bd=0, highlightthickness=0, activebackground=self.background) self.stop_button = HoverButton(button_frame, image_path=r'widgets/stop.png', command=self._stop, text='Stop', compound='center', font=("Arial", 10, "bold"), bg=self.background, bd=0, highlightthickness=0, activebackground=self.background) self.start_button.grid(row=0, column=1) self.stop_button.grid(row=0, column=1) self.stop_button.grid_forget() self.logger = Logger(main_frame, height=18, bg=self.background, bd=0, relief=SUNKEN) self.logger.grid(row=1, column=0, sticky='news')
def __init__(self, window, running, data, count, progress_value): # variables self.running = running self.data = data self.count = count self.progress_value = progress_value # master/parent window contains all gui elements self.window = window window.title("TNRIS DataHub Bulk Download Utility") # frame variables - parent is window self.top_frame = tk.Frame(window, borderwidth=10) self.middle_frame_1 = tk.Frame(window, borderwidth=10) self.middle_frame_2 = tk.Frame(window, borderwidth=10) self.middle_left_frame_2 = tk.Frame(self.middle_frame_2, borderwidth=10) self.middle_left_frame_2.pack(side='left', expand=1) self.middle_right_frame_2 = tk.Frame(self.middle_frame_2, borderwidth=10) self.middle_right_frame_2.pack(side='right', expand=1) self.middle_frame_3 = tk.Frame(window, borderwidth=10, padx=10) self.middle_frame_4 = tk.Frame(window, borderwidth=10) self.bottom_frame = tk.Frame(window, borderwidth=10, pady=10) self.frame_list = [ self.top_frame, self.middle_frame_1, self.middle_frame_2, self.middle_frame_3, self.middle_frame_4, self.bottom_frame ] # for loop to pack all frames for f in self.frame_list: f.pack(fill='both') # label variables self.label_1 = tk.Label(self.top_frame, text="Enter a TNRIS DataHub Collection ID: ") self.label_2 = tk.Label(self.middle_frame_1, text="If the collection entered has multiple resource types, filter them here.") self.label_3 = tk.Label(self.middle_frame_1, text="No filter selection will result in all collection resources downloaded.") self.label_list = [self.label_1, self.label_2, self.label_3] # for loop to configure all labels with font for l in self.label_list: l.configure(font=('Courier', 10, 'bold')) l.pack(fill='both') # collection id entry self.collection_id = tk.Entry(self.top_frame, width=45, font=('Courier', 10)) self.collection_id.pack() self.collection_id.focus() self.label_4 = tk.Label(self.top_frame, text="Browse to a directory where you can save your downloaded data.") self.label_5 = tk.Label(self.middle_left_frame_2, text="Lidar") self.label_6 = tk.Label(self.middle_right_frame_2, text="Imagery") self.lbl_list = [self.label_4, self.label_5, self.label_6] for lbl in self.lbl_list: lbl.config(font=('Courier', 10, 'bold'), pady=10) lbl.pack(fill='both') # resource types check box variables - onvalue string is used in the api query (resource_type_abbreviation) self.type_value = tk.StringVar() self.type_value.set("") self.type_1 = tk.Checkbutton(self.middle_left_frame_2, text="Lidar Point Cloud", var=self.type_value, onvalue="LPC", offvalue="") self.type_2 = tk.Checkbutton(self.middle_left_frame_2, text="Hypsography", var=self.type_value, onvalue="HYPSO", offvalue="") self.type_3 = tk.Checkbutton(self.middle_left_frame_2, text="Digital Elevation Model", var=self.type_value, onvalue="DEM", offvalue="") self.type_placeholder = tk.Label(self.middle_left_frame_2, text="") # this empty label is used for alignment self.type_4 = tk.Checkbutton(self.middle_right_frame_2, text="Color Infrared (3 Band)", var=self.type_value, onvalue="CIR", offvalue="") self.type_5 = tk.Checkbutton(self.middle_right_frame_2, text="Natural Color (3 Band)", var=self.type_value, onvalue="NC", offvalue="") self.type_6 = tk.Checkbutton(self.middle_right_frame_2, text="Natural Color/Color Infrared (4 Band)", var=self.type_value, onvalue="NC-CIR", offvalue="") self.type_7 = tk.Checkbutton(self.middle_right_frame_2, text="Black & White (1 Band)", var=self.type_value, onvalue="BW", offvalue="") self.type_list = [self.type_1, self.type_2, self.type_3, self.type_placeholder, self.type_4, self.type_5, self.type_6, self.type_7] # for loop to pack & configure checkbuttons for t in self.type_list: t.config(font=('Courier', 10)) t.pack(fill="both") # Progress bar widget self.progress = Progressbar(self.middle_frame_3, orient='horizontal') self.progress.pack(fill='both') # Progress bar config self.progress.config(mode='determinate', value=0, maximum=100) # print messages from the downloader method self.display_message_1 = tk.StringVar() self.display_message_2 = tk.StringVar() self.error_message = tk.StringVar() self.display_message_1.set("Messages here provide download progress feedback.") self.message_area_1 = tk.Label(self.middle_frame_4, textvariable=self.display_message_1, font=('Courier', 10)) self.message_area_2 = tk.Label(self.middle_frame_4, textvariable=self.display_message_2, font=('Courier', 10), fg='green') self.message_area_3 = tk.Label(self.middle_frame_4, textvariable=self.error_message, font=('Courier', 10), fg='red') self.message_area_list = [self.message_area_1, self.message_area_2, self.message_area_3] # for loop to pack message areas for a in self.message_area_list: a.pack(fill='both') self.folder_path = tk.StringVar() self.label_4 = tk.Label(self.top_frame, textvariable=self.folder_path) self.label_4.configure(font=('Courier', 10), pady=10) self.label_4.pack(fill='both') # pack buttons that run methods self.browse = tk.Button(self.top_frame, text="Browse", command=self.browse_button) self.browse.pack() self.getdata = tk.Button(self.bottom_frame, text="Get Data", command=self.start) self.getdata.pack(side='right', expand=1) self.stop_it = tk.Button(self.bottom_frame, text="Stop", command=self.stop) self.stop_it.pack(side='left', expand=1)
#_________________________________________________ROW 3: threshold_label = Label(window, text="Limit the job to :", font=("Arial Bold", 12)) threshold_label.grid(column=0, row=3,padx = (10,5), pady = 10) def hint(event): messagebox.showinfo("Hint", "Enter an integer number to limit the job or leave it blank to process all the files") threshold_txtbox = Entry(window,width=50) threshold_txtbox.grid(column=1, row=3, padx = 5, pady = 10) threshold_txtbox.bind("<1>", hint) threshold_label2 = Label(window, text="files", font=("Arial Bold", 12)) threshold_label2.grid(column=2, columnspan = 3, row=3,padx = (5,10), pady = 10) #_________________________________________________ROW 4: bar = Progressbar(window, length=480) bar.grid(column=0, columnspan = 3, row=4, sticky = W+E, pady= 10, padx = 10) #_________________________________________________ROW 5: keepOriginalFile_state = BooleanVar() keepOriginalFile_state.set(True) #set check state keepFiles_checkbox = Checkbutton(window, text='Keep original files', var=keepOriginalFile_state, font=("Arial Bold", 10)) keepFiles_checkbox.grid(column=0, row=5, padx=(10,0)) def mainProcess_GUImode(sourcePath, destinyPath, threshold = -1, keepOriginalFile = True): totalAmoutnFiles = len(os.listdir(sourcePath)) if threshold == -1: threshold = totalAmoutnFiles count = 0 #print(threshold)
#statistics statLabel = Label(window, text="Statistics", font=("Arial Bold", 15)) statLabel.grid(column=0, row=0) popLabel = Label(window, text="Population: " + str(int(population)), font=("Arial", 10)) popLabel.grid(column=0, row=1) yearLabel = Label(window, text="Year: " + str(year), font=("Arial", 10)) yearLabel.grid(column=0, row=2) #population bar style = ttk.Style() style.theme_use('default') if population > 9000000000: style.configure("red4.Horizontal.TProgressbar", background='red4') bar = Progressbar(window, length=800, style='red4.Horizontal.TProgressbar') elif population > 8000000000: style.configure("red2.Horizontal.TProgressbar", background='red2') bar = Progressbar(window, length=800, style='red2.Horizontal.TProgressbar') elif population > 6000000000: style.configure("DarkOrange1.Horizontal.TProgressbar", background='DarkOrange1') bar = Progressbar(window, length=800, style='DarkOrange1.Horizontal.TProgressbar') elif population > 4000000000: style.configure("forest green.Horizontal.TProgressbar", background='forest green') bar = Progressbar(window, length=800, style='forest green.Horizontal.TProgressbar')
canvas.config(width=w, height=h) img = ImageTk.PhotoImage(im) canvas.create_image(w/2,h/2, anchor=CENTER, image=img) progress['value'] = 100 root.update_idletasks() location = Text(root, height = 1, width = 20,bg="black",fg=theme[0],highlightbackground=theme[1]) mapRange = Text(root, height = 1, width = 20,bg="black",fg=theme[0],highlightbackground=theme[1]) canvas = Canvas(root, bg="black", width = w, height = h,highlightbackground=theme[1]) label = Label(root, text = "> RANGE [METERS]",font=("Monospace", 14),bg="black", fg=theme[0],highlightbackground=theme[1]) flabel = Label(root, text = "> LOCATION",font =("Monospace", 14),bg="black", fg=theme[0],highlightbackground=theme[1]) fbtn = Button(root, height = 2, width = 20,bg="black", fg=theme[0], text ="Render Map", command = lambda:show_map(),activebackground=theme[1],font =("Monospace", 14),highlightbackground=theme[1]) s = ttk.Style() s.theme_use('default') s.configure("black.Horizontal.TProgressbar", background=theme[0], highlightbackground=theme[1]) progress = Progressbar(root, orient = HORIZONTAL,length = 200, mode = 'determinate', s = 'black.Horizontal.TProgressbar') location.place(relx=0.9, rely=0.15, anchor=CENTER) label.place(relx=0.1, rely=0.1, anchor=CENTER) flabel.place(relx=0.9, rely=0.1, anchor=CENTER) fbtn.place(relx=0.9, rely=0.2, anchor=CENTER) progress.place(relx=0.1, rely=0.2, anchor=CENTER) mapRange.place(relx=0.1, rely=0.15, anchor=CENTER) canvas.place(relx=0.5, rely=0.5, anchor=CENTER) mainloop()
lbPP = [] # 内层进程列表,用于生成一列 # 第一列到四列 for j in range(4): varLbPP.append(tk.StringVar()) if j == 0: varLbPP[j].set(pidList[i]) else: varLbPP[j].set('NaN') lbPP.append( tk.Label(frmResult, textvariable=varLbPP[j], font=('Songti', 12))) lbPP[j].grid(row=i + 1, column=j) varLbP.append(varLbPP) lbP.append(lbPP) # 第五列进程进度条 bar.append(Progressbar(frmResult, length=barlength)) bar[i].grid(row=i + 1, column=4, pady=28) # 提示信息 lHelp = tk.Label( window, text="电计1806张子航 201873049\n\n左上角为进程模拟调度结果\n\n右上角为进程输入\n\n右下角为算法与功能选择", font=('SongTi', 15)) # 在图形界面上设定标签 lHelp.place(relx=0.25, rely=0.65) # 放置标签 menubar = tk.Menu(window) # 创建一个菜单栏 filemenu = tk.Menu(menubar, tearoff=0) # 创建一个File菜单项 # 将上面定义的空菜单命名为File,放在菜单栏中,就是装入那个容器中 menubar.add_cascade(label='文件', menu=filemenu)
frequency += f frequen = dict(frequency.most_common(15)) total = sum(frequency.values()) frequen['Others'] = total - sum(frequen.values()) fun = round(sum(funs) / len(funs), 1) rest = round(sum(rests) / len(rests), 1) work = round(sum(works) / len(works), 1) compel = round(sum(compels) / len(compels), 1) useless = round(sum(uselesses) / len(uselesses), 1) sleep = round(sum(sleeps) / len(sleeps), 1) sleep_st = round(sum(sleep_sts) / len(sleep_sts), 1) if len(sleep_sts) > 0 else 0 sleep_ed = round(sum(sleep_eds) / len(sleep_eds), 1) if len(sleep_eds) > 0 else 0 record = [target_id, fun, rest, work, compel, useless, sleep, sleep_st, sleep_ed, str(frequen)] return record if __name__ == '__main__': Root = Tk() Root.title('WizStatistics') Root.config(bg='white') Cfg = Config(Root) Pgb = Progressbar(Root, orient='horizontal', length=500, mode='determinate') Pgb.pack() ID_FileNames, ID_Dates = wiz_week_index(Cfg) read_data(Root, Cfg, Pgb, ID_Dates, ID_FileNames, 'all', dialog=True) Root.mainloop()
toolbar.add_command(label="Help", command=help_command) toolbar.add_command(label="Tags", command=open_tags) toolbar.add_command(label="Recommend", command=recommend_words) toolbar.add_command(label="Disclaimer", command=disclaimer) #toolbar.add_command(label="Train", command = train_data) #do not put brackets on function because it causes errors input_text = tkinter.Entry(main, width=60) #input frame = tkinter.Frame(main, width=360, height=200) #to restrict the geometry of output_text output_text = tkinter.Text(frame, wrap="word") #output output_text.config(state="disabled") #disable editing input_text.pack(pady=20, padx=20) output_text.place(x=0, y=0, height=200, width=360) frame.pack() #pack frame main.bind('<Return>', run) main.resizable(False, False) main.geometry("400x300") # define width and height of window main.config(menu=toolbar, background="#ddd") bar = Progressbar(main, orient="horizontal", length=360, mode="determinate") bar.pack(pady=15) main.iconbitmap('pshs_icon.ico') #display menu main.mainloop() ################## E n d o f U s e r I n t e r f a c e ##################
def Progressbar(self): return Progressbar(self.root, orient=HORIZONTAL, length=self.root.winfo_screenwidth() / 5.0, maximum=100, mode='determinate', value=0)
return cli #Create widget for user and address ssh connection userSsh = tk.StringVar() Entry(window, bg='bisque', fg='maroon', textvariable=userSsh).place(x=200, y=120) Label(window,text='insert username').place(x=200, y=90) ipAdres = tk.StringVar() Entry(window, bg ='bisque', fg='maroon', textvariable=ipAdres).place(x=200, y=180) Label(window,text='insert Ip').place(x=200, y=150) passwd = tk.StringVar() Entry(window, bg ='bisque', fg='maroon', textvariable=passwd, show='*').place(x=200, y=240) Label(window,text='insert password').place(x=200, y=210) Button(window, text="Make autoremove", command=autoremove, activebackground="green").place(x=10, y=120) Button(window, text="Display L users", command=display_list_user, activebackground="green").place(x=10, y=150) Button(window, text="Display pakg list", command=display_package_list, activebackground="green").place(x=10, y=180) progress = Progressbar(window, orient = HORIZONTAL, length = 100, mode = 'indeterminate') # Function responsible for the updation # of the progress bar value def bar(): import time progress['value'] = 20 window.update_idletasks() time.sleep(0.5) progress['value'] = 40 window.update_idletasks() time.sleep(0.5) progress['value'] = 50 window.update_idletasks()
## public key if choose Mode B row = 4 ## progress bar row = 5 row = 5 ratio = DoubleVar() ratio_per = StringVar() ratio_per.set("Progress: " + str(ratio.get() / 3.0)[:3] + "%") ratio_per_label = Label(root, textvariable=ratio_per) ratio_per_label.grid(row=row, column=0, columnspan=10) row = 6 file_size_int = IntVar() progress = Progressbar(orient='horizontal', length=300, mode='determinate', variable=ratio, maximum=300) progress.grid(row=row, column=0, columnspan=10) ## button OK row = 6 row = 7 def get_file(HOST, PORT, file_name, request_code): PORT = int(PORT) #HOST = str(input("Enter the ip address: ")) tcpCliSock = socket(AF_INET, SOCK_STREAM) tcpCliSock.connect((HOST, PORT)) data = "" #sent = tcpCliSock.recv(1000).decode('utf-8')
LoadingVideo = Label(mainFrame, font=('Aerial', 12), textvariable=loadingMessage, bg='#ffffff') LoadingVideo.place(x=390, y=370) downloadButton = Button(mainFrame, font=('Aerial', 14), text='Start Downlaod', relief=FLAT, command=startDownloadThread, highlightthickness=4, highlightcolor="#CCCCCC") progressBar = Progressbar(mainFrame, length=300, orient=HORIZONTAL, mode='determinate') videoPreview = Frame(mainFrame, height=160, width=800) videoPreview.place(x=50, y=500) videoTumbnail = Label(mainFrame, height=138, width=246, image=dummyThumbnail) videoTumbnail.place(x=60, y=510) title = StringVar() title.set('Video title will appear here...') vidoTitle = Message(mainFrame, width=530, textvariable=title, font=('Aerial', 13), fg='#0D0D0D')
def Train_data(): datadir = "F:\\2019-2020\\BE\\Register\\2.SGI Brain Tumor Detection Using Machine Learning\\Phase6\\Brain Toumer" Categories = ["no", "yes"] j = 0 wb = Workbook() sheet1 = wb.add_sheet('Sheet 1') lbl = tk.Label(window, text="Training", width=20, height=2, fg="red", font=('times', 13, ' bold ')) lbl.place(x=850, y=355) progress = Progressbar(window, orient=HORIZONTAL, length=500, mode='determinate', maximum=253) for category in Categories: path = os.path.join(datadir, category) #print(len(os.listdir(path)) for img in os.listdir(path): #name= filedialog.askopenfilename() img = cv2.imread(os.path.join(path, img)) dim = (180, 218) img = cv2.resize(img, dim) img1 = img #print(img.shape[:2]) im_out = np.zeros(img.shape[:2], dtype="uint8") * 255 mask = np.zeros(img.shape[:2], dtype="uint8") * 255 img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) height, width = img_gray.shape ret, im_th = cv2.threshold(img_gray, 180, 255, cv2.THRESH_BINARY) #cv2.imshow('image Throshold', im_th) denoised = cv2.medianBlur(im_th, 9) #cv2.imshow('image Denoised', denoised) edges = cv2.Canny(denoised, 100, 200) #cv2.imshow('Edges',edges) # noise removal kernel = np.ones((3, 3), np.uint8) opening = cv2.morphologyEx(denoised, cv2.MORPH_OPEN, kernel, iterations=2) # sure background area sure_bg = cv2.dilate(opening, kernel, iterations=3) # Finding sure foreground area dist_transform = cv2.distanceTransform(opening, cv2.DIST_L2, 5) ret, sure_fg = cv2.threshold(dist_transform, 0.7 * dist_transform.max(), 255, 0) # Finding unknown region sure_fg = np.uint8(sure_fg) unknown = cv2.subtract(sure_bg, sure_fg) # Marker labelling ret, markers = cv2.connectedComponents(sure_fg) # Add one to all labels so that sure background is not 0, but 1 markers = markers + 1 # Now, mark the region of unknown with zero markers[unknown == 255] = 0 markers = cv2.watershed(img, markers) img[markers == 1] = [255, 255, 255] img1[markers == 1] = [0] im_th = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) #cv2.imshow('image marker',img) img1 = cv2.bitwise_and(img, img, mask=mask) g = skimage.feature.greycomatrix(im_th, [1], [0], levels=256, symmetric=False, normed=True) contrast = skimage.feature.greycoprops(g, 'contrast')[0][0] energy = skimage.feature.greycoprops(g, 'energy')[0][0] homogeneity = skimage.feature.greycoprops(g, 'homogeneity')[0][0] correlation = skimage.feature.greycoprops(g, 'correlation')[0][0] sheet1.write(j, 0, contrast) sheet1.write(j, 1, energy) sheet1.write(j, 2, homogeneity) sheet1.write(j, 3, correlation) print(j) j = j + 1 wb.save('xlwt example.xls') progress['value'] = j window.update_idletasks() progress.place(x=850, y=400) lbl = tk.Label(window, text="Training Completed", width=20, height=2, fg="red", font=('times', 13, ' bold ')) lbl.place(x=850, y=355)
#Agregar un SpinBox (widget de números) giro = Spinbox(ventana, from_=0, to=100, width=6) giro.grid(column=2, ) # Establecer el valor por defecto del Spinbox # var =IntVar() # var.set(36) # spin = Spinbox(window, from_=0, to=100, width=5, textvariable=var) #Adicionar el widget Progressbar from tkinter.ttk import Progressbar progreso = Progressbar(ventana, length=200, style='black.Horizontal.TProgressbar') progreso.grid(column=0, row=0) # adicionar mas adelante formas de personalizar la barra de progreso #--- #--- #--- #--- progreso['value'] = 70 #Adicionar un diálogo para archivos (elegir archivo y directorio) imi = 0 if imi == 1: from tkinter import filedialog archivos = filedialog.askopenfilename(
entry.pack() forGui=[] goToGV=tk.Button(root,font=("courier",8),text="click here to go to Gurmatveechar.com",bg="gray",command=openGV) goToGV.pack() button=tk.Button(root,font=("courier",12),text="click here after you have copy and pasted the link you want",bg="gray",command=lambda: main(entry.get())) button.pack() label=tk.Label(root,width=45,height=4,bg="#80c1ff",font=("courier",13),text="It might take some time to download the files") label.pack() h = Scrollbar(root, orient = 'horizontal') h.pack(side = BOTTOM, fill = X) progress = Progressbar(root, orient = HORIZONTAL,length = 100, mode = 'determinate',) progress.pack(pady = 10) v = Scrollbar(root) v.pack(side = RIGHT, fill = Y) t = tk.Text(root, wrap = NONE,xscrollcommand = h.set,yscrollcommand = v.set) t.pack(side=TOP,fill="both") h.config(command=t.xview) v.config(command=t.yview) root.mainloop()
prevs = Button(root, text="previous", width=15, command=playprev, state=DISABLED) prevs.place(x=70, y=55) #volume buttons Button(root, text='volume +', width=15, command=volume_up).place(x=750, y=75) Button(root, text='volume -', width=15, command=volume_down).place(x=750, y=115) # Progressbar Setup ProgressbarContainer = Label(root, bg='pale turquoise') ProgressbarContainer.place(x=50, y=190) ProgressbarSlide = Progressbar(ProgressbarContainer, length=825) ProgressbarSlide.grid(row=0, column=1) ProgressbarEt = Label(ProgressbarContainer, text='--:--:--') ProgressbarEt.grid(row=0, column=2) ProgressbarSt = Label(ProgressbarContainer, text='--:--:--') ProgressbarSt.grid(row=0, column=0) #Loop loopb = Button(root, text='repeat : off', width=15, command=loop) loopb.place(x=310, y=130) # Volume Bar setup VolumebarSlide = Progressbar(root, length=100, orient=VERTICAL, value=volume,
def run(self): try: if (len(self.dropdownMenu.get()) > 0) and (len(self.text_outputDir.get("1.0",'end-1c')) > 0): if (self.opt_csv.get() + self.opt_shp.get() + self.opt_report.get() + self.opt_json.get()) > 0: self.root.geometry(str(self.root_w)+ 'x' + str(self.root_h + 50)) # self.root.update() self.root.update() sleep(1) # self.busy() func_row = self.row self.inputObj = self.getTextFields() self.inputObj.update({'study_region': self.dropdownMenu.get()}) self.inputObj.update({'opt_csv': self.opt_csv.get()}) self.inputObj.update({'opt_shp': self.opt_shp.get()}) self.inputObj.update({'opt_report': self.opt_report.get()}) self.inputObj.update({'opt_json': self.opt_json.get()}) self.progress = Progressbar(mode = 'indeterminate') self.progress.grid(row=func_row, column=1, pady=(0,10), padx=50, sticky='nsew') func_row += 1 self.label_progress = tk.Label(self.root, text='Initializing', font='Helvetica 8', background=self.backgroundColor, fg=self.foregroundColor) self.label_progress.grid(row=func_row, column=1, sticky='nsew') self.label_progress.config(text='Establishing connection to SQL Server') self.progress['value'] = 0 self.root.update_idletasks() try: t0 = time() hazus = Exporting(self.inputObj) hazus.setup() hazus.logger.create(self.inputObj['output_directory'] + '/' + self.inputObj['study_region']) self.logFile = hazus.logger.logFile hazus.logger.log('Connected to SQL Server') self.updateProgressBar() hazus.logger.log('Retrieving and parsing data') self.updateProgressBar() hazus.getData() hazus.logger.log('Results are ready for outputting') self.updateProgressBar() if self.inputObj['opt_csv']: hazus.logger.log('Creating CSVs') self.updateProgressBar() hazus.toCSV() hazus.logger.log('CSVs created') self.updateProgressBar() if self.inputObj['opt_shp']: hazus.logger.log('Creating Shapefiles') self.updateProgressBar() hazus.toShapefile() hazus.logger.log('Shapefiles created') self.updateProgressBar() if self.inputObj['opt_report']: hazus.logger.log('Creating report (exchanging patience for maps)') self.updateProgressBar() hazus.toReport() hazus.logger.log('Report created') self.updateProgressBar() hazus.logger.log('Finished exporting') self.updateProgressBar() print('Hazus results available locally at: ' + self.inputObj['output_directory'] + '\\' + self.inputObj['study_region']) self.progress['value'] = 100 # self.notbusy() print('Total elasped time: ' + str(time() - t0)) tk.messagebox.showinfo("Hazus", "Success! Output files can be found at: " + self.inputObj['output_directory'] + '/' + self.inputObj['study_region']) self.root.geometry(str(self.root_w) + 'x' + str(self.root_h)) self.progress.destroy() self.label_progress.destroy() hazus.logger.destroy() except: try: self.progress.destroy() self.label_progress.destroy() hazus.logger.destroy() except: print('unable to destroy progress bar and label') self.root.geometry(str(self.root_w) + 'x' + str(self.root_h)) # self.notbusy() tk.messagebox.showerror('Hazus', str(sys.exc_info()[1])) else: tk.messagebox.showwarning('Hazus', 'Select at least one option to export') else: tk.messagebox.showwarning('Hazus', 'Make sure a study region and output directory have been selected') except: self.root.geometry(str(self.root_w) + 'x' + str(self.root_h)) ctypes.windll.user32.MessageBoxW(None, u"Unable to open correctly: " + str(sys.exc_info()[1]), u'Hazus - Message', 0)
rad1 = Radiobutton(window,text='First', value=1) rad2 = Radiobutton(window,text='Second', value=2) rad3 = Radiobutton(window,text='Third', value=3) rad1.grid(column=0, row=0) rad2.grid(column=1, row=0) rad3.grid(column=2, row=0) from tkinter.ttk import Progressbar bar = Progressbar(window, length=200, style='black.Horizontal.TProgressbar') bar['value'] = 70 bar.grid(column=12, row=0) from tkinter import Menu menu = Menu(window) new_item = Menu(menu) new_item.add_command(label='New') menu.add_cascade(label='File', menu=new_item) window.config(menu=menu)
def __init__(self, mc): self.mc = mc self.window = Tk() self.window.title("Екатеринбург") self.window.geometry("1800x1000") self.result = '' self.n_1 = self.m_1 = None self.modes = ('fwd', 'bwd', 'fwd_bwd') self.load = Image.open("./images/Ekb_graph_cropped.png") self.image = ImageTk.PhotoImage(self.load) self.img = Label(self.window, image=self.image) self.img.grid(column=3, columnspan=100, row=1, rowspan=100) Label(self.window, text='').grid(row=0) Label(self.window, text='', width=10).grid(column=0) Label(self.window, width=10).grid(column=2) Button(self.window, text='Показать Екатеринбург', command=partial(self.set_image, "Ekb_graph_cropped")).grid(column=1, row=1, pady=3) Label(self.window, text='').grid(column=1, row=2) Label(self.window, text='Часть 1').grid(column=1, row=3) Label(self.window, text='M = ').grid(column=0, row=4, sticky=E) self.m_1_input = Spinbox(self.window, width=5, from_=1, to=10) self.m_1_input.grid(column=1, row=4, sticky=W) Label(self.window, text='N = ').grid(column=0, row=5, sticky=E) self.n_1_input = Spinbox(self.window, width=5, from_=1, to=100) self.n_1_input.grid(column=1, row=5, sticky=W) Button(self.window, text='Выбрать', command=self.set_m_n_1).grid(column=1, row=6, sticky=W, pady=1) self.show_chosen_1 = Button(self.window, text='Показать выбранные', command=partial(self.set_image, "points_for_1_part")) Label(self.window, text='mode(1): ').grid(column=0, row=8, sticky=E) self.mode_1 = Combobox(self.window, width=15) self.mode_1.grid(column=1, row=8, sticky=W) self.mode_1['values'] = ("Туда", "Обратно", "Туда-обратно") self.mode_1.current(0) self.task_1_1_a = Button(self.window, text='Рассчитать 1а', command=self.count_first_a) self.show_1_1_a = Button(self.window, text='Show', command=partial(self.set_image, 'task_1_a')) Label(self.window, text='X = ').grid(column=0, row=9, sticky=E) self.x = Entry(self.window, width=7) self.x.grid(column=1, row=9, sticky=W) self.task_1_1_b = Button(self.window, text='1б', command=self.count_first_b) self.show_1_1_b = Button(self.window, text='Show', command=partial(self.set_image, 'task_1_b')) Label(self.window, text='mode(2): ').grid(column=0, row=10, sticky=E) self.mode_2 = Combobox(self.window, width=15) self.mode_2.grid(column=1, row=10, sticky=W) self.mode_2['values'] = ("Туда", "Обратно", "Туда-обратно") self.mode_2.current(0) self.task_1_2 = Button(self.window, text='п. 2', command=self.count_second) self.show_1_2 = Button(self.window, text='Show', command=partial(self.set_image, 'task_2')) self.task_1_3 = Button(self.window, text='п. 3', command=self.count_third) self.show_1_3 = Button(self.window, text='Show', command=partial(self.set_image, 'task_3')) self.task_1_4 = Button(self.window, text='п. 4', command=self.count_fourth) self.show_1_4 = Button(self.window, text='Show', command=partial(self.set_image, 'task_4')) Label(self.window, text='', height=1).grid(column=1, row=13) self.wait_first = Label(self.window, text='', fg='red') self.wait_first.grid(column=1, row=14) Label(self.window, text='', height=2).grid(column=1, row=15) Label(self.window, text='Часть 2').grid(column=1, row=16) Button(self.window, text='Показать карту инфраструктурных объектов', command=partial(self.set_image, "inf_objs")).grid(column=1, row=17, pady=2) Label(self.window, text='N = ').grid(column=1, row=18) self.n_input = Spinbox(self.window, from_=1, to=100, width=5) self.n_input.grid(column=1, row=18, sticky=E) Label(self.window, text='Индекс инф. объекта: ').grid(column=1, row=19) self.inf_index = Spinbox(self.window, from_=0, to=21, width=5) self.inf_index.grid(column=1, row=19, sticky=E) Button(self.window, text='Рассчитать', command=self.count_sp).grid(column=1, row=20) Label(self.window, text='', height=2).grid(column=1, row=21) self.progress = Progressbar(self.window, orient=HORIZONTAL, length=0, mode='determinate') self.progress.grid(column=1, row=22) self.progress_info = Label(self.window, text='') self.progress_info.grid(column=1, row=23) Label(self.window, text='', height=2).grid(column=1, row=24) self.combo = Combobox(self.window, width=30) self.combo['values'] = ( "Дерево кратчайших путей", "Дендрограмма", "Разделение на 2 кластера", "Деревья 2 центроид", "Дерево от 2 центроид до объекта", "Разделение на 3 кластера", "Деревья 3 центроид", "Дерево от 3 центроид до объекта", "Разделение на 5 кластеров", "Деревья 5 центроид", "Дерево от 5 центроид до объекта" ) self.combo.current(0) self.show_btn = Button(self.window, text='Показать', command=self.set_combo_image) self.add_recount = Button(self.window, text='Добавить пункт назначения и пересчитать', command=self.add_and_recount) Label(self.window, text='Test').grid(column=1, row=29, pady=3, sticky=W) Label(self.window, text='File:').grid(column=0, row=30, pady=1, sticky=E) self.filename = Entry(self.window, width=15) self.filename.grid(column=1, row=30, sticky=W) Label(self.window, text='Start:').grid(column=0, row=31, pady=1, sticky=E) self.start_id = Entry(self.window, width=5) self.start_id.grid(column=1, row=31, sticky=W) Label(self.window, text='Dest:').grid(column=0, row=32, pady=1, sticky=E) self.dest_id = Entry(self.window, width=5) self.dest_id.grid(column=1, row=32, sticky=W) self.count_test = Button(self.window, text='count', command=self.count_test) self.count_test.grid(column=1, row=33, pady=2, sticky=W) Button(self.window, text='exit', command=partial(sys.exit, 0)).grid(column=1, row=34, pady=5)
def clear_me(self): """ :return: None """ self.clear_window() if self.image is None: mb.showinfo("info", "Not open image for editing Serial Number") return me_file = self.open_file() dir_output = self.image.path if me_file != -1: self.verbose_log(txt_label=f"[*] ME file: {me_file}", y=230) wd = os.getcwd() current_dir = PurePath(wd) if current_dir.parts[-1] != "fit11": os.chdir("fit11") output_path = F"{PurePath(dir_output).parent}/{PurePath(dir_output).stem}_CleanME.bin" # -w<path> Overrides the $WorkingDir environment variable. # -s<path> Overrides the $SourceDir environment variable fit_proc = subprocess.Popen(f"fit.exe -b -o {output_path} " f"-f {self.image} " f"-me {me_file}") progress = Progressbar(root, orient=HORIZONTAL, length=100, mode='indeterminate') progress.place(x=50, y=260) self.list_to_clear.append(progress) import time while True: progress['value'] += 20 root.update_idletasks() time.sleep(0.5) fit_status = fit_proc.poll() if fit_status is not None: _logger.debug(F"FIT status ==> {fit_status}") if fit_status == 5002: self.verbose_log( txt_label=F"[*] ERROR: Invalid input file type.", y=260, fg="red") break elif fit_proc.poll() == 0: self.verbose_log( txt_label=F"[*] Full Flash image written to ==>", y=260, fg="green") self.verbose_log(txt_label=F"\t{output_path}", y=280) mv_source_dir = PurePath(self.image.path) mv_destination_dir = PurePath.joinpath( PurePath(output_path).parent, datetime.datetime.now().strftime( '%Y-%m-%d_%H-%M-%S')) _logger.debug(F"build dir ==> {mv_destination_dir}") subprocess.run(F"mkdir {mv_destination_dir}") subprocess.run( F"mv {mv_source_dir.stem} {mv_destination_dir}") break else: self.verbose_log(txt_label=F"[*] ERROR: Build Failed!", y=260, fg="red") break
def initialize(self): # Source format Checkbox list self.source_format_list = [] self.frame_source_format = tk.LabelFrame(self, text="Source formats") self.frame_source_format.pack(side=tk.TOP, fill=tk.BOTH) # Tuple list to save btn widget & the checkbox state variable for idx, filetype in enumerate(OPEN_FILETYPES[1:]): checkbox_state = tk.IntVar() self.source_format_list.append(( tk.Checkbutton( self.frame_source_format, text=filetype[1][1:].upper(), variable=checkbox_state, onvalue=True, offvalue=False, ), checkbox_state, )) self.source_format_list[idx][0].pack(side=tk.LEFT) # Setting default input format self.source_format_list[0][0].toggle() # Destination Format Option Menu self.frame_destination_format = tk.Frame(self) self.frame_destination_format.pack(side=tk.TOP, fill=tk.X) tk.Label(self.frame_destination_format, text="Destination format:").pack(side=tk.LEFT) self.dest_format = tk.StringVar(self) self.dest_format.set(SAVE_EXT_LIST[0].upper()) self.dest_menu = tk.OptionMenu( self.frame_destination_format, self.dest_format, *[fmt.upper() for fmt in SAVE_EXT_LIST], ) self.dest_menu.pack(side=tk.LEFT) tk.Button( self.frame_destination_format, text="Process Batch Edit", command=self._root().batch_edit, ).pack(side=tk.LEFT) def _select_folder(folder_path, Event=None): folder_path.set(filedialog.askdirectory(initialdir=os.curdir)) self.focus() def widget_entry_template( frame, label, starting_value="", entry_width=60, label_width=len("Destination folder:"), ): entry_frame = tk.Frame(frame) entry_frame.pack(side=tk.TOP, fill=tk.X) tk.Label(entry_frame, text=label, width=label_width, anchor=tk.W).pack(side=tk.LEFT) entry_frame.entry_value = tk.StringVar(value=starting_value) entry_path = tk.Entry( entry_frame, textvariable=entry_frame.entry_value, width=60, exportselection=0, ) entry_path.pack(side=tk.LEFT) tk.Button( entry_frame, text="...", command=lambda: (_select_folder(entry_frame.entry_value)), ).pack(side=tk.LEFT) return entry_frame self.frame_batch_src_path = widget_entry_template( self, "Source folder:") self.frame_batch_dest_path = widget_entry_template( self, "Destination folder:") self.frame_progress_bar = tk.LabelFrame(self, relief=tk.RIDGE, bd=2, text="Awaiting process") self.frame_progress_bar.pack(side=tk.TOP, fill=tk.BOTH) self.progress_bar = Progressbar( self.frame_progress_bar, orient=HORIZONTAL, length=self.cget("width"), mode="determinate", ) self.progress_bar.pack(side=tk.LEFT)
def __init__(self): self.window = tk.Tk() self.window.geometry("720x550") self.widgets = {} # Language dropdown # Options bar self.opt_bar = tk.Frame(self.window, height=40) languages = list(lang_ctl._ALL.keys()) self.current_lang = StringVar(self.window) self.current_lang.set(languages[0]) self.lang_menu = tk.OptionMenu(self.opt_bar, self.current_lang, *languages) self.lang_menu.pack(side="right", fill="both", expand=True) # Get lang self.text_dict = lang_ctl.get_lang(self.current_lang.get()) self.window.title(self.text_dict["window"]["title"]) select_lang_label = tk.Label( self.opt_bar, text=self.text_dict["window"]["select_lang"]) self.widgets["window/select_lang"] = select_lang_label select_lang_label.pack(side="top", fill="both", expand=True) self.opt_bar.pack(side="top") # Top Frame self.menu_top = tk.Frame(self.window, height=100) # Main text welcome_text = tk.Label(self.menu_top, text=self.text_dict["window"]["body"], anchor="w", justify="left") self.widgets["window/body"] = welcome_text welcome_text.pack() self.menu_top.pack(side="top", fill="both", expand=True) # It's duplicated, we need a list of widgets here self.widgets["window/select_file"] = [] self.widgets["button/open"] = [] self.widgets["window/sample_path"] = [] # Mid Frame self.menu_credentials = tk.Frame(self.window, height=1, width=200) self.menu_credentials_left = tk.Frame(self.menu_credentials) creds = tk.Label(self.menu_credentials, text=self.text_dict["window"]["credentials"], font=("", 16)) self.widgets["window/credentials"] = creds creds.pack(side=tk.TOP, pady=5) # Delete credentials button del_button = tk.Button( self.menu_credentials, text=self.text_dict["button"]["delete"], command=self.reset_credentials, height=2, width=30, ) self.widgets["button/delete"] = del_button del_button.pack(side=tk.TOP, pady=10) tk.Label(self.menu_credentials_left, text="Email", font=("", 10)).pack(side=tk.TOP) self.menu_credentials_left.pack(side=tk.LEFT, padx=(0, 10)) self.menu_credentials_right = tk.Frame(self.menu_credentials) # User Entry self.username = StringVar(self.window) self.username.set("*****@*****.**") self.user_box = tk.Entry(self.menu_credentials_right, textvariable=self.username, width=40) self.user_box.pack(side=tk.TOP) self.menu_credentials_right.pack(side=tk.RIGHT) self.menu_credentials.pack(pady=10) self.menu_mid = tk.Frame(self.window, height=150) self.menu_mid.pack(side="top", fill="both", expand=True) self.menu_mid_left = tk.Frame(self.menu_mid, height=200, width=200, bd=2, relief="groove", padx=5) self.input_file_box(self.menu_mid_left, False, True) self.menu_mid_left.pack(side="left", fill="both", expand=True, padx=10, pady=10) self.menu_mid_right = tk.Frame(self.menu_mid, height=200, width=200, bd=2, relief="groove", padx=5) self.input_file_box(self.menu_mid_right, True, False) self.menu_mid_right.pack(side="right", fill="both", expand=True, padx=10, pady=10) # Bottom Frame self.menu_bot = tk.Frame(self.window, height=50) # Checkbox Menu self.options_menu = tk.Frame(self.window, height=20, relief="groove", bd=2) # Checkbox Debug self.checkbox_debug = tk.BooleanVar(self.window) self.checkbox_debug.set(True) debug_checkbox = tk.Checkbutton( self.options_menu, text=self.text_dict["settings"]["debug"], variable=self.checkbox_debug, command=self.debug_checkbox_clicked, ) self.widgets["settings/debug"] = debug_checkbox debug_checkbox.pack(side="right") # Checkbox SendIfFiles self.checkbox_only_att = tk.BooleanVar(self.window) self.checkbox_only_att.set(True) sendiffiles_checkbox = tk.Checkbutton( self.options_menu, text=self.text_dict["settings"]["only_att"], variable=self.checkbox_only_att, command=self.onlyatt_checkbox_clicked) self.widgets["settings/only_att"] = sendiffiles_checkbox sendiffiles_checkbox.pack(side="left", padx=(5, 0)) self.num_att = tk.Spinbox(self.options_menu, from_=0, to=99) self.num_att.pack(side="left", padx=(0, 0)) # Checkbox OnlyPDF self.checkbox_onlypdf = tk.BooleanVar(self.window) self.checkbox_onlypdf.set(True) onlypdf_checkbox = tk.Checkbutton( self.options_menu, text=self.text_dict["settings"]["only_pdf"], variable=self.checkbox_onlypdf, command=self.onlypdf_checkbox_clicked, ) self.widgets["settings/only_pdf"] = onlypdf_checkbox onlypdf_checkbox.pack(side="left", padx=(20, 20)) self.options_menu.pack(side="top", pady=(0, 10)) # Execute bttton run_button = tk.Button(self.menu_bot, text=self.text_dict["button"]["run"], font=("", 14), command=self.bar_init, height=2, width=30) self.widgets["button/run"] = run_button run_button.pack() self.progressbar = Progressbar(self.menu_bot, mode="indeterminate") self.progressbar.pack(side="bottom", fill="both", expand=True, padx=5, pady=5) self.progressbar.config(value=0, maximum=0) self.menu_bot.pack(fill="both", expand=True) # link function to change dropdown self.current_lang.trace("w", self.change_lang) self.domainCtl = Domain_Ctl() self.window.mainloop()
root.geometry('640x480') root.rowconfigure([1, 2, 3, 4, 5, 6], minsize=0, weight=100) root.columnconfigure([0, 1], minsize=0, weight=1) menu = Menu(root) menu_item = Menu(menu) menu_item.add_command(label="Settings", command=settings) menu_item.add_command(label="How to play", command=howtoplay) menu.add_cascade(label="Info", menu=menu_item) root.config(menu=menu) lbl_round = tk.Label(root, text=("Round # " + str(rounds) + "/" + str(tot_rds)), font='Serif 16') lbl_round.grid(row=0, sticky=tk.W) p_bar = Progressbar(root, length=500) p_bar['value'] = 0 p_bar.grid(column=0, row=1, columnspan=2) lbl_top = tk.Label( root, text=("You have a " + str(odds) + "% chance of winning $ " + str(gamble) + "\nor you can take the lump sum of $ " + str(lump_sum)), font=("Serif", 18)) lbl_top.grid(row=2, columnspan=2) lbl_top1 = tk.Label(root, text='Player 1 Score:', font='Serif 16 italic') lbl_top1.grid(column=0, row=4) lbl_top2 = tk.Label(root, text='Computer Score:', font='Serif 16 italic') lbl_top2.grid(column=0, row=5) s1 = tk.Label(master=root, text="0", font='Serif 16') s1.grid(row=4, column=1) s2 = tk.Label(master=root, text="0", font='Serif 16')
var=createKmlChkState) createKml_checkBox.place(x=10, y=595) ### Create .csv Text Entry createCsvChkState = tk.BooleanVar() createCsvChkState.set(True) createCsv_checkBox = tk.Checkbutton(window, text='Create .csv File', font=('Arial Bold', 16), var=createCsvChkState) createCsv_checkBox.place(x=10, y=625) ### Make status bar lbl = tk.Label(window, text='Progress:', font=('Arial Bold', 10)) lbl.place(x=250, y=635) statusBar = Progressbar(window, length=190) statusBar['value'] = 0 statusBar.place(x=320, y=635) # Run Button Callback def runAtl03(): # Update status bar statusBar['value'] = 0 window.update() # Make atlMeasuredData a global variable global atlMeasuredData # Initialize variables
# tkinter 25 Add a Progressbar widget from tkinter import * from tkinter.ttk import Progressbar window = Tk() window.title("First") window.geometry("500x500") bar = Progressbar(window, length=300) bar['value'] = 30 bar.grid(column=0, row=0) window.mainloop()
the_window = Tk() # Give the window a title the_window.title('Pump me up!') ###### PUT YOUR CODE HERE # 1. Define a function which will be called each # time the button is pressed to "step" the # progress bar up def isPressed(): if bar['value'] < 100: bar['value'] += 10 # 2. Create the Button widget and pack it into # the main window push_button = Button(the_window, text = 'Push', font = ('Arial', 16), \ command = isPressed) push_button.pack() # 3. Create the Progressbar widget and pack it into # the main window bar = Progressbar(the_window, orient = VERTICAL, length = 200, \ mode = 'determinate') bar.pack() # Start the event loop to react to user inputs the_window.mainloop()
def __init__(self, master=None): self.fontePadrao = ("Arial", "12") self.primeiroContainer = Frame(master) self.primeiroContainer["pady"] = 20 self.primeiroContainer.pack() self.segundoContainer = Frame(master) self.segundoContainer["padx"] = 20 self.segundoContainer.pack() self.terceiroContainer = Frame(master) self.terceiroContainer["padx"] = 20 self.terceiroContainer.pack() self.quartoContainer = Frame(master) self.quartoContainer["pady"] = 20 self.quartoContainer.pack() self.quintoContainer = Frame(master) self.quintoContainer["pady"] = 20 self.quintoContainer.pack() self.sextoContainer = Frame(master) self.sextoContainer["pady"] = 20 self.sextoContainer.pack() self.titulo = Label(self.primeiroContainer, text="Gerador de código") self.titulo["font"] = ("Arial", "14", "bold") self.titulo.pack() self.barcode_type = Label(self.segundoContainer, text="Tipo barcode", font=self.fontePadrao) self.barcode_type.pack(side=LEFT) self.barcode_type = Entry(self.segundoContainer) self.barcode_type["width"] = 10 self.barcode_type["font"] = ("Calibri", "12") self.barcode_type.pack(side=LEFT) self.includetext = Label(self.segundoContainer, text="Incluir Texto", font=self.fontePadrao) self.includetext.pack(side=LEFT) self.includetext = Entry(self.segundoContainer) self.includetext["width"] = 10 self.includetext["font"] = ("Calibri", "12") self.includetext.pack(side=RIGHT) self.pathfileLabel = Label(self.terceiroContainer, text="Local (*csv)", font=self.fontePadrao) self.pathfileLabel.pack(side=LEFT) self.pathfile = Entry(self.terceiroContainer) self.pathfile["width"] = 50 self.pathfile["font"] = ("Calibri", "12") self.pathfile.pack(side=LEFT) self.search_path_file = Button(self.terceiroContainer) self.search_path_file["text"] = "Localizar Arquivo" self.search_path_file["width"] = 15 self.search_path_file["command"] = self.open_explore_file self.search_path_file["fg"] = "black" self.search_path_file.pack(side=RIGHT, padx=10, pady=10) self.pathsaveLabel = Label(self.quartoContainer, text="Local salvar", font=self.fontePadrao) self.pathsaveLabel.pack(side=LEFT) self.pathsave = Entry(self.quartoContainer) self.pathsave["width"] = 50 self.pathsave["font"] = ("Calibri", "12") self.pathsave.pack(side=LEFT) self.search_path_dir = Button(self.quartoContainer) self.search_path_dir["text"] = "Localizar diretorio" self.search_path_dir["width"] = 15 self.search_path_dir["command"] = self.open_explore_dir self.search_path_dir.pack(side=RIGHT, padx=10, pady=10) self.generator = Button(self.quintoContainer) self.generator["text"] = "Executar" self.generator["font"] = ("Calibri", "12") self.generator["fg"] = "white" self.generator["width"] = 20 self.generator["bg"] = "blue" self.generator["command"] = self.create_code self.generator.pack() # self.mensagem = Label(self.sextoContainer, text="") # self.mensagem["font"] = ("Calibri", "12", "italic") # self.mensagem.pack() self.progress = Progressbar(self.sextoContainer, orient="horizontal", maximum=100, mode="determinate")
def export_all_fitting_graphs(calcul_1D, analyze_1D, run_program): location = askdirectory(title="Please choose a directory") if location is not None and location is not '': for widget in analyze_1D.Frame1_2.winfo_children(): widget.destroy() Label(analyze_1D.Frame1_2, text="Export").pack(side=LEFT) progress = Progressbar(analyze_1D.Frame1_2, orient="horizontal", mode='determinate') progress.pack(side=LEFT) progress["value"] = 0 progress["maximum"] = len(calcul_1D.phi) for i in range(len(calcul_1D.phi)): progress["value"] = progress["value"] + 1 progress.update() try: x = [ calcul_1D.two_theta_pearson[i], calcul_1D.two_theta_pearson[i] ] y = [ min(calcul_1D.matrix_real_intensity[i]), max(calcul_1D.matrix_intensity_limit[i]) ] fig = plt.figure(figsize=(10, 10), dpi=100) plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_intensity_limit[i], label='original') plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_background_intensity[i], label='background') plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_real_intensity[i], label='substrat background') plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_F1_peak1[i], label='k alpha 1') plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_F2_peak1[i], label='k alpha 2') if len(calcul_1D.peaks) >= 2: plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_F1_peak2[i]) plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_F2_peak2[i]) if len(calcul_1D.peaks) == 3: plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_F1_peak3[i]) plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_F2_peak3[i]) plt.plot(calcul_1D.matrix_two_theta_limit[i], calcul_1D.matrix_F_pearson[i], label='fitting pearson vii') plt.plot(x, y, label=r"$2\theta_{0}$" "=" + str(calcul_1D.two_theta_pearson[i]) + "") plt.xlabel(r"$2\theta$") plt.ylabel("Intensity") plt.title("phi=" + str(float(calcul_1D.phi[i])) + "; psi=" + str(float(calcul_1D.psi[i])) + "") plt.legend(loc='upper left', bbox_to_anchor=(-0.1, -0.2, 1.2, 0), ncol=3, mode="expand", borderaxespad=0., fontsize='x-small') plt.subplots_adjust(bottom=0.3) except (IndexError, ValueError): plt.close(fig) else: plt.savefig(str(location) + "/fitting_phi=" + str(float(calcul_1D.phi[i])) + "_psi=" + str(float(calcul_1D.psi[i])) + ".png", bbox_inches="tight") plt.close(fig) for widget in analyze_1D.Frame1_2.winfo_children(): widget.destroy() run_program.fenetre.mainloop()