def HeaderInfo(): window = tk.Toplevel(root) window.title("Header Information") window.resizable(True, True) header_info = Table(window, dataframe=df) header_info.autoResizeColumns() header_info.show()
def __init__(self, master): toplevel = Toplevel() toplevel.title("Table") frame = Frame(toplevel) frame.grid(row=0, column=0) table = Table(frame, dataframe=sources) table.show()
def print_unusual_amino_acid(self): '''Check if ico file exist''' if self.check_if_ico_exist() == False: return f'"logo.ico" file doesnt exist. File has to be added to the directory;{self.ico_path()}' '''check if unusual_amino.csv" exist''' if self.check_if_data_exist() == False: return f'"unusual_amino.csv" doesnt exist. Amino acid has to be added first;{self.data_path()}' '''check if unusual_amino.csv is empty - first checked if exist''' if self.check_if_unusual_amino_is_empty() == 'True': return f'Please note that file "unusual_amino.csv" is empty; Or it contains only one row' else: '''Sets icon''' root = tk.Tk() root.title('PeptideMassCalculator') root.iconbitmap(self.ico_path()) frame = tk.Frame(root) frame.pack(fill='both', expand=True) datatable = Table(frame, showtoolbar=False, showstatusbar=True) datatable.show() '''shows unusual_amino.csv in the table''' datatable.importCSV(filename=self.data_path(), dialog=False) root.mainloop()
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) df = self.get_cryptocurrency() tb_m = TableModel(dataframe=df) table = Table(self, model=tb_m) table.show() table.redraw()
def affiche_data(self, data, v): y1 = self.y // 20 y2 = self.y // 14 y3 = self.y - y1 - y2 x3 = self.x // 5 if v == 'train': self.hide_show('train', '0') self.btrain_cleaning.grid() f = Frame(self.root) f.grid(row=0, column=0) pt = Table(self.centre_frame1, dataframe=data, height=y3 - y2, width=3 * x3 - 30) pt.show() if v == 'test': self.hide_show('test', '1') self.btrain_cleaning.grid_forget() self.btest_cleaning.grid() f = Frame(self.root) f.grid(row=0, column=0) pt = Table(self.centre_frame1, dataframe=data, height=y3 - y2, width=3 * x3 - 30) pt.show()
def get_stats(dataframe): # creates a new tkinter window (using the pandastable module) # with all the pandas descriptive statistics for the dataframe root = tk.Tk() frame1 = tk.Frame(root) frame1.pack(side="top") frame2 = tk.Frame(root) frame2.pack(side="bottom") root.title(f"Stats table for {dataframe.name}") tk.Label( frame1, text= "1: count, 2: mean, 3: standard deviation, 4: minimum, 5: 25% quartile, " "6: median, 7: 75% quartile, 8: max").pack() # row indexes can't be changed in pandastable, so we need to make a tkinter Label to display this information table = Table(frame2, dataframe=dataframe.describe(), width=750, height=200) table.show() root.mainloop()
def get_stats_for_var( dataframe, column: str ): # displays descriptive statistics for a single column in new window new_dataframe = ((dataframe.loc[:, [column]]).describe()) new_dataframe.index = [ "count", "mean", "standard deviation", "minimum", "25% quartile", "median", "75% quartile", "max" ] root = tk.Tk() root.title(f"descriptive statistics for {column}") frame1 = tk.Frame(root) frame1.pack(side="top") frame2 = tk.Frame(root) frame2.pack(side="bottom") tk.Label( frame1, text= "1: count, 2: mean, 3: standard deviation, 4: minimum, 5: 25% quartile, " "6: median, 7: 75% quartile, 8: max").pack() table = Table(frame2, dataframe=new_dataframe, width=300, height=200) table.show() root.mainloop()
class TableView(tk.Frame): def __init__(self, master, dataframe): super().__init__(master) master.geometry("350x230") self.pack(fill=tk.BOTH, expand=True) self._df = dataframe self.df = self._df.copy() self.create_widget() def create_widget(self): self.bt = tk.Button(self, text="Show Table", command=self.show_table) self.bt.pack(fill=tk.BOTH, expand=True) def show_table(self): self.tbl_window = tk.Toplevel(self.master) frame = tk.Frame(self.tbl_window) frame.pack(fill=tk.BOTH, expand=True) self.tbl = Table(frame, dataframe=self.df) self.tbl.showIndex() self.tbl.show() frame_reset = tk.Frame(self.tbl_window) frame_reset.pack(fill=tk.BOTH, expand=True) btn = tk.Button(frame_reset, text="Reset DataFrame", command=self.reset_df) btn.pack() def reset_df(self): if messagebox.askyesno("Confirmation", "Do you really reset?"): self.df = self._df.copy() self.tbl_window.destroy() self.show_table()
def customPandasTable(self, parent): def set_order(cols_order): # fix kolejnosci kolumn x = [] for i in cols_order: x.append(list(df.columns).index(i)) return x tableFrame = tk.LabelFrame(parent, bd=0, bg="#515E5A") tableFrame.pack(fill=tk.BOTH, expand=1) df = pd.DataFrame(self.dataSet) # wczytanie danych df = df.transpose( ) # transpozycja danych ( zamiana wierszy z kolumnami ) # TODO: dodac obsluge nazw kolumn przy pustej tabeli if df.keys().__len__() is not 0: df = df[df.columns[set_order(list( self.dataSet[str(0)].keys()))]] # fix kolejnosci kolumn if 'Result' in df.columns: df['Result'] = df['Result'].astype(int) if 'ID' in df.columns: df['ID'] = df['ID'].astype(int) table = Table(tableFrame, dataframe=df, showtoolbar=False, showstatusbar=False) table.show() return tableFrame
def allYearsGDPPrediction(countries, predictionYear): df = pd.DataFrame(columns=[ 'Countries', 'GDP in 2015', 'Predicted GDP in ' + str(predictionYear) ]) for i in countries: if dataframeCreation(i) is False: print(i + "'s dataframe is empty!") df = df.append(pd.Series([i, 'No Data To Make Prediction'], index=df.columns), ignore_index=True) else: pred1 = linearReg2(i, 2015, dataframeCreation(i))[1][0][0] pred2 = linearReg2(i, predictionYear, dataframeCreation(i))[1][0][0] df = df.append(pd.Series([i, pred1, pred2], index=df.columns), ignore_index=True) df.index += 1 window = tk.Toplevel() window.title("All Countries' GDP Prediction in the year: %s" % predictionYear) f = Frame(window) f.pack(fill=BOTH, expand=1) pt = Table(f, dataframe=df, showstatusbar=True, width=200, height=300) options = {'cellwidth': 150, 'floatprecision': 4, 'align': 'center'} config.apply_options(options, pt) pt.showIndex() pt.show() return df
def clean_text(self, v): if v == 'data1': self.data['statement'] = self.data["statement"].apply( lambda x: " ".join(word.lower() for word in x.split())) self.data['statement'] = self.data["statement"].str.replace( r"\W", " ") self.statement = list(self.data["statement"]) self.statement = go_nettoyage.replace1(self.statement) y1 = self.y // 20 y2 = self.y // 14 y3 = self.y - y1 - y2 x3 = self.x // 5 pt = Table(self.centre_frame1, dataframe=self.data, height=y3 - y2, width=3 * x3 - 30) pt.show() self.btext_steming.grid(row=1, column=0) if v == 'data2': self.data2['statement'] = self.data2["statement"].apply( lambda x: " ".join(word.lower() for word in x.split())) self.data2['statement'] = self.data2["statement"].str.replace( r"\W", " ") self.statement2 = list(self.data2["statement"]) self.statement2 = go_nettoyage.replace1(self.statement2) self.btext_steming.grid(row=1, column=0)
def print_protected_amino_acid_and_not(self, type): '''Check if ico file exist''' if self.check_if_ico_exist() == False: return f'"logo.ico" file doesnt exist. File has to be added to the directory;{self.ico_path()}' else: if type == "protected": amino = self.protectedamino title = "Protected Amino Acid" if type == "notprotected": amino = self.notprotectedamino title = "Amino Acid" if type == "endings": amino = self.endings title = "Terminus" root = tk.Tk() root.title(f'PeptideMassCalculator - {title}') root.iconbitmap(self.ico_path()) frame = tk.Frame(root) frame.pack(fill='both', expand=True) datatable = Table(frame, dataframe=amino, showstatusbar=True) datatable.show() root.mainloop()
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) lable = tk.Label(self, text="Firewall", font=LARGE_FONT) lable.pack(pady=10, padx=10) objPF = Firewall() dfPF = objPF.failed_attempt() print("-------------Screen UI ---", dfPF) lable1 = tk.Label(self, text="Firewall Unauthorised Access", font=LARGE_FONT) lable1.pack(pady=20, padx=10) f = tk.Frame(self) f.pack(pady=12, padx=5, expand=False) pt = Table(f, dataframe=dfPF, showstatusbar=True, showtoolbar=False) pt.show() button2 = tk.Button( self, text="Traffic", command=lambda: controller.show_frame(PageFirewallActiveUser)) button2.pack() button1 = tk.Button(self, text="Back", command=lambda: controller.show_frame(StartPage)) button1.pack()
def EstadisticosPregRes(): global root #screenEA.withdraw() root = Toplevel(screen) root.title('PandasTable Example') root.geometry('900x400') global dataPreg dataPreg = pd.DataFrame(list(col_pregunta_respuesta.find())) dataPreg = pd.DataFrame(dataPreg) del dataPreg['_id'] print(dataPreg.isnull().sum()) dataPreg = dataPreg[dataPreg['calificacion'].notna()] frame = tk.Frame(root) frame.pack(fill='both', expand=True) pt = Table(frame, dataframe=dataPreg) pt.show() buttonCali = tk.Button(root, text='Preguntas\nPor calificación',bd=7, font = ("monaco",10,"bold"),padx=4,pady=4,fg="#263b54", command = GraficaPreg_Calif,activeforeground="#1c2e44") buttonCali.place(x=30,y=342) buttonUsu = tk.Button(root, text='NPQRS\nPor Usuario',bd=7, font = ("monaco",10,"bold"),padx=4,pady=4,fg="#263b54", command = GraficaPreg_Usu,activeforeground="#1c2e44") buttonUsu.pack() buttonEs = tk.Button(root, text='Frecuencia\nCalificación',bd=7, font = ("monaco",10,"bold"),padx=4,pady=4,fg="#263b54", command = GraficaPreg_FrecEs,activeforeground="#1c2e44") buttonEs.place(x=720,y=342)
def get_subsitute(): name = t1.get() # Get the index of the item that matches the title idx = indices[name] # Get the pairwsie similarity scores of all items with that items sim_scores = list(enumerate(cosine_sim[idx])) # Sort the items based on the similarity scores def get_key(elem): return elem[1] sim_scores.sort(key=get_key, reverse=True) # Get the scores of the 10 most similar items sim_scores = sim_scores[1:11] # Get the items indices item_indices = [i[0] for i in sim_scores] # Return the top 10 most similar items #print (type( df_new['name'].iloc[item_indices])) df = ((df_new.iloc[item_indices].sort_values(by='price'))) pt = Table(frame, dataframe=df) pt.place(x=0, y=300) pt.show()
def afficher_idf(self,root): centre_frame1 = Frame(root, bg='white', width=630, height=700) centre_frame1.grid(row=3, column=0, sticky=N) centre_frame1.grid_propagate(0) self.data = pd.DataFrame(self.tf_idf2, columns=list(self.tf_idf2[0].keys())) pt = Table(centre_frame1, dataframe=self.data, height=self.h, width=self.w) pt.show()
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) lable = tk.Label(self, text="Apache Server", font=LARGE_FONT) lable.grid(row=0, column=1) button1 = tk.Button(self, text="Back", command=lambda: controller.show_frame(StartPage)) button1.grid(row=3, column=1) # Object of Apache Class print("-----------PageApapche-------") obj_ap = Apache_Server() apache_df = obj_ap.apache_analysis() print(apache_df) lb1 = tk.Label(self, text="Sucessfull Attempts", font=MID_FONT) lb1.grid(row=1, column=0) f = tk.Frame(self) f.grid(row=2, column=0) pt_apache_active = Table(f, dataframe=apache_df, showstatusbar=True, showtoolbar=False) pt_apache_active.show() apache_df_fail = obj_ap.apache_failed() lb2 = tk.Label(self, text="Failed Attempts", font=MID_FONT) lb2.grid(row=1, column=2) g = tk.Frame(self) g.grid(row=2, column=2) pt_apache_fail = Table(g, dataframe=apache_df_fail, showstatusbar=True, showtoolbar=False) pt_apache_fail.show()
def gui_show_database_content(database_obj): """GUI shows the remaining questions in selected_database.""" display_top = Toplevel() display_top.title("All questions in Database") tables_list = pd.DataFrame(r.to_dict() for r in database_obj) tables_list.rename(columns={ 0: "ID", 1: "Question", 2: "Answer1", 3: "Answer2", 4: "Answer3", 5: "Answer4", 6: "Answer5", 7: "1 if Correct", 8: "1 if Correct", 9: "1 if Correct", 10: "1 if Correct", 11: "1 if Correct" }, inplace=True) my_frame = Frame(display_top) my_frame.grid(row=5, column=0, columnspan=10) display_table = Table(parent=my_frame, dataframe=tables_list, showtoolbar=True) display_table.show()
class Pairings(tk.Toplevel): def __init__(self, master) -> None: super().__init__(master=master) self.wm_title(f"Pairings for Round {master.tnmt.round}") self.setup_menu() self.chart = tk.Frame(master=self) self.chart.pack() self.table = Table(self.chart, dataframe=master.tnmt.pair(), showstatusbar=True, showtoolbar=True) self.table.show() def setup_menu(self): self.menu = tk.Menu(self) result_menu = tk.Menu(self.menu, tearoff=0) result_menu.add_command(label="Finalize", command=self.update_results) self.menu.add_cascade(label='Results', menu=result_menu) self.config(menu=self.menu) def update_results(self, event=None): results = ([float(i) for i in self.table.model.df["WResult"].tolist()]) self.master.tnmt.record_results(results) self.master.update_standings() self.destroy()
def get_comp(): value = t1.get() df = (support_data[(support_data['name_x'] == value) | (support_data['name_y'] == value)].sort_values( by='support', ascending=False).head(10)) pt = Table(frame, dataframe=df) pt.place(x=0, y=300) pt.show()
def pandas_interface(): df = pd.read_excel("datos_papers.xlsx", sheet_name='datos') top = Toplevel() pt = Table(top, dataframe=df, showtoolbar=True, showstatusbar=True) pt.show() pass
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) df = self.get_history() tb_m = TableModel(dataframe=df) table = Table(self, model=tb_m) table.show() #alter the DataFrame in some way, then update table.redraw()
class processingFrame(Frame): def __init__(self, master): # 1 is csv, 2 is file with correct fields # txt,xls,append file names self.filename1="" self.filename2="" self.filename3="" self.trouble=[] self.maxwordlen=[] self.checklabel= StringVar() self.countlabel= StringVar() self.neglabel=StringVar() # make frames for each step self.processing = Frame(master, bg="#DAF7A6" ) Frame.__init__(self,self.processing) self.processing.grid(column=0,row=1) # Make Frames for tables, buttons and output self.stuffframe = Frame(self.processing,bg="#DAF7A6") self.stuffframe.grid(column = 0,row = 0, sticky=W+N) # Frames for tables tableframe1 = Frame(self.processing,bg="#DAF7A6") tableframe1.grid(column=2,row = 0, sticky = N) self.stuffframe2 = Frame(tableframe1) self.stuffframe2.grid(row=0,column=0, sticky=E) # This is the Table Frame for showing data self.f1 = Frame(tableframe1) self.f1.grid(row = 0, column = 3, columnspan=25, rowspan=15, sticky = N) #tableframe2 = Frame(self.processing,bg="#DAF7A6") #tableframe2.grid(column=2,row = 1, sticky = N) self.stuffframe3 = Frame(tableframe1) self.stuffframe3.grid(row=1,column=0, sticky=E) # This is the table frame for negatives self.f2 = Frame(tableframe1, bg="#DAF7A6") self.f2.grid(row = 1, column = 3, columnspan=25, rowspan=15,pady=(320,0), sticky = S) #self.toplevel = Toplevel() #Buttons/Text self.title2 = Label(self.stuffframe,text="Cleaning & Processing Data", font = "-weight bold") self.title2.grid(row=0,column=0,sticky=W+N) self.title3 = Label(self.stuffframe,text="Visit Github.com/ljstrnadiii") self.title3.grid(row=1,column=0,sticky=W+N) self.text1 = Label(self.stuffframe, text="Choose files:") self.text1.grid(row=2,column=0, pady =(10,0),sticky=W) self.button1= Button(self.stuffframe, text="Scanned txt", command = self.browsecsv) self.button1.grid(row=3, column=0, sticky=W) self.button7= Button(self.stuffframe, text="amend data", command = self.ammend) self.button7.grid(row=4, column=0, sticky=W) self.button2= Button(self.stuffframe, text="Valid xls", command = self.browsevalid) self.button2.grid(row=5, column=0, sticky = W) self.text2 = Label(self.stuffframe, text="Process:") self.text2.grid(row=7,column=0, pady =(10,0), sticky = W) self.button3= Button(self.stuffframe, text="Correct", command = self.check ) self.button3.grid(row=8, column=0,sticky=W+N ) self.button4= Button(self.stuffframe, text="Get Count", command = self.count) self.button4.grid(row=9, column=0, sticky = W+N) label1 = Label(self.processing,text ="") self.title_instr = Label(self.stuffframe,text="Procedure: show negative, edit, update, repeat") self.title_instr.grid(row=15,column=0,sticky=W+N) self.button5 = Button(self.stuffframe, text="show negatives", command = self.fixnegs) self.button5.grid(row=16, column = 0, sticky = W) self.button6 = Button(self.stuffframe, text="update", command = self.update) self.button6.grid(row=17, column = 0, sticky = W) # setting tables up self.pt1 = Table(self.f1, rows=14,column=24, showtoolbar=False, showstatusbar=False) self.pt2 = Table(self.f2, rows=17, column=24, showtoolbar=False, showstatusbar=False) self.pt1.show() self.pt2.show() self.processing.config(bd=5) # functions made for Window def browsecsv(self): Tk().withdraw() self.filename1 = askopenfilename() filename = ntpath.basename(self.filename1) Label(self.stuffframe,text=filename, wraplength = 200 , justify = LEFT).grid(row=10, column=0, sticky=W) def ammend(self): Tk().withdraw() self.filename3 = askopenfilename() filename = ntpath.basename(self.filename3) Label(self.stuffframe,text=filename, wraplength = 200 , justify = LEFT).grid(row=11, column=0, sticky=W) def browsevalid(self): Tk().withdraw() self.filename2 = askopenfilename() filename = ntpath.basename(self.filename2) Label(self.stuffframe,text=filename ).grid(row=12, column=0, sticky = W) def check(self): text1 = proc.correctfields(self.filename1, self.filename2) proc.ammend(self.filename1,self.filename3) self.checklabel.set(text1) #label1 = Label(self.stuffframe,textvariable = self.checklabel, \ # wraplength=250, justify=LEFT) #label1.grid(row=13,column=0, sticky = W) def count(self): self.corrected, self.trouble, self.text2 = \ proc.getcount(self.filename1) # self.pt1, \ self.countlabel.set(self.text2) Label2 = Label(self.stuffframe, text = self.countlabel.get(), \ wraplength = 250,justify=LEFT) Label2.grid(row = 14, column = 0, sticky =W) self.corrected = self.corrected.fillna(0) self.pt1.model.df = self.corrected self.pt1.redraw() def fixnegs(self): if len(self.trouble)>0: dq = self.corrected.ix[self.corrected[ \ "Account_Number"]==self.trouble[-1][-1],:] print(list(dq)) dq = dq[["Store","Inv_Type","Date",self.trouble[-1][-2]]] # where is the neg value and what it is. append it in a column where = self.trouble[-1][-3] negcol=np.zeros(len(dq)) negcol[where-1]=self.trouble[-1][-6] dq["value"]=negcol # uncomment for label of neg value # self.n = (self.trouble[-1][-5].isoformat()[0:10],self.trouble[-1][-6]) #self.neglabel.set(str(self.n)) #Label3 = Label(self.stuffframe, text = self.neglabel.get(), \ # wraplength = 250,justify=LEFT) #Label3.grid(row=15,column=0,sticky=W) dq = pd.DataFrame(dq) dq = dq.fillna(0) dq[list(dq)[-2]]= dq[list(dq)[-2]].astype(int) dq[list(dq)[-1]]= dq[list(dq)[-1]].astype(int) dq[list(dq)[-4]]= dq[list(dq)[-4]].astype(int) self.pt2.model.df = dq#.loc[:last+1,:] self.pt2.redraw() # pop last element from list assuming user will update before fixnegs again self.trouble.pop() else: self.pt2.clearTable() self.pt2.redraw() def update(self): #note: i dont think i need a child table: # try to just create a table in fixnegs and below in update call on the # df o update accordingly. consider the indexes though self.pt1.model.df.update(self.pt2.model.df) self.pt1.redraw() #uncomment to save self.pt1.model.df.to_csv(self.filename1, index=False)
def Report(ImageFrame, ImageLabel, ComplaintsOTButton,ProductIssueButton,CompanyButton,ReportButton): try: global REFRESH_COT_FLG,ReportRefreshFlag ReportRefreshFlag=True REFRESH_COT_FLG=True ComplaintsOTButton.config(state=DISABLED) ProductIssueButton.config(state=DISABLED) CompanyButton.config(state=DISABLED) ReportButton.config(state=DISABLED) ImageLabel.destroy() TopFetchFrame=Frame(ImageFrame) TopFetchFrame.pack(side=TOP) BottomFrame=Frame(ImageFrame) BottomFrame.pack() f = plt.figure() pt = Table(TopFetchFrame,showtoolbar=True) pt.model=TableModel(rows=20,columns=5) pt.show() def ReportAnimate(i): try: global REFRESH_COT_FLG if REFRESH_COT_FLG is True: global FilteredDF,ReportRefreshFlag ax1=f.add_subplot(131) ax1.clear() ax1.pie(FilteredDF.Issue.groupby([FilteredDF.CompanyResponseConsumer]).count(), labels=pd.unique(FilteredDF.CompanyResponseConsumer),shadow=True,autopct='%1.1f%%', startangle=90) ax1.set_title('Company Response') ax2=f.add_subplot(132) ax2.clear() ax2.pie(FilteredDF.Issue.groupby([FilteredDF.TimelyResponseSts]).count(), labels=pd.unique(FilteredDF.TimelyResponseSts),shadow=True,autopct='%1.1f%%', startangle=90) ax2.set_title('Timely Closure') ax3=f.add_subplot(133) ax3.clear() ax3.pie(FilteredDF.Issue.groupby([FilteredDF.ConsumerDisputedSts]).count(), labels=pd.unique(FilteredDF.ConsumerDisputedSts),shadow=True,autopct='%1.1f%%', startangle=90) ax3.set_title('User Satisfaction') ReportDF=FilteredDF ReportDF['Issue Count']=ReportDF.ComplaintId PivotDF=ReportDF.pivot_table(['Issue Count'], index=['Company'], columns=['Product'], aggfunc='count', fill_value =0 ) PivotColumnIndex=list(PivotDF.index.values) DF=pd.DataFrame(PivotDF,index=PivotColumnIndex) if ReportRefreshFlag is True: pt.updateModel(TableModel(dataframe=DF)) pt.showIndex() pt.redraw() ReportRefreshFlag=False else: pt.updateModel(TableModel(dataframe=DF)) pt.showIndex() pt.redraw() REFRESH_COT_FLG=False except Exception as e: print(e) canvas = FigureCanvasTkAgg(f, BottomFrame) canvas.show() canvas.get_tk_widget().pack() ani=animation.FuncAnimation(f,ReportAnimate,1000) except Exception as e: print('')