def showCatgory(): Cat1_window = tk.Toplevel(root) Cat1_window.geometry('300x400') Cat1_window.resizable(0, 0) Cat1_window.title('1000萬發票 消費品項統計表') frame1 = Frame(Cat1_window) frame1.place(x=0, y=10, width=280, height=400) scrBar1 = tk.Scrollbar(Cat1_window) scrBar1.pack(side=tk.RIGHT, fill=tk.Y) tree1 = Treeview(Cat1_window, columns=('c1', 'c2'), show='headings', yscrollcommand=scrBar1.set) tree1.column('c1', width=200, anchor='center') tree1.column('c2', width=80, anchor='center') tree1.heading('c1', text='品項') tree1.heading('c2', text='出現次數') tree1.pack(side=tk.LEFT, fill=tk.Y) scrBar1.config(command=tree1.yview) tree1.bind('<Button-1>', treeviewClick) sort1000 = [[v[1], v[0]] for v in Cat_1000.items()] sort1000.sort() sort1000.reverse() for z in sort1000: tree1.insert('', 'end', text=z[1], values=(z[1], z[0])) Cat2_window = tk.Toplevel(root) Cat2_window.geometry('300x400') Cat2_window.resizable(0, 0) Cat2_window.title('200萬發票 消費品項統計表') frame2 = Frame(Cat2_window) frame2.place(x=0, y=10, width=280, height=400) scrBar2 = tk.Scrollbar(Cat2_window) scrBar2.pack(side=tk.RIGHT, fill=tk.Y) tree2 = Treeview(Cat2_window, columns=('w1', 'w2'), show='headings', yscrollcommand=scrBar2.set) tree2.column('w1', width=200, anchor='center') tree2.column('w2', width=80, anchor='center') tree2.heading('w1', text='品項') tree2.heading('w2', text='出現次數') tree2.pack(side=tk.LEFT, fill=tk.Y) scrBar2.config(command=tree2.yview) tree2.bind('<Button-1>', treeviewClick) sort200 = [[v[1], v[0]] for v in Cat_200.items()] sort200.sort() sort200.reverse() for z in sort200: tree2.insert('', 'end', text=z[1], values=(z[1], z[0]))
def __init__(self): self.win = Tk() self.win.title("The Hive") self.win.geometry('{}x{}'.format(800, 450)) # self.canvas = Canvas(self.win, bg='#454b54') self.canvas = Canvas(self.win, bg='#454b54') self.canvas.pack(expand=TRUE, fill=BOTH) self.frame = Frame(self.canvas, bg='#454b54', width=600, height=340) self.frame.pack(expand=TRUE) self.tree = Treeview(self.frame, columns=2, show="headings", height="15") self.list = Treeview(self.frame, columns=(1, 2, 3, 4, 5), show="headings", height="15")
def makeFileViewPanel(self): panel = Frame(self) panel.place(x=0, y=0, width=580, height=280) scrollBar = Scrollbar(panel) scrollBar.pack(side=RIGHT, fill=Y) global _fileViewTree _fileViewTree = Treeview(panel, columns=('c1', 'c2', 'c3', 'c4'), show='headings', yscrollcommand=scrollBar.set) _fileViewTree.column('c1', width=70, anchor='center') _fileViewTree.column('c2', width=70, anchor='center') _fileViewTree.column('c3', width=70, anchor='center') _fileViewTree.column('c4', width=370, anchor='center') _fileViewTree.heading('c1', text='Event No') _fileViewTree.heading('c2', text='Props') _fileViewTree.heading('c3', text='Alarms') _fileViewTree.heading('c4', text='Summary') _fileViewTree.pack(side=LEFT, fill=Y) scrollBar.config(command=_fileViewTree.yview) def listClick(event): selection = _fileViewTree.selection() if len(selection) != 0: item = _fileViewTree.focus() if item in selection: _fileViewTree.selection_remove(item) return 'continue' _fileViewTree.bind('<Button-1>', listClick)
def createFoodMenuList(self): self.frame1 = Frame(self) self.frame2 = Frame(self) from tkinter.ttk import Treeview tv = Treeview(self) tv['columns'] = ('location', 'city', 'cutomer_count', 'total_table', 'total_waiter', 'sales') tv.heading("#0", text='Restaurant name', anchor='w') tv.column("#0", anchor="w") tv.heading('location', text='Location') tv.column('location', anchor='center', width=100) tv.heading('city', text='City') tv.column('city', anchor='center', width=100) tv.heading('cutomer_count', text='Customer Count') tv.column('cutomer_count', anchor='center', width=100) tv.heading('total_table', text='Total Table') tv.column('total_table', anchor='center', width=100) tv.heading('total_waiter', text='Total Waiter') tv.column('total_waiter', anchor='center', width=100) tv.heading('sales', text='Sales') tv.column('sales', anchor='center', width=100) tv.grid(sticky=(N, S, W, E)) self.frame1.treeview = tv self.frame1.grid_rowconfigure(0, weight=1) self.frame1.grid_columnconfigure(0, weight=1) self.frame2.grid(row=0, column=1, sticky=N) self.button = Button(self.frame2, text="Add") self.button.grid(row=0, column=0) self.button1 = Button(self.frame2, text="Modify") self.button1.grid(row=1, column=0) self.button2 = Button(self.frame2, text="Delete") self.button2.grid(row=2, column=0) self.button3 = Button(self.frame2, text="Delete All") self.button3.grid(row=3, column=0)
def loadTable(self, keyphraseDF, columns, searchResults): # TODO: make reusable for various df's self.keyphraseDF = keyphraseDF self.searchResults = searchResults tv = Treeview(self) tv['columns'] = columns tv.heading("#0", text='keyphrase_full') tv.column("#0", anchor="w", width=300) for column in tv['columns']: tv.heading(column, text=column, command=lambda _col=column: self.treeview_sort_column( tv, _col, True)) tv.column(column, anchor='center', width=100) tv.grid(sticky=(N, S, W, E)) self.treeview = tv self.grid_rowconfigure(0, weight=1) self.grid_columnconfigure(0, weight=1) for (i, row) in self.keyphraseDF.iterrows(): self.treeview.insert('', 'end', text=row["keyphrase_full"], values=tuple(row[column] for column in columns)) self.treeview.bind("<Double-1>", self.onClick) self.treeview.bind("<Enter>", self.onEnter)
def create_tree(self): if self.tree: self.tree.destroy() style = Style(self.left_frame) style.configure('Calendar.Treeview', rowheight=50) self.tree = Treeview(self.left_frame, columns='#1', height=400, selectmode="extended", yscrollcommand=self.scrollbary.set, xscrollcommand=self.scrollbarx.set, style='Calendar.Treeview') self.scrollbary.config(command=self.tree.yview) self.scrollbary.pack(side=RIGHT, fill=Y) self.scrollbarx.config(command=self.tree.xview) self.scrollbarx.pack(side=BOTTOM, fill=X) self.tree.heading('#0', text='image', anchor=CENTER) self.tree.heading('#1', text='file_name') self.tree.column('#0', width=80, anchor=CENTER) if self.files: for key in self.files: self.tree.insert("", 'end', values=key, image=self.files[key]) self.tree.pack(side=BOTTOM)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.root = self.winfo_toplevel() self.root.title(" ".join((APPNAME, VERSION, "| Report"))) self.root.resizable(0, 0) self.items = None headers = ('Page', 'Rank', 'PageRank Value', 'Incoming') self.t = Scale(self, from_=0, to=1, label='n-th iteration', bd=1, width=7, orient='horizontal', command=self.__set_t) self.t.pack(fill='x') self.label = Label(self, anchor='e') self.label.pack(fill='x') self.tree = Treeview(self, columns=headers, show="headings", height=REPORT_HEIGHT) self.tree.column(0, anchor='center', width=55) self.tree.column(1, anchor='center', width=55) self.tree.column(2, width=175) self.tree.column(3, anchor='center', width=55) self.scroll = Scrollbar(self, command=self.tree.yview) self.scroll.pack(side='right', fill='y') self.tree.config(yscrollcommand=self.scroll.set) for col in headers: self.tree.heading(col, text=col.title()) self.root.master.focus_force() self.root.bind('<Key>', self.__keys)
def init_startpage(self): table_headings = ["Название", "Длина", "Дата создания"] self.route_table = Treeview(self.form, selectmode="browse", \ show='headings', height = 25) self.route_table["columns"] = table_headings self.route_table["displaycolumns"] = table_headings for head in table_headings: self.route_table.heading(head, text=head, anchor=CENTER) colomn_width = 200 self.route_table.column("Название", anchor=CENTER, width=colomn_width) self.route_table.column("Длина", anchor=CENTER, width=colomn_width) self.route_table.column("Дата создания", anchor=CENTER, width=colomn_width) self.about_route_button = Button(self.form, text="Подробно",\ width=15,height=3, command=self.about_route) self.delete_route_button = Button(self.form, text='Удалить',\ width=15,height=3, command=self.delete_route) self.create_route_button = Button(self.form, text='Создать',\ width=15,height=3, command=self.create_route) self.import_route_button = Button(self.form, text='Импорт',\ width=15,height=3, command=self.import_route) self.presenter.fill_routes_table()
def __init__(self, master, names): self.widget = Frame(master) self._tree = Treeview(self.widget, columns='name') self._tree.grid(row=0, column=0, sticky=(N, S, W, E)) self._tree.view = self self.widget.columnconfigure(0, weight=1) self.widget.rowconfigure(0, weight=1) self._tree.column('name', width=50) self._tree['show'] = 'tree' actions = { 'edit': lambda e: self.edit(), 'search': lambda e: self.search(), 'focus_next': lambda e: self.focus_next(), 'focus_prev': lambda e: self.focus_prev(), 'select': lambda e: self._tree.selection_toggle(self._tree.focus()), 'clear_selection': lambda e: self._tree.selection_set([]) } kb.make_bindings(kb.tagview, actions, self._tree.bind) self._iids = dict() self._names = dict() logger.debug('Names: %s', names) self.widget.focus_set = self._tree.focus_set for name in sorted(names): iid = self._tree.insert('', 'end', text=name) self._names[iid] = name self._iids[name] = iid self._scroll = Scrollbar(self.widget, command=self._tree.yview) self._tree['yscrollcommand'] = self._scroll.set self._scroll.grid(row=0, column=1, sticky=(N, S)) self.widget.columnconfigure(1, weight=0)
def __init__(self, data): Page.__init__(self) self.data = data print('>>>>>>>>>>>>>>>>>>>',self.data) from defuse import knap a,b=knap(data) print('>>>>>>>>>>>> a , b',a,b) label = tk.Label(self, text="The set of executable query plans:") tree = Treeview(self, columns=('Execution Cost','Response Time','Reputation','Results number')) tree.heading('#0', text='Data Services') tree.heading('#1', text='Execution Cost') tree.heading('#2', text='Response Time') tree.heading('#4', text='Results number') tree.heading('#3', text='Reputation') tree.column('#4',stretch=tk.YES) tree.column('#3', stretch=tk.YES) tree.column('#1', stretch=tk.YES) tree.column('#2', stretch=tk.YES) tree.column('#0', stretch=tk.YES) tree.grid(row=4, columnspan=6, sticky='nsew') tree.insert('', 'end', text = "Data_Servcie1", values=(b,"----",a,"--")) tree.pack() b1 = Button(self, text='Execute', cursor='exchange') b1.pack(side=RIGHT, padx=5, pady=5) b2 = Button(self, text='Select', cursor='exchange') b2.pack(side=RIGHT, padx=5, pady=5) b3 = Button(self, text='Confirm', cursor='exchange') b3.pack(side=RIGHT, padx=5, pady=5)
def viewuser(): win = Tk() win.title('View User') win.geometry("800x300+270+180") win.resizable(False, False) treeview = Treeview(win, columns=("Name", "User ID", "Branch", "Mobile No"), show='headings') treeview.heading("Name", text="Name") treeview.heading("User ID", text="User ID") treeview.heading("Branch", text="Branch") treeview.heading("Mobile No", text="Mobile No") treeview.column("Name", anchor='center') treeview.column("User ID", anchor='center') treeview.column("Branch", anchor='center') treeview.column("Mobile No", anchor='center') index = 0 iid = 0 connectdb() details = cur.fetchall() for row in details: treeview.insert("", index, iid, value=row) index = iid = index + 1 treeview.pack() win.mainloop() closedb()
def issuedbook(): connectdb() q = 'SELECT * FROM BookIssue' cur.execute(q) details = cur.fetchall() if len(details) != 0: win = Tk() win.title('View Books') win.geometry("800x300+270+180") win.resizable(False, False) treeview = Treeview(win, columns=("Student ID", "Serial No", "Issue Date", "Expiry Date"), show='headings') treeview.heading("Student ID", text="Student ID") treeview.heading("Serial No", text="Serial No") treeview.heading("Issue Date", text="Issue Date") treeview.heading("Expiry Date", text="Expiry Date") treeview.column("Student ID", anchor='center') treeview.column("Serial No", anchor='center') treeview.column("Issue Date", anchor='center') treeview.column("Expiry Date", anchor='center') index = 0 iid = 0 for row in details: treeview.insert("", index, iid, value=row) index = iid = index + 1 treeview.pack() win.mainloop() else: messagebox.showinfo("Books", "No Book Issued") closedb()
def viewbook(): win = Tk() win.title('View Books') win.geometry("800x300+270+180") win.resizable(False, False) treeview = Treeview(win, columns=("Subject", "Title", "Author", "Serial No"), show='headings') treeview.heading("Subject", text="Subject") treeview.heading("Title", text="Title") treeview.heading("Author", text="Author") treeview.heading("Serial No", text="Serial No") treeview.column("Subject", anchor='center') treeview.column("Title", anchor='center') treeview.column("Author", anchor='center') treeview.column("Serial No", anchor='center') index = 0 iid = 0 connectdb() q = 'SELECT * FROM Book' cur.execute(q) details = cur.fetchall() for row in details: treeview.insert("", index, iid, value=row) index = iid = index + 1 treeview.pack() win.mainloop() closedb()
def con_table(self, program_name): table_margin = Frame(self.frame, width=300) table_margin.pack(side=LEFT) scrollbarx = Scrollbar(table_margin, orient=HORIZONTAL) scrollbary = Scrollbar(table_margin, orient=VERTICAL) tree = Treeview(table_margin, columns=("Id", "Value", "Type"), height=400, selectmode="extended", yscrollcommand=scrollbary.set, xscrollcommand=scrollbarx.set) scrollbary.config(command=tree.yview) scrollbary.pack(side=RIGHT, fill=Y) scrollbarx.config(command=tree.xview) scrollbarx.pack(side=BOTTOM, fill=X) tree.heading('Id', text="Id", anchor=W) tree.heading('Value', text="Value", anchor=W) tree.heading('Type', text="Type", anchor=W) tree.column('#0', stretch=NO, minwidth=0, width=0) tree.column('#1', stretch=NO, minwidth=0, width=30) tree.column('#2', stretch=NO, minwidth=0, width=70) tree.column('#3', stretch=NO, minwidth=0, width=40) tree.pack() with open("./results/" + program_name + "/CONST.csv", newline="") as file: reader = csv.reader(file) for row in reader: tree.insert("", "end", values=(row[0], row[1], row[2]))
def tokens_table(self, program_name): table_margin = Frame(self.frame, width=500) table_margin.pack(side=LEFT) scrollbarx = Scrollbar(table_margin, orient=HORIZONTAL) scrollbary = Scrollbar(table_margin, orient=VERTICAL) tree = Treeview(table_margin, columns=("Token number", "Line number", "Token", "IDN id", "CON id", "LAB id", "TOK id"), height=400, selectmode="extended", yscrollcommand=scrollbary.set, xscrollcommand=scrollbarx.set) scrollbary.config(command=tree.yview) scrollbary.pack(side=RIGHT, fill=Y) scrollbarx.config(command=tree.xview) scrollbarx.pack(side=BOTTOM, fill=X) tree.heading('Token number', text="Token number", anchor=W) tree.heading('Line number', text="Line number", anchor=W) tree.heading('Token', text="Token", anchor=W) tree.heading('IDN id', text="IDN id", anchor=W) tree.heading('CON id', text="CON id", anchor=W) tree.heading('LAB id', text="LAB id", anchor=W) tree.heading('TOK id', text="TOK id", anchor=W) tree.column('#0', stretch=NO, minwidth=0, width=0) tree.column('#1', stretch=NO, minwidth=0, width=90) tree.column('#2', stretch=NO, minwidth=0, width=80) tree.column('#3', stretch=NO, minwidth=0, width=110) tree.column('#4', stretch=NO, minwidth=0, width=50) tree.column('#5', stretch=NO, minwidth=0, width=50) tree.column('#6', stretch=NO, minwidth=0, width=50) tree.column('#7', stretch=NO, minwidth=0, width=50) tree.pack() with open("./results/" + program_name + "/tokens.csv", newline="") as file: reader = csv.reader(file) for row in reader: tree.insert("", "end", values=(row[0], row[1], row[2], row[3], row[4], row[5], row[6]))
def add_frame(self): self.frame=Frame(self.win, width=600, height=350) self.frame.place(x=100, y=20) x, y= 70,20 # using treeview to show the table # mention number of columns self.tr=Treeview(self.frame, columns=('A','B','C','D'), selectmode="extended") # heading key+text self.tr.heading('#0', text='Sr no') self.tr.column('#0', minwidth=0, width=100, stretch=NO) self.tr.heading('#1', text='Source') self.tr.column('#1', minwidth=0, width=100, stretch=NO) self.tr.heading('#2', text='Income') self.tr.column('#2', minwidth=0, width=100, stretch=NO) self.tr.heading('#3', text='Update') self.tr.column('#3', minwidth=0, width=100, stretch=NO) self.tr.heading('#4', text='Delete') self.tr.column('#4', minwidth=0, width=100, stretch=NO) j=0 for i in db.db.show_income(): self.tr.insert('', index=j, text=i[0], values=(i[1], i[2], 'Update', 'Delete')) j+=1 # create an action on selected row self.tr.bind('<Double-Button-1>', self.actions) self.tr.place(x=50, y=y+50) self.win.mainloop()
def __init__(self, root, model: ManageUIModel): super().__init__(root, text="Records", padding=10) self.model = model self.packed = False self._edit_img = load_image("edit", width=16, color=(38, 158, 54)) cols = ["timestamp"] # cols=["timestamp", "source", "hash"] self.tree = Treeview(self, padding=5, columns=cols) self.tree.heading("timestamp", text="Timestamp") # self.tree.heading("source", text="Data Source") # self.tree.heading("hash", text="Hash") self.tree.pack(fill=BOTH, expand=True) self.frm_src_btns = Frame(self, padding=5) self.frm_src_btns.pack(fill=X) def show_rebuilder(): RebuildDialog.create_dialog(self.model.var_metarecord.get()) self.btn_src_add = Button(self.frm_src_btns, text="Import Previous Backups", command=show_rebuilder) self.btn_src_add.pack(side=LEFT) def show_clean(): CleanDialog.create_dialog(self.model.var_metarecord.get()) self.btn_src_add = Button(self.frm_src_btns, text="Remove Redundant Files", command=show_clean) self.btn_src_add.pack(side=LEFT) self.model.var_metarecord.trace_add(self._metarecord_changed)
def CreateUI(self): self.frame1 = Frame(self) self.frame2 = Frame(self) from tkinter.ttk import Treeview tv = Treeview(self) tv['columns'] = ('address', 'phone_no', 'check_in', 'waiter', 'table', 'bill') tv.heading("#0", text='Customer Name', anchor='w') tv.column("#0", anchor="w") tv.heading('address', text='Address') tv.column('address', anchor='center', width=100) tv.heading('phone_no', text='Phone No.') tv.column('phone_no', anchor='center', width=100) tv.heading('check_in', text='Check In To') tv.column('check_in', anchor='center', width=100) tv.heading('waiter', text='Waiter') tv.column('waiter', anchor='center', width=100) tv.heading('table', text='Table No.') tv.column('table', anchor='center', width=100) tv.heading('bill', text='Current Bill') tv.column('bill', anchor='center', width=100) tv.grid(sticky=(N, S, W, E)) self.frame1.treeview = tv self.frame1.grid_rowconfigure(0, weight=1) self.frame1.grid_columnconfigure(0, weight=1) self.frame2.grid(row=0, column=1, sticky=N) self.button = Button(self.frame2, text="Add") self.button.grid(row=0, column=0) self.button1 = Button(self.frame2, text="Modify") self.button1.grid(row=1, column=0) self.button2 = Button(self.frame2, text="Delete") self.button2.grid(row=2, column=0) self.button3 = Button(self.frame2, text="Delete All") self.button3.grid(row=3, column=0)
def init_about_route(self): table_headings = ["№ точки", "Долгота", "Широта", "Высота"] self.point_table = Treeview(self.form, selectmode="browse", \ show='headings', height = 25) self.point_table["columns"] = table_headings self.point_table["displaycolumns"] = table_headings for head in table_headings: self.point_table.heading(head, text=head, anchor=CENTER) colomn_width = 150 self.point_table.column("№ точки", anchor=CENTER, width=colomn_width) self.point_table.column("Долгота", anchor=CENTER, width=colomn_width) self.point_table.column("Широта", anchor=CENTER, width=colomn_width) self.point_table.column("Высота", anchor=CENTER, width=colomn_width) self.edit_point_button = Button(self.form, text="Редактировать",\ width=15,height=3, command=self.edit_point) self.back_from_point_to_start_button = Button(self.form, text='Назад',\ width=15,height=3, command=self.back_from_point_to_start) self.point_edit_entry = Text(self.form, height=1.2, width=16, font='Arial 12')
def add_frame(self): self.frame = Frame(self.win, width=600, height=350) self.frame.place(x=80, y=20) x, y = 70, 20 # use treeview to show the data in forms of table #mention the number of columns self.tr = Treeview(self.frame, columns=('A', 'B', 'C', 'D'), selectmode="extended") # heading key + text self.tr.heading('#0', text='Sr No') self.tr.column('#0', minwidth=0, width=100, stretch=NO) self.tr.heading('#1', text='Source') self.tr.column('#1', minwidth=0, width=100, stretch=NO) self.tr.heading('#2', text='Description') self.tr.column('#2', minwidth=0, width=100, stretch=NO) self.tr.heading('#3', text='Update') self.tr.column('#3', minwidth=0, width=100, stretch=NO) self.tr.heading('#4', text='Delete') self.tr.column('#4', minwidth=0, width=100, stretch=NO) j = 0 for i in db.db.show_income(): self.tr.insert('', index=j, text=i[0], values=(i[1], i[2], 'Update', 'Delete')) j += 1 self.tr.place(x=50, y=y + 50) self.win.mainloop()
def _setup_widgets(self): msg = Label( wraplength="4i", justify="left", anchor="n", padding=(10, 2, 10, 6), text=("Ttk is the new Tk themed widget set. One of the widgets it " "includes is a tree widget, which can be configured to " "display multiple columns of informational data without " "displaying the tree itself. This is a simple way to build " "a listbox that has multiple columns. Clicking on the " "heading for a column will sort the data by that column. " "You can also change the width of the columns by dragging " "the boundary between them.")) msg.pack(fill='x') container = Frame() container.pack(fill='both', expand=True) # XXX Sounds like a good support class would be one for constructing # a treeview with scrollbars. self.tree = Treeview(columns=tree_columns, show="headings", style='font.Treeview') vsb = Scrollbar(orient="vertical", command=self.tree.yview) hsb = Scrollbar(orient="horizontal", command=self.tree.xview) self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set) self.tree.grid(column=0, row=0, sticky='nsew', in_=container) vsb.grid(column=1, row=0, sticky='ns', in_=container) hsb.grid(column=0, row=1, sticky='ew', in_=container) container.grid_columnconfigure(0, weight=1) container.grid_rowconfigure(0, weight=1)
def __init__(self, master, **kwargs): super().__init__(master, **kwargs) self.search_text = StringVar() self.console_text = StringVar() # Treeview setup col_ids = ("first_name", "surname", "phone", "email", "last_edited") self.contacts_list = Treeview(self, columns=col_ids, show='headings') for col_id, text in zip( col_ids, ["First name", "Surname", "Phone", "Email", "Last edited"]): self.contacts_list.column(col_id, stretch=True, width=160) self.contacts_list.heading(col_id, text=text) # Search panel search_panel = Frame(self) search_entry = Entry(search_panel, textvariable=self.search_text) self.search_btn = Button(search_panel, text="Search") search_entry.pack(side=LEFT) self.search_btn.pack(side=LEFT) # Controls self.add_btn = Button(self, text="Add") self.edit_btn = Button(self, text="Edit") self.delete_btn = Button(self, text="Delete") self.console = Label(self, textvariable=self.console_text) # Layout search_panel.pack() self.contacts_list.pack() self.console.pack() self.delete_btn.pack(side=RIGHT) self.edit_btn.pack(side=RIGHT) self.add_btn.pack(side=RIGHT)
def loadTableWindow2(self, secondWindowDF, columns, clicked_keyphrase): # TODO: make reusable for various df's self.secondWindowDF = secondWindowDF tv = Treeview(self) #tv['columns'] = columns tv.heading("#0", text='#') tv.column("#0", anchor="w", width=600) #for column in tv['columns']: # tv.heading(column, text=column) # tv.column(column, anchor='center', width=350) tv.grid(sticky=(N, S, W, E)) self.treeview = tv self.grid_rowconfigure(0, weight=1) self.grid_columnconfigure(0, weight=1) for (i, row) in self.secondWindowDF.iterrows(): #print(clicked_keyphrase) #print(row["body"]) highlighted_text = highlight(keyphrase=clicked_keyphrase, text=row['body'], words=5) self.treeview.insert('', 'end', text=str(i) + " " + highlighted_text) self.treeview.bind("<Double-1>", self.onClick2)
def submit(tree2): roots = Tk() roots.geometry("920x570+100+50") roots.title("Billing") roots.config(bg="#ffe0b2") c = con.cursor() s = 0 for child in tree2.get_children(): s = s + tree2.item(child)["values"][1] totalSum.set(s) navbar2 = Frame(roots, bg="#212121", height=50, width=920) navbar2.place(x=0, y=0) outbtn = Button(navbar2, text="Back", font=("Noto sans", 12, "bold"), fg="#ffffff", bg="#c62828", relief="flat", command=roots.destroy) outbtn.place(x=830, y=5) tree3 = Treeview(roots, columns=('pname', 'pprice')) tree3.heading('pname', text='Product Name') tree3.heading('pprice', text='Price') tree3.column("pname", width=90) tree3.column("pprice", width=90) tree3.pack(side=LEFT, anchor=N, fill='x', expand=TRUE, pady=(90, 0)) tree3['show'] = 'headings' for data in tree2.get_children(): tree3.insert('', '0', values=(tree2.item(data)["values"])) buyButton = Button(roots, text="Buy", font=("Noto sans", 12, "bold"), fg="#ffffff", bg="#c62828", relief="flat", command=lambda: add_sales(roots)) buyButton.place(x=830, y=450) total_label = Label(roots, text="Total : ", font=("Noto sans", 12, "bold"), fg="#212121", bg="#ffe0b2") total_label.place(x=200, y=400) total_labelVal = Label(roots, text=totalSum.get(), font=("Noto sans", 12, "bold"), fg="#212121", bg="#ffe0b2") total_labelVal.place(x=260, y=400) roots.mainloop()
def createWindow(self): self.window = Toplevel(self.app) self.window.title('Search') self.window.protocol("WM_DELETE_WINDOW", self.handleClose) self.input = Entry(self.window, textvariable=self.regex) self.input.grid(row=0, column=0) self.input.bind('<Return>', self.search) self.input.bind('<Escape>', lambda ev: self.window.focus()) self.searchButton = Button(self.window, text='Search', command=self.search, takefocus=0) self.searchButton.grid(row=0, column=1) self.resultCount = Label(self.window, text='0 results') self.resultCount.grid(row=0, column=2) cols = ('File', 'Tier', 'Time', 'Text') self.scroll = Scrollbar(self.window, orient='vertical') self.resultList = Treeview(self.window, columns=cols, show="headings", yscrollcommand=self.scroll.set, selectmode='browse') self.scroll.config(command=self.resultList.yview) for col in cols: self.resultList.heading(col, text=col) self.resultList.grid(row=2, column=0, columnspan=3, sticky='news') self.resultList.bind('<Double-1>', self.onClick) Grid.rowconfigure(self.window, 2, weight=1) Grid.columnconfigure(self.window, 0, weight=1) self.scroll.grid(row=2, column=3, sticky='ns')
def __init__(self, fruit_list, **kw): # init drop down super().__init__(**kw) self.fruit_list = fruit_list self.type_select = StringVar(self) header = Label(self) header.grid(row=0, column=0, columnspan=2, pady=10) type_options = OptionMenu( header, self.type_select, *models.TYPES, command=self.set_group) type_options.config(width=14) type_options.grid(row=0, column=0) # init start simulator button simulator_btn = Button( header, text="模拟器", command=lambda: sm.Simulator().mainloop()) simulator_btn.grid(row=0, column=1) # init treeView self.tree = Treeview(self, columns=["名称", "效果"], show="headings") self.tree.column("名称", width=50, anchor='center') self.tree.column("效果", width=150, anchor='center') self.tree.heading("名称", text="名称") self.tree.heading("效果", text="效果") self.tree.grid(row=1, column=0) self.tree.bind("<Double-1>", self.select_item) self.select_item_callback = lambda x: x vbar = Scrollbar(self, orient=VERTICAL, command=self.tree.yview) self.tree.configure(yscrollcommand=vbar.set) vbar.grid(row=1, column=1, sticky=NS) # default value self.set_group(models.TYPES[0])
def my_orders(self): """Creates menu with list of user orders.""" self.initialize_main_buttons() self.function_frame = tk.Frame(self.master, bg=my_config.BACKGROUND) self.function_frame.pack() # creating listbox for customers list_label = tk.Label(self.function_frame, text='my orders:', width=100, bg=my_config.BACKGROUND) list_label.grid(row=0, column=0, pady=(10, 0)) # creating treeview for customers self.my_orders_tree = Treeview(self.function_frame, columns=MY_ORDERS_COLUMNS, show='headings', height=10) self.my_orders_tree.grid(row=1, column=0) for column_name, width in zip(MY_ORDERS_COLUMNS, MY_ORDERS_COLUMNS_SIZE): self.my_orders_tree.column(column_name, width=width, anchor=tk.CENTER) self.my_orders_tree.heading(column_name, text=column_name) scrollbar = tk.Scrollbar(self.function_frame, orient=tk.VERTICAL) scrollbar.configure(command=self.my_orders_tree.set) self.my_orders_tree.configure(yscrollcommand=scrollbar) self.my_orders_tree.bind('<ButtonRelease-1>', self.order_selection) # adding records from DB to treeview records = db.orders_product_info(my_config.MY_ID) for record in records: self.my_orders_tree.insert('', tk.END, values=[record[0], record[1], record[2], record[3]])
def mostra_ranking(parent): columns = ("zero", "um", "dois", "tres") tabela = Treeview(parent, selectmode='browse', show="headings", columns=columns) tabela.column("zero", width=200) tabela.column("um", width=70) tabela.column("dois", width=100) tabela.column("tres", width=70) tabela.heading("zero", text="Jogador", anchor='center') tabela.heading("um", text="Recorde", anchor='center') tabela.heading("dois", text="Pontuação Total", anchor='center') tabela.heading("tres", text="Posição", anchor='center') tabela.pack(side='left', fill=BOTH, pady=10, padx=10) vsb = Scrollbar(parent, orient="vertical", command=tabela.yview) vsb.pack(side='left', fill='y') tabela.configure(yscrollcommand=vsb.set) atualiza_lista_jogadores(tabela) return tabela
def open_records(self): top = Toplevel() top.title('记录') top.maxsize(600, 600) Label(top, text='欢迎使用人脸识别系统', width=35, height=2, bg='#56764C').grid(row=0, columnspan=2, sticky=W + E) columns = ('所选目标', '出现时间', '消失时间', '持续时间') tree = Treeview(top, show='headings', columns=columns) tree.column('所选目标', width=150, anchor='center') tree.column('出现时间', width=150, anchor='center') tree.column('消失时间', width=150, anchor='center') tree.column('持续时间', width=150, anchor='center') tree.heading('所选目标', text='所选目标') tree.heading('出现时间', text='出现时间') tree.heading('消失时间', text='消失时间') tree.heading('持续时间', text='持续时间') sql = "select * from records where aid = '%s'" % user.id ret = sql_conn(sql) for i in range(len(ret)): tree.insert('', i, values=(ret[i]['object_name'], ret[i]['appear'], ret[i]['disappear'], ret[i]['last_time'])) tree.grid(row=1, column=0, sticky=NSEW) scrollbar = Scrollbar(top) scrollbar.grid(row=1, column=1, sticky=NS) scrollbar.config(command=tree.yview)
def CreateUI(self): from tkinter.ttk import Treeview param = Treeview(self) param['columns'] = ('parametername', 'paramvalue', 'updatedvalue') param.heading("#0", text='Server', anchor='w') param.column("#0", anchor="w", minwidth=0, width=150, stretch=NO) param.heading('parametername', text='Parameter Name') param.column('parametername', anchor="w", minwidth=0, width=350, stretch=NO) param.heading('paramvalue', text='Parameter Value') param.column('paramvalue', anchor="w", minwidth=0, width=100, stretch=NO) param.heading('updatedvalue', text='Updated Value') param.column('updatedvalue', anchor='center') param.grid(sticky=(N, S, W, E)) self.treeview = param self.grid_rowconfigure(0, weight=1) self.grid_columnconfigure(0, weight=1) self.treeview.bind("<Double-Button-1>", self.TableItemClick)