How to use tree_view method in avocado

Best Python code snippet using avocado_python

summary_frame.py

Source:summary_frame.py Github

copy

Full Screen

...17 self.sort_reverse = False18 self.waiting_label = None19 self.tree_view = None20 self.scroll_bar = None21 def update_tree_view(self):22 if(self.tree_view):23 #Delete previous data24 for entry in self.tree_view.get_children():25 self.tree_view.delete(entry)26 #Insert new data sorted27 for user in self.data["entries"]:28 value = [val for index, val in enumerate(user.values()) if index in (0, 3)]29 self.tree_view.insert('', 'end', values=value)30 def show(self):31 #Create a waiting label32 if not self.waiting_label:33 self.waiting_label = tk.Label(self, text='Loading data...')34 self.waiting_label.pack(fill=tk.BOTH, expand=True)35 #Loading data36 parallel_run(extractor.get_logins_list, self.set_data)37 #Call parent show method38 super().show()39 def set_data(self, data):40 if self.shown:41 if self.waiting_label:42 self.waiting_label.destroy()43 self.waiting_label = None44 #Create tree view45 if not self.tree_view:46 self.tree_view = ttk.Treeview(self, columns=TABLE_COLUMNS, show="headings")47 self.tree_view.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)48 #Create scroll bar49 if not self.scroll_bar:50 self.scroll_bar = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.tree_view.yview)51 self.scroll_bar.pack(side=tk.RIGHT, fill=tk.Y)52 53 #Attach scrollbar to tree view54 self.tree_view.configure(yscrollcommand=self.scroll_bar.set)55 #Create column entries56 for entry in TABLE_COLUMNS:57 self.tree_view.heading(entry, text=entry, command=lambda col=entry: self.handle_sort(col))58 #Format date59 self.data = data60 for entry in self.data["entries"]:61 entry["date"] = datetime.strftime(entry["date"], "%a %b %d %H:%M:%S %Y")62 63 #Log the data64 self.logger.write_log(json.dumps(self.data) ,level=LogLevel.INFO)65 #Update data and sort by date by default66 self.handle_sort('date')67 def hide(self):68 #Destroy elements69 if self.waiting_label:70 self.waiting_label.destroy()71 self.waiting_label = None72 if self.tree_view:73 self.tree_view.destroy()74 self.tree_view = None75 if self.scroll_bar:76 self.scroll_bar.destroy()77 self.scroll_bar = None78 super().hide()79 #Handle sort when user click on columns80 def handle_sort(self, col):81 #Reset previous sorted col82 if self.tree_view:83 self.tree_view.heading(self.sort_by, text=self.sort_by)84 #If previous was clicked reverse order, if another one was clicked reset order and change sorting value85 if self.sort_by == col:86 self.sort_reverse = not self.sort_reverse87 else:88 self.sort_by = col89 self.sort_reverse = False90 if(self.sort_by == 'date'):91 #Sort the data by date92 self.data["entries"].sort(key=lambda entry: datetime.strptime(entry['date'], "%a %b %d %H:%M:%S %Y"), reverse=self.sort_reverse)93 else:94 #Sort the data95 self.data["entries"].sort(key=lambda entry: entry[self.sort_by], reverse=self.sort_reverse)96 #Update tree view97 self.update_tree_view()98 #Add text on sorted value99 if self.tree_view:100 if(self.sort_reverse):101 self.tree_view.heading(col, text=col + " (descending)")102 else:...

Full Screen

Full Screen

tab_frame.py

Source:tab_frame.py Github

copy

Full Screen

...17 self.sort_reverse = False18 self.waiting_label = None19 self.tree_view = None20 self.scroll_bar = None21 def update_tree_view(self):22 if(self.tree_view):23 #Delete previous data24 for entry in self.tree_view.get_children():25 self.tree_view.delete(entry)26 #Insert new data sorted27 for user in self.data["entries"]:28 value = [val for val in user.values()]29 self.tree_view.insert('', 'end', values=value)30 def show(self):31 #Create a waiting label32 if not self.waiting_label:33 self.waiting_label = tk.Label(self, text='Loading data...')34 self.waiting_label.pack(fill=tk.BOTH, expand=True)35 #Loading data36 parallel_run(extractor.get_logins_list, self.set_data)37 #Call parent show method38 super().show()39 def set_data(self, data):40 if self.shown:41 if self.waiting_label:42 self.waiting_label.destroy()43 self.waiting_label = None44 #Create tree view45 if not self.tree_view:46 self.tree_view = ttk.Treeview(self, columns=TABLE_COLUMNS, show="headings")47 self.tree_view.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)48 #Create scroll bar49 if not self.scroll_bar:50 self.scroll_bar = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.tree_view.yview)51 self.scroll_bar.pack(side=tk.RIGHT, fill=tk.Y)52 53 #Attach scrollbar to tree view54 self.tree_view.configure(yscrollcommand=self.scroll_bar.set)55 #Create column entries56 for entry in TABLE_COLUMNS:57 self.tree_view.heading(entry, text=entry, command=lambda col=entry: self.handle_sort(col))58 #Format date59 self.data = data60 for entry in self.data["entries"]:61 entry["date"] = datetime.strftime(entry["date"], "%a %b %d %H:%M:%S %Y")62 63 #Log the data64 self.logger.write_log(json.dumps(self.data) ,level=LogLevel.INFO)65 #Update data and sort by date by default66 self.handle_sort('date')67 def hide(self):68 #Destroy elements69 if self.waiting_label:70 self.waiting_label.destroy()71 self.waiting_label = None72 if self.tree_view:73 self.tree_view.destroy()74 self.tree_view = None75 if self.scroll_bar:76 self.scroll_bar.destroy()77 self.scroll_bar = None78 super().hide()79 #Handle sort when user click on columns80 def handle_sort(self, col):81 #Reset previous sorted col82 if self.tree_view:83 self.tree_view.heading(self.sort_by, text=self.sort_by)84 #If previous was clicked reverse order, if another one was clicked reset order and change sorting value85 if self.sort_by == col:86 self.sort_reverse = not self.sort_reverse87 else:88 self.sort_by = col89 self.sort_reverse = False90 if(self.sort_by == 'date'):91 #Sort the data by date92 self.data["entries"].sort(key=lambda entry: datetime.strptime(entry['date'], "%a %b %d %H:%M:%S %Y"), reverse=self.sort_reverse)93 else:94 #Sort the data95 self.data["entries"].sort(key=lambda entry: entry[self.sort_by], reverse=self.sort_reverse)96 #Update tree view97 self.update_tree_view()98 #Add text on sorted value99 if self.tree_view:100 if(self.sort_reverse):101 self.tree_view.heading(col, text=col + " (descending)")102 else:...

Full Screen

Full Screen

ParserErrorsDialog.py

Source:ParserErrorsDialog.py Github

copy

Full Screen

1"""2Copyright 2013 Free Software Foundation, Inc.3This file is part of GNU Radio4GNU Radio Companion is free software; you can redistribute it and/or5modify it under the terms of the GNU General Public License6as published by the Free Software Foundation; either version 27of the License, or (at your option) any later version.8GNU Radio Companion is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU General Public License for more details.12You should have received a copy of the GNU General Public License13along with this program; if not, write to the Free Software14Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA15"""16from __future__ import absolute_import17import six18from gi.repository import Gtk, GObject19from .Constants import MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT20class ParserErrorsDialog(Gtk.Dialog):21 """22 A dialog for viewing parser errors23 """24 def __init__(self, error_logs):25 """26 Properties dialog constructor.27 Args:28 block: a block instance29 """30 GObject.GObject.__init__(self, title='Parser Errors', buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT))31 self._error_logs = None32 self.tree_store = Gtk.TreeStore(str)33 self.update_tree_store(error_logs)34 column = Gtk.TreeViewColumn('XML Parser Errors by Filename')35 renderer = Gtk.CellRendererText()36 column.pack_start(renderer, True)37 column.add_attribute(renderer, 'text', 0)38 column.set_sort_column_id(0)39 self.tree_view = tree_view = Gtk.TreeView(self.tree_store)40 tree_view.set_enable_search(False) # disable pop up search box41 tree_view.set_search_column(-1) # really disable search42 tree_view.set_reorderable(False)43 tree_view.set_headers_visible(False)44 tree_view.get_selection().set_mode(Gtk.SelectionMode.NONE)45 tree_view.append_column(column)46 for row in self.tree_store:47 tree_view.expand_row(row.path, False)48 scrolled_window = Gtk.ScrolledWindow()49 scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)50 scrolled_window.add(tree_view)51 self.vbox.pack_start(scrolled_window, True)52 self.set_size_request(2*MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT)53 self.show_all()54 def update_tree_store(self, error_logs):55 """set up data model"""56 self.tree_store.clear()57 self._error_logs = error_logs58 for filename, errors in six.iteritems(error_logs):59 parent = self.tree_store.append(None, [str(filename)])60 try:61 with open(filename, 'r') as fp:62 code = fp.readlines()63 except EnvironmentError:64 code = None65 for error in errors:66 # http://lxml.de/api/lxml.etree._LogEntry-class.html67 em = self.tree_store.append(parent, ["Line {e.line}: {e.message}".format(e=error)])68 if code:69 self.tree_store.append(em, ["\n".join(70 "{} {}{}".format(line, code[line - 1].replace("\t", " ").strip("\n"),71 " " * 20 + "<!-- ERROR -->" if line == error.line else "")72 for line in range(error.line - 2, error.line + 3) if 0 < line <= len(code)73 )])74 def run(self):75 """76 Run the dialog and get its response.77 Returns:78 true if the response was accept79 """80 response = Gtk.Dialog.run(self)81 self.destroy()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful