fixed display name in treeview
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,6 +20,7 @@ const Themes = {
|
||||
class AnalogTimePicker extends CustomTkBase{
|
||||
|
||||
static widgetType = "analog_timepicker"
|
||||
static displayName = "Analog Timepicker"
|
||||
|
||||
static requiredImports = [
|
||||
...CustomTkBase.requiredImports,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { CustomTkWidgetBase } from "./base"
|
||||
class Button extends CustomTkWidgetBase{
|
||||
|
||||
static widgetType = "button"
|
||||
static displayName = "Button"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -5,6 +5,7 @@ import { CustomTkBase } from "./base"
|
||||
class Frame extends CustomTkBase{
|
||||
|
||||
static widgetType = "frame"
|
||||
static displayName = "Frame"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -6,6 +6,7 @@ import { CustomTkWidgetBase } from "./base"
|
||||
export class Input extends CustomTkWidgetBase{
|
||||
|
||||
static widgetType = "entry"
|
||||
static displayName = "Entry"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CustomTkWidgetBase } from "./base"
|
||||
class Label extends CustomTkWidgetBase{
|
||||
|
||||
static widgetType = "label"
|
||||
|
||||
static displayName = "Label"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -6,6 +6,7 @@ import { CustomTkBase } from "./base"
|
||||
class MainWindow extends CustomTkBase{
|
||||
|
||||
static widgetType = "main_window"
|
||||
static displayName = "Main Window"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -8,6 +8,7 @@ import { CustomTkWidgetBase } from "./base"
|
||||
class SpinBox extends CustomTkWidgetBase{
|
||||
|
||||
static widgetType = "spin_box"
|
||||
static displayName = "Spin Box"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -20,6 +20,7 @@ const Themes = {
|
||||
class AnalogTimePicker extends TkinterBase{
|
||||
|
||||
static widgetType = "analog_timepicker"
|
||||
static displayName = "Analog Timepicker"
|
||||
|
||||
static requiredImports = [
|
||||
...TkinterBase.requiredImports,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { TkinterWidgetBase } from "./base"
|
||||
class Button extends TkinterWidgetBase{
|
||||
|
||||
static widgetType = "button"
|
||||
static displayName = "Button"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -5,6 +5,7 @@ import {TkinterBase} from "./base"
|
||||
class Frame extends TkinterBase{
|
||||
|
||||
static widgetType = "frame"
|
||||
static displayName = "Frame"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -6,6 +6,7 @@ import { TkinterWidgetBase } from "./base"
|
||||
export class Input extends TkinterWidgetBase{
|
||||
|
||||
static widgetType = "entry"
|
||||
static displayName = "Entry"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -7,6 +7,7 @@ import { TkinterWidgetBase } from "./base"
|
||||
class Label extends TkinterWidgetBase{
|
||||
|
||||
static widgetType = "label"
|
||||
static displayName = "Label"
|
||||
|
||||
|
||||
constructor(props) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import { TkinterBase } from "./base"
|
||||
class MainWindow extends TkinterBase{
|
||||
|
||||
static widgetType = "main_window"
|
||||
static displayName = "Main Window"
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user