Top-rated recipes tagged "table"http://code.activestate.com/recipes/tags/table/top/2017-05-06T19:06:05-07:00ActiveState Code RecipesRender tables for text interface (Python)
2010-04-20T18:02:51-07:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/577202-render-tables-for-text-interface/
<p style="color: grey">
Python
recipe 577202
by <a href="/recipes/users/57155/">Denis Barmenkov</a>
(<a href="/recipes/tags/format/">format</a>, <a href="/recipes/tags/table/">table</a>, <a href="/recipes/tags/text/">text</a>).
Revision 2.
</p>
<p>Sometime pprint module is not enough for formatting data for console or log file output.
This module provide function which fill the gap.</p>
<p><strong>Sample function call:</strong></p>
<pre class="prettyprint"><code>nums = [ '1', '2', '3', '4' ]
speeds = [ '100', '10000', '1500', '12' ]
desc = [ '', 'label 1', 'none', 'very long description' ]
lines = format_table( [(nums, ALIGN_RIGHT|PADDING_ALL, 'NUM'),
(speeds, ALIGN_RIGHT|PADDING_ALL, 'SPEED'),
(desc, ALIGN_LEFT|PADDING_ALL, 'DESC')] )
</code></pre>
<p><strong>Output:</strong></p>
<pre class="prettyprint"><code>=======================================
| NUM | SPEED | DESC |
=======================================
| 1 | 100 | |
| 2 | 10000 | label 1 |
| 3 | 1500 | none |
| 4 | 12 | very long description |
=======================================
</code></pre>
Tkinter table with scrollbars (Python)
2017-05-06T19:06:05-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580793-tkinter-table-with-scrollbars/
<p style="color: grey">
Python
recipe 580793
by <a href="/recipes/users/4189907/">Miguel Martínez López</a>
(<a href="/recipes/tags/scrollbars/">scrollbars</a>, <a href="/recipes/tags/table/">table</a>, <a href="/recipes/tags/tkinter/">tkinter</a>).
Revision 13.
</p>
<p>I created here a tkinter table with scrollbar support. I use one of my other recipes for the mousewheel support and scrolling:</p>
<p><a href="https://code.activestate.com/recipes/580640-scrolling-frame-with-mouse-wheel-support" rel="nofollow">https://code.activestate.com/recipes/580640-scrolling-frame-with-mouse-wheel-support</a></p>
Simple multicolumn listbox for tkinter (Python)
2017-05-02T22:27:15-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580794-simple-multicolumn-listbox-for-tkinter/
<p style="color: grey">
Python
recipe 580794
by <a href="/recipes/users/4189907/">Miguel Martínez López</a>
(<a href="/recipes/tags/listbox/">listbox</a>, <a href="/recipes/tags/multicolumn/">multicolumn</a>, <a href="/recipes/tags/table/">table</a>, <a href="/recipes/tags/tkinter/">tkinter</a>).
</p>
<p>This recipe makes easy to work a treeview widget like a table.</p>
<p>It has several options for styling:</p>
<ul>
<li>heading_anchor</li>
<li>heading_font</li>
<li>heading_background</li>
<li>heading_foreground</li>
<li>cell_anchor</li>
<li>cell_background</li>
<li>cell_foreground</li>
<li>cell_font</li>
<li>cell_pady</li>
<li>height</li>
<li>padding</li>
<li>adjust_heading_to_content</li>
<li>stripped_rows</li>
<li>headers</li>
<li>selection_background</li>
<li>selection_foreground</li>
<li>field_background</li>
</ul>
<p>The "command" parameter is a callback and its called each time a row is selected.</p>
Tkinter table (Python)
2017-05-02T21:19:51-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580786-tkinter-table/
<p style="color: grey">
Python
recipe 580786
by <a href="/recipes/users/4189907/">Miguel Martínez López</a>
(<a href="/recipes/tags/table/">table</a>, <a href="/recipes/tags/tkinter/">tkinter</a>).
Revision 24.
</p>
<p>Table of data for tkinter.</p>
<p>Here there is an improved vesion with vertical scrollbar support:</p>
<p><a href="https://code.activestate.com/recipes/580793-tkinter-table-with-scrollbars" rel="nofollow">https://code.activestate.com/recipes/580793-tkinter-table-with-scrollbars</a></p>
Multiplication table (Python)
2011-04-21T09:12:26-07:00Boubakrhttp://code.activestate.com/recipes/users/4176416/http://code.activestate.com/recipes/577672-multiplication-table/
<p style="color: grey">
Python
recipe 577672
by <a href="/recipes/users/4176416/">Boubakr</a>
(<a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/multiplication/">multiplication</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/table/">table</a>).
</p>
<p>Multiplication table (Python)</p>
Tkinter treeview like a table or multicolumn listbox (Python)
2017-05-02T22:27:48-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580746-tkinter-treeview-like-a-table-or-multicolumn-listb/
<p style="color: grey">
Python
recipe 580746
by <a href="/recipes/users/4189907/">Miguel Martínez López</a>
(<a href="/recipes/tags/editable/">editable</a>, <a href="/recipes/tags/listbox/">listbox</a>, <a href="/recipes/tags/megawidget/">megawidget</a>, <a href="/recipes/tags/multicolumn/">multicolumn</a>, <a href="/recipes/tags/table/">table</a>, <a href="/recipes/tags/tkinter/">tkinter</a>, <a href="/recipes/tags/treeview/">treeview</a>).
Revision 33.
</p>
<p>This trick provides use my other recipe:</p>
<p><a href="https://code.activestate.com/recipes/580794-simple-multicolumn-listbox-for-tkinter/" rel="nofollow">https://code.activestate.com/recipes/580794-simple-multicolumn-listbox-for-tkinter/</a></p>
<p>This recipes defines a <em>Tk_Table:</em> A table that extends the multicolumn listbox adding row numbers, making the cells editable and adding autoscrollbars.</p>
<p><em>Tk_Table</em></p>
<p>It has the same options than <em>Multicolumn_Listbox</em>, and some extra parameters to configure the new functionality.</p>
<p>Setting the editable keyword to True, makes the widget editable.</p>
<p>If you want stripped rows, pass the stripped_rows with a tuple (or list) of two colors.</p>
<p>If you want row numbers, then pass to <em>row_numbers</em> parameter a True value.</p>
<p>These are the extra options for this class:</p>
<ul>
<li>entry_background</li>
<li>entry_foreground</li>
<li>entry_validatecommand</li>
<li>entry_selectbackground</li>
<li>entry_selectborderwidth</li>
<li>entry_selectforeground</li>
<li>scrollbar_background</li>
<li>scrollbar_troughcolor</li>
<li>rowlabel_anchor</li>
<li>rowlabel_minwidth</li>
<li>rowlabel_hoverbackground</li>
<li>frame_relief</li>
<li>frame_borderwidth</li>
<li>frame_background</li>
<li>row_numbers</li>
</ul>
How to parse a table in a PDF document (Python)
2016-04-10T22:43:57-07:00Jorj X. McKiehttp://code.activestate.com/recipes/users/4193772/http://code.activestate.com/recipes/580635-how-to-parse-a-table-in-a-pdf-document/
<p style="color: grey">
Python
recipe 580635
by <a href="/recipes/users/4193772/">Jorj X. McKie</a>
(<a href="/recipes/tags/cbz/">cbz</a>, <a href="/recipes/tags/epub/">epub</a>, <a href="/recipes/tags/fitz/">fitz</a>, <a href="/recipes/tags/mupdf/">mupdf</a>, <a href="/recipes/tags/openxps/">openxps</a>, <a href="/recipes/tags/parsing/">parsing</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/pymupdf/">pymupdf</a>, <a href="/recipes/tags/table/">table</a>, <a href="/recipes/tags/xps/">xps</a>).
Revision 4.
</p>
<p>A Python function that converts a table contained in a page of a PDF (or OpenXPS, EPUB, CBZ, XPS) document to a matrix-like Python object (list of lists of strings).</p>
Generate behave table (Python)
2015-05-19T07:16:06-07:00Nicolas Laurancehttp://code.activestate.com/recipes/users/4192224/http://code.activestate.com/recipes/579055-generate-behave-table/
<p style="color: grey">
Python
recipe 579055
by <a href="/recipes/users/4192224/">Nicolas Laurance</a>
(<a href="/recipes/tags/bdd/">bdd</a>, <a href="/recipes/tags/behave/">behave</a>, <a href="/recipes/tags/table/">table</a>).
</p>
<p>When writing BDD code with behave, you may want to include a set of examples for scenario outline, or provide a table for setting up initial conditions. This snippet ease the pain of formatting the table properly as text</p>
Formating strings (print a table) (Batch)
2013-06-18T07:52:03-07:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578562-formating-strings-print-a-table/
<p style="color: grey">
Batch
recipe 578562
by <a href="/recipes/users/4184115/">greg zakharov</a>
(<a href="/recipes/tags/format/">format</a>, <a href="/recipes/tags/string/">string</a>, <a href="/recipes/tags/table/">table</a>).
</p>
<p>As you know there are no escape characters such as "\t" in the windows command language but it does not mean that we can not format text. Command prompt has its own tricks. At firstly, you need declare enabledelayedexpansion after setlocal command in your batch file to get access for some interesting things; secondly, use <code><nul set /p "str=[string]"</code> construction which is equal print function in C language. OK, next batch file print multiplication table.</p>