fixed code generation for custom tkinter

This commit is contained in:
paul
2024-09-30 22:18:08 +05:30
parent af0ac90499
commit 10b6e2872a
21 changed files with 80 additions and 833 deletions

View File

@@ -85,7 +85,7 @@ function generateTkinterCodeList(widgetList = [], widgetRefs = [], parentVariabl
async function generateTkinterCode(projectName, widgetList=[], widgetRefs=[], assetFiles){
console.log("widgetList and refs", projectName, widgetList, widgetRefs, assetFiles)
// console.log("widgetList and refs", projectName, widgetList, widgetRefs, assetFiles)
let mainWindowCount = 0

View File

@@ -19,7 +19,8 @@ class OptionMenu extends TkinterWidgetBase{
...this.state,
isDropDownOpen: false,
widgetName: "Option menu",
size: { width: 120, height: 'fit' },
size: { width: 120, height: 30 },
fitContent: { width: true, height: true },
attrs: {
...this.state.attrs,
defaultValue: {
@@ -55,11 +56,11 @@ class OptionMenu extends TkinterWidgetBase{
const config = convertObjectToKeyValueString(this.getConfigCode())
const defaultValue = this.getAttrValue("defaultValue")
const options = JSON.stringify(this.getAttrValue("widgetOptions").inputs)
const options = this.getAttrValue("widgetOptions").inputs
const code = [
`${variableName}_options = ${options}`,
`${variableName}_var = tk.StringVar(value="${defaultValue || options.at(1) || ""}")`,
`${variableName}_options = ${JSON.stringify(options)}`,
`${variableName}_var = tk.StringVar(value="${options.at(1) || defaultValue || ''}")`,
`${variableName} = tk.OptionMenu(${parent}, ${variableName}_var, *${variableName}_options)`
]

View File

@@ -14,7 +14,8 @@ class Slider extends TkinterWidgetBase{
this.state = {
...this.state,
widgetName: "Scale",
size: { width: 'fit', height: 'fit' },
size: { width: 120, height: 10 },
fitContent: {width: true, height: true},
attrs: {
...this.state.attrs,
styling: {