# FIRST FRAME - PARÂMETRO DE APLICAÇÃO check1 = tk.Checkbutton(frame_aplicacao, text="Salvar em Arquivo", variable=saveasfile, command=switch_button_state) check1.deselect() check1.grid(row=0, sticky=tk.W) check2 = tk.Checkbutton(frame_aplicacao, text="Sobrescrever conteúdo\n anterior do arquivo", variable=sobrescrever, state=tk.DISABLED) check2.deselect() check2.grid(row=1, padx=(10,0)) namefile_label = tk.Label(frame_aplicacao, text="Nome arquivo: ") namefile_label.grid(row=1, column=1, sticky=tk.E) saveasfile_Entry = tk.Entry(frame_aplicacao, width=30, state=tk.DISABLED) saveasfile_Entry.grid(row=1,column=2) selectfile_button = tk.Button(frame_aplicacao, text="Select a File", relief=tk.RAISED, state=tk.DISABLED, command=openfile) selectfile_button.grid(row=1,column=3, padx=15) check3 = tk.Checkbutton(frame_aplicacao, text="Salvar em Banco de Dados", variable=savedatabase) check3.deselect() check3.grid(row=3, sticky=tk.W) #aaaa # ----------------------------------------------------------------------------------------------------- # Parâmetros da Requisição frame_requisicao = tk.LabelFrame(root, text="Parâmetros da Requisição", padx=40, pady=15) frame_requisicao.grid(row=0, column=0, sticky=tk.E+tk.N+tk.S+tk.W, ipadx=5, ipady=5, padx=5, pady=5)
df = pd.DataFrame(hashlist, columns=["Hashes"]) filename = "Hashtag_" + str(hashtag) + ".csv" df.to_csv(filename, encoding='utf-8', index=False) print(filename + " saved in same directory.") def ok(hashtag_guess, hashtag_get): global hashtag hashtag = hashtag_guess.get() print("Automation begins..") hashtag_get.destroy() hashtag_get = tk.Tk() hashtag_get.title("Twitter Hashtag") hashtag_get.geometry("500x150") hashtag_text = tk.Label(hashtag_get, text="Enter the Hashtag without #:", font="Serif 25") hashtag_guess = tk.Entry(hashtag_get, font="Serif 25") okbtn = tk.Button(text="Ok", command=lambda: ok(hashtag_guess, hashtag_get), height=2, width=10) hashtag_text.pack() hashtag_guess.pack() okbtn.pack() hashtag_get.mainloop() find_hashtags(hashtag)
def create_widgets(self): self.client_label = tk.Label(self, text="=======\nCLIENTS\n=======") self.client_label.pack() """CLIENTS FRAME""" self.client_frame = tk.Frame(self, borderwidth=2, relief='ridge') self.client_frame.pack(side="top") self.client_list_label = tk.Label(self.client_frame, text="-Client List-") self.client_list_label.pack() self.client_list = Radiobar(self.client_frame) self.client_list.pack(side="left") self.view_client = tk.Button(self.client_list, text="Display Client") self.view_client.bind("<Button>", self.display_client) self.view_client.pack(side="bottom") self.client_info = tk.Listbox(self.client_frame, width=0, height=0) self.client_info.pack(side="right") """ADD/REMOVE CLIENTS FRAME""" self.change_client_list = tk.Frame(self, borderwidth=2, relief='ridge') self.change_client_list.pack(side="top") self.change_client_label = tk.Label(self.change_client_list, text="-Add or Remove a Client-") self.change_client_label.pack(side="top") """ADD CLIENTS""" self.add_client = tk.Frame(self, borderwidth=1, relief='ridge') self.add_client.pack(side="left") self.add_client_label = tk.Label(self.add_client, text="Add New Client") self.add_client_label.pack(side="top") self.add_name_label = tk.Label(self.add_client, text="Name") self.add_name_label.pack() self.add_client_name = tk.Entry(self.add_client) self.add_client_name.pack() self.add_surname_label = tk.Label(self.add_client, text="Surname") self.add_surname_label.pack() self.add_client_surname = tk.Entry(self.add_client) self.add_client_surname.pack() self.add_email_label = tk.Label(self.add_client, text="Email") self.add_email_label.pack() self.add_client_email = tk.Entry(self.add_client) self.add_client_email.pack() self.add_contact_label = tk.Label(self.add_client, text="Contact Number") self.add_contact_label.pack() self.add_client_contact = tk.Entry(self.add_client) self.add_client_contact.pack() self.add_client_confirm = tk.Button(self.add_client, text="Confirm") self.add_client_confirm.bind("<Button>", self.add_new_client) self.add_client_confirm.pack(side="bottom") """REMOVE CLIENTS""" self.remove_client = tk.Frame(self, borderwidth=1, relief='ridge') self.remove_client.pack(side="right") self.remove_client_label = tk.Label(self.remove_client, text="Remove a Client") self.remove_client_label.pack(side="top") self.remove_name_label = tk.Label(self.remove_client, text="Name") self.remove_name_label.pack() self.remove_client_name = tk.Entry(self.remove_client) self.remove_client_name.pack() self.remove_surname_label = tk.Label(self.remove_client, text="Surname") self.remove_surname_label.pack() self.remove_client_surname = tk.Entry(self.remove_client) self.remove_client_surname.pack() self.remove_client_confirm = tk.Button(self.remove_client, text="Confirm") self.remove_client_confirm.bind("<Button>", self.remove_old_client) self.remove_client_confirm.pack(side="bottom") """RETURN TO MAIN MENU""" self.client_back = tk.Button(self, text="Return", fg="red") self.client_back.bind('<Button>', self.go_back) self.client_back.pack()
def display_load_template(self): self.clear_frame() self.create_widgets() self.loadtemplatebutton = tk.Button( self.master, text="Load template", width=35, command=self.load_template, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.loadtemplatebutton.grid(row=2, column=1, columnspan=2, sticky=tk.EW, padx=5, pady=5) self.radiolm1 = tk.Radiobutton( self.master, text="latest value", variable=self.__lm, value='l', bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.radiolm1.grid(row=3, column=1, sticky=tk.W) self.radiolm1.config(state='disabled') self.radiolm2 = tk.Radiobutton( self.master, text="mean value", variable=self.__lm, value='m', bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.radiolm2.grid(row=3, column=2, sticky=tk.W) self.radiolm2.config(state='disabled') self.findbutton = tk.Button(self.master, text="Make data file", width=35, command=self.make_datafile, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.findbutton.grid(row=4, column=1, columnspan=2, sticky=tk.EW, padx=5, pady=5) self.findbutton.config(state='disabled') self.savebutton = tk.Button(self.master, text="Save as CSV", width=35, command=self.write_csv, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.savebutton.grid(row=5, column=1, columnspan=2, sticky=tk.EW, padx=5, pady=5) self.savebutton.config(state='disabled')
def __init__(self, parent): self.root = parent self.root.title("Ekran Glowny") self.frame = tk.Frame(parent) self.frame.pack() self.root['bg'] = "#FCAFAF" self.root.protocol("WM_DELETE_WINDOW", self.root.quit()) def_font = tf.nametofont("TkDefaultFont") def_font.configure(family='Georgia') self.root.option_add("*Font",def_font) self.entryBoxList = {} self.found = ListItem self.templateStack = [] self.fromFileStack = [] self.dummyTemplate = ListItem('','','') self.actualDrawings = [] datafromfolder = readFolder() for source, name, time in datafromfolder: testowe = ListItem(name, time, source) self.templateStack.append(testowe) self.JinjaEnv = Environment( loader=FileSystemLoader('szablony'), autoescape=select_autoescape(['txt', 'xml']) ) #template = self.JinjaEnv.get_template('szablon.txt') #druk = template.render(imie="Jan",nazwisko="Kowalski") canvas = Canvas(self.frame, width=1300, height=900, bg="#FCAFAF") canvas.create_rectangle(492, 260, 1287, 884, fill="#ED6868") canvas.pack() def focus_next_widget(event): event.widget.tk_focusNext().focus() return("break") button1 = tk.Button( self.frame, text="Stwórz szablon", width=20, height=10, bg="#DCE19C", command=self.openFrame, takefocus=0 ) button1.pack() button1.place(y=44, x=79) myTip1 = Hovertip(button1,"Tutaj zacznij tworzenie nowego formularza od podstaw") button2 = tk.Button( self.frame, text="Wgraj z pliku", width=20, height=10, bg="#C0D9B7", takefocus=0, command=self.openFromFile, ) button2.pack() button2.place(y=44, x=279) myTip2 = Hovertip(button2,"Wgraj formularz znajdujacy sie poza folderem szablonow na liste") button3 = tk.Button( self.frame, text="Chmura szablonów", width=20, height=10, bg="#B2D4DC", takefocus=0 ) button3.pack() button3.place(y=44, x=479) myTip3 = Hovertip(button3,"Świat formularzy z internetu") self.textfield = tk.Text( self.frame, bg='white', ) #textfield.insert(INSERT, druk) self.textfield.pack() self.textfield.place(y=44, x=714, height=147, width=573) self.textfield.bind("<Tab>", focus_next_widget) self.textfield.bind("<Return>", lambda event : self.getTextEntry()) myTip4 = Hovertip(self.textfield,"Aby zaczac wpisz skrot formularza z listy po lewej") texfieldlabel = tk.Label( self.frame, text="Wpisz skroty szablonow/gotowy tekst", font=("Helvetica", 10), bg=self.root['bg'] ) texfieldlabel.pack() texfieldlabel.place(x=713, y=17, height=20, width=379) keyinfolabel = tk.Label( self.frame, text="Ctrl+s rozpocznij wypis | Ctrl+z zakoncz wypis | Ctrl+c do schowka", font=("Helvetica", 10), bg=self.root['bg'] ) keyinfolabel.pack() keyinfolabel.place(x=100, y=17, height=20, width=500) myTip5 = Hovertip(keyinfolabel,"Najwazniejsze skroty klawiszowe w programie") Xbutton = tk.Button( self.frame, text="X", width=4, height=2, bg="lightgrey", command=self.cleanTextfield, takefocus=0 ) Xbutton.pack() Xbutton.place(x=1250, y=7) myTip6 = Hovertip(Xbutton,"Wyczysc pole") self.tree = ttk.Treeview( self.frame, takefocus=1 ) self.tree["columns"] = ("COL2", "COL3") self.tree.column("#0", width=100) self.tree.heading("#0", text="Nazwa", anchor=tk.W) self.tree.column("COL2", width=100) self.tree.heading("COL2", text="Skrót", anchor=tk.W) self.tree.column("COL3", width=100) self.tree.heading("COL3", text="Data edycji", anchor=tk.W) number = 0 for testowe in self.templateStack: number += 1 self.tree.insert('', 'end', 'ID{0}'.format( number), text=testowe.name, values=(testowe.abbr, testowe.date)) self.tree.pack() self.tree.place(x=44, y=251, height=633, width=382) self.tree.bind('<ButtonRelease-1>', self.updateTextfieldFromClick) self.tree.bind('<Return>', self.updateTextfieldFromClick) try: child_id = self.tree.get_children()[0] except IndexError: self.tree.insert('', 'end', 'ID{0}'.format(number), text="Brak szablonow", values=("w folderze szablony", "00:00:00")) child_id = self.tree.get_children()[0] self.tree.focus_set() self.tree.focus(child_id) self.tree.selection_set(child_id) #myTip7 = Hovertip(tk.Widget,"Tutaj znajduja sie wszystkie formularze z katalogu szablony") treelabel = tk.Label( self.frame, text="Twoje szablony", font=("Helvetica", 10), bg=self.root['bg'] ) treelabel.pack() treelabel.place(x=20, y=222, height=20, width=150) editbutton = tk.Button( self.frame, text="Edytuj w edytorze", width=14, height=1, bg="#DCE19C", command=self.openFrameWithTmp, takefocus=0 ) editbutton.pack() editbutton.place(y=224, x=320) myTip8 = Hovertip(editbutton,"Użyj aby podejrzec zawartosc formularza lub wprowadzic w nim zmiany") savebutton = tk.Button( self.frame, text="Zapisz do pliku", width=14, height=1, bg="#C0D9B7", takefocus=0 ) savebutton.pack() savebutton.place(y=224, x=460) myTip9 = Hovertip(savebutton,"Eksportuj wszystkie formularze do archiwum") refreshbutton = tk.Button( self.frame, text="Odswiez", width=14, height=1, bg="#00ff00", command=self.refreshTmpList, takefocus=0 ) refreshbutton.pack() refreshbutton.place(y=224, x=180) myTip10 = Hovertip(refreshbutton,"Odśwież listę formularzy i wyczyść okno rysowania") self.startbutton = tk.Button( self.frame, text="Rozpocznij wypis", width=14, height=2, bg="lightgrey", activebackground='#00ff00', command=self.getTextEntry, takefocus=1 ) self.startbutton.pack() self.startbutton.place(x=840, y=201) self.startbutton.bind("<Return>", lambda event : self.getTextEntry()) myTip11 = Hovertip(self.startbutton,"Zacznij rysowanie formularza z pola powyzej") self.clipboardbutton = tk.Button( self.frame, text="Do schowka", width=14, height=2, bg="lightgrey", activebackground='#00ff00', command=self.copyToClipboard, takefocus=0 ) self.clipboardbutton.pack() self.clipboardbutton.place(x=998, y=201) myTip12 = Hovertip(self.clipboardbutton,"Skopiuj pole powyzej do systemowego schowka") exportbutton = tk.Button( self.frame, text="Eksport pdf/rtf", width=14, height=2, bg="lightgrey", takefocus=0, command=self.printPDF ) exportbutton.pack() exportbutton.place(x=1156, y=201) myTip13 = Hovertip(exportbutton,"Otworz powyższe w formie dokumentu tekstowego") progresslabel = tk.Label( self.frame, text="Pasek postępu", font=("Helvetica",12), bg=("#ED6868") ) progresslabel.pack() progresslabel.place(x=1020, y=850) self.endworkbutton = tk.Button( self.frame, text="Zakończ", width=10, height=2, bg="lightgrey", activebackground='#00ff00', command=self.readWork, takefocus=1 ) self.endworkbutton.pack() self.endworkbutton.place(x=1175, y=839) self.endworkbutton.bind("<Return>", lambda event : self.readWork()) myTip14 = Hovertip(self.endworkbutton,"Wygeneruj wydruk formularza z podanych zmiennych") self.root.bind("<Control-s>", lambda event, : self.getTextEntry()) self.root.bind("<Control-z>", lambda event, : self.readWork()) self.root.bind("<Control-c>", lambda event, : self.copyToClipboard())
label['text'] = 'Welcome!' # If reset is pressed while the stopwatch is running. else: label['text'] = 'Starting' root = Tkinter.Tk() root.title("Stopwatch") # Fixing the window size. root.minsize(width=250, height=70) label = Tkinter.Label(root, text="Welcome!", fg="black", font="Verdana 30 bold") label.pack() f = Tkinter.Frame(root) start = Tkinter.Button(f, text='Start', width=6, command=lambda: Start(label)) stop = Tkinter.Button(f, text='Stop', width=6, state='disabled', command=Stop) reset = Tkinter.Button(f, text='Reset', width=6, state='disabled', command=lambda: Reset(label)) f.pack(anchor='center', pady=5) start.pack(side="left") stop.pack(side="left") reset.pack(side="left") root.mainloop()
def display_select_measures(self): self.clear_frame() self.radio1 = tk.Radiobutton(self.master, text="From template", variable=self.__mode, value=1, command=self.display_load_template, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.radio1.grid(row=1, column=1, sticky=tk.W) self.radio2 = tk.Radiobutton(self.master, text="Choose measures", variable=self.__mode, value=2, command=self.display_select_measures, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.radio2.grid(row=1, column=3, sticky=tk.E) self.choosebutton = tk.Button(self.master, text="Choose measures", width=25, command=self.choose_measures, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.choosebutton.grid(row=2, column=1, columnspan=3, sticky=tk.EW, padx=5, pady=5) self.missinglabel = tk.Label(self.master, text="Max missing data (0-1):", bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.missinglabel.grid(row=3, column=1, columnspan=2, sticky=tk.W, padx=5, pady=5) self.missingentry = tk.Entry(self.master, width=8) self.missingentry.grid(row=3, column=3, sticky=tk.E, padx=5, pady=5) self.missingentry.insert(10, '0.2') self.radiolm1 = tk.Radiobutton( self.master, text="latest value", variable=self.__lm, value='l', bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.radiolm1.grid(row=4, column=1, sticky=tk.W) self.radiolm1.config(state='disabled') self.radiolm2 = tk.Radiobutton( self.master, text="mean value", variable=self.__lm, value='m', bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.radiolm2.grid(row=4, column=3, sticky=tk.E) self.radiolm2.config(state='disabled') self.nelephlabel = tk.Label(self.master, text=("-"), bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=2, highlightbackground=self.master.darkcolour, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.nelephlabel.grid(row=6, column=1, columnspan=3, sticky=tk.EW, padx=5, pady=5) self.findbutton = tk.Button(self.master, text="Make data file", width=25, command=self.make_datafile_from_gui, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.findbutton.grid(row=7, column=1, columnspan=3, sticky=tk.EW, padx=5, pady=5) self.findbutton.config(state='disabled') self.savebutton = tk.Button(self.master, text="Save as CSV", width=25, command=self.write_csv, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.savebutton.grid(row=8, column=1, columnspan=3, sticky=tk.EW, padx=5, pady=5) self.savebutton.config(state='disabled')
def call_record_func(): test_temp = 0 def confirm_from_date_func(): test_temp = 0 if (from_year_box.get()== '') or (from_month_box.get()=='') or (from_day_box.get()==''): test_temp = -1 if from_month_box.get() in the_thirties: if from_day_box.get() == '31': test_temp = -1 elif from_month_box.get() == 'Feb': if (int(from_year_box.get()) == 2100) or (int(from_year_box.get())%4 != 0): if int(from_day_box.get()) > 28: test_temp = -1 elif int(from_year_box.get())%4 == 0: if int(from_day_box.get()) > 29: test_temp = -1 return test_temp def confirm_to_date_func(): test_temp = 0 if (to_year_box.get()== '') or (to_month_box.get()=='') or (to_day_box.get()==''): test_temp = -1 if to_month_box.get() in the_thirties: if to_day_box.get() == '31': test_temp = -1 elif to_month_box.get() == 'Feb': if (int(to_year_box.get()) == 2100) or (int(to_year_box.get())%4 != 0): if int(to_day_box.get()) > 28: test_temp = -1 elif int(to_year_box.get())%4 == 0: if int(to_day_box.get()) > 29: test_temp = -1 return test_temp def confirm_period_func(): # 月份改數字 test_temp = 0 if int(from_year_box.get()) > int(to_year_box.get()): test_temp = -1 elif from_year_box.get() == to_year_box.get(): if month_list.index(from_month_box.get()) > month_list.index(to_month_box.get()): test_temp = -1 elif from_month_box.get() == to_month_box.get(): if int(from_day_box.get()) > int(to_day_box.get()): test_temp = -1 return test_temp def confirm_which_sort_func(): test_temp = 0 if which_sort_box.get() == '': test_temp = -1 return test_temp error = 0 # 檢測各項是否有效。若無效,按確認輸入不會收取值 error += confirm_from_date_func() error += confirm_to_date_func() error += confirm_period_func() error += confirm_which_sort_func() if error != 0: tkinter.messagebox.showinfo('錯誤','有什麼沒寫或寫錯囉!') else: from_month0 = str(month_list.index(from_month_box.get())+1) if month_list.index(from_month_box.get())+1 < 10: from_month0 = '0'+str(month_list.index(from_month_box.get())+1) from_day0 = from_day_box.get() if int(from_day_box.get()) < 10: from_day0 = '0'+from_day_box.get() to_month0 = str(month_list.index(to_month_box.get())+1) if month_list.index(to_month_box.get())+1 < 10: to_month0 = '0'+str(month_list.index(to_month_box.get())+1) to_day0 = to_day_box.get() if int(to_day_box.get()) < 10: to_day0 = '0'+to_day_box.get() selected_time1 = from_year_box.get()+'-'+from_month0+'-'+from_day0 selected_time2 = to_year_box.get()+'-'+to_month0+'-'+to_day0 selected_sort = which_sort_box.get() if selected_sort == '全部': result_list = func.all_entry_period(selected_time1, selected_time2) in_sum = func.income_period_sum(selected_time1, selected_time2) ex_sum = func.period_sum(selected_time1, selected_time2) all_sum = tk.Label(self, text='期間收入總額 = '+str(in_sum)+' 元、期間支出總額 = '+str(ex_sum)+' 元', font = SMALL_FONT, fg='Navy') all_sum.pack() if selected_sort == '收入': result_list = func.income_entry_period(selected_time1, selected_time2) money_sum = func.income_period_sum(selected_time1, selected_time2) tk.Label(self, text='').pack() all_sum = tk.Label(self, text=' 期間總收入:$'+str(money_sum)+' ', font=MEDIUM_FONT, fg='azure', bg='deep pink') all_sum.pack() tk.Label(self, text='').pack() if selected_sort == '支出': result_list = func.expense_entry_period(selected_time1, selected_time2) money_sum = func.period_sum(selected_time1, selected_time2) tk.Label(self, text='').pack() all_sum = tk.Label(self, text=' 期間總支出:$'+str(money_sum)+' ', font=MEDIUM_FONT, fg='azure', bg='deep pink') all_sum.pack() tk.Label(self, text='').pack() record_list = ttk.Treeview(self) record_list['columns'] = ['日期','收/支','金額','類別','子類別','飲食類別','方式','備註'] record_list.heading('日期', text='日期') record_list.heading('收/支', text='收/支') record_list.heading('金額', text='金額') record_list.heading('類別', text='類別') record_list.heading('子類別', text='子類別') record_list.heading('飲食類別', text='飲食類別') record_list.heading('方式', text='方式') record_list.heading('備註', text='備註') for i in range(len(result_list)): record_list.insert('', i, text=str(i+1), values=tuple(result_list[i])) record_list.pack(padx=30) def close_record_func(): record_list.destroy() all_sum.pack_forget() close_record_button = tk.Button(self, text='關閉此筆紀錄', font=SMALLER_FONT,command=lambda:[close_record_func(),enable()]) close_record_button.place(x=30,y=200) if selected_sort == '收入': colors = ['gold', 'yellowgreen', 'lightcoral'] in_percent_match = func.MainCat_income_pie(selected_time1, selected_time2, in_sort_number_list) in_percent = [] for i in in_percent_match: in_percent += [i[1]] pyplot.rcParams['font.sans-serif'] = ['SimHei'] pyplot.pie(in_percent, labels=in_sort_english, colors=colors, autopct = '%1.1f%%', startangle=0) pyplot.title('INCOME') pyplot.show() elif selected_sort == '支出': colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue', 'lavender', 'orange', 'Navy', 'yellow'] ex_percent_match = func.MainCat_expense_pie(selected_time1, selected_time2, out_sort_number_list) ex_percent = [] out_labels = [] for i in ex_percent_match: ex_percent += [i[1]] out_labels += [i[0]] pyplot.rcParams['font.sans-serif'] = ['SimHei'] pyplot.pie(ex_percent, labels=out_labels, colors=colors, autopct = '%1.1f%%', startangle=0) pyplot.title('EXPENSE') pyplot.show()
def __init__(self, parent, root): super().__init__(parent) label = tk.Label(self, text='好好犒賞自己吧!', font=LARGE_FONT) label.pack(pady=20) def call_reward_func(): if reward_month_box.get()=='' or reward_year_box.get()=='': tkinter.messagebox.showinfo('錯誤','有什麼沒寫或寫錯囉!') else: budget, paid, percentage, overbudget = func.check_budget(int(reward_year_box.get()), month_list.index(reward_month_box.get())+1) diff = budget - paid restaurant_id = func.highest_cuisine() recommend = db.Recommendation() restaurant = recommend.get_restaurants(restaurant_id) congrats1 = tk.Label(self, text=f'這個月總花費:${paid} / 設定的預算:${budget}', font=SMALL_FONT, fg='DeepSkyBlue4') congrats1.pack() congrats6 = tk.Label(self, text=f'花費佔預算的{percentage}', font=MEDIUM_FONT, fg='cyan4') congrats6.pack() if overbudget == True : congrats2 = tk.Label(self, text='哎呀,超過預算了 '+str(-diff)+' 元', font=CONGRATS_FONT, fg='OrangeRed3') congrats2.pack() elif overbudget == False : congrats2 = tk.Label(self, text='還剩 '+str(diff)+' 元', font=LARGE_FONT, fg='PaleGreen4') congrats2.pack() space9 = tk.Label(self, text='') space9.pack() msg = f'根據您的用餐習慣,我們發現你最愛「{out_sort_match[restaurant_id-1][1]}」。\n\n因此我們推薦以下餐廳:\n' recommend = tk.Label(self,text=msg, font=SMALL_FONT, fg='DodgerBlue4') recommend.pack() recommend_list = ttk.Treeview(self) recommend_list['columns'] = ('推薦餐廳','評分','價格指數','Google Plus地址') recommend_list.heading('推薦餐廳', text='推薦餐廳') recommend_list.heading('評分', text='評價') recommend_list.heading('價格指數', text='價格') recommend_list.heading('Google Plus地址', text='Google Plus地址') for i in range(len(restaurant)): val = [] # '貳房 頂級鍋物', 4.93, 0, '4GP2+XQ 北投區 台北市', '火鍋' s = restaurant[i] p_dict = {0:'無資料', 1:'$', 2:'$$', 3:'$$$', 4:'$$$$'} name, score, price, geo = s[0], round(s[1],2), p_dict[s[2]], s[3] val = [name,score,price,geo] recommend_list.insert('', i, text=f'{i+1}', values=(val)) recommend_list.pack(padx=30) def close_reward_func(): congrats1.destroy() congrats2.destroy() congrats6.destroy() if overbudget == False: space9.destroy() recommend.destroy() recommend_list.destroy() close_reward_button = tk.Button(self, text='關閉此筆紀錄', font=SMALLER_FONT,command=lambda:[close_reward_func(),enable(call_reward_button)]) close_reward_button.place(x=40, y=300) # 選擇月份 reward = tk.Label(self, text='選擇月份(年月):', font=SMALL_FONT) reward.pack() reward_year_box = ttk.Combobox(self) reward_year_box['values']=tuple(year_list) reward_year_box.pack() reward_month_box = ttk.Combobox(self) reward_month_box['values'] = tuple(month_list) reward_month_box.pack() call_reward_button = tk.Button(self, text='恭喜!', font=SMALL_FONT, command=lambda:[call_reward_func(),disable(call_reward_button)]) call_reward_button.pack() def disable(bt): bt.config(state='disabled') def enable(bt): bt.config(state='normal') back = tk.Button(self, text='返回', font=SMALL_FONT, command=lambda: root.show_frame(StartPage)).place(x=40,y=590)
frame_sessions.pack(fill=tk.Y, side=tk.LEFT) #Creates a list of frame_sessions so that each session has its own options show_sessions = [] for i in sessions: show_sessions.append(makeform(frame_sessions, i)) ##rules frame_event_rules = tk.Frame(root, relief=tk.RAISED, borderwidth=1) frame_event_rules.pack(fill=tk.Y, side=tk.LEFT) show_event_rules = makeform(frame_event_rules, event_rules_fields) #Save, load, run, submit buttons frame_buttons = tk.Frame(root, relief=tk.RAISED, borderwidth=1) frame_buttons.pack(side=tk.BOTTOM) submit_Button = tk.Button(frame_buttons, text='Save Settings', command=WriteJson) #change name run_Button = tk.Button(frame_buttons, text='Run accServer', command=RunaccServer) load_Button = tk.Button(frame_buttons, text='Load config') save_Button = tk.Button(frame_buttons, text='Save config') submit_Button.pack(side=tk.RIGHT) run_Button.pack(side=tk.RIGHT) load_Button.pack(side=tk.RIGHT) save_Button.pack(side=tk.RIGHT) #each frame becomes a tab tab_main.add(frame_settings, text="settings") tab_main.add(frame_assists, text="assists") tab_main.add(frame_event, text="events")
def __init__(self, parent, root): super().__init__(parent) topic = tk.Label(self, text='輸入收支', font=LARGE_FONT) topic.pack(pady=20) # 上下留空間 # 日期 date_topic = tk.Label(self, text='*選擇日期(年月日):', font=SMALL_FONT).pack() year_box = ttk.Combobox(self) year_box['values'] = tuple(year_list) year_box.pack() month_box = ttk.Combobox(self) month_box['values'] = tuple(month_list) month_box.pack() day_box = ttk.Combobox(self) day_box['values'] = tuple(day_list) day_box.pack() # 收或支多少、取得類別(有互動) space1 = tk.Label(self, text='').pack() money_topic = tk.Label(self, text='*金額:', font=SMALL_FONT).pack() radioValue = tk.IntVar() income_box = tk.Radiobutton(self, text='收入', font=SMALLER_FONT, variable=radioValue, value=0).pack() expense_box = tk.Radiobutton(self, text='支出', font=SMALLER_FONT, variable=radioValue, value=1).pack() amount_var = tk.StringVar() amount_box = tk.Entry(self, textvariable=amount_var, bd=1).pack() # bd = 邊框 # 類別 space2 = tk.Label(self, text='').pack() sort_topic = tk.Label(self, text='*主分類:', font=SMALL_FONT).pack() sort_box = ttk.Combobox(self) sort_box['values'] = tuple(sort) sort_box.pack() #子類別 space13 = tk.Label(self, text='').pack() small_sort_topic = tk.Label(self, text='*子分類:', font = SMALL_FONT).pack() small_sort_box = ttk.Combobox(self) small_sort_box['values'] = tuple(small_sort) small_sort_box.pack() # 飲食類別 space12 = tk.Label(self, text='').pack() food_topic = tk.Label(self, text='飲食類別:', font=SMALL_FONT).pack() food_box = ttk.Combobox(self) food_box['values'] = tuple(food_list) food_box.pack() # 金融方式 space3 = tk.Label(self, text='').pack() way_topic = tk.Label(self, text='*方式:', font=SMALL_FONT).pack() way_box = ttk.Combobox(self) way_box['values'] = tuple(way_list) way_box.pack() # 備註 space4 = tk.Label(self, text='').pack() btw_topic = tk.Label(self, text='備註:', font=SMALL_FONT).pack() btw_var = tk.StringVar() btw = tk.Entry(self, textvariable=btw_var, bd=1).pack() def confirm_everything_func(): # =0:正確、=-1:錯誤 def confirm_date_func(): test_temp = 0 if (year_box.get()== '') or (month_box.get()=='') or (day_box.get()==''): test_temp = -1 if month_box.get() in the_thirties: if day_box.get() == '31': test_temp = -1 elif month_box.get() == 'Feb': if (int(year_box.get()) == 2100) or (int(year_box.get())%4 != 0): if int(day_box.get()) > 28: test_temp = -1 elif int(year_box.get())%4 == 0: if int(day_box.get()) > 29: test_temp = -1 return test_temp def confirm_amount_func(): test_temp = 0 if (amount_var.get()).isdigit() == False: test_temp = -1 elif int(amount_var.get()) <= 0: test_temp = -1 return test_temp def confirm_sort_func(): test_temp = 0 if sort_box.get() == '': test_temp = -1 if sort_box.get() == '-----------收入-----------': test_temp = -1 if sort_box.get() == '-----------支出-----------': test_temp = -1 return test_temp def confirm_small_sort_func(): test_temp = 0 if radioValue.get() == 0 and small_sort_box.get() != '收入': test_temp = -1 if small_sort_box.get() == '--------------------------': test_temp = -1 if (sort_box.get() in out_sort) and (small_sort_box.get() not in sort_dict_simple[sort_box.get()]): test_temp = -1 return test_temp def confirm_food_func(): test_temp = 0 if (sort_box.get() == '食品酒水') and (food_box.get() == ''): test_temp = -1 elif (sort_box.get() != '食品酒水') and (food_box.get() != '無 / 不適用'): test_temp = -1 return test_temp def confirm_inex_sort_match_func(): test_temp = 0 if radioValue.get() == 0: if sort_box.get() not in in_sort: test_temp = -1 if radioValue.get() == 1: if sort_box.get() not in out_sort: test_temp = -1 return test_temp def confirm_way_func(): test_temp = 0 if way_box.get() == '': test_temp = -1 return test_temp error = 0 # 檢測各項是否有效。若無效,按確認輸入不會收取值 error += confirm_date_func() error += confirm_amount_func() error += confirm_sort_func() error += confirm_small_sort_func() error += confirm_food_func() error += confirm_inex_sort_match_func() error += confirm_way_func() if error != 0: tkinter.messagebox.showinfo('錯誤','有什麼沒寫或寫錯囉!') elif error ==0: tkinter.messagebox.showinfo('已輸入','已輸入') in_ex = '' if radioValue.get() == 0: in_ex = 'Income' elif radioValue.get() == 1: in_ex = 'Expense' if food_box.get() == '無 / 不適用': food_number = 16 else: food_number = pure_food_number_list[pure_food_list.index(food_box.get())] if month_list.index(month_box.get())+1<10 and int(day_box.get())<10: date_str = year_box.get()+'-0'+str(month_list.index(month_box.get())+1)+'-0'+day_box.get() elif month_list.index(month_box.get())+1<10 and int(day_box.get())>=10: date_str = year_box.get()+'-0'+str(month_list.index(month_box.get())+1)+'-'+day_box.get() elif month_list.index(month_box.get())+1>=10 and int(day_box.get())<10: date_str = year_box.get()+'-'+str(month_list.index(month_box.get())+1)+'-0'+day_box.get() elif month_list.index(month_box.get())+1>=10 and int(day_box.get())>=10: date_str = year_box.get()+'-'+str(month_list.index(month_box.get())+1)+'-'+day_box.get() way_number = way_number_list[way_list.index(way_box.get())] if small_sort_box.get() == '收入': small_or_in_sort_number = in_sort_number_list[in_sort.index(sort_box.get())] else: small_or_in_sort_number = pure_small_sort_number[pure_small_sort.index(small_sort_box.get())] r = [in_ex, btw_var.get(), food_number, date_str, int(amount_var.get()),way_number, small_or_in_sort_number] store = db.Entry() timenow = dt.strptime(dt.now().isoformat(), '%Y-%m-%dT%H:%M:%S.%f') # YYYY-MM-DD HH:MM:SS.SSS in_ex, description, cui_id, ymd, price, method, id = r[0], r[1], r[2], r[3], r[4], r[5], r[6] store.add_entry(in_ex, description, cui_id, ymd, price, method, timenow, id) # 完成 space5 = tk.Label(self, text='').pack() confirm_everything_button = tk.Button(self, text='確認輸入', font=SMALL_FONT, fg='red', command=confirm_everything_func).pack() back = tk.Button(self, text='返回', font=SMALL_FONT, command=lambda: root.show_frame(StartPage)).place(x=40,y=590)
with open(os.path.join(folder_selected, filename), 'w') as fp: json.dump(model, fp, indent=4, sort_keys=True) #------------------------------------------------------------------------- messagebox.showinfo('', 'Success!') #------------------------ btn_download.configure(text="Run", bg="#02B844") btn_download = tk.Button(viewer2, text="Download", bg="#02B844", fg="black", height=1, width=10, command=download_button) btn_download.pack(side="right", fill=None, expand=False) btn_download_help = CreateToolTip(btn_download, 'Select an organism to download the model') #-------------------------------- #========================= # LOAD MODEL #========================= def load_model():
def __init__(self): # TOPLEVEL STUFF------------------------------------------------------- # Initialize main window self.main_window = tkinter.Tk() self.main_window.geometry("600x470") # Window title self.main_window.title("Healthy Beaches Tidal Analysis Program") # FRAME DESIGN--------------------------------------------------------- # Main frames self.top_frame = tkinter.Frame(self.main_window, borderwidth=2, relief="groove") self.date_frame = tkinter.Frame(self.main_window, borderwidth=2, relief="groove") self.show_date_frame = tkinter.Frame(self.date_frame, borderwidth=2, relief="groove") self.data_entry_frame = tkinter.Frame(self.main_window, borderwidth=2, relief="groove") self.button_frame = tkinter.Frame(self.main_window, borderwidth=2, relief="groove") # Data entry sub-frames self.entry_label_frame = tkinter.Frame(self.data_entry_frame, borderwidth=2, relief="groove") self.entry_frame = tkinter.Frame(self.data_entry_frame, borderwidth=2, relief="groove") # WIDGETS-------------------------------------------------------------- # Frame labels self.top_label = tkinter.Label(self.top_frame, text="Welcome to the Healthy Beaches tidal analysis program. \nPlease complete the form entirely and click Analyze Tides.", relief="groove") self.date_label = tkinter.Label(self.date_frame, text="Enter date of sample collection", relief="groove") self.show_date_label = tkinter.Label(self.show_date_frame, relief="groove", wraplength=120) self.entry_label = tkinter.Label(self.entry_frame, text="Enter sample times for each location using HHMM notation", relief="groove") self.header_location = tkinter.Label(self.entry_frame, text="Sample Location", relief="groove", anchor="w") self.header_time = tkinter.Label(self.entry_frame, text="Sample Time", relief="groove", anchor="w") self.header_result = tkinter.Label(self.entry_frame, text="Tidal Period", relief="groove", anchor="w") # Date frame self.month = tkinter.Label(self.date_frame, text="Month") self.day = tkinter.Label(self.date_frame, text="Day") self.year = tkinter.Label(self.date_frame, text="Year") self.month_entry = tkinter.Entry(self.date_frame, width=2) self.day_entry = tkinter.Entry(self.date_frame, width=2) self.year_entry = tkinter.Entry(self.date_frame, width=4) # Sample entry frame self.BahiaMar = tkinter.Label(self.entry_frame, text="Bahia Mar", relief="groove", anchor="w") self.Sebastian = tkinter.Label(self.entry_frame, text="Sebastian St", relief="groove", anchor="w") self.HughTaylor = tkinter.Label(self.entry_frame, text="Hugh Taylor Birch", relief="groove", anchor="w") self.Commercial = tkinter.Label(self.entry_frame, text="Commercial Pier", relief="groove", anchor="w") self.Pompano = tkinter.Label(self.entry_frame, text="Pompano Pier", relief="groove", anchor="w") self.NE16 = tkinter.Label(self.entry_frame, text="NE 16 St", relief="groove", anchor="w") self.Deerfield = tkinter.Label(self.entry_frame, text="Deerfield Pier", relief="groove", anchor="w") self.Hallandale = tkinter.Label(self.entry_frame, text="Hallandale Beach", relief="groove", anchor="w") self.Harrison = tkinter.Label(self.entry_frame, text="Harrison St", relief="groove", anchor="w") self.Minnesota = tkinter.Label(self.entry_frame, text="Minnesota St", relief="groove", anchor="w") self.Custer = tkinter.Label(self.entry_frame, text="Custer St", relief="groove", anchor="w") self.Dania = tkinter.Label(self.entry_frame, text="Dania Pier", relief="groove", anchor="w") self.JohnLloyd = tkinter.Label(self.entry_frame, text="John U Lloyd", relief="groove", anchor="w") self.entryBahiaMar = tkinter.Entry(self.entry_frame, width=6) self.entrySebastian = tkinter.Entry(self.entry_frame, width=6) self.entryHughTaylor = tkinter.Entry(self.entry_frame, width=6) self.entryCommercial = tkinter.Entry(self.entry_frame, width=6) self.entryPompano = tkinter.Entry(self.entry_frame, width=6) self.entryNE16 = tkinter.Entry(self.entry_frame, width=6) self.entryDeerfield = tkinter.Entry(self.entry_frame, width=6) self.entryHallandale = tkinter.Entry(self.entry_frame, width=6) self.entryHarrison = tkinter.Entry(self.entry_frame, width=6) self.entryMinnesota = tkinter.Entry(self.entry_frame, width=6) self.entryCuster = tkinter.Entry(self.entry_frame, width=6) self.entryDania = tkinter.Entry(self.entry_frame, width=6) self.entryJohnLloyd = tkinter.Entry(self.entry_frame, width=6) self.resultBahiaMar = tkinter.Label(self.entry_frame) self.resultSebastian = tkinter.Label(self.entry_frame) self.resultHughTaylor = tkinter.Label(self.entry_frame) self.resultCommercial = tkinter.Label(self.entry_frame) self.resultPompano = tkinter.Label(self.entry_frame) self.resultNE16 = tkinter.Label(self.entry_frame) self.resultDeerfield = tkinter.Label(self.entry_frame) self.resultHallandale = tkinter.Label(self.entry_frame) self.resultHarrison = tkinter.Label(self.entry_frame) self.resultMinnesota = tkinter.Label(self.entry_frame) self.resultCuster = tkinter.Label(self.entry_frame) self.resultDania = tkinter.Label(self.entry_frame) self.resultJohnLloyd = tkinter.Label(self.entry_frame) #self.sampleTimesColumn = [self.entryBahiaMar, self.entrySebastian, self.entryHughTaylor, self.entryCommercial, self.entryPompano, self.entryNE16, self.entryDeerfield, self.entryHallandale, self.entryHarrison, self.entryMinnesota, self.entryCuster, self.entryDania, self.entryJohnLloyd] # Button frame self.findTides_button = tkinter.Button(self.button_frame, text="Analyze Tides", relief="raised", command=self.analyzeTides) self.reset_button = tkinter.Button(self.button_frame, text="Reset", relief="raised", command=self.reset) # GEOMETRY MANAGEMENT-------------------------------------------------- # Main frames self.top_frame.grid(column=0, row=0, sticky="w") self.date_frame.grid(column=0, row=1, sticky="w") self.data_entry_frame.grid(column=0, row=2, sticky="w") self.button_frame.grid(column=0, row=3, sticky="w") # Date frame self.date_label.grid(column=0, row=0, sticky="nw", columnspan=6) self.month.grid(column=0, row=1, sticky="e") self.month_entry.grid(column=1, row=1) self.day.grid(column=2, row=1, sticky="e") self.day_entry.grid(column=3, row=1) self.year.grid(column=4, row=1, sticky="e") self.year_entry.grid(column=5, row=1) self.show_date_label.grid(column=6, row=0) self.show_date_frame.grid(column=7, row=0, sticky="nw", padx=(10,0)) # Sample entry frame self.entry_label.grid(column=0, row=0, sticky="ew", columnspan=3) self.entry_frame.grid(column=0, row=1, sticky="w") self.header_location.grid(column=0, row=1, sticky="ew") self.header_time.grid(column=1, row=1, sticky="ew") self.header_result.grid(column=2, row=1, sticky="ew") self.BahiaMar.grid(column=0, row=2, sticky="ew") self.Sebastian.grid(column=0, row=3, sticky="ew") self.HughTaylor.grid(column=0, row=4, sticky="ew") self.Commercial.grid(column=0, row=5, sticky="ew") self.Pompano.grid(column=0, row=6, sticky="ew") self.NE16.grid(column=0, row=7, sticky="ew") self.Deerfield.grid(column=0, row=8, sticky="ew") self.Hallandale.grid(column=0, row=9, sticky="ew") self.Harrison.grid(column=0, row=10, sticky="ew") self.Minnesota.grid(column=0, row=11, sticky="ew") self.Custer.grid(column=0, row=12, sticky="ew") self.Dania.grid(column=0, row=13, sticky="ew") self.JohnLloyd.grid(column=0, row=14, sticky="ew") self.entryBahiaMar.grid(column=1, row=2, sticky="ew") self.entrySebastian.grid(column=1, row=3, sticky="ew") self.entryHughTaylor.grid(column=1, row=4, sticky="ew") self.entryCommercial.grid(column=1, row=5, sticky="ew") self.entryPompano.grid(column=1, row=6, sticky="ew") self.entryNE16.grid(column=1, row=7, sticky="ew") self.entryDeerfield.grid(column=1, row=8, sticky="ew") self.entryHallandale.grid(column=1, row=9, sticky="ew") self.entryHarrison.grid(column=1, row=10, sticky="ew") self.entryMinnesota.grid(column=1, row=11, sticky="ew") self.entryCuster.grid(column=1, row=12, sticky="ew") self.entryDania.grid(column=1, row=13, sticky="ew") self.entryJohnLloyd.grid(column=1, row=14, sticky="ew") self.resultBahiaMar.grid(column=2, row=2, sticky="w") self.resultSebastian.grid(column=2, row=3, sticky="w") self.resultHughTaylor.grid(column=2, row=4, sticky="w") self.resultCommercial.grid(column=2, row=5, sticky="w") self.resultPompano.grid(column=2, row=6, sticky="w") self.resultNE16.grid(column=2, row=7, sticky="w") self.resultDeerfield.grid(column=2, row=8, sticky="w") self.resultHallandale.grid(column=2, row=9, sticky="w") self.resultHarrison.grid(column=2, row=10, sticky="w") self.resultMinnesota.grid(column=2, row=11, sticky="w") self.resultCuster.grid(column=2, row=12, sticky="w") self.resultDania.grid(column=2, row=13, sticky="w") self.resultJohnLloyd.grid(column=2, row=14, sticky="w") # Button frame self.findTides_button.grid(column=0, row=0, sticky="ew", ipadx=(50)) self.reset_button.grid(column=1, row=0, sticky="ew", ipadx=(50)) # PACKING WIDGETS------------------------------------------------------ # Packing not needed for frames managed with geometry manager self.top_label.pack() # Mainloop tkinter.mainloop()
def init_window(self): self.master.title("T79 Configuration App") self.grid() # Set up the Entry widgets for each network parameter: for ind, (key, param) in enumerate(self.params.items()): self.param_labels[param[0]] = tk.Label(self, text=param[1]) self.param_labels[param[0]].grid(row=ind, column=0) self.param_var[param[0]] = tk.StringVar(self) self.param_var[param[0]].set(param[2][param[2].index(param[3])]) self.param_entry[param[0]] = tk.OptionMenu( self, self.param_var[param[0]], *param[2]) self.param_entry[param[0]].grid(row=ind, column=1, columnspan=ENTRY_COLSPAN) self.param_entry[param[0]].config(state=tk.DISABLED) # Set the Radar CAN Interface entry widget to ENABLED and give it focus: self.param_entry["can_interface"].config(state=tk.NORMAL, fg="black") self.param_entry["can_interface"].focus_set() # Connect Button: self.connect_button = tk.Button(self, text="CONNECT", command=self.connect_to_radar) self.connect_button.grid(row=4, column=0) # Send Configuration Button: self.send_config_button = tk.Button(self, text="CONFIGURE", command=self.send_config_to_radar) self.send_config_button.grid(row=4, column=1) self.send_config_button.config(state=tk.DISABLED) # Start Radar Button: self.start_radar_button = tk.Button(self, text="START", command=self.start_radar) self.start_radar_button.grid(row=4, column=2) self.start_radar_button.config(state=tk.DISABLED) # Run Radar Button: self.stop_radar_button = tk.Button(self, text="STOP", command=self.stop_radar) self.stop_radar_button.grid(row=4, column=3) self.stop_radar_button.config(state=tk.DISABLED) # Display for output: self.text_display = tk.Text(self, width=65, height=10) self.text_display.grid(row=0, column=4, rowspan=5) self.update_text_display_newline( "Please enter the radar socketCAN interface name (for example, can0) and press CONNECT." ) # Scrollbar for display text: self.scrollbar_display = tk.Scrollbar(self, command=self.text_display.yview) self.scrollbar_display.grid(row=0, column=5, rowspan=5) self.text_display['yscrollcommand'] = self.scrollbar_display.set
img1 = ImageTk.PhotoImage(img1) # 表示するイメージを用意 #PILでjpgを使用 img1 = Image.open(open('1.jpg', 'rb')) img1.thumbnail((500, 500), Image.ANTIALIAS) img1 = ImageTk.PhotoImage(img1) # 表示するイメージを用意 canvas1 = tk.Canvas( root, # 親要素をメインウィンドウに設定 width=500, # 幅を設定 height=500 # 高さを設定 #relief=tk.RIDGE # 枠線を表示 # 枠線の幅を設定 ) canvas1.place(x=0, y=0) # メインウィンドウ上に配置 canvas1.create_image( # キャンバス上にイメージを配置 0, # x座標 0, # y座標 image=img1, # 配置するイメージオブジェクトを指定 tag="illust", # タグで引数を追加する。 anchor=tk.NW # 配置の起点となる位置を左上隅に指定 ) # Buttonを設置してみる Button1 = tk.Button(text=u'何も起こらないボタン') Button1.pack() # Buttonを設置してみる Button2 = tk.Button(text=u'消すボタン', ) Button2.bind("<Button-1>", deleteEntry) # ボタンが押されたときに実行される関数をバインドします Button2.pack() root.mainloop()
stat_column = self.column status_update(stat_txt, stat_row, stat_column, self.person) self.btn = tk.Button(master, text = txt1, bd = '5', command = first) self.btn.grid(row=1, column=1, columnspan=1) self.btn2 = tk.Button(master, text = txt2, bd = '5', command = second) self.btn2.grid(row=1, column=2, columnspan=1) def status_update(txt, row, column, p): set_text(txt, str(row), str(column)) if txt == 'SEND HELP': trigger = tk.Tk() Alert(trigger, 'ALERT: Help Requested', 'ALERT', 'STATUS', column, p) elif txt == 'ANALYZE': trigger = tk.Tk() Alert(trigger, 'Analyzing: ' + p.name + ' has had the following interactions to consider, in' + ' the form of [Name, Location, First Timestamp, Last Timestamp, Number Interactions]: ' + '\n' + str(p.interactions[1:]), 'WARN', 'STATUS', p.rank, p) + '\n' + '' return 'ANALYZE' dict['NAME1'].focus() btn = tk.Button(root, text='ALERT!', bd='5', command=inject) btn.grid(row=num + 1, column=3, columnspan=1) btn2 = tk.Button(root, text='FEVER!', bd='5', command=scare) btn2.grid(row=num + 1, column=2, columnspan=1) root.after(1000, simulate) root.mainloop()
tkinter.Label(card_frame, textvariable=dealer_score_label, background="green", fg="white").grid(row=1, column=0) # embeded frame to hold the card images. dealer_card_frame = tkinter.Frame(card_frame, background="green") dealer_card_frame.grid(row=0, column=1, stick="ew", rowspan=2) player_score_label = tkinter.IntVar() tkinter.Label(card_frame, text="Player", background="green", fg="white").grid(row=2, column=0) tkinter.Label(card_frame, textvariable=player_score_label, background="green", fg="white").grid(row=3, column=0) # emebeded frame to hold the card images player_card_frame = tkinter.Frame(card_frame, background="green") player_card_frame.grid(row=2, column=1, sticky="ew", rowspan=2) button_frame = tkinter.Frame(mainWindow) button_frame.grid(row=3, column=0, columnspan=3, sticky="w") dealer_button = tkinter.Button(button_frame, text="Dealer", command=deal_dealer) dealer_button.grid(row=0, column=0) player_button = tkinter.Button(button_frame, text="Player", command=deal_player) player_button.grid(row=0, column=1) # load cards cards = [] load_images(cards) print(cards) # Create a new Deck of cards and shuffle them. deck = list(cards) random.shuffle(deck) # Create the list to store dealers and players hands. dealer_hand = []
#create monitor text number_monitor = tk.Text(root, width=25, height=5, bg='black', fg='white', relief='ridge', bd=20) number_monitor.grid(row=0, column=0, columnspan=6) #create butttons btn_clear = tk.Button(root, text='C', width=2, height=1, font=('Tahoma', '18'), bg='#10100F', fg='red', command=lambda: number_clear()) btn_clear.grid(row=1, column=0) btn_jam = tk.Button(root, text='+', width=2, height=1, font=('Tahoma', '18'), bg='#10100F', fg='red', command=lambda: jam_numbers()) btn_jam.grid(row=1, column=1)
def config(self): Config = tk.LabelFrame(self.window, text="配置", padx=25, pady=2) # 水平,垂直方向上的边距均为 10 Config.place(x=3, y=100) tk.Label(Config, text="解析域名:").grid(column=0, row=0, sticky='w', pady=2) # tk.Label(Config, text="解析次数:").grid(column=0, row=1, sticky='w', pady=2) # tk.Label(Config, text="爬取线程:").grid(column=0, row=2, sticky='w', pady=2) # tk.Label(Config, text="爬取频率/s:").grid(column=0, row=3, sticky='w', pady=2) # 添加波特率标签 tk.Label(Config, text="保存路径:").grid(column=0, row=4, sticky='w', pady=2) # 添加波特率标签 with open(os.path.join(self.base_path, 'config.ini'), 'r+') as f: # 读取配置信息 config = eval(f.read()) self.domainVar.set(config.get('domain', 'https://www.baidu.com/')) self.spidermunVar.set(config.get('spidernum', 1000)) self.threadnumVar.set(config.get('threadnum', 30)) self.timeVar.set(config.get('timenum', 0)) self.save_pathVar.set( config.get('path', os.path.join(self.base_path, 'title'))) # 自定义配置信息 self.domainEntry = tk.Entry(Config, textvariable=self.domainVar, width=22) self.domainEntry.grid(column=1, row=0, pady=2) self.spider_numEntry = tk.Entry(Config, textvariable=self.spidermunVar, width=22) self.spider_numEntry.grid(column=1, row=1, pady=2) self.threadEntry = tk.Entry(Config, textvariable=self.threadnumVar, width=22) self.threadEntry.grid(column=1, row=2, pady=2) self.timeEntry = tk.Entry(Config, textvariable=self.timeVar, width=22) self.timeEntry.grid(column=1, row=3, pady=2) self.pathEntry = tk.Entry(Config, textvariable=self.save_pathVar, width=22) self.pathEntry.grid(column=1, row=4, pady=2) self.pathBtn = tk.Button(Config, text="选择路径", command=self.check_path) self.pathBtn.grid(column=2, row=4, pady=2, ipadx=15, padx=10) self.config_queue.put(config) Config_start = tk.LabelFrame(self.window, text="操作", padx=10, pady=2) # 水平,垂直方向上的边距均为 10 Config_start.place(x=3, y=275) tk.Button(Config_start, text="更新配置", command=self.updata_config).grid(column=0, row=0, pady=2, ipadx=40, padx=15) self.startBtn = tk.Button(Config_start, text="开始采集", command=self.start_spider) self.startBtn.grid(column=0, row=1, pady=2, ipadx=40, padx=22) self.stopBtn = tk.Button(Config_start, text="暂停采集", command=self.stop_spider) self.stopBtn.config(state=tk.DISABLED) self.stopBtn.grid(column=1, row=1, pady=2, ipadx=40, padx=22)
def __init__(self, window, mmc): self.window = window self.window.title("Live Camera") self.window.protocol('WM_DELETE_WINDOW', self.delete) self.last_channel = '' self.mmc = mmc row_col_config(self.window, 4, 4) self.Options = tk.Frame(self.window) self.Options.grid(row=0, column=0, rowspan=4, columnspan=1, sticky=tk.W + tk.E + tk.N + tk.S) # Base the number of items in the Options frame on how many # LED configurations exist self.led_intensities = read_yaml(LED_YAML_PATH) row_col_config(self.Options, len(self.led_intensities.keys()) + 10, 2) tk.Label(self.Options, text="Settings").grid(row=0, column=0, columnspan=2) self.channel = tk.StringVar() self.channels = {} self.exposures = {} for i, (key, val) in enumerate(self.led_intensities.items()): self.channels[key] = tk.Radiobutton(self.Options, text=key, variable=self.channel, value=key) self.channels[key].grid(row=i + 3, column=0) if key == 'BFF': self.channels[key].select() for i, (k, v) in enumerate(self.channels.items()): self.exposures[k] = tk.StringVar(self.Options, value=get_default(k)) tk.Entry(self.Options, textvariable=self.exposures[k]).grid(row=i + 3, column=1, sticky='EW') self.Image = tk.Frame(self.window) self.Image.grid(row=0, column=1, rowspan=4, columnspan=3, sticky=tk.W + tk.E + tk.N + tk.S) # row_col_config(self.Image, 9, 2) # Camera Scale self.scale = 3 self.dim = tuple( (np.asarray(sc_utils.get_frame_size()) / self.scale).astype(int)) # self.dim = (int(self.width / self.scale), int(self.height / self.scale)) self.vid = VideoCapture(mmc) self.canvas = tk.Canvas(self.Image, width=self.dim[0], height=self.dim[1]) self.canvas.grid() # Button that lets the user take a snapshot self.btn_snapshot = tk.Button(self.Options, text="Snapshot", width=50, command=self.snapshot) self.btn_snapshot.grid(row=len(self.led_intensities.keys()) + 9, column=0, columnspan=2) # self.exp_entry = tk.Entry( # window, textvariable=tk.StringVar(window, value="1")) # self.exp_entry.grid() # After it is called once, the update method will be automatically called every delay milliseconds self.delay = 15 self.update()
def choose_measures(self, *args): self.view_window = tk.Toplevel(self.master, bg=self.master.lightcolour) self.view_window.title("Select measures") self.view_window.grid_columnconfigure(0, weight=1) self.view_window.grid_columnconfigure(3, weight=1) self.view_window.grid_rowconfigure(0, weight=1) self.view_window.grid_rowconfigure(2, weight=1) self.tv1label = tk.Label(self.view_window, text="Available measures", bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.tv1label.grid(row=1, column=1, sticky=tk.EW, pady=5) self.tv1label = tk.Label(self.view_window, text="Selected measures", bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour) self.tv1label.grid(row=1, column=2, sticky=tk.EW, pady=5) self.tv1 = ttk.Treeview(self.view_window, height=20, columns=('Unit', 'Description'), show="tree") self.tv1.heading("#0", text='Class') self.tv1.heading("#1", text='Type') self.tv1.column("#0", width=120, stretch=0) self.tv1.column("#1", width=20, stretch=0) self.tv1.heading('Unit', text='Unit') self.tv1.column('Unit', anchor='w', width=50) self.tv1.heading('Description', text='Description') self.tv1.column('Description', anchor='w', width=200) self.tv1.grid(row=2, column=1, padx=5, pady=5, sticky=tk.N) self.tv2 = ttk.Treeview(self.view_window, height=20, columns=('Unit', 'Description'), show="tree") self.tv2.heading("#0", text='Class') self.tv2.heading("#1", text='Type') self.tv2.column("#0", width=120, stretch=0) self.tv2.column("#1", width=20, stretch=0) self.tv2.heading('Unit', text='Unit') self.tv2.column('Unit', anchor='w', width=50) self.tv2.heading('Description', text='Description') self.tv2.column('Description', anchor='w', width=200) self.tv2.grid(row=2, column=2, padx=5, pady=5, sticky=tk.N) self.tv1.bind("<Double-1>", self.OnDoubleClick1) self.tv2.bind("<Double-1>", self.OnDoubleClick2) self.donebutton = tk.Button( self.view_window, text='Done', width=15, command=self.finish_choosing, bg=self.master.lightcolour, fg=self.master.darkcolour, highlightthickness=0, activebackground=self.master.darkcolour, activeforeground=self.master.lightcolour ) # Select measures button opens a window that allows to select any number of measures self.donebutton.grid(row=3, column=2, sticky=tk.E, padx=5, pady=5) # Retrieve the classes ('disease','accident',...) and types (detailed events) self.__classes_types = self.master.db.get_measure_list() classes_all = [] for c in self.__classes_types: classes_all.append(c[0]) self.__classes = list(set(classes_all)) self.__classes.sort(key=lambda k: (k[0])) self.__types = [] for t in self.__classes_types: if t in self.__types: pass else: self.__types.append(t) self.__selected_classes = [] self.__selected_types = [] self.__available_classes = [] #This is to break the vicious binding for c in self.__classes: self.__available_classes.append(c) self.__available_types = [] for t in self.__types: self.__available_types.append(t) for c in self.__available_classes: globals()[c] = self.tv1.insert("", "end", text=c, open=True, tags=('class', )) for t in self.__available_types: name = t[0] self.tv1.insert(globals()[name], "end", text=t[1], values=t[2:4], tags=('type', )) self.tv1.bind("<Double-1>", self.OnDoubleClick1) self.tv2.bind("<Double-1>", self.OnDoubleClick2)
def __init__(self, master): self.master = master tk.Frame.__init__(self, self.master) self.master.title("Smart Scope") self.live_class = None ###################################################### # Layout the frames and notebooks ###################################################### row_col_config(self.master, 4, 4) self.Sidebar = tk.Frame(self.master) self.Sidebar.grid(row=0, column=3, rowspan=4, columnspan=1, sticky=tk.W + tk.E + tk.N + tk.S) row_col_config(self.Sidebar, 8, 1) self.BarcodeFrame = tk.Frame(self.Sidebar, highlightbackground="black", highlightcolor="black", highlightthickness=1) self.BarcodeFrame.grid(row=0, column=0, rowspan=4, sticky=tk.W + tk.E + tk.N + tk.S) row_col_config(self.BarcodeFrame, 4, 1) self.Mainframe = tk.Frame(master) self.Mainframe.grid(row=0, column=0, rowspan=4, columnspan=3, sticky=tk.W + tk.E + tk.N + tk.S) self.nb = ttk.Notebook(self.Mainframe) self.imaging_parameters = ttk.Frame(self.nb) self.nb.add(self.imaging_parameters, text='Imaging Parameters') row_col_config(self.imaging_parameters, 14, 4) self.system = ttk.Frame(self.nb) self.nb.add(self.system, text='System Parameters') self.nb.pack(expand=1, fill='both') row_col_config(self.system, 14, 4) ###################################################### # Layout the buttons, labels, and entries ###################################################### # Sidebar tk.Button(self.Sidebar, text="Live Image", command=self.camera).grid(row=7, column=0, ipadx=10, ipady=3, padx=3, pady=3) tk.Label(self.BarcodeFrame, text="Barcode").grid(row=0, column=0) self.barcode_number = tk.StringVar(self.BarcodeFrame, value='') self.barcode_val = tk.Entry(self.BarcodeFrame, textvariable=self.barcode_number) self.barcode_val.grid(row=1, column=0) tk.Button(self.BarcodeFrame, text="Scan Barcode", command=self.scan_barcode).grid(row=3, column=0, ipadx=10, ipady=3, padx=3, pady=3) tk.Button(self.BarcodeFrame, text="Save", command=self.save_barcode).grid(row=4, column=0, ipadx=18, ipady=3, padx=3, pady=3) tk.Button(self.BarcodeFrame, text="Load", command=self.load_barcode).grid(row=5, column=0, ipadx=18, ipady=3, padx=3, pady=3) start = tk.Button(self.Sidebar, text="Start", font=('Sans', '10', 'bold'), command=self.image) start.grid(row=8, column=0, ipadx=23, ipady=3, padx=3, pady=3) # Imaging # Experiment self.config_yaml_data = read_yaml(CONFIG_YAML_PATH) self.experiment_params = { 'Chip': 1, 'Cycle Number': 2, 'Drug': 3, 'Cell': 4, 'Origin': 5, 'Start Date': 6, 'Concentration': 7, 'Chip Index': 8 } self.ExperimentFrame = tk.Frame(self.imaging_parameters, highlightbackground="black", highlightcolor="black", highlightthickness=1) self.ExperimentFrame.grid(row=0, column=0, rowspan=9, columnspan=2, sticky=tk.W + tk.E + tk.N + tk.S) row_col_config(self.ExperimentFrame, 9, 2) tk.Label(self.ExperimentFrame, text="Experiment").grid(row=0, column=0, columnspan=2) for k, v in self.experiment_params.items(): if k == 'Chip': self.experiment_params[k] = DropDown( self.ExperimentFrame, k, get_default(k), ([val['name'] for val in self.config_yaml_data['chips']]), v) elif k == 'Drug': self.experiment_params[k] = DropDown( self.ExperimentFrame, k, get_default(k), ([val for val in self.config_yaml_data['drugs']]), v) elif k == 'Cell': self.experiment_params[k] = DropDown( self.ExperimentFrame, k, get_default(k), ([val for val in self.config_yaml_data['cells']]), v) elif k == 'Origin': self.experiment_params[k] = DropDown( self.ExperimentFrame, k, get_default(k), ([val for val in self.config_yaml_data['origins']]), v) else: self.experiment_params[k] = Entry(self.ExperimentFrame, k, get_default(k), v) # Exposure self.led_intensities = read_yaml(LED_YAML_PATH) # print(self.led_intensities) self.exposure_params = {} self.exposure_checkboxes = {} for i, (key, val) in enumerate(self.led_intensities.items()): self.exposure_params[key] = i + 1 self.exposure_checkboxes[key] = tk.BooleanVar() if key == 'BFF': self.exposure_checkboxes[key].set(True) self.ExposureFrame = tk.Frame(self.imaging_parameters) self.ExposureFrame.grid(row=9, column=0, rowspan=4, columnspan=2, sticky=tk.W + tk.E + tk.N + tk.S) row_col_config(self.ExposureFrame, 8, 3) tk.Label(self.ExposureFrame, text="Exposure").grid(row=0, column=0, columnspan=2) for i, (k, v) in enumerate(self.exposure_checkboxes.items()): tk.Checkbutton(self.ExposureFrame, text=k, variable=v, onvalue=True, offvalue=False).grid(row=i + 1, column=2) for k, v in self.exposure_params.items(): self.exposure_params[k] = Entry(self.ExposureFrame, k, get_default(k), v) # Focus self.focus_params = { 'Step Size (um)': 1, 'Initial Focus Range (um)': 2, 'Focus Range (um)': 3, 'Focus Points X': 4, 'Focus Points Y': 5, 'Focus Exposure': 6 } self.FocusFrame = tk.Frame(self.imaging_parameters) self.FocusFrame.grid(row=0, column=2, rowspan=9, columnspan=2, sticky=tk.W + tk.E + tk.N + tk.S) row_col_config(self.FocusFrame, 7, 2) tk.Label(self.FocusFrame, text="Focus").grid(row=0, column=0, columnspan=4) for k, v in self.focus_params.items(): self.focus_params[k] = Entry(self.FocusFrame, k, get_default(k), v) # Saving self.saving_params = { 'Folder': 1, 'Output Image Pixel Width': 2, 'Output Image Pixel Height': 3 } self.SaveFrame = tk.Frame(self.imaging_parameters, highlightbackground="black", highlightcolor="black", highlightthickness=1) self.SaveFrame.grid(row=9, column=2, rowspan=6, columnspan=2, sticky=tk.W + tk.E + tk.N + tk.S) row_col_config(self.SaveFrame, 4, 3) tk.Label(self.SaveFrame, text="Saving").grid(row=0, column=0, columnspan=4) for k, v in self.saving_params.items(): self.saving_params[k] = Entry(self.SaveFrame, k, get_default(k), v) tk.Button(self.SaveFrame, text='...', command=lambda: self.get_directory(self.saving_params[ 'Folder'])).grid(row=1, column=2) # System Tab Layout # General self.system_params = { 'Alignment Model': 1, 'Focus Model': 2, 'Objective': 3, 'Apartments in Image X': 4, 'Apartments in Image Y': 5, 'Image Rotation (degrees)': 6, } self.SystemFrame = tk.Frame(self.system, highlightbackground="black", highlightcolor="black", highlightthickness=1) self.SystemFrame.grid(row=0, column=0, rowspan=14, columnspan=2, sticky=tk.W + tk.E + tk.N + tk.S) row_col_config(self.SystemFrame, 7, 3) tk.Label(self.SystemFrame, text="General").grid(row=0, column=0, columnspan=4) for k, v in self.system_params.items(): if k == 'Image Rotation (degrees)': self.system_params[k] = DropDown(self.SystemFrame, k, get_default(k), ['0', '90', '180', '270'], v) else: self.system_params[k] = Entry(self.SystemFrame, k, get_default(k), v) tk.Button(self.SystemFrame, text='...', command=lambda: self.get_filename(self.system_params[ 'Alignment Model'])).grid(row=1, column=2) tk.Button(self.SystemFrame, text='...', command=lambda: self.get_filename(self.system_params[ 'Focus Model'])).grid(row=2, column=2) # Calibration self.calibration_params = { 'Frame to Pixel Ratio': 2, 'First Position X': 5, 'First Position Y': 6, } self.CalibrationFrame = tk.Frame(self.system) self.CalibrationFrame.grid(row=0, column=2, rowspan=14, columnspan=2, sticky=tk.W + tk.E + tk.N + tk.S) row_col_config(self.CalibrationFrame, 6, 3) tk.Label(self.CalibrationFrame, text="Calibration").grid(row=0, column=0, columnspan=4) tk.Button(self.CalibrationFrame, text='Calibrate Stage/Pixel Ratio', command=self.ratio_calibrate).grid() self.calibration_params['Frame to Pixel Ratio'] = Entry( self.CalibrationFrame, 'Calibrated Stage to Pixel Ratio:', get_default('Frame to Pixel Ratio'), 2) tk.Label(self.CalibrationFrame, textvariable=self.calibration_params['Frame to Pixel Ratio'] ).grid() tk.Button(self.CalibrationFrame, text='Calibrate First Postion', command=self.first_point_calibration).grid() self.calibration_params['First Position X'] = Entry( self.CalibrationFrame, 'Calibrated First Postion X:', get_default('First Position X'), 5) self.calibration_params['First Position Y'] = Entry( self.CalibrationFrame, 'Calibrated First Postion Y:', get_default('First Position Y'), 6) tk.Label( self.CalibrationFrame, textvariable=self.calibration_params['First Position X']).grid() tk.Label( self.CalibrationFrame, textvariable=self.calibration_params['First Position Y']).grid() self.x_stage_dir = tk.BooleanVar() self.y_stage_dir = tk.BooleanVar() tk.Checkbutton(self.CalibrationFrame, text='Flip X Stage Direction', variable=self.x_stage_dir, onvalue=True, offvalue=False, command=self.toggle_stage_direction).grid() tk.Checkbutton(self.CalibrationFrame, text='Flip X Stage Direction', variable=self.y_stage_dir, onvalue=True, offvalue=False, command=self.toggle_stage_direction).grid() ###################################################### # Get Stage Controller ###################################################### self.mmc = sc_utils.get_stage_controller("COM7")
clearing() text_field.insert(0, 'Do not use latters!') app.after(2000, clearing) result = round(result, length) temp = math.modf(result) if temp[0] == 0: result = int(result) clearing() return text_field.insert(0, result) def solve(): solution(0) ###################################### btn_clear = tk.Button(app, text='C', width=10, height=2, font='verdana 14 bold', command=clearing) btn_clear.grid(row=1, column=2) btn_clear.config(bg='#F4E2BF') btn_sum = tk.Button(app, text='=', width=10, height=2, font='verdana 14 bold', command=solve) btn_sum.grid(row=2, column=2) btn_sum.config(bg='#b3ffff') btn_multiply = tk.Button(app, text='*', width=10, height=2, font='verdana 14 bold', command=multiplying) btn_multiply.grid(row=3, column=2) btn_sum = tk.Button(app, text='+', width=10, height=2, font='verdana 14 bold', command=summing) btn_sum.grid(row=4, column=2) btn_difference = tk.Button(app, text='-', width=10, height=2, font='verdana 14 bold', command=differing) btn_difference.grid(row=5, column=2)
unzip(root.zipped_file, root.destination) rename_files(root.destination) add_file(root.criteria, root.destination) # ***** MAIN PROGRAM ***** # create window root = tk.Tk() root.geometry("800x600") root.title("File Renamer") # *** create entry screen *** # zipped file picker tk.Label(root, text="Zipped file location").grid(row=1, column=0) zip_btn = tk.Button(root, text="Choose File", command=zip_btn_click) zip_btn.grid(row=1, column=1) # desitnation folder tk.Label(root, text="Destination folder").grid(row=2, column=0) dest_btn = tk.Button(root, text="Choose Folder", command=dest_btn_click) dest_btn.grid(row=2, column=1) # criteria sheet tk.Label(root, text="Criteria Sheet").grid(row=3, column=0) crit_btn = tk.Button(root, text="Choose File", command=crit_btn_click) crit_btn.grid(row=3, column=1) # go button go_btn = tk.Button(root, text="Go", command=go_btn_click) go_btn.grid(row=4, column=1)
def Create_Spinbox(self): #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Procedure to Store Settings~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def Store_values(): self.Setting_Store['Max Temperature'] = self.TempMax self.Setting_Store['Min Temperature'] = self.TempMin self.Setting_Store['Temperature Spike Range'] = self.TempSpike self.Setting_Store['pH Spike Range'] = self.pHSpike self.Setting_Store['Max pH'] = self.pHMax self.Setting_Store['Min pH'] = self.pHMin self.SaveData = [self.Setting_Store['Max Temperature'], self.Setting_Store['Min Temperature'], self.Setting_Store['Temperature Spike Range'],self.Setting_Store['pH Spike Range'], self.Setting_Store['Max pH'],self.Setting_Store['Min pH']] with open('Settings_Info', 'r+') as file: file.truncate(0) file.write(self.SaveData) file.close() print(file) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Temp Spinbox~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #Creates spinbox self.spinTemp1 = tk.Spinbox(self, from_=0, to=20, width = 5) self.spinTemp1.grid(column=0, row=3) #Label spinbox labelSpinTemp = tk.Label(self, text = 'Temperature Spike Range', font = MID_FONT) labelSpinTemp.grid(column = 0, row = 2, columnspan = 3) self.spinTempMin = tk.Spinbox(self, value = self.RangeMin, width = 5) self.spinTempMin.grid(column=0, row=5) labelSpinTemp1 = tk.Label(self, text = 'Minimum Temperature', font = MID_FONT) labelSpinTemp1.grid(column = 0, row = 4, columnspan = 3) self.spinTempMax = tk.Spinbox(self, from_= 20, to= 45, width = 5) self.spinTempMax.grid(column=0, row=7) labelSpinTemp2 = tk.Label(self, text = 'Maximum Temperature', font = MID_FONT) labelSpinTemp2.grid(column = 0, row = 6, columnspan = 3) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~pH Spinbox~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ self.spin_pH = tk.Spinbox(self, from_= 0, to= 5, width = 5) self.spin_pH.grid(column= 5, row=3) labelSpinpH = tk.Label(self, text = 'pH spike range', font = MID_FONT) labelSpinpH.grid(column = 5 , row = 2, columnspan = 6) self.spin_pHMax = tk.Spinbox(self, from_= 6, to= 12, width = 5) self.spin_pHMax.grid(column=5, row=5) labelSpinpH1 = tk.Label(self, text = 'Maximum pH', font = MID_FONT) labelSpinpH1.grid(column = 5, row = 4, columnspan = 3) self.spin_pHMin = tk.Spinbox(self, from_= 0, to= 6, width = 5) self.spin_pHMin.grid(column=5, row=7) labelSpinpH2 = tk.Label(self, text = 'Minimum pH', font = MID_FONT) labelSpinpH2.grid(column = 5, row = 6, columnspan = 3) #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Save Button~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ saveButton = tk.Button(self, text = "Save", command = Store_values) saveButton.grid(column = 3, row = 10)
import tkinter as tk def create_window(): window = tk.Toplevel(root) root = tk.Tk() b = tk.Button(root, text="Create new window", command=create_window) b.pack() root.mainloop()
def sliderChange(): global thrvalue thrvalue = sl.get() #Adds labels, video displays and buttons to a grid control. lb1 = tk.Label(imageFrame, text="Original Video") lb1.grid(row=0, column=0, padx=10, pady=2) lb2 = tk.Label(imageFrame, text="Background Filter") lb2.grid(row=0, column=1) display1 = tk.Label(imageFrame) display1.grid(row=1, column=0) # Display 1 display2 = tk.Label(imageFrame) display2.grid(row=1, column=1) # Display 2 bkgndBtn = tk.Button(imageFrame, text="Set background", command=backgroundSnapshot) bkgndBtn.grid(row=2, column=0) saveBtn = tk.Button(imageFrame, text="Save image", command=saveSnapshot) saveBtn.grid(row=2, column=1) sl = tk.Scale(imageFrame, from_=0, to=100, tickinterval=5, orient=tk.HORIZONTAL, length=450) sl.grid(row=3, column=0) sl.set(30) lb3 = tk.Label(imageFrame, text="By: Angel Espinoza") lb3.grid(row=3, column=1)
key, encrypted_text = encrypt(text_to_send) c.send(key+" ".encode()+encrypted_text) text_to_send="" c.close() st = Thread(target=socket_thread); st.start() def startRecording(): global recording_happening recording_happening=True t=Thread(target=record) t.start() print("start recording") start_button = tk.Button(frame, text="start",command=startRecording) start_button.pack(side=tk.LEFT) def stopRecording(): global recording_happening recording_happening=False print("stop recording") stop_buttton = tk.Button(frame,text="stop",command=stopRecording) stop_buttton.pack(side=tk.RIGHT) root.mainloop()
def __init__(self): # Some colors that will be used. self.button_col has an extra (commented- # out) option; the difference isn't that extreme, though noticeable. self.main_bg = "#21252B" self.gui_text_col = "#9da5b4" self.button_col = "#30353e" #"#282C34" # The main/only window. Use it wisely. self.master = tkinter.Tk() self.master.title("Mallory's Caption Maker <3") # Sets the background color of the window. self.master.configure(bg=self.main_bg) # Creation of widget elements. self.person_label = tkinter.Label(self.master, text="Who?", bg=self.main_bg, fg=self.gui_text_col) self.what_was_done_label = tkinter.Label(self.master, text="What?", bg=self.main_bg, fg=self.gui_text_col) self.time_label = tkinter.Label(self.master, text="When?", bg=self.main_bg, fg=self.gui_text_col) self.person_entry = tkinter.Entry(self.master, bg=self.gui_text_col) self.what_was_done_entry = tkinter.Entry(self.master, bg=self.gui_text_col) self.time_entry = tkinter.Entry(self.master, bg=self.gui_text_col) # Binds the return key to create a caption, when in the entry fields. self.person_entry.bind( "<Return>", lambda x: self.add_caption(self.person_entry.get( ), self.what_was_done_entry.get(), self.time_entry.get())) self.what_was_done_entry.bind( "<Return>", lambda x: self.add_caption(self.person_entry.get( ), self.what_was_done_entry.get(), self.time_entry.get())) self.time_entry.bind( "<Return>", lambda x: self.add_caption(self.person_entry.get( ), self.what_was_done_entry.get(), self.time_entry.get())) # For use in adding captions with add_caption. self.highest_row_index = 1 # For use in columnspan cases. self.total_columns = 6 # Creates the button that is used to generate captions. self.action_button = tkinter.Button( self.master, text="GO!", command=lambda: self.add_caption(self.person_entry.get( ), self.what_was_done_entry.get(), self.time_entry.get()), fg=self.gui_text_col, bg=self.button_col) # Placement of entry fields and their respective labels. self.person_label.grid(row=0, column=0, pady=10, padx=10) # I added pady only to the first column because it stays like that # for the other columns. self.person_entry.grid(row=0, column=1, sticky="we", padx=10) self.what_was_done_label.grid(row=0, column=2, padx=10) self.what_was_done_entry.grid(row=0, column=3, sticky="we", padx=10) self.time_label.grid(row=0, column=4, padx=10) self.time_entry.grid(row=0, column=5, sticky="we", padx=10) # Placement of button. # Button should span the window width and stretch accordingly. self.action_button.grid(row=1, column=0, sticky="we", columnspan=self.total_columns, pady=5) # Makes the columns scale according to the window width. # Entry fields have double weight. self.master.columnconfigure(0, weight=1) self.master.columnconfigure(1, weight=2) self.master.columnconfigure(2, weight=1) self.master.columnconfigure(3, weight=2) self.master.columnconfigure(4, weight=1) self.master.columnconfigure(5, weight=2) # The main loop. Duh. self.master.mainloop()
) canvas.pack() frame = tk.Frame(canvas, bg='white') frame.place( relwidth=0.8, relheight=0.8, relx=0.1, rely=0.1 ) openfile = tk.Button( root, text="Open File", padx=10, pady=10, fg='white', bg="#263D42", command=addApp ) openfile.pack() runApps = tk.Button( root, text="Run Apps", padx=10, pady=10, fg='white', bg="#263D42", command=runApps )