MCPcopy Create free account
hub / github.com/PaulleDemon/PyUIBuilder / generateCode

Function generateCode

src/frameworks/customtk/widgets/label.js:74–102  ·  view source on GitHub ↗
(variableName, parent)

Source from the content-addressed store, hash-verified

72 }
73
74 generateCode(variableName, parent){
75
76
77 const labelText = this.getAttrValue("labelWidget")
78 // Border color and border width are not implemented for label
79 const {border_color, border_width, ...config} = this.getConfigCode()
80 const image = this.getAttrValue("imageUpload")
81
82 // console.log("Object: ", config)
83
84 let labelInitialization = `${variableName} = ctk.CTkLabel(master=${parent}, text="${labelText}")`
85
86 const code = []
87
88 if (image?.name){
89 code.push(`${variableName}_img = Image.open(${getPythonAssetPath(image.name, "image")})`)
90 code.push(`${variableName}_img = ImageTk.PhotoImage(${variableName}_img)`)
91 // code.push("\n")
92 labelInitialization = `${variableName} = ctk.CTkLabel(master=${parent}, image=${variableName}_img, text="${labelText}", compound=ctk.TOP)`
93 }
94
95 // code.push("\n")
96 code.push(labelInitialization)
97 return [
98 ...code,
99 `${variableName}.configure(${convertObjectToKeyValueString(config)})`,
100 `${variableName}.${this.getLayoutCode()}`
101 ]
102 }
103
104
105 getToolbarAttrs(){

Callers

nothing calls this directly

Calls 3

getPythonAssetPathFunction · 0.90
getConfigCodeMethod · 0.45

Tested by

no test coverage detected