Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/Flatfile_examples/csv_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# Create a simple layout for working with our flatfile data.
# Note that you can set a specific table name to use, but here I am just using the defaul 'Flatfile'
# Lets also use some sortable headers so that we can rearrange the flatfile data when saving
headings=ss.TableHeadings()
headings.add_column('name', 'Name', width=12)
headings.add_column('address', 'Address', width=25)
headings.add_column('phone', 'Phone #', width=10)
headings.add_column('email', 'EMail', width=25)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column('name', 'Name', width=12)
table_builder.add_column('address', 'Address', width=25)
table_builder.add_column('phone', 'Phone #', width=10)
table_builder.add_column('email', 'EMail', width=25)

layout = [
[ss.selector('Flatfile', sg.Table, num_rows=10, headings=headings)],
[ss.selector('Flatfile', table_builder)],
[ss.field('Flatfile.name')],
[ss.field('Flatfile.address')],
[ss.field('Flatfile.phone')],
Expand Down
10 changes: 5 additions & 5 deletions examples/MSAccess_examples/journal_msaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
# -------------------------
# Define the columns for the table selector using the TableHeading convenience class.
# This will also allow sorting!
headings = ss.TableHeadings()
headings.add_column("title", "Title", width=40)
headings.add_column("entry_date", "Date", width=10)
headings.add_column("mood_id", "Mood", width=20)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column("title", "Title", width=40)
table_builder.add_column("entry_date", "Date", width=10)
table_builder.add_column("mood_id", "Mood", width=20)

layout = [
[ss.selector("Journal", sg.Table, num_rows=10, headings=headings)],
[ss.selector("Journal", table_builder)],
[ss.actions("Journal")],
[
ss.field("Journal.entry_date"),
Expand Down
10 changes: 5 additions & 5 deletions examples/MySQL_examples/journal_mysql_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
# -------------------------
# Define the columns for the table selector using the TableHeading convenience class.
# This will also allow sorting!
headings = ss.TableHeadings()
headings.add_column("title", "Title", width=40)
headings.add_column("entry_date", "Date", width=10)
headings.add_column("mood_id", "Mood", width=20)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column("title", "Title", width=40)
table_builder.add_column("entry_date", "Date", width=10)
table_builder.add_column("mood_id", "Mood", width=20)

layout = [
[ss.selector("Journal", sg.Table, num_rows=10, headings=headings)],
[ss.selector("Journal", table_builder)],
[ss.actions("Journal")],
[
ss.field("Journal.entry_date"),
Expand Down
10 changes: 5 additions & 5 deletions examples/PostgreSQL_examples/journal_postgres_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
# -------------------------
# Define the columns for the table selector using the TableHeading convenience class.
# This will also allow sorting!
headings = ss.TableHeadings()
headings.add_column("title", "Title", width=40)
headings.add_column("entry_date", "Date", width=10)
headings.add_column("mood_id", "Mood", width=20)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column("title", "Title", width=40)
table_builder.add_column("entry_date", "Date", width=10)
table_builder.add_column("mood_id", "Mood", width=20)

layout = [
[ss.selector("Journal", sg.Table, num_rows=10, headings=headings)],
[ss.selector("Journal", table_builder)],
[ss.actions("Journal")],
[
ss.field("Journal.entry_date"),
Expand Down
10 changes: 5 additions & 5 deletions examples/SQLServer_examples/journal_sqlserver_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
# -------------------------
# Define the columns for the table selector using the TableHeading convenience class.
# This will also allow sorting!
headings = ss.TableHeadings(sort_enable=True)
headings.add_column("title", "Title", width=40)
headings.add_column("entry_date", "Date", width=10)
headings.add_column("mood_id", "Mood", width=20)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column("title", "Title", width=40)
table_builder.add_column("entry_date", "Date", width=10)
table_builder.add_column("mood_id", "Mood", width=20)

layout = [
[ss.selector("Journal", sg.Table, num_rows=10, headings=headings)],
[ss.selector("Journal", table_builder)],
[ss.actions("Journal")],
[
ss.field("Journal.entry_date"),
Expand Down
12 changes: 6 additions & 6 deletions examples/SQLite_examples/address_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def validate_zip():
# CREATE PYSIMPLEGUI LAYOUT
# -------------------------
# Define the columns for the table selector. This will allow entries to be sorted by column!
headings = ss.TableHeadings()
headings.add_column('firstName', 'First name:', 15)
headings.add_column('lastName', 'Last name:', 15)
headings.add_column('city', 'City:', 13)
headings.add_column('fkState', 'State:', 5)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column('firstName', 'First name:', 15)
table_builder.add_column('lastName', 'Last name:', 15)
table_builder.add_column('city', 'City:', 13)
table_builder.add_column('fkState', 'State:', 5)

layout = [
[ss.selector("Addresses", sg.Table, headings=headings, num_rows=10)],
[ss.selector("Addresses", table_builder, num_rows=10)],
[ss.field("Addresses.fkGroupName", sg.Combo, size=(30, 10), auto_size_text=False)],
[ss.field("Addresses.firstName", label="First name:")],
[ss.field("Addresses.lastName", label="Last name:")],
Expand Down
8 changes: 4 additions & 4 deletions examples/SQLite_examples/checkbox_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
# CREATE PYSIMPLEGUI LAYOUT
# -------------------------
# Create a table heading object
headings = ss.TableHeadings(allow_cell_edits=True)
table_builder = ss.TableBuilder(allow_cell_edits=True)

# Add columns to the table heading
headings.add_column('id', 'id', width=5)
table_builder.add_column('id', 'id', width=5)

columns = ['bool_none', 'bool_true', 'bool_false', 'int_none', 'int_true', 'int_false', 'text_none', 'text_true', 'text_false']

for col in columns:
headings.add_column(col, col, width=8)
table_builder.add_column(col, col, width=8)

fields = []
for col in columns:
Expand All @@ -50,7 +50,7 @@
[sg.Text('This test shows pysimplesql checkbox behavior.')],
[sg.Text('Each column is labeled as type: bool=BOOLEAN, int=INTEGER, text=TEXT')],
[sg.Text("And the DEFAULT set for new records, no default set, True,1,'True', or False,0,'False'")],
[ss.selector('checkboxes', sg.Table, num_rows=10, headings=headings, row_height=25)],
[ss.selector('checkboxes', table_builder, row_height=25)],
[ss.actions('checkboxes', edit_protect=False)],
fields,
]
Expand Down
10 changes: 5 additions & 5 deletions examples/SQLite_examples/journal_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# CREATE PYSIMPLEGUI LAYOUT
# -------------------------
# Define the columns for the table selector
headings = ss.TableHeadings()
headings.add_column("title", "Title", width=40)
headings.add_column("entry_date", "Date", width=10)
headings.add_column("mood_id", "Mood", width=20)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column("title", "Title", width=40)
table_builder.add_column("entry_date", "Date", width=10)
table_builder.add_column("mood_id", "Mood", width=20)

layout = [
[ss.selector('Journal', sg.Table, key='sel_journal', num_rows=10, headings=headings)],
[ss.selector('Journal', table_builder, key='sel_journal')],
[ss.actions('Journal', 'act_journal', edit_protect=False)],
[ss.field('Journal.entry_date')],
[ss.field('Journal.mood_id', sg.Combo, size=(30, 10), label='My mood:', auto_size_text=False)],
Expand Down
14 changes: 8 additions & 6 deletions examples/SQLite_examples/journal_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@
# CREATE PYSIMPLEGUI LAYOUT
# -------------------------
# Define the columns for the table selector using the TableHeading convenience class.
headings = ss.TableHeadings(
table_builder = ss.TableBuilder(
num_rows = 10,
sort_enable=True, # Click a header to sort
allow_cell_edits=True # Double-click a cell to make edits
allow_cell_edits=True, # Double-click a cell to make edits
style=ss.TableStyler(row_height=25)
)
headings.add_column('title', 'Title', width=40)
headings.add_column('entry_date', 'Date', width=10)
headings.add_column('mood_id', 'Mood', width=20)
table_builder.add_column('title', 'Title', width=40)
table_builder.add_column('entry_date', 'Date', width=10)
table_builder.add_column('mood_id', 'Mood', width=20)

layout = [
[ss.selector('Journal', sg.Table, num_rows=10, headings=headings, row_height=25)],
[ss.selector('Journal', table_builder)],
[ss.actions('Journal')],
[ss.field('Journal.entry_date'),
sg.CalendarButton(
Expand Down
10 changes: 5 additions & 5 deletions examples/SQLite_examples/journal_with_data_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
# CREATE PYSIMPLEGUI LAYOUT
# -------------------------
# Define the columns for the table selector using the TableHeading convenience class. This will also allow sorting!
headings = ss.TableHeadings()
headings.add_column('title', 'Title', width=40)
headings.add_column('entry_date', 'Date', width=10)
headings.add_column('mood_id', 'Mood', width=20)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column('title', 'Title', width=40)
table_builder.add_column('entry_date', 'Date', width=10)
table_builder.add_column('mood_id', 'Mood', width=20)

layout=[
[ss.selector('Journal', sg.Table, key='sel_journal', num_rows=10, headings=headings)],
[ss.selector('Journal', table_builder, key='sel_journal')],
[ss.actions('Journal', 'act_journal', edit_protect=False)],
[ss.field('Journal.entry_date')],
[ss.field('Journal.mood_id', sg.Combo, size=(30, 10), auto_size_text=False)],
Expand Down
8 changes: 4 additions & 4 deletions examples/SQLite_examples/many_to_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
[ss.field('Color.name', label_above=True)]
]

headings = ss.TableHeadings(sort_enable=True)
headings.add_column('person_id', 'Person', 18)
headings.add_column('color_id', 'Favorite Color', 18)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column('person_id', 'Person', 18)
table_builder.add_column('color_id', 'Favorite Color', 18)
favorites_layout = [
[ss.selector('FavoriteColor', sg.Table, key='sel_favorite', num_rows=10, headings=headings)],
[ss.selector('FavoriteColor', table_builder, key='sel_favorite')],
[ss.actions('act_favorites', 'FavoriteColor', edit_protect=False, search=False)],
[ss.field('FavoriteColor.person_id', element=sg.Combo, size=(30, 10), label='Person:', auto_size_text=False)],
[ss.field('FavoriteColor.color_id', element=sg.Combo, size=(30, 10), label='Color:', auto_size_text=False)]
Expand Down
75 changes: 41 additions & 34 deletions examples/SQLite_examples/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
# -----------------------------
custom = {
"ttk_theme": os_ttktheme,
"marker_sort_asc": " ⬇",
"marker_sort_desc": " ⬆",
"marker_sort_asc": " ⬇ ",
"marker_sort_desc": " ⬆ ",
}
custom = custom | os_tp
ss.themepack(custom)
Expand Down Expand Up @@ -162,23 +162,38 @@
# fmt: on
layout = [[sg.Menu(menu_def, key="-MENUBAR-", font="_ 12")]]

# Define the columns for the table selector using the TableHeading class.
order_heading = ss.TableHeadings(
sort_enable=True, # Click a heading to sort
# Set our universal table options
table_style = ss.TableStyler(
row_height=25,
expand_x=True,
expand_y=True,
frame_pack_kwargs={"expand": True, "fill": "both"},
)

# Define the columns for the table selector using the Tabletable class.
order_table = ss.TableBuilder(
num_rows=5,
sort_enable=True, # Click a table to sort
allow_cell_edits=True, # Double-click a cell to make edits.
# Exempted: Primary Key columns, Generated columns, and columns set as readonly
add_save_heading_button=True, # Click 💾 in sg.Table Heading to trigger DataSet.save_record()
apply_search_filter=True, # Filter rows as you type in the search input
lazy_loading=True, # For larger DataSets, inserts slice of rows. See `LazyTable`
add_save_heading_button=True, # Click 💾 in sg.Table Heading to trigger DataSet.save_record()
style=table_style,
)

# Add columns
order_heading.add_column(column="order_id", heading_column="ID", width=5)
order_heading.add_column("customer_id", "Customer", 30)
order_heading.add_column("date", "Date", 20)
order_heading.add_column(
"total", "total", width=10, readonly=True
) # set to True to disable editing for individual columns!)
order_heading.add_column("completed", "✔", 8)
order_table.add_column(column="order_id", heading="ID", width=5)
order_table.add_column("customer_id", "Customer", 30)
order_table.add_column("date", "Date", 20)
order_table.add_column(
column="total",
heading="Total",
width=10,
readonly=True, # set to True to disable editing for individual columns!
col_justify="right", # default, "left". Available: "left", "right", "center"
)
order_table.add_column("completed", "✔", 8)

# Layout
layout.append(
Expand All @@ -187,25 +202,26 @@
[
ss.selector(
"orders",
sg.Table,
num_rows=5,
headings=order_heading,
row_height=25,
order_table,
)
],
[ss.actions("orders")],
[sg.Sizer(h_pixels=0, v_pixels=20)],
]
)

# order_details TableHeadings:
details_heading = ss.TableHeadings(
sort_enable=True, allow_cell_edits=True, add_save_heading_button=True
# order_details TableBuilder:
details_table = ss.TableBuilder(
num_rows=10,
sort_enable=True,
allow_cell_edits=True,
add_save_heading_button=True,
style=table_style,
)
details_heading.add_column("product_id", "Product", 30)
details_heading.add_column("quantity", "quantity", 10)
details_heading.add_column("price", "price/Ea", 10, readonly=True)
details_heading.add_column("subtotal", "subtotal", 10)
details_table.add_column("product_id", "Product", 30)
details_table.add_column("quantity", "Quantity", 10, col_justify="right")
details_table.add_column("price", "Price/Ea", 10, readonly=True, col_justify="right")
details_table.add_column("subtotal", "Subtotal", 10, readonly=True, col_justify="right")

orderdetails_layout = [
[sg.Sizer(h_pixels=0, v_pixels=10)],
Expand All @@ -217,10 +233,7 @@
[
ss.selector(
"order_details",
sg.Table,
num_rows=10,
headings=details_heading,
row_height=25,
details_table,
)
],
[ss.actions("order_details", default=False, save=True, insert=True, delete=True)],
Expand All @@ -244,12 +257,6 @@
icon=ss.themepack.icon,
)

# Expand our sg.Tables so they fill the screen
win["orders:selector"].expand(True, True)
win["orders:selector"].table_frame.pack(expand=True, fill="both")
win["order_details:selector"].expand(True, True)
win["order_details:selector"].table_frame.pack(expand=True, fill="both")

# Init pysimplesql Driver and Form
# --------------------------------

Expand Down
10 changes: 5 additions & 5 deletions examples/SQLite_examples/selectors_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
"""

# PySimpleGUI™ layout code
headings = ss.TableHeadings()
headings.add_column('name', 'Name', width=10)
headings.add_column('example', 'Example', width=40)
headings.add_column('primary_color', 'Primary Color?', width=15)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column('name', 'Name', width=10)
table_builder.add_column('example', 'Example', width=40)
table_builder.add_column('primary_color', 'Primary Color?', width=15)

record_columns = [
[ss.field('Colors.name', label='Color name:')],
[ss.field('Colors.example', label='Example usage: ')],
[ss.field('Colors.primary_color', element=sg.CBox, label='Primary Color?')],
]
selectors = [
[ss.selector('Colors', element=sg.Table, key='tableSelector', headings=headings, num_rows=10)],
[ss.selector('Colors', element=table_builder, key='tableSelector')],
[ss.selector('Colors', size=(15, 10), key='selector1')],
[ss.selector('Colors', element=sg.Slider, size=(26, 18), key='selector2'),
ss.selector('Colors', element=sg.Combo, size=(30, 10), key='selector3')],
Expand Down
12 changes: 6 additions & 6 deletions examples/journal_multiple_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
# CREATE PYSIMPLEGUI LAYOUT
# -------------------------
# Define the columns for the table selector using the TableHeading convenience class. This will also allow sorting!
headings = ss.TableHeadings(sort_enable=True)
headings.add_column('title', 'Title', width=40)
headings.add_column('entry_date', 'Date', width=10)
headings.add_column('mood_id', 'Mood', width=20)
table_builder = ss.TableBuilder(num_rows=10)
table_builder.add_column('title', 'Title', width=40)
table_builder.add_column('entry_date', 'Date', width=10)
table_builder.add_column('mood_id', 'Mood', width=20)

layout = [
[sg.Text('Selected driver: '), sg.Text('', key='driver')],
[ss.selector('Journal', sg.Table, num_rows=10, headings=headings)],
[ss.selector('Journal', table_builder)],
[ss.actions('Journal')],
[ss.field('Journal.entry_date'), sg.CalendarButton("Select Date", close_when_date_chosen=True,
target="Journal.entry_date", # <- target matches field() name
Expand Down Expand Up @@ -104,5 +104,5 @@
- using Form.field() and Form.selector() functions for easy GUI element creation
- using the label keyword argument to Form.record() to define a custom label
- using Tables as Form.selector() element types
- Using the TableHeadings() function to define sortable table headings
- Using the TableBuilder() function to define sortable table headings
"""
Loading