From 81c3056a10cfe020bd0afb5e9d25d602f34d2b37 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 11 Mar 2025 07:23:17 +0530 Subject: [PATCH] fixed display name in treeview --- src/canvas/widgets/base.js | 5 +++++ src/canvas/widgets/widgetDragDrop.js | 1 + src/frameworks/customtk/plugins/analogTimepicker.js | 1 + src/frameworks/customtk/plugins/mapview.js | 2 ++ src/frameworks/customtk/plugins/pandasTable.js | 1 + src/frameworks/customtk/plugins/videoPlayer.js | 1 + src/frameworks/customtk/sidebarWidgets.js | 2 +- src/frameworks/customtk/widgets/button.js | 1 + .../customtk/widgets/{ checkButton.js => checkButton.js} | 2 ++ src/frameworks/customtk/widgets/frame.js | 1 + src/frameworks/customtk/widgets/input.js | 1 + src/frameworks/customtk/widgets/label.js | 2 +- src/frameworks/customtk/widgets/mainWindow.js | 1 + src/frameworks/customtk/widgets/optionMenu.js | 1 + src/frameworks/customtk/widgets/slider.js | 2 ++ src/frameworks/customtk/widgets/spinBox.js | 1 + src/frameworks/customtk/widgets/toplevel.js | 1 + src/frameworks/tkinter/plugins/analogTimepicker.js | 1 + src/frameworks/tkinter/plugins/mapview.js | 1 + src/frameworks/tkinter/plugins/pandasTable.js | 1 + src/frameworks/tkinter/plugins/videoPlayer.js | 1 + src/frameworks/tkinter/sidebarWidgets.js | 2 +- src/frameworks/tkinter/widgets/button.js | 1 + .../tkinter/widgets/{ checkButton.js => checkButton.js} | 2 ++ src/frameworks/tkinter/widgets/frame.js | 1 + src/frameworks/tkinter/widgets/input.js | 1 + src/frameworks/tkinter/widgets/label.js | 1 + src/frameworks/tkinter/widgets/mainWindow.js | 1 + src/frameworks/tkinter/widgets/optionMenu.js | 1 + src/frameworks/tkinter/widgets/slider.js | 2 ++ src/frameworks/tkinter/widgets/spinBox.js | 1 + src/frameworks/tkinter/widgets/toplevel.js | 2 ++ src/sidebar/treeviewContainer.js | 2 +- 33 files changed, 43 insertions(+), 4 deletions(-) rename src/frameworks/customtk/widgets/{ checkButton.js => checkButton.js} (99%) rename src/frameworks/tkinter/widgets/{ checkButton.js => checkButton.js} (99%) diff --git a/src/canvas/widgets/base.js b/src/canvas/widgets/base.js index b050d5e..dfb0d89 100644 --- a/src/canvas/widgets/base.js +++ b/src/canvas/widgets/base.js @@ -32,6 +32,7 @@ const ATTRS_KEYS = ['value', 'label', 'tool', 'onChange', 'options', 'toolProps' class Widget extends React.Component { static widgetType = "widget" + static displayName = "Widget" static requirements = [] // requirements for the widgets (libraries) eg: tkvideoplayer, tktimepicker static requiredImports = [] // import statements @@ -347,6 +348,10 @@ class Widget extends React.Component { return this.constructor.widgetType } + getDisplayName(){ + return this.constructor.displayName + } + getRequirements(){ return this.constructor.requirements } diff --git a/src/canvas/widgets/widgetDragDrop.js b/src/canvas/widgets/widgetDragDrop.js index 07b4707..616f9f4 100644 --- a/src/canvas/widgets/widgetDragDrop.js +++ b/src/canvas/widgets/widgetDragDrop.js @@ -3,6 +3,7 @@ import { useDragWidgetContext } from "./draggableWidgetContext" import { useDragContext } from "../../components/draggable/draggableContext" +// NOTE: not in use // FIXME: sometimes even after drag end the showDroppable is visible /** * @param {} - widgetRef - the widget ref for your widget diff --git a/src/frameworks/customtk/plugins/analogTimepicker.js b/src/frameworks/customtk/plugins/analogTimepicker.js index f92f480..203a98d 100644 --- a/src/frameworks/customtk/plugins/analogTimepicker.js +++ b/src/frameworks/customtk/plugins/analogTimepicker.js @@ -20,6 +20,7 @@ const Themes = { class AnalogTimePicker extends CustomTkBase{ static widgetType = "analog_timepicker" + static displayName = "Analog Timepicker" static requiredImports = [ ...CustomTkBase.requiredImports, diff --git a/src/frameworks/customtk/plugins/mapview.js b/src/frameworks/customtk/plugins/mapview.js index 1447aa9..0dee3b9 100644 --- a/src/frameworks/customtk/plugins/mapview.js +++ b/src/frameworks/customtk/plugins/mapview.js @@ -13,6 +13,8 @@ import { CustomTkBase } from "../widgets/base" class MapView extends CustomTkBase{ static widgetType = "map_view" + static displayName = "Map View" + static requiredImports = [ ...CustomTkBase.requiredImports, diff --git a/src/frameworks/customtk/plugins/pandasTable.js b/src/frameworks/customtk/plugins/pandasTable.js index c072805..58eea0c 100644 --- a/src/frameworks/customtk/plugins/pandasTable.js +++ b/src/frameworks/customtk/plugins/pandasTable.js @@ -70,6 +70,7 @@ const ResizableTable = ({minRows=5, minCols=5}) => { class PandasTable extends CustomTkBase{ static widgetType = "pandas_table" + static displayName = "Pandas Table" static requiredImports = [ ...CustomTkBase.requiredImports, diff --git a/src/frameworks/customtk/plugins/videoPlayer.js b/src/frameworks/customtk/plugins/videoPlayer.js index 2dedb51..1df7875 100644 --- a/src/frameworks/customtk/plugins/videoPlayer.js +++ b/src/frameworks/customtk/plugins/videoPlayer.js @@ -12,6 +12,7 @@ import { getPythonAssetPath } from "../../utils/pythonFilePath" class VideoPlayer extends CustomTkBase{ static widgetType = "video_player" + static displayName = "Video Player" static requiredImports = [ ...CustomTkBase.requiredImports, diff --git a/src/frameworks/customtk/sidebarWidgets.js b/src/frameworks/customtk/sidebarWidgets.js index 9759f5f..38136b3 100644 --- a/src/frameworks/customtk/sidebarWidgets.js +++ b/src/frameworks/customtk/sidebarWidgets.js @@ -7,7 +7,7 @@ import Label from "./widgets/label" import Button from "./widgets/button" import OptionMenu from "./widgets/optionMenu" import Slider from "./widgets/slider" -import { CheckBox, RadioButton } from "./widgets/ checkButton" +import { CheckBox, RadioButton } from "./widgets/checkButton" import { Input, Text } from "./widgets/input" import SpinBox from "./widgets/spinBox" diff --git a/src/frameworks/customtk/widgets/button.js b/src/frameworks/customtk/widgets/button.js index e85714b..39970cf 100644 --- a/src/frameworks/customtk/widgets/button.js +++ b/src/frameworks/customtk/widgets/button.js @@ -6,6 +6,7 @@ import { CustomTkWidgetBase } from "./base" class Button extends CustomTkWidgetBase{ static widgetType = "button" + static displayName = "Button" constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/ checkButton.js b/src/frameworks/customtk/widgets/checkButton.js similarity index 99% rename from src/frameworks/customtk/widgets/ checkButton.js rename to src/frameworks/customtk/widgets/checkButton.js index d478a67..ca626ec 100644 --- a/src/frameworks/customtk/widgets/ checkButton.js +++ b/src/frameworks/customtk/widgets/checkButton.js @@ -8,6 +8,8 @@ import { CustomTkWidgetBase } from "./base" export class CheckBox extends CustomTkWidgetBase{ static widgetType = "check_button" + static displayName = "Check Box" + constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/frame.js b/src/frameworks/customtk/widgets/frame.js index 286ec70..61b2105 100644 --- a/src/frameworks/customtk/widgets/frame.js +++ b/src/frameworks/customtk/widgets/frame.js @@ -5,6 +5,7 @@ import { CustomTkBase } from "./base" class Frame extends CustomTkBase{ static widgetType = "frame" + static displayName = "Frame" constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/input.js b/src/frameworks/customtk/widgets/input.js index ee73d93..c5c0c38 100644 --- a/src/frameworks/customtk/widgets/input.js +++ b/src/frameworks/customtk/widgets/input.js @@ -6,6 +6,7 @@ import { CustomTkWidgetBase } from "./base" export class Input extends CustomTkWidgetBase{ static widgetType = "entry" + static displayName = "Entry" constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/label.js b/src/frameworks/customtk/widgets/label.js index 0e36b12..1e580dc 100644 --- a/src/frameworks/customtk/widgets/label.js +++ b/src/frameworks/customtk/widgets/label.js @@ -7,7 +7,7 @@ import { CustomTkWidgetBase } from "./base" class Label extends CustomTkWidgetBase{ static widgetType = "label" - + static displayName = "Label" constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/mainWindow.js b/src/frameworks/customtk/widgets/mainWindow.js index 4e49556..43fb927 100644 --- a/src/frameworks/customtk/widgets/mainWindow.js +++ b/src/frameworks/customtk/widgets/mainWindow.js @@ -6,6 +6,7 @@ import { CustomTkBase } from "./base" class MainWindow extends CustomTkBase{ static widgetType = "main_window" + static displayName = "Main Window" constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/optionMenu.js b/src/frameworks/customtk/widgets/optionMenu.js index b272023..f1265f0 100644 --- a/src/frameworks/customtk/widgets/optionMenu.js +++ b/src/frameworks/customtk/widgets/optionMenu.js @@ -7,6 +7,7 @@ import { convertObjectToKeyValueString, removeKeyFromObject } from "../../../uti class OptionMenu extends CustomTkWidgetBase{ static widgetType = "option_menu" + static displayName = "Option Menu" constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/slider.js b/src/frameworks/customtk/widgets/slider.js index 8378978..50d9266 100644 --- a/src/frameworks/customtk/widgets/slider.js +++ b/src/frameworks/customtk/widgets/slider.js @@ -7,6 +7,8 @@ import { CustomTkWidgetBase } from "./base" class Slider extends CustomTkWidgetBase{ static widgetType = "scale" + static displayName = "Scale" + // FIXME: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/spinBox.js b/src/frameworks/customtk/widgets/spinBox.js index b333563..56f2374 100644 --- a/src/frameworks/customtk/widgets/spinBox.js +++ b/src/frameworks/customtk/widgets/spinBox.js @@ -8,6 +8,7 @@ import { CustomTkWidgetBase } from "./base" class SpinBox extends CustomTkWidgetBase{ static widgetType = "spin_box" + static displayName = "Spin Box" constructor(props) { super(props) diff --git a/src/frameworks/customtk/widgets/toplevel.js b/src/frameworks/customtk/widgets/toplevel.js index 446153c..a5d13e0 100644 --- a/src/frameworks/customtk/widgets/toplevel.js +++ b/src/frameworks/customtk/widgets/toplevel.js @@ -5,6 +5,7 @@ import Tools from "../../../canvas/constants/tools" class TopLevel extends Widget{ static widgetType = "toplevel" + static displayName = "Top Level" constructor(props) { super(props) diff --git a/src/frameworks/tkinter/plugins/analogTimepicker.js b/src/frameworks/tkinter/plugins/analogTimepicker.js index 41a30fc..16cd45d 100644 --- a/src/frameworks/tkinter/plugins/analogTimepicker.js +++ b/src/frameworks/tkinter/plugins/analogTimepicker.js @@ -20,6 +20,7 @@ const Themes = { class AnalogTimePicker extends TkinterBase{ static widgetType = "analog_timepicker" + static displayName = "Analog Timepicker" static requiredImports = [ ...TkinterBase.requiredImports, diff --git a/src/frameworks/tkinter/plugins/mapview.js b/src/frameworks/tkinter/plugins/mapview.js index a2cd063..e0b11ec 100644 --- a/src/frameworks/tkinter/plugins/mapview.js +++ b/src/frameworks/tkinter/plugins/mapview.js @@ -13,6 +13,7 @@ import { TkinterBase } from "../widgets/base" class MapView extends TkinterBase{ static widgetType = "map_view" + static displayName = "Map View" static requiredImports = [ ...TkinterBase.requiredImports, diff --git a/src/frameworks/tkinter/plugins/pandasTable.js b/src/frameworks/tkinter/plugins/pandasTable.js index 14ef746..86436d5 100644 --- a/src/frameworks/tkinter/plugins/pandasTable.js +++ b/src/frameworks/tkinter/plugins/pandasTable.js @@ -70,6 +70,7 @@ const ResizableTable = ({minRows=5, minCols=5}) => { class PandasTable extends TkinterBase{ static widgetType = "pandas_table" + static displayName = "Pandas Table" static requiredImports = [ ...TkinterBase.requiredImports, diff --git a/src/frameworks/tkinter/plugins/videoPlayer.js b/src/frameworks/tkinter/plugins/videoPlayer.js index 15e2dcf..40fd1ae 100644 --- a/src/frameworks/tkinter/plugins/videoPlayer.js +++ b/src/frameworks/tkinter/plugins/videoPlayer.js @@ -12,6 +12,7 @@ import { getPythonAssetPath } from "../../utils/pythonFilePath" class VideoPlayer extends TkinterBase{ static widgetType = "video_player" + static displayName = "Video Player" static requiredImports = [ ...TkinterBase.requiredImports, diff --git a/src/frameworks/tkinter/sidebarWidgets.js b/src/frameworks/tkinter/sidebarWidgets.js index 4ff5250..fa02095 100644 --- a/src/frameworks/tkinter/sidebarWidgets.js +++ b/src/frameworks/tkinter/sidebarWidgets.js @@ -7,7 +7,7 @@ import Label from "./widgets/label" import Button from "./widgets/button" import OptionMenu from "./widgets/optionMenu" import Slider from "./widgets/slider" -import { CheckBox, RadioButton } from "./widgets/ checkButton" +import { CheckBox, RadioButton } from "./widgets/checkButton" import { Input, Text } from "./widgets/input" import SpinBox from "./widgets/spinBox" diff --git a/src/frameworks/tkinter/widgets/button.js b/src/frameworks/tkinter/widgets/button.js index e5b6fb9..abd68b1 100644 --- a/src/frameworks/tkinter/widgets/button.js +++ b/src/frameworks/tkinter/widgets/button.js @@ -6,6 +6,7 @@ import { TkinterWidgetBase } from "./base" class Button extends TkinterWidgetBase{ static widgetType = "button" + static displayName = "Button" constructor(props) { super(props) diff --git a/src/frameworks/tkinter/widgets/ checkButton.js b/src/frameworks/tkinter/widgets/checkButton.js similarity index 99% rename from src/frameworks/tkinter/widgets/ checkButton.js rename to src/frameworks/tkinter/widgets/checkButton.js index 0b103bc..8bf86a4 100644 --- a/src/frameworks/tkinter/widgets/ checkButton.js +++ b/src/frameworks/tkinter/widgets/checkButton.js @@ -8,6 +8,8 @@ import { TkinterWidgetBase } from "./base" export class CheckBox extends TkinterWidgetBase{ static widgetType = "check_button" + static displayName = "Check Box" + constructor(props) { super(props) diff --git a/src/frameworks/tkinter/widgets/frame.js b/src/frameworks/tkinter/widgets/frame.js index adf6c21..7fe02d1 100644 --- a/src/frameworks/tkinter/widgets/frame.js +++ b/src/frameworks/tkinter/widgets/frame.js @@ -5,6 +5,7 @@ import {TkinterBase} from "./base" class Frame extends TkinterBase{ static widgetType = "frame" + static displayName = "Frame" constructor(props) { super(props) diff --git a/src/frameworks/tkinter/widgets/input.js b/src/frameworks/tkinter/widgets/input.js index 1380204..3a3a4d5 100644 --- a/src/frameworks/tkinter/widgets/input.js +++ b/src/frameworks/tkinter/widgets/input.js @@ -6,6 +6,7 @@ import { TkinterWidgetBase } from "./base" export class Input extends TkinterWidgetBase{ static widgetType = "entry" + static displayName = "Entry" constructor(props) { super(props) diff --git a/src/frameworks/tkinter/widgets/label.js b/src/frameworks/tkinter/widgets/label.js index 1a97c5a..bdd654a 100644 --- a/src/frameworks/tkinter/widgets/label.js +++ b/src/frameworks/tkinter/widgets/label.js @@ -7,6 +7,7 @@ import { TkinterWidgetBase } from "./base" class Label extends TkinterWidgetBase{ static widgetType = "label" + static displayName = "Label" constructor(props) { diff --git a/src/frameworks/tkinter/widgets/mainWindow.js b/src/frameworks/tkinter/widgets/mainWindow.js index c8cb70c..189732e 100644 --- a/src/frameworks/tkinter/widgets/mainWindow.js +++ b/src/frameworks/tkinter/widgets/mainWindow.js @@ -6,6 +6,7 @@ import { TkinterBase } from "./base" class MainWindow extends TkinterBase{ static widgetType = "main_window" + static displayName = "Main Window" constructor(props) { super(props) diff --git a/src/frameworks/tkinter/widgets/optionMenu.js b/src/frameworks/tkinter/widgets/optionMenu.js index a454006..255047b 100644 --- a/src/frameworks/tkinter/widgets/optionMenu.js +++ b/src/frameworks/tkinter/widgets/optionMenu.js @@ -7,6 +7,7 @@ import { convertObjectToKeyValueString } from "../../../utils/common" class OptionMenu extends TkinterWidgetBase{ static widgetType = "option_menu" + static displayName = "Option Menu" constructor(props) { super(props) diff --git a/src/frameworks/tkinter/widgets/slider.js b/src/frameworks/tkinter/widgets/slider.js index c72763d..fc6cc20 100644 --- a/src/frameworks/tkinter/widgets/slider.js +++ b/src/frameworks/tkinter/widgets/slider.js @@ -7,6 +7,8 @@ import {TkinterBase, TkinterWidgetBase} from "./base" class Slider extends TkinterWidgetBase{ static widgetType = "scale" + static displayName = "Scale" + // FIXME: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use constructor(props) { super(props) diff --git a/src/frameworks/tkinter/widgets/spinBox.js b/src/frameworks/tkinter/widgets/spinBox.js index 56cdf6d..b14e814 100644 --- a/src/frameworks/tkinter/widgets/spinBox.js +++ b/src/frameworks/tkinter/widgets/spinBox.js @@ -8,6 +8,7 @@ import {TkinterBase, TkinterWidgetBase} from "./base" class SpinBox extends TkinterWidgetBase{ static widgetType = "spin_box" + static displayName = "Spin Box" constructor(props) { super(props) diff --git a/src/frameworks/tkinter/widgets/toplevel.js b/src/frameworks/tkinter/widgets/toplevel.js index 35e4183..4938ea0 100644 --- a/src/frameworks/tkinter/widgets/toplevel.js +++ b/src/frameworks/tkinter/widgets/toplevel.js @@ -5,6 +5,8 @@ import Tools from "../../../canvas/constants/tools" class TopLevel extends Widget{ static widgetType = "toplevel" + static displayName = "Top Level" + constructor(props) { super(props) diff --git a/src/sidebar/treeviewContainer.js b/src/sidebar/treeviewContainer.js index ea6f82c..95e210d 100644 --- a/src/sidebar/treeviewContainer.js +++ b/src/sidebar/treeviewContainer.js @@ -13,7 +13,7 @@ import { useWidgetContext } from "../canvas/context/widgetContext" function transformWidgets(widgets, widgetRefs, isTopLevel=true) { // console.log("Wdiegts refs: ", widgetRefs) return widgets.map(widget => ({ - title: widget.widgetType.name, // Assuming widgetType is a class + title: widgetRefs.current[widget.id].current.getDisplayName(), // Assuming widgetType is a class key: widget.id, isTopLevel: isTopLevel, widgetRef: widgetRefs.current[widget.id],