What is the best way to show data in a table in Tkinter?

A ttk.Treeview without the tree part can be used to display a table: tree = ttk.Treeview(master, columns=(‘Position’, ‘Name’, ‘Score’), show=’headings’) Then set the column labels with tree.heading(<column>, text=”Label”) and add rows with tree.insert(“”, “end”, values=(<position>, <name>, <score>)) The first argument is the item’s parent, since you want a table, all items have the same parent, … Read more

BeautifulSoup: Get the contents of a specific table

This is not the specific code you need, just a demo of how to work with BeautifulSoup. It finds the table who’s id is “Table1” and gets all of its tr elements. html = urllib2.urlopen(url).read() bs = BeautifulSoup(html) table = bs.find(lambda tag: tag.name==’table’ and tag.has_attr(‘id’) and tag[‘id’]==”Table1″) rows = table.findAll(lambda tag: tag.name==’tr’)

NumPy: Pretty print tabular data

I seem to be having good output with prettytable: from prettytable import PrettyTable x = PrettyTable(dat.dtype.names) for row in dat: x.add_row(row) # Change some column alignments; default was ‘c’ x.align[‘column_one’] = ‘r’ x.align[‘col_two’] = ‘r’ x.align[‘column_3’] = ‘l’ And the output is not bad. There is even a border switch, among a few other options: … Read more

Group several same value field into a single cell

You can use this sample: <?xml version=”1.0″ encoding=”UTF-8″?> <jasperReport xmlns=”http://jasperreports.sourceforge.net/jasperreports” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd” name=”year_sum_quarter” language=”groovy” pageWidth=”595″ pageHeight=”842″ columnWidth=”555″ leftMargin=”20″ rightMargin=”20″ topMargin=”20″ bottomMargin=”20″> <property name=”ireport.zoom” value=”1.0″/> <property name=”ireport.x” value=”0″/> <property name=”ireport.y” value=”0″/> <queryString> <![CDATA[]]> </queryString> <field name=”year” class=”java.lang.Integer”/> <field name=”month” class=”java.lang.String”/> <field name=”sum” class=”java.lang.Integer”/> <field name=”q” class=”java.lang.Integer”/> <variable name=”yearSum” class=”java.lang.Integer” resetType=”Group” resetGroup=”yearGroup” calculation=”Sum”> <variableExpression><![CDATA[$F{sum}]]></variableExpression> </variable> <variable … Read more