Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Merge df1228e into 916ae22
Browse files Browse the repository at this point in the history
  • Loading branch information
codetent committed Jun 24, 2019
2 parents 916ae22 + df1228e commit b181419
Show file tree
Hide file tree
Showing 9 changed files with 767 additions and 2 deletions.
1 change: 0 additions & 1 deletion docs/tkinter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Currently these tkinter widgets are missing in teek:
* ``tkinter.Scale``, ``tkinter.ttk.Scale``
* ``tkinter.ttk.Sizegrip``
* ``tkinter.Spinbox``
* ``tkinter.ttk.Treeview``

If the project uses some of these, you can still use them with
:ref:`Tcl calls <tcl-calls>`. However, that's kind of painful, so if the
Expand Down
56 changes: 56 additions & 0 deletions docs/treeview.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. _treeview:

Treeview Widget
===============

**Manual page:** :man:`ttk_treeview(3tk)`

This widget is useful for creating tabular lists or tree structures.
Let's look at an example.

::

import teek

window = teek.Window('Treeview Example')
treeview = teek.Treeview(window, columns=['forename', 'surname', 'age'])
treeview.pack(fill='both', expand=True)

treeview.rows.append(['John', 'Star', 32])
treeview.rows.append(['Patrick', 'Tram', 19])

window.geometry(300, 200)
window.on_delete_window.connect(teek.quit)
teek.run()

This program displays a treeview widget with overall 4 columns (first + value
columns) and 2 rows. The first column is for description purposes only and
cannot contain any data. Let's go trough some of the code.

::

treeview.columns.append('forename')

This line creates a :class:`.TreeviewColumn` with the title *forename* and
appends it to the column list of the treeview.

::

treeview.rows.append(['John', 'Star', 32])

This code creates a :class:`.TreeviewRow` with the given values (1. column:
*John*, 2. column: *Star*, 3. column: *32*) and appends it to the rows of the
treeview.

The *rows* and *columns* attributes of the :class:`.Treeview` behave like normal
lists and therefore, items can be inserted and deleted as with lists. The only
exception is the manipulation of the first column which is prohibited.

Here is some reference:

.. autoclass:: teek.Treeview
:members:
.. autoclass:: teek.TreeviewColumn
:members:
.. autoclass:: teek.TreeviewRow
:members:
6 changes: 6 additions & 0 deletions docs/widgets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ looking for, and ignore rest of this.
canvas
menu
notebook
treeview
textwidget

.. autoclass:: teek.Widget
Expand Down Expand Up @@ -49,6 +50,11 @@ looking for, and ignore rest of this.

See :ref:`notebook`.

.. class:: teek.Treeview
:noindex:

See :ref:`treeview`.

.. autoclass:: teek.Progressbar
:members:
.. autoclass:: teek.Scrollbar
Expand Down
29 changes: 29 additions & 0 deletions examples/treeview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import teek

root = teek.Window()
root.on_delete_window.connect(teek.quit)

treeview = teek.Treeview(
root,
columns=[
teek.TreeviewColumn(text='a', anchor='e'),
'b'
],
rows=[
teek.TreeviewRow(values=(1, 2, 3, 4)),
(5, 6, 7, 8)
]
)
treeview.pack()

treeview.columns.append(teek.TreeviewColumn(text='c', anchor='w'))
treeview.columns.append('d')

treeview.columns[1].config['command'].connect(lambda: print('click'))

treeview.rows.append(teek.TreeviewRow(values=(9, 10, 11, 12)))
treeview.rows.append([13, 14, 15, 16])

treeview.rows[0].config['text'] = 'text'

teek.run()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ keywords = "pythonic tk tcl tkinter gui beginner"

[tool.flit.metadata.requires-extra]
# lxml is in soup_viewer because examples/soup.py does BeautifulSoup(string, 'lxml')
image_loader = ["pillow", "reportlab", "svglib", "lxml"]
image_loader = ["pillow", "reportlab", "svglib==0.9.0", "lxml"]
soup_viewer = ["beautifulsoup4", "lxml"]
1 change: 1 addition & 0 deletions teek/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ class TclError(Exception):
Progressbar, Scrollbar, Separator, Spinbox)
from teek._widgets.notebook import Notebook, NotebookTab
from teek._widgets.text import Text
from teek._widgets.treeview import Treeview, TreeviewColumn, TreeviewRow
from teek._widgets.windows import Window, Toplevel
from teek import dialog, extras

0 comments on commit b181419

Please sign in to comment.