Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from changes in develop #1164

Merged
merged 4 commits into from
Oct 13, 2024
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
62 changes: 28 additions & 34 deletions docs/refmans/gui/viselements/generic/date_range.md_template
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ for more information on this property.

# Usage

## Selecting a date range {data-source="gui:doc/examples/blocks/date_range_simple.py"}
## Selecting a date range {data-source="gui:doc/examples/controls/date_range_simple.py"}

The [*dates*](#p-dates) property (which is the default property for this control) must be set to an
array of two `datetime.date` objects, representing the selected start and end dates of the
range.

Assuming the variable *dates* was defined by the following code:

```python
import datetime

Expand All @@ -41,7 +40,6 @@ dates = [start_date, end_date]
```

The definition of the date range selector is as simple as:

!!! taipy-element
default={dates}

Expand All @@ -53,31 +51,28 @@ The date range selector looks like this:
</figure>

An `on_change` callback can be set to retrieve the user's selection:

```python
def on_change(s: State, name: str, value: any):
if name == "dates":
# value[0] is set to the first selected date
# value[1] is set to the first selected date
```

## Selecting a range with times {data-source="gui:doc/examples/blocks/date_range_with_time.py"}
## Selecting a range with times {data-source="gui:doc/examples/controls/date_range_with_time.py"}

You can set the [*with_time*](#p-with_time) property to True to display the range time: the
dates should then be instances of `datetime.datetime`.

Here is some code that defines the date range with specific time values:

```python
import datetime

start_date = datetime.date(2023, 3, 26, 7, 37)
end_date = datetime.date(2023, 3, 26, 19, 2)
start_date = datetime.datetime(2023, 3, 26, 7, 37)
end_date = datetime.datetime(2023, 3, 26, 19, 2)
dates = [start_date, end_date]
```

The control definition just has the [*with_time*](#p-with_time) property set to True:

!!! taipy-element
default={dates}
with_time:b=True
Expand All @@ -89,14 +84,13 @@ Here is how the date range selector looks like:
<figcaption>Date range selector with time</figcaption>
</figure>

## Custom labels {data-source="gui:doc/examples/blocks/date_range_labels.py"}
## Custom labels {data-source="gui:doc/examples/controls/date_range_labels.py"}

The [*label_start*](#p-label_start) and [*label_end*](#p-label_end) properties can be used to
label the date fields to provide context to the user.

Here is how a hotel reservation application may declare a date range selector with appropriate
labels for booking a given period:

!!! taipy-element
default={dates}
label_start=Check-in
Expand Down Expand Up @@ -129,29 +123,29 @@ The start and end date pickers contain a date input field with the "MuiInputBase
Below are examples of CSS rules that modify the colors of the date range control:
```css
.taipy-date-range {
.taipy-date-range-picker-start {
.MuiInputBase-root {
& {
color: green;
}

.MuiIconButton-root: {
color: green;
}
}
}

.taipy-date-range-picker-end {
.MuiInputBase-root {
& {
color: orange;
}

.MuiIconButton-root {
color: orange;
}
}
}
.taipy-date-range-picker-start {
.MuiInputBase-root {
& {
color: green;
}

.MuiIconButton-root: {
color: green;
}
}
}

.taipy-date-range-picker-end {
.MuiInputBase-root {
& {
color: orange;
}

.MuiIconButton-root {
color: orange;
}
}
}
}
```

Expand Down
13 changes: 13 additions & 0 deletions docs/release-notes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ This is the list of changes to Taipy releases as they were published.
[`taipy-templates` 4.0](https://pypi.org/project/taipy-templates/4.0.0/), and
[`taipy-rest` 4.0](https://pypi.org/project/taipy-rest/4.0.0/) packages.

## Known issues

<h4><strong><code>taipy-gui</code></strong> 4.0.0</h4>

- The [**-H**](../userman/advanced_features/configuration/gui-config.md#p-port) short command line
option for setting the server hostname is broken.<br/>
Please use the full **--host** option instead.<br/>
This issue will be fixed in the next technical release for Taipy GUI.

## New Features

<h4><strong><code>taipy</code></strong> 4.0.0</h4>
Expand Down Expand Up @@ -262,6 +271,10 @@ additional features.

## New Features

- Authentication now supports
[Microsoft Entra ID](https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id)
including SSO and GUI integration.<br/>
TODO - Documentation is in progress.
- Support for [Polars DataFrame Library](https://docs.pola.rs/).<br/>
Tabular data nodes (`CSVDataNode^`, `ParquetDataNode^`, `ExcelDataNode^`, `SQLTableDataNode^`,
and `SQLDataNode^`) can now expose the data as Polars objects. They all support
Expand Down
53 changes: 27 additions & 26 deletions docs/tutorials/articles/using_tables/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ You can customize the style of a table in Taipy using two properties:

1. *class_name*: This property allows you to apply a CSS class to the entire table.

2. *style*: With this property, you can apply a CSS class to specific rows, which you specify in
Python.
2. *row_class_name*: With this property, you can apply a CSS class to specific rows, which you
specify in Python.

### Property 1: class_name

Expand Down Expand Up @@ -134,17 +134,17 @@ script. For example, if your Taipy application code is in `main.py`, your CSS co
`main.css` in the same directory. You can find more details about this
[here](../../../userman/gui/styling/index.md#style-sheets).

### Property 2: style
### Property 2: row_class_name

To have more precise control over our styling, we can utilize the style property of tables
to assign CSS classes to individual rows in the table. For instance, we can assign a
user-defined **highlight-row** CSS class to rows where the **Category** column is **Dessert** to
To have more precise control over our styling, we can utilize the *row_class_name* property of
the table control to assign CSS classes to individual rows in the table. For instance, we can assign
a user-defined **highlight-row** CSS class to rows where the **Category** column is **Dessert** to
give them a yellow background.

![Property style](images/using_tables_3.png){width=50% : .tp-image-border }

The style property accepts a function. This function is applied to each row of the table and
returns a string specifying the CSS class to be used for that particular row. To create the
The *row_class_name* property accepts a function. This function is applied to each row of the table
and returns a string specifying the CSS class to be used for that particular row. To create the
table mentioned above, you can use the following code:

```python title="main.py"
Expand All @@ -153,11 +153,11 @@ def table_style(state, index, row):

table_properties = {
"class_name": "rows-bordered rows-similar", # optional
"style": table_style,
"row_class_name": table_style,
}

main_md = Markdown("<|{food_df}|table|properties=table_properties|>")
# or Markdown("<|{food_df}|table|class_name=rows-bordered rows-similar|style=table_style|>")
# or Markdown("<|{food_df}|table|class_name=rows-bordered rows-similar|row_class_name=table_style|>")
```

```css
Expand All @@ -170,25 +170,25 @@ main_md = Markdown("<|{food_df}|table|properties=table_properties|>")
In our code, we also made use of the *class_name* property mentioned earlier, and we applied
two Stylekit table classes: **rows-bordered** and **rows-similar**. The **rows-similar** class
removes the default 0.5 opacity from odd rows. While it wasn't necessary, using it does enhance
the table's appearance when applying our **highlight-row** style.
the table's appearance when applying our **highlight-row** CSS class.

## Modifying Data

Tables offer various properties for modifying data within the table. Notably, the *on_edit*,
*on_add*, and *on_delete* properties can receive user-defined **callback** functions. This
function is executed when you interact with the table, but it only appears when you specify the
relevant data modification property.
*on_add*, and *on_delete* properties can receive user-defined **callback** functions. These
functions are executed when you interact with the table. The interaction element appear when the
table is explicitly defined as *editable*.

Taipy doesn't come with default functions for these properties, so we'll define each function
ourselves to match our specific needs. We're also including the
[notify](../../../userman/gui/notifications.md) function within our data modification callback
Although Taipy comes with default callback function implementation for these properties, we will
define each function ourselves to match our specific needs. We're also including the
[*notify()*](../../../userman/gui/notifications.md) function within our data modification callback
functions to send notifications to the user about their changes.

## Editing (*on_edit*)

When the *on_edit* property is used, new buttons with a pencil icon are added to each cell.
Clicking it allows the user to modify the value of that cell,
then clicking the tick triggers the callback function:
When the *editable* property is used, new buttons with a pencil icon are added to each cell.
Clicking it allows the user to modify the value of that cell. If *on_edit* is set to a callback
function, then clicking the tick triggers the callback function:

![Editing](images/tables-on_edit.gif){width=50% : .tp-image-border }

Expand All @@ -208,7 +208,7 @@ def food_df_on_edit(state, var_name, payload):
state.food_df = new_food_df
notify(state, "I", f"Edited value from '{old_value}' to '{value}'. (index '{index}', column '{col}')")

main_md = Markdown("<|{food_df}|table|on_edit=food_df_on_edit|>")
main_md = Markdown("<|{food_df}|table|editable|on_edit=food_df_on_edit|>")
```

The table documentation provides more information on the function signature which is slightly
Expand All @@ -221,9 +221,9 @@ we instead create a copy of the DataFrame, modify the relevant cell, then assign

## Adding (*on_add*)

Adding and deleting are quite similar to editing. When you specify the *on_add* property, a
`button` with a 'plus' icon is included, and when clicked, it triggers the defined *on_add*
callback function.
Adding and deleting are quite similar to editing. When *editable* is True, a
`button` with a 'plus' icon is included, and when clicked, it triggers the callback function
speficied in the *on_add* property.

![Adding](images/tables-on_add.gif){width=50% : .tp-image-border }

Expand All @@ -236,7 +236,7 @@ def food_df_on_add(state, var_name, payload):

notify(state, "S", f"Added a new row.")

main_md = Markdown("<|{food_df}|table|on_add=food_df_on_add|>")
main_md = Markdown("<|{food_df}|table|editable|on_add=food_df_on_add|>")
```

This code simply adds a new empty row to the top of the table (DataFrame).
Expand All @@ -258,7 +258,7 @@ def food_df_on_delete(state, var_name, payload):
state.food_df = state.food_df.drop(index=index)
notify(state, "E", f"Deleted row at index '{index}'")

main_md = Markdown("<|{food_df}|table|on_delete=food_df_on_delete|>")
main_md = Markdown("<|{food_df}|table|editable|on_delete=food_df_on_delete|>")
```

## Complete Code
Expand Down Expand Up @@ -311,6 +311,7 @@ if __name__ == "__main__":

table_properties = {
"class_name": "rows-bordered",
"editable": True,
"filter": True,
"on_edit": food_df_on_edit,
"on_delete": food_df_on_delete,
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/getting_started/index.md_template
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ For more realistic and advanced use cases, check out our

<div class="tp-row tp-row--gutter-sm">
<div class="tp-col-12 tp-col-md-6 d-flex">
<a class="tp-content-card tp-content-card--primary" href="../tutorials/articles/understanding_gui/">
<a class="tp-content-card tp-content-card--primary" href="../articles/understanding_gui/">
<header class="tp-content-card-header">
<img class="tp-content-card-icon--small" src="images/visualize.svg">
<h3>Understanding GUI</h3>
Expand Down
2 changes: 2 additions & 0 deletions mkdocs.yml_template
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ extra:
# to enable disqus, uncomment the following and put your disqus id below
# disqus: disqus_id
generator: false
exclude_docs: |
*.md_template
# uncomment the following and put your google tracking id below to enable GA
#google_analytics:
#- UA-xxx
Expand Down
Loading
Loading