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

Function getLayoutCode

src/frameworks/tkinter/widgets/base.js:55–188  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53
54
55 getLayoutCode(){
56 const {layout: parentLayout, direction, gap, align="start"} = this.getParentLayout()
57
58
59 const absolutePositioning = this.getAttrValue("positioning")
60
61 let layoutManager = `pack()`
62 const marginX = this.getAttrValue("margin.marginX")
63 const marginY = this.getAttrValue("margin.marginY")
64
65 const paddingX = this.getAttrValue("padding.padX")
66 const paddingY = this.getAttrValue("padding.padY")
67
68 let config = {}
69
70 if (marginX){
71 config["padx"] = marginX
72 }
73
74 if (marginY){
75 config["pady"] = marginY
76 }
77
78 if (paddingX){
79 config["ipadx"] = paddingX
80 }
81
82 if (paddingY){
83 config["ipady"] = paddingY
84 }
85
86 if (parentLayout === Layouts.PLACE || absolutePositioning){
87
88 config['x'] = Math.trunc(this.state.pos.x)
89 config['y'] = Math.trunc(this.state.pos.y)
90
91 // config["width"] = Math.trunc(this.state.size.width)
92 // config["height"] = Math.trunc(this.state.size.height)
93
94 if (!this.state.fitContent.width){
95 config["width"] = Math.trunc(this.state.size.width)
96 }
97 if (!this.state.fitContent.height){
98 config["height"] = Math.trunc(this.state.size.height)
99 }
100
101 const configStr = convertObjectToKeyValueString(config)
102
103 layoutManager = `place(${configStr})`
104
105 }else if (parentLayout === Layouts.FLEX){
106
107 const packSide = this.getAttrValue("flexManager.side")
108
109 if (packSide === "" || packSide === "top"){
110
111 config['side'] = `tk.TOP`
112

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected