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

Function generateCode

src/frameworks/tkinter/widgets/label.js:160–186  ·  view source on GitHub ↗
(variableName, parent)

Source from the content-addressed store, hash-verified

158 }
159
160 generateCode(variableName, parent){
161
162
163 const labelText = this.getAttrValue("labelWidget")
164
165 const config = convertObjectToKeyValueString(this.getConfigCode())
166 const image = this.getAttrValue("imageUpload")
167
168 let labelInitialization = `${variableName} = tk.Label(master=${parent}, text="${labelText}")`
169
170 const code = []
171
172 if (image?.name){
173 // code.push(`${variableName}_img = Image.open(${getPythonAssetPath(image.name, "image")})`)
174 // code.push(`${variableName}_img = ImageTk.PhotoImage(${variableName}_img)`)
175 // code.push("\n")
176 labelInitialization = `${variableName} = ImageLabel(master=${parent}, image_path=${getPythonAssetPath(image.name, "image")}, text="${labelText}", compound=tk.TOP, mode="${this.getAttrValue("imageSize.mode")}")`
177 }
178
179 // code.push("\n")
180 code.push(labelInitialization)
181 return [
182 ...code,
183 `${variableName}.config(${config})`,
184 `${variableName}.${this.getLayoutCode()}`
185 ]
186 }
187
188
189 getToolbarAttrs(){

Callers

nothing calls this directly

Calls 3

getPythonAssetPathFunction · 0.90
getConfigCodeMethod · 0.45

Tested by

no test coverage detected