-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into issue/848
- Loading branch information
Showing
61 changed files
with
1,327 additions
and
625 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
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,47 @@ | ||
# Copyright 2021-2024 Avaiga Private Limited | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
# ----------------------------------------------------------------------------------------- | ||
# To execute this script, make sure that the taipy-gui package is installed in your | ||
# Python environment and run: | ||
# python <script> | ||
# ----------------------------------------------------------------------------------------- | ||
# A chatting application based on the chat control. | ||
# In order to see the users' avatars, the image files must be stored next to this script. | ||
# If you want to test this application locally, you need to use several browsers and/or | ||
# incognito windows so a given user's context is not reused. | ||
# ----------------------------------------------------------------------------------------- | ||
from taipy.gui import Gui, Icon | ||
|
||
msgs = [ | ||
["1", "msg 1", "Alice", None], | ||
["2", "msg From Another unknown User", "Charles", None], | ||
["3", "This from the sender User", "taipy", "./beatrix-avatar.png"], | ||
["4", "And from another known one", "Alice", None], | ||
] | ||
users = [ | ||
["Alice", Icon("./alice-avatar.png", "Alice avatar")], | ||
["Charles", Icon("./charles-avatar.png", "Charles avatar")], | ||
["taipy", Icon("./beatrix-avatar.png", "Beatrix avatar")], | ||
] | ||
|
||
|
||
def on_action(state, id: str, payload: dict): | ||
(reason, varName, text, senderId, imageData) = payload.get("args", []) | ||
msgs.append([f"{len(msgs) +1 }", text, senderId, imageData]) | ||
state.msgs = msgs | ||
|
||
|
||
page = """ | ||
<|{msgs}|chat|users={users}|allow_send_images|> | ||
""" | ||
|
||
if __name__ == "__main__": | ||
Gui(page).run(title="Chat - Images") |
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,16 @@ | ||
from taipy.gui import Gui | ||
|
||
status = [ | ||
("warning", "Task is launched."), | ||
("warning", "Tasks is waiting."), | ||
("error", "Task timeout."), | ||
("success", "Task Succeeded"), | ||
("info", "Process was cancelled.") | ||
] | ||
|
||
page = """ | ||
<|{status}|status|use_icon|> | ||
""" | ||
|
||
if __name__ == "__main__": | ||
Gui(page).run(title="Status - With icons") |
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,20 @@ | ||
from taipy.gui import Gui | ||
|
||
status = [ | ||
("warning", "Task is launched."), | ||
("warning", "Tasks is waiting."), | ||
("error", "Task timeout."), | ||
("success", "Task Succeeded"), | ||
("info", "Process was cancelled.") | ||
] | ||
|
||
# Info: svg icon (pants.svg) | ||
# success: no icon | ||
# warning: default icon | ||
# error: inline svg icon (red disc) | ||
page = """ | ||
<|{status}|status|don't use_icon|use_icon[info]=https://www.svgrepo.com/show/530594/pants.svg|use_icon[success]|use_icon[error]=<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'><circle cx='12' cy='12' r='10' fill='red'/></svg>|> | ||
""" # noqa: E501 | ||
|
||
if __name__ == "__main__": | ||
Gui(page).run(title="Status - With mixed icons") |
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,16 @@ | ||
from taipy.gui import Gui | ||
|
||
status = [ | ||
("warning", "Task is launched."), | ||
("warning", "Tasks is waiting."), | ||
("error", "Task timeout."), | ||
("success", "Task Succeeded"), | ||
("info", "Process was cancelled.") | ||
] | ||
|
||
page = """ | ||
<|{status}|status|> | ||
""" | ||
|
||
if __name__ == "__main__": | ||
Gui(page).run(title="Status - Simple") |
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,20 @@ | ||
from taipy.gui import Gui | ||
|
||
status = [ | ||
("warning", "Task is launched."), | ||
("warning", "Tasks is waiting."), | ||
("error", "Task timeout."), | ||
("success", "Task Succeeded"), | ||
("info", "Process was cancelled.") | ||
] | ||
|
||
# Info: svg icon (pants.svg) | ||
# success: svg icon (hotel.svg) | ||
# warning: svg icon (diving-goggles.svg) | ||
# error: svg icon (hat.svg) | ||
page = """ | ||
<|{status}|status|use_icon[info]=https://www.svgrepo.com/show/530594/pants.svg|use_icon[success]=https://www.svgrepo.com/show/530595/hotel.svg|use_icon[warning]=https://www.svgrepo.com/show/530596/diving-goggles.svg|use_icon[error]=https://www.svgrepo.com/show/530597/hat.svg|> | ||
""" | ||
|
||
if __name__ == "__main__": | ||
Gui(page).run(title="Status - With SVG icons") |
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
50 changes: 50 additions & 0 deletions
50
doc/gui/extension/example_library/front-end/src/VisualLabelList.tsx
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,50 @@ | ||
import React, { useMemo } from "react"; | ||
import { LoV, useLovListMemo } from "taipy-gui"; | ||
|
||
interface VisualLabelListProps { | ||
lov?: LoV; | ||
defaultLov?: string; | ||
sort?: "asc" | "desc"; | ||
} | ||
|
||
const styles = { | ||
listItem: { | ||
display: "flex", | ||
alignItems: "center", | ||
}, | ||
image: { | ||
marginRight: "8px", | ||
width: "1em", | ||
height: "1em", | ||
}, | ||
}; | ||
|
||
const VisualLabelList: React.FC<VisualLabelListProps> = ({ lov, defaultLov = "", sort }) => { | ||
const lovList = useLovListMemo(lov, defaultLov); | ||
|
||
const sortedLovList = useMemo(() => { | ||
if (sort) { | ||
return lovList.slice().sort((a, b) => { | ||
return sort === "asc" ? a.id.localeCompare(b.id) : b.id.localeCompare(a.id); | ||
}); | ||
} | ||
return lovList; | ||
}, [lovList, sort]); | ||
|
||
return ( | ||
<div> | ||
<ul> | ||
{sortedLovList.map((item, index) => ( | ||
<li key={index} style={styles.listItem}> | ||
{typeof item.item === "string" ? null : ( | ||
<img src={item.item.path} alt={item.item.text} style={styles.image} /> | ||
)} | ||
{item.id} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; | ||
|
||
export default VisualLabelList; |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,28 @@ | ||
# Copyright 2021-2024 Avaiga Private Limited | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations under the License. | ||
from example_library import ExampleLibrary | ||
|
||
from taipy.gui import Gui, Icon | ||
|
||
languages = [ | ||
["Python", Icon("images/python.png", "Python logo")], | ||
["JavaScript", Icon("images/javascript.png", "JavaScript logo")], | ||
["TypeScript", Icon("images/typescript.png", "TypeScript logo")], | ||
["Java", Icon("images/java.png", "Java logo")], | ||
["C++", Icon("images/cpp.png", "C++ logo")], | ||
] | ||
|
||
page = """ | ||
<|{languages}|example.visual_label_list|sort=asc|> | ||
""" | ||
|
||
if __name__ == "__main__": | ||
Gui(page, libraries=[ExampleLibrary()]).run(title="List of item") |
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.