def __init__(self, master = None): Tk.Frame.__init__(self, master) self.master.wm_geometry("650x300+250+200") self.master.title(u"Amazon 本検索") #タイトルラベル titleLabel = Tk.Label(self, master, text = u"中文", font=('Helvetica', '10', 'bold')) titleLabel.grid(row = 0, column = 0, padx = 0, pady = 0) #タイトル入力 self.titleStrVar = Tk.StringVar() self.titleInputEntry = Tk.Entry(self, textvariable = self.titleStrVar) self.titleInputEntry.grid(row = 1, column = 0, padx = 5, pady = 5) # 検索ボタン button = Tk.Button(self, text="検索", command=self.search, width = 10) button.grid(row = 1, column = 1, padx = 5, pady = 5) # テーブル self.tableVar = ta.ArrayVar(self) #self.__set_table_title() table = ta.Table(self, rows=10, cols=3, state='disabled', width=10, height=10, titlerows=1, colwidth=30, variable=self.tableVar, selecttype='row') table.grid(row = 2, column = 0, columnspan = 2, sticky=Tk.W + Tk.E + Tk.N + Tk.S)
def table_test(): #### DEFINES THE INTERFACE #### master = tk.Tk() master.geometry('500x200+250+200') master.title('Dogs') #### DEFINING THE TABLE #### tb = tktable.Table(master, state='disabled', width=50, titlerows=1, rows=5, cols=4, colwidth=20) columns = ['Breed', 'Price', 'Location', 'Age'] #### LIST OF LISTS DEFINING THE ROWS AND VALUES IN THOSE ROWS #### values = [['Doodle', '1500', 'Chicago', '1'], ['Pug', '700', 'Kansas City', '2'], ['Westie', '1000', 'Lincoln', '1'], ['Poodle', '900', 'Atlanta', '2']] #### SETS THE DOGS INTO THE TABLE #### #### VVVVVVVVVVVVVVVVVVVVVVVVVVV #### #DEFINING THE VAR TO USE AS DATA IN TABLE var = tktable.ArrayVar(master) row_count = 0 col_count = 0 #SETTING COLUMNS for col in columns: index = "%i,%i" % (row_count, col_count) var[index] = col col_count += 1 row_count = 1 col_count = 0 #SETTING DATA IN ROWS for row in values: for item in row: print(item) index = "%i,%i" % (row_count, col_count) ## PLACING THE VALUE IN THE INDEX CELL POSITION ## var[index] = item #### IGNORE THIS IF YOU WANT, JUST SETTING SOME CELL COLOR #### try: if int(item) > 999: tb.tag_cell('green', index) except: pass ############################################################### col_count += 1 col_count = 0 row_count += 1 #### ABOVE CODE SETS THE DOG INTO THE TABLE #### ################################################ #### VARIABLE PARAMETER SET BELOW ON THE 'TB' USES THE DATA DEFINED ABOVE #### tb['variable'] = var tb.pack() #tb.tag_cell('green',index) tb.tag_configure('green', background='green') #### MAINLOOPING #### tk.mainloop()
def _buildtable(self): self.tb = tktable.Table( self.master, state='disable', rowstretch='all', colstretch='all', height='1', rows=len(self.data[0]), cols=len(self.data), resizeborders='col', borderwidth='0.5', variable=self.var, flashmode='on', usecommand=0, titlecols=1, selectmode='extended', selecttitle=1, selecttype='row', ) ysb = tk.Scrollbar(self.master, orient="vertical", command=self.tb.yview_scroll) xsb = tk.Scrollbar(self.master, orient="horizontal", command=self.tb.xview_scroll) self.tb.configure(yscrollcommand=ysb.set, xscrollcommand=xsb.set) ysb.pack(side='right', fill='y', in_=self.master) xsb.pack(side='bottom', fill='x', in_=self.master) # tb['variable'] = self.var # adjust the width for the content j = 0 columnwidth = {} for item in self.data: for i in item: if (str(j) in columnwidth) == False: columnwidth[str(j)] = len(i.title()) elif (len(i.title())) > columnwidth[str(j)]: columnwidth[str(j)] = len(i.title()) j += 1 self.tb.width(**columnwidth) self.tb.pack(expand=1, fill='both') self.tb.tag_configure('sel', bg='yellow') #tb.tag_cell('green',index) # tb.tag_configure('green', background='green') #### MAINLOOPING ####s def OnClick(event): global table_data index = self.tb.index('active') if self.tb.tag_includes('title', index) == True: print(1) sortby(table_data, index) self.tb.bind("<Double-Button-1>", OnClick)
def __init__(self, master): """master is the top level window""" master.geometry(("%dx%d") % (250, 60)) master.title("Test") frame = Frame(master) frame.pack() var = tktable.ArrayVar(frame) for y in range(6): for x in range(6): index = "%i,%i" % (y, x) var[index] = index label = Label(frame, text="test2") label.pack(side='top', fill='x') quit = Button(frame, text="QUIT", command=root.destroy) quit.pack(side='bottom', fill='x') test = tktable.Table(frame, rows=6, cols=6, state='disabled', width=6, height=6, titlerows=1, titlecols=0, roworigin=0, colorigin=0, selectmode='browse', selecttype='row', rowstretch='unset', colstretch='last', flashmode='on', variable=var, usecommand=0) test.pack(expand=1, fill='both') test.tag_configure('sel', background='yellow') test.tag_configure('active', background='blue') test.tag_configure('title', anchor='w', bg='red', relief='sunken')
def create_table(self): global tb global var global flashcard_frame global row_count row_count = 0 flashcard_frame = tk.Frame(root) flashcard_frame.pack() tb = tktable.Table(flashcard_frame, width=50, rows=80, cols=2, titlerows=1, colwidth=40) var = tktable.ArrayVar(flashcard_frame) tb['variable'] = var tb.pack()
def __init__(self, version): self.root = mtTkinter.Tk(className='FOECLIGBCalculator') self.root.title(version + ' FOE CLI GB Calculator') self.root.geometry("250x350") self.version = version self.gbTitle = mtTkinter.StringVar() self.gbOwnerName = mtTkinter.StringVar() self.remainingFPs = mtTkinter.StringVar() self.investText = mtTkinter.StringVar() self.profitText = mtTkinter.StringVar() self.warningText = mtTkinter.StringVar() self.tableArray = tktable.ArrayVar(self.root) self.Table = tktable.Table(self.root, state='disabled', titlerows=1, rows=6, cols=3, variable=self.tableArray, flashmode='on') self.createWindow()
def __init__(self): self.win = tk.Tk() self.win.title("Net Worth Worksheet") self.var = None self.row_count = 0 self.tb = None self.net_worth = Net_Worth() self.assets = self.net_worth.assets self.liabilities = self.net_worth.liabilities self.tb = tktable.Table(self.win, width=50, rows=80, cols=2, colwidth=40) self.var = tktable.ArrayVar(self.win) self.text_intro() self.update_gui() self.show_assets() tk.mainloop()
def _buildtable(self): self.Table = tktable.Table(self.master, state='disabled', rowstretch='all', colstretch='none', height='3', rows=len(self.data[0]), cols=len(self.data), # resizeborders='col', borderwidth='1', variable=self.var, usecommand=0, titlecols=1, titlerows=1, selectmode='extended', selecttitle=1, selecttype='cell',) ysb = tk.Scrollbar(self.master,orient="vertical", command=self.Table.yview_scroll) xsb = tk.Scrollbar(self.master,orient="horizontal", command=self.Table.xview_scroll) self.Table.configure(yscrollcommand=ysb.set,xscrollcommand=xsb.set) ysb.pack(side='right', fill='y',in_=self.master) xsb.pack(side='bottom',fill='x',in_=self.master) j=0 columnwidth={} for item in self.data: for i in item: if (str(j) in columnwidth) == False: columnwidth[str(j)]= 10 elif (len(i.title())) > columnwidth[str(j)]: columnwidth[str(j)]= len(i.title()) j+=1 # self.Table.delete_rows(1,count=1) # self.Table['state']='disabled' self.Table.width(**columnwidth) self.Table.pack(expand=1,fill='both') self.Table.tag_configure('sel', bg='goldenrod1') # change the tag color for i in range(1,len(self.data)): self.Table.tag_cell('Report1','0,%i' % (i)) self.Table.tag_lower('Report1',belowthis='title') self.Table.tag_configure('Report1',bg=report_color['Report1']) # popupmenu code self.menu = tk.Menu(self.Table, tearoff=0) self.menu.add_command(label="Search Related Report") self.menu.add_separator() self.menu.add_command(label="Analyze",) self.menu.add_separator() self.menu.add_command(label="Hello!") def popupmenu(event): index = self.Table.index('active') if self.Table.tag_includes('title',index) == True: # offset = self.menu.yposition(3) self.menu.post(event.x_root, event.y_root) self.Table.bind("<Button-2>", popupmenu) #tb.tag_cell('green',index) # tb.tag_configure('green', background='green') #### MAINLOOPING ####s def DoubleClick(event): index = self.Table.index('active') if self.Table.tag_includes('title',index) == True: sortdata(index,self) self.Table.bind("<Double-Button-1>",DoubleClick)
#!/usr/bin/evn python # -*- coding: utf-8 -*- # python version 2.7.6 from Tkinter import * import tktable root = Tk() root.title("Probabilidade e estatistica") table = tktable.Table(root, rows=2, cols=10) table.pack() root.mainloop()
def _build_table(self): self.Table = tktable.Table(self.tableframe, state='disabled', rowstretch='all', colstretch='all', height='1', rows=len(self.data[0]), cols=len(self.data), # resizeborders='col', borderwidth='1', variable=self.var, usecommand=0, titlerows=1, # selectmode='extended', selecttitle=1, selecttype='row',) ysb = tk.Scrollbar(self.tableframe,orient="vertical", command=self.Table.yview_scroll) xsb = tk.Scrollbar(self.tableframe,orient="horizontal", command=self.Table.xview_scroll) self.Table.configure(yscrollcommand=ysb.set,xscrollcommand=xsb.set) ysb.pack(side='right', fill='y',in_=self.tableframe) xsb.pack(side='bottom',fill='x',in_=self.tableframe) j=0 columnwidth={} for item in self.data: for i in item: if (str(j) in columnwidth) == False: columnwidth[str(j)]= 10 elif (len(i.title())) > columnwidth[str(j)]: columnwidth[str(j)]= len(i.title()) j+=1 # self.Table.delete_rows(1,count=1) # self.Table['state']='disabled' self.Table.width(**columnwidth) self.Table.pack(expand=1,fill='both') self.Table.tag_configure('sel', bg='goldenrod1') # # popupmenu code # self.menu = tk.Menu(self.Table, tearoff=0) # self.menu.add_command(label="Search Related Report") # self.menu.add_separator() # self.menu.add_command(label="Analyze",) # self.menu.add_separator() # self.menu.add_command(label="Hello!") # def popupmenu(event): # index = self.Table.index('active') # if self.Table.tag_includes('title',index) == True: # # offset = self.menu.yposition(3) # self.menu.post(event.x_root, event.y_root) # self.Table.bind("<Button-2>", popupmenu) #tb.tag_cell('green',index) # tb.tag_configure('green', background='green') #### MAINLOOPING ####s def DoubleClick(event): global report_names index = self.Table.index('active') if self.Table.tag_includes('title',index) == True: self.sortdata(index) else: index_x = int(index.split(',')[0]) # print(index_x) index = self.cur_df.index.tolist()[index_x-1] keyword_raw = self.cur_df.ix[(index)].tolist() keyword = [] for item in keyword_raw: keyword.append(item.replace('[','\[').replace(']','\]')) for item in report_details: content = re.match(r'(.*Startpoint\: %s.*(?:.*\n)*?.*Endpoint\: %s.*(?:.*\n)*?.*Path Group\: %s.*(?:.*\n)*?.*slack \([A-Z]*\).*?%s.*)' % (keyword[0],keyword[1],keyword[2],keyword[3]),item) if content != None: _str = content.group() self.Table.bind("<Double-Button-1>",DoubleClick)
def setTable(self, tableFrame, gridRow, gridColumn, rows, cols, excel): tb = tktable.Table(tableFrame, selectmode="browse", state='disabled', width=8, height=11, font=(6), exportselection=0, titlerows=1, titlecols=1, rows=rows + 1, cols=cols + 1, colwidth=9) #### LIST OF LISTS DEFINING THE ROWS AND VALUES IN THOSE ROWS #### #### SETS THE DOGS INTO THE TABLE #### #DEFINING THE VAR TO USE AS DATA IN TABLE var = tktable.ArrayVar(tableFrame) row_count = 0 col_count = 1 #SETTING COLUMNS for col in range(0, cols): index = "%i,%i" % (row_count, col_count) var[index] = ExcelDiffer.GetColumnLeter(col) col_count += 1 #SETTING ROWS row_count = 1 col_count = 0 for row in range(0, rows): index = "%i,%i" % (row_count, col_count) var[index] = row + 1 row_count += 1 #SETTING DATA IN ROWS row_count = 1 col_count = 1 for row in excel.data: for item in row: index = "%i,%i" % (row_count, col_count) ## PLACING THE VALUE IN THE INDEX CELL POSITION ## if item is None: var[index] = "" else: var[index] = item col_count += 1 col_count = 1 row_count += 1 #### ABOVE CODE SETS THE DOG INTO THE TABLE #### ################################################ #### VARIABLE PARAMETER SET BELOW ON THE 'TB' USES THE DATA DEFINED ABOVE #### tb['variable'] = var tb.tag_configure('title', relief='raised', anchor='center', background='#D3D3D3', fg='BLACK', state='disabled') tb.width(**{"0": 5}) xScrollbar = Scrollbar(tableFrame, orient='horizontal') xScrollbar.grid(row=gridRow + 1, column=gridColumn, sticky="ew") xScrollbar.config(command=tb.xview_scroll) tb.config(xscrollcommand=xScrollbar.set) yScrollbar = Scrollbar(tableFrame) yScrollbar.grid(row=gridRow, column=gridColumn + 1, sticky="ns") yScrollbar.config(command=ScrollDummy(tb).yview) tb.config(yscrollcommand=yScrollbar.set) tb.grid(sticky="nsew", row=gridRow, column=gridColumn) return tb, var
def _buildtable(self): self.tb = tktable.Table( self.master, state='disabled', rowstretch='all', colstretch='none', height='1', rows=len(self.data[0]), cols=len(self.data), resizeborders='col', borderwidth='0.5', variable=self.var, flashmode='on', usecommand=0, titlecols=1, titlerows=1, selectmode='extended', selecttitle=1, selecttype='cell', ) ysb = tk.Scrollbar(self.master, orient="vertical", command=self.tb.yview_scroll) xsb = tk.Scrollbar(self.master, orient="horizontal", command=self.tb.xview_scroll) self.tb.configure(yscrollcommand=ysb.set, xscrollcommand=xsb.set) ysb.pack(side='right', fill='y', in_=self.master) xsb.pack(side='bottom', fill='x', in_=self.master) # tb['variable'] = self.var # adjust the width for the content j = 0 columnwidth = {} for item in self.data: for i in item: if (str(j) in columnwidth) == False: columnwidth[str(j)] = len(i.title()) + 4 elif (len(i.title())) > columnwidth[str(j)]: columnwidth[str(j)] = len(i.title()) + 4 j += 1 self.tb.width(**columnwidth) self.tb.pack(expand=1, fill='both') self.tb.tag_configure('sel', bg='goldenrod1') # popupmenu code self.menu = tk.Menu(self.tb, tearoff=0) self.menu.add_command(label="Search Related Report") self.menu.add_separator() self.menu.add_command(label="Analyze", ) self.menu.add_separator() self.menu.add_command(label="Hello!") def popupmenu(event): index = self.tb.index('active') if self.tb.tag_includes('title', index) == True: offset = self.menu.yposition(3) self.menu.post(event.x, event.y + offset) self.tb.bind("<Button-2>", popupmenu) #tb.tag_cell('green',index) # tb.tag_configure('green', background='green') #### MAINLOOPING ####s def DoubleClick(event): global current_data index = self.tb.index('active') if self.tb.tag_includes('title', index) == True: #print(2) sortby(index) self.tb.bind("<Double-Button-1>", DoubleClick)
def __init__(self, master, title_column, data): self.var = tktable.ArrayVar(master) self.num_cols = 1 + len(data) self.num_rows = len(title_column) row_count = 0 col_count = 0 #SETTING COLUMNS for row in title_column: index = "%i,%i" % (row_count, col_count) self.var[index] = row row_count += 1 col_count = 1 row_count = 0 #SETTING DATA IN ROWS for col in data: for item in col: #print(item) index = "%i,%i" % (row_count, col_count) ## PLACING THE VALUE IN THE INDEX CELL POSITION ## self.var[index] = item #### IGNORE THIS IF YOU WANT, JUST SETTING SOME CELL COLOR #### ''' try: if int(item) > 999: tb.tag_cell('green',index) except: pass''' ############################################################### row_count += 1 row_count = 0 col_count += 1 #### ABOVE CODE SETS THE DOG INTO THE TABLE #### self.tb = tktable.Table( master, state='disabled', rowstretch='all', colstretch='all', height='1', rows=self.num_rows, cols=self.num_cols, resizeborders='col', borderwidth='0.5', variable=self.var, flashmode='on', usecommand=0, titlerows=1, titlecols=1, ) # columns0 = ['Timing Path Group', 'Levels of Logic', 'Critical Path Length', 'Critical Path Slack', 'Critical Path Clk Period', 'Total Negative Slack', 'No. of Violating Paths', 'Worst Hold Violation', 'Total Hold Violation', 'No. of Hold Violations'] #### LIST OF LISTS DEFINING THE ROWS AND VALUES IN THOSE ROWS #### # values = [['INPUTS', '1.000', '0.238', '0.643', '1.000', '0.000', '0.000', '0.000', '0.000', '0.000'], ['OUTPUTS', '1.000', '0.108', '0.292', '0.500', '0.000', '0.000', '0.000', '0.000', '0.000'], ['rclk', '7.000', '0.543', '-0.066', '0.500', '-0.106', '2.000', '0.000', '0.000', '0.000'], ['wclk', '5.000', '0.946', '0.035', '1.000', '0.000', '0.000', '0.000', '0.000', '0.000']] #### SETS THE DOGS INTO THE TABLE #### #### VVVVVVVVVVVVVVVVVVVVVVVVVVV #### #DEFINING THE VAR TO USE AS DATA IN TABLE ################################################ #### VARIABLE PARAMETER SET BELOW ON THE 'TB' USES THE DATA DEFINED ABOVE #### ysb = tk.Scrollbar(master, orient="vertical", command=self.tb.yview_scroll) xsb = tk.Scrollbar(master, orient="horizontal", command=self.tb.xview_scroll) self.tb.configure(yscrollcommand=ysb.set, xscrollcommand=xsb.set) ysb.pack(side='right', fill='y', in_=master) xsb.pack(side='bottom', fill='x', in_=master) # tb['variable'] = self.var # adjust the width for the content j = 1 columnwidth = {} for item in data: for i in item: if (str(j) in columnwidth) == False: columnwidth[str(j)] = len(i.title()) elif (len(i.title())) > columnwidth[str(j)]: columnwidth[str(j)] = len(i.title()) j += 1 for item in title_column: if (str(0) in columnwidth) == False: columnwidth[str(0)] = len(item.title()) elif (len(item.title())) > columnwidth[str(0)]: columnwidth[str(0)] = len(item.title()) self.tb.width(**columnwidth) #for col in columns: # tb.columnconfigure(col, width=tkFont.Font().measure(col.title())) # tb.columnconfigure(col, width=tkFont.Font().measure(col.title())) self.tb.pack(expand=1, fill='both')
def Maximizar(): perdidoMinimizar.append(0) ############INICIO ALGORITMO################ #Obtengo los maximos y minimos de cada variable asi como sus mjs for i in range(len(z)): #para cada variable en la funcion objetivo if z[i].get( ) != "": # No tomes en cuenta las variables que estan vacias en la funcion objetivo minimos.append(Minimo(i)) #obten el minimo de la variable maximos.append(Maximo(i)) #obten el maximo de la variable mjs.append( Calcula_mj(minimos[i], maximos[i]) ) #obtener cuantos bits debe tener la poblacion por culpa de esa variable ImprimeArreglos() #modificacion Vicky # recupera el numero de iteraciones y lo guarda en otra variable for i in range(len(Itera)): iteraciones = int(Itera[i].get()) print iteraciones for i in range(4): #Creo 4 vectores de poblacion """ En las siguientes iteraciones, en lugar de crear nuevos vectores y usar append se va a hacer poblacion[i]=Cruza(Num_de_vector1,Num_de_vector2) O en su defecto poblacion[i]=Mutacion(Num_de_vector1) """ poblacion.append(NuevoVector( )) ##Creo un nuevo vector que tenga el tamano de todas las mjs SeleccionNatural( i) ##Antes de aceptarlo, veo que cumpla con las condiciones (s.a.) ############################ AQUI INICIARIA LA ITERACION N ################################################ while True: """ Ahora que ya tengo vectores que cumplen con las condicions (s.a), empiezo a llenar la tabla (ver tus apuntes) En este caso empiezo con las variables X,Y,W,V pero con su valor real, el cual se obtiene de_ min+decimal(CADENA BINARA)*(maximo-minimo)(2**mjs-1) """ for i in range(4): #Para cada vector Variable_enTabla( i) #Obtengo los valores X,Y.W.V que genera dicho vector Evalua_Z_enTabla( i ) #Evaluo los valores anteriores en la funcion objetivo y tengo Z Sumatoria_Z() #Hago la sumatoria en z Porcientos() #Saco los porcentajes AcumulativoZ() #Hago el zig zag de la tabla Aleatorios() #Genero cuatro numeros aleatorios de 0 a 1 for i in range(4): #Para cada vector de la poblacion SegundaSeleccion( i ) #Checo cuales vectores sobreviven para mutaciones y cruzas y cuales no ImprimeArreglos() #time.sleep(10) print "*************************************************" if int(Itera[0].get()) > 10: n = 10 else: n = 2 if iteraciones > n: for i in range(4): if (Sobrevive(i) == 0): numeroVeredicto1 = int(random.uniform(0, 4)) numeroVeredicto2 = int(random.uniform(0, 4)) if (veredicto[numeroVeredicto1] == veredicto[numeroVeredicto2]): numeroVeredicto2 = int(random.uniform(0, 4)) poblacion[i] = Cruzar(veredicto[numeroVeredicto1], veredicto[numeroVeredicto2]) SeleccionNatural_ConCruza(i, veredicto[numeroVeredicto1], veredicto[numeroVeredicto2]) else: for i in range(4): if (Sobrevive(i) == 0): poblacion[i] = Mutar(i) poblacion[i] = SeleccionNatural_ConMutacion(i) """ Faltaria por agregar las mutaciones y las cruzas """ iteraciones = iteraciones - 1 print iteraciones if iteraciones == 0: obtieneResultado() break #time.sleep(10) ####################################################AQUI TERMINARIA LA ITERACION ################################3 """ Esto es lo que dibuja la tabla (hasta antes de "def SegundaSeleccion") """ #OBTENER VALOR DE Z PARA LA TABLA #Configuraciones basicas otra_ventana = tk.Toplevel() vent = tk.Frame(otra_ventana) raiz.withdraw() vent.grid(column=0, row=0, padx=(50, 50), pady=(10, 10)) vent.columnconfigure(0, weight=1) vent.rowconfigure(0, weight=1) stringObjetivo = "Z=" cont = 0 conta = 0 for l in range(len(z)): if (z[l].get() != ""): conta += 1 for l in range(len(z)): if (z[l].get() != ""): if (cont == 0): stringObjetivo += z[l].get() + "X" if (cont == 1): stringObjetivo += z[l].get() + "Y" if (cont == 2): stringObjetivo += z[l].get() + "W" if (cont == 3): stringObjetivo += z[l].get() + "V" if (cont < conta - 1): stringObjetivo += "+" cont += 1 Label_FuncionObjetivo = tk.Label(vent, text=stringObjetivo) Label_FuncionObjetivo.grid(column=3, row=0) Label_FuncionTexto = tk.Label(vent, text="Funcion Objetivo: Z=" + str(resultado[0])) Label_FuncionTexto.grid(column=0, row=0, columnspan=3) Label_XRes = tk.Label(vent, text="X=" + str(resultado[1])) Label_XRes.grid(column=1, row=1) Label_YRes = tk.Label(vent, text="Y=" + str(resultado[2])) Label_YRes.grid(column=2, row=1) Label_WRes = tk.Label(vent, text="W=" + str(resultado[3])) Label_WRes.grid(column=3, row=1) Label_VRes = tk.Label(vent, text="V=" + str(resultado[4])) Label_VRes.grid(column=4, row=1) Boton_salir = tk.Button(vent, text="Salir", command=fin) Boton_salir.grid(column=3, row=15) Tabla = tkt.Table(vent, rows=5, cols=5) for i in range(5): for j in range(10): if (i == 0): if (j == 0): l = tk.Label(vent, text="X") elif (j == 1): l = tk.Label(vent, text="Y") elif (j == 2): l = tk.Label(vent, text="W") elif (j == 3): l = tk.Label(vent, text="V") elif (j == 4): l = tk.Label(vent, text="Z") elif (j == 5): l = tk.Label(vent, text="% z") elif (j == 6): l = tk.Label(vent, text="% z acumulado") elif (j == 7): l = tk.Label(vent, text="Aleatorios") elif (j == 8): l = tk.Label(vent, text="Nuevo V") elif (j == 0): if perdidoMinimizar[0] == 1: l = tk.Label(vent, text=str(float(x_entabla[i - 1]) / (10))) else: l = tk.Label(vent, text=str(x_entabla[i - 1])) elif (j == 1): if perdidoMinimizar[0] == 1: l = tk.Label(vent, text=str(float(y_entabla[i - 1]) / (10))) else: l = tk.Label(vent, text=str(y_entabla[i - 1])) elif (j == 2): if perdidoMinimizar[0] == 1: l = tk.Label(vent, text=str(float(w_entabla[i - 1]) / (10))) else: l = tk.Label(vent, text=str(w_entabla[i - 1])) elif (j == 3): if perdidoMinimizar[0] == 1: l = tk.Label(vent, text=str(float(v_entabla[i - 1]) / (10))) else: l = tk.Label(vent, text=str(v_entabla[i - 1])) elif (j == 4): if perdidoMinimizar[0] == 1: l = tk.Label(vent, text=str(float(z_entabla[i - 1]) / (10))) else: l = tk.Label(vent, text=str(z_entabla[i - 1])) elif (j == 5): l = tk.Label(vent, text=str(porcentaje_z[i - 1])) elif (j == 6): l = tk.Label(vent, text=str(z_acumulado[i - 1])) elif (j == 7): l = tk.Label(vent, text=str(aleatorios_tabla[i - 1])) elif (j == 8): l = tk.Label(vent, text=str(veredicto[i - 1])) l.grid(row=i + 5, column=j) #Tabla.grid(column=1, row=2,columnspan=6) otra_ventana.mainloop()
def drawtable(frame, df): var = tktable.ArrayVar() i = 0 table_data = [] for item in df.columns.tolist(): table_data.append(df[item].tolist()) table_data[i].insert(0, item) i += 1 #print(table_data) col_count = 0 row_count = 0 for column in table_data: for row in column: index = "%i,%i" % (row_count, col_count) #print(index) var[index] = row row_count += 1 col_count += 1 row_count = 0 Table = tktable.Table( frame, state='disabled', rowstretch='all', colstretch='all', height=str(len(table_data[0])), rows=len(table_data[0]), cols=len(table_data), # resizeborders='col', borderwidth='2', variable=var, usecommand=0, titlerows=1, # selectmode='extended', selecttitle=1, selecttype='cell') Table.grid(row=0, column=0, padx=3, pady=3) j = 0 columnwidth = {} for item in table_data: for i in item: if (str(j) in columnwidth) == False: columnwidth[str(j)] = 15 elif (len(str(i).title())) > columnwidth[str(j)]: columnwidth[str(j)] = len(str(i).title()) j += 1 vbar = Scrollbar(frame, orient="vertical", command=Table.yview_scroll) Table.configure(yscrollcommand=vbar.set) #vbar.pack(side='right', fill='y',in_=frame) #Table.pack(expand=1,fill='both') Table.grid(row=0, column=0, padx=3, pady=3) vbar.grid(row=0, column=1, sticky=NS) Table.width(**columnwidth) Table.tag_configure('sel', bg='khaki') return var, Table