def __init__(self, master, report_details): self.master = master self.masterframe = tk.Frame(self.master) self.tableframe = tk.Frame(self.masterframe) self.var = tktable.ArrayVar(self.tableframe) self._str_path_detail_t = tk.StringVar() self.text_box_t = tk.Label(self.masterframe, textvariable=self._str_path_detail_t, justify='left', anchor='w') self._str_path_detail_b = tk.StringVar() self.text_box_b = tk.Label(self.masterframe, textvariable=self._str_path_detail_b, justify='left', anchor='w') self.showflag = 0 self.sortflag = 0 self.convert_details(report_details) self.raw_df = self.cur_df.copy() self.data = self.to_table(self.cur_df) self._assign_var() self._build_table() self.text_box_t.pack(side='top') self.text_box_b.pack(side='bottom') self.tableframe.pack(side='bottom', after=self.text_box_b, expand=1, fill='both') self.master.add(self.masterframe, sticky='nesw')
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 __init__(self,master,data): self.master = tk.Frame(master) self.var = tktable.ArrayVar(self.master) self.showflag = 0 self.data = data self._assign_var() self._buildtable() self.master.pack(expand=1,fill='both')
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 __init__(self,master,dataframe): self.master = master self.masterframe = tk.Frame(master) self.var = tktable.ArrayVar(self.masterframe) self.showflag = 0 self.sortflag = 0 self.detail_flag = False self.raw_df = dataframe.copy() self.cur_df = dataframe.copy() self.data = self.to_table(self.cur_df) self._assign_var() self._build_table(master) self.masterframe.pack(expand=1,fill='both',side='top')
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 __init__(self, master, dataframe, report_details, report_num): self.master = master self.panedwindow = tk.PanedWindow(master, orient='vertical', sashrelief='sunken', sashwidth=8, showhandle=True, handlepad=400, handlesize=9) self.panedwindow.pack(expand=1, fill='both') self.masterframe = tk.Frame(self.panedwindow) self.var = tktable.ArrayVar(self.masterframe) self.report_details = report_details self.report_num = report_num self.showflag = 0 self.sortflag = 0 self.detail_flag = False self.raw_df = dataframe.copy() self.cur_df = dataframe.copy() self.data = self.to_table(self.cur_df) self._assign_var() self._build_table() # self.Table.selection_set('2,2','3,3') self.panedwindow.add(self.masterframe, sticky='news', minsize=200)
def __init__(self, master, data_array): self.master = master self.data = data_array self.var = tktable.ArrayVar(self.master) self._assign_var() self._buildtable()
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 __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 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