This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
767 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.