import Tools from "../../../canvas/constants/tools" import { convertObjectToKeyValueString } from "../../../utils/common" import { CustomTkWidgetBase } from "./base" class Button extends CustomTkWidgetBase{ static widgetType = "button" static displayName = "Button" constructor(props) { super(props) this.state = { ...this.state, size: { width: 80, height: 40 }, widgetName: "Button", attrs: { ...this.state.attrs, buttonLabel: { label: "Button Label", tool: Tools.INPUT, // the tool to display, can be either HTML ELement or a constant string toolProps: {placeholder: "Button label", maxLength: 100}, value: "Button", onChange: (value) => this.setAttrValue("buttonLabel", value) } } } } componentDidMount(){ super.componentDidMount() this.setAttrValue("styling.backgroundColor", "#029CFF") this.setAttrValue("styling.foregroundColor", "#fff") } generateCode(variableName, parent){ const labelText = this.getAttrValue("buttonLabel") const config = convertObjectToKeyValueString(this.getConfigCode()) return [ `${variableName} = ctk.CTkButton(master=${parent}, text="${labelText}")`, `${variableName}.configure(${config})`, `${variableName}.${this.getLayoutCode()}` ] } getToolbarAttrs(){ const toolBarAttrs = super.getToolbarAttrs() return ({ id: this.__id, widgetName: toolBarAttrs.widgetName, buttonLabel: this.state.attrs.buttonLabel, size: toolBarAttrs.size, ...this.state.attrs, }) } renderContent(){ return (