import Widget from "../../../canvas/widgets/base" import Tools from "../../../canvas/constants/tools" import { CustomTkBase } from "./base" class MainWindow extends CustomTkBase{ static widgetType = "main_window" static displayName = "Main Window" constructor(props) { super(props) this.droppableTags = { exclude: ["image", "video", "media", "main_window", "toplevel"] } this.state = { ...this.state, size: { width: 700, height: 400 }, widgetName: "main", attrs: { ...this.state.attrs, title: { label: "Window Title", tool: Tools.INPUT, // the tool to display, can be either HTML ELement or a constant string toolProps: {placeholder: "Window title", maxLength: 40}, value: "Main Window", onChange: (value) => this.setAttrValue("title", value) } } } } componentDidMount(){ this.setAttrValue("styling.backgroundColor", "#23272D") super.componentDidMount() // this.setWidgetName("main") // Don't do this as this will cause conflicts while loading names } generateCode(variableName, parent){ const backgroundColor = this.getAttrValue("styling.backgroundColor") return [ `${variableName} = ctk.CTk()`, `${variableName}.configure(fg_color="${backgroundColor}")`, `${variableName}.title("${this.getAttrValue("title")}")` ] } getToolbarAttrs(){ const toolBarAttrs = super.getToolbarAttrs() return ({ id: this.__id, widgetName: toolBarAttrs.widgetName, title: this.state.attrs.title, size: toolBarAttrs.size, ...this.state.attrs, }) } renderContent(){ return (
{this.getAttrValue("title")}
{this.props.children}
) } } export default MainWindow