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

Function generateCode

src/frameworks/tkinter/widgets/mainWindow.js:59–86  ·  view source on GitHub ↗
(variableName, parent)

Source from the content-addressed store, hash-verified

57 // }
58
59 generateCode(variableName, parent){
60
61 const backgroundColor = this.getAttrValue("styling.backgroundColor")
62
63 const logo = this.getAttrValue("logo")
64
65 const {width, height} = this.getSize()
66
67 const code = [
68 `${variableName} = tk.Tk()`,
69 `${variableName}.config(bg="${backgroundColor}")`,
70 `${variableName}.title("${this.getAttrValue("title")}")`,
71 `${variableName}.geometry("${width}x${height}")`,
72 ...this.getGridLayoutConfigurationCode(variableName)
73 ]
74
75 if (logo?.name){
76
77 // code.push(`\n`)
78 code.push(`${variableName}_img = Image.open(${getPythonAssetPath(logo.name, "image")})`)
79 code.push(`${variableName}_img = ImageTk.PhotoImage(${variableName}_img)`)
80 code.push(`${variableName}.iconphoto(False, ${variableName}_img)`)
81 // code.push("\n")
82 }
83
84
85 return code
86 }
87
88 getImports(){
89 const imports = super.getImports()

Callers

nothing calls this directly

Calls 1

getPythonAssetPathFunction · 0.90

Tested by

no test coverage detected