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

Function generateCode

src/frameworks/tkinter/widgets/optionMenu.js:54–74  ·  view source on GitHub ↗
(variableName, parent)

Source from the content-addressed store, hash-verified

52 }
53
54 generateCode(variableName, parent){
55
56
57 const config = convertObjectToKeyValueString(this.getConfigCode())
58
59 const defaultValue = this.getAttrValue("defaultValue")
60 const options = this.getAttrValue("widgetOptions").inputs
61
62 const code = [
63 `${variableName}_options = ${JSON.stringify(options)}`,
64 `${variableName}_var = tk.StringVar(value="${options.at(1) || defaultValue || ''}")`,
65 `${variableName} = tk.OptionMenu(${parent}, ${variableName}_var, *${variableName}_options)`
66 ]
67
68
69 return [
70 ...code,
71 `${variableName}.config(${config})`,
72 `${variableName}.${this.getLayoutCode()}`
73 ]
74 }
75
76 getToolbarAttrs(){
77

Callers

nothing calls this directly

Calls 2

getConfigCodeMethod · 0.45

Tested by

no test coverage detected