minor bug fixes

This commit is contained in:
paul
2024-09-29 20:57:10 +05:30
parent 97fca285d7
commit 923e371f1f
4 changed files with 20 additions and 17 deletions

View File

@@ -117,7 +117,7 @@ async function generateTkinterCode(projectName, widgetList=[], widgetRefs=[], as
// TODO: avoid adding \n inside the list instead rewrite using code.join("\n")
const code = [
"# This code is generated by PyUIbuilder: https://github.com/paulledemon",
"# This code is generated by PyUIbuilder: https://github.com/PaulleDemon/PyUIBuilder",
"\n\n",
...imports.flatMap((item, index) => index < imports.length - 1 ? [item, "\n"] : [item]), //add \n to every line
"\n\n",
@@ -132,12 +132,14 @@ async function generateTkinterCode(projectName, widgetList=[], widgetRefs=[], as
const createFileList = [
{
fileData: code.join("\n"),
fileData: code.join(""),
fileName: "main.py",
folder: ""
}
]
console.log("requirements: ", requirements)
if (requirements.length > 0){
createFileList.push({
fileData: requirements.join("\n"),
@@ -176,11 +178,11 @@ async function generateTkinterCode(projectName, widgetList=[], widgetRefs=[], as
}
// createFilesAndDownload(createFileList, projectName).then(() => {
// message.success("Download complete")
// }).catch(() => {
// message.error("Error while downloading")
// })
createFilesAndDownload(createFileList, projectName).then(() => {
message.success("Download complete")
}).catch(() => {
message.error("Error while downloading")
})
}

View File

@@ -54,19 +54,19 @@ export class TkinterBase extends Widget {
const expand = this.getAttrValue("flexManager.expand")
if (fillX){
config['fill'] = "'x'"
config['fill'] = `"x"`
}
if (fillY){
config['fill'] = "'y'"
config['fill'] = `"y"`
}
if (fillX && fillY){
config['fill'] = "'both'"
config['fill'] = `"both"`
}
if (expand){
config['expand'] = 'True'
config['expand'] = "True"
}
layoutManager = `pack(${convertObjectToKeyValueString(config)})`

View File

@@ -58,9 +58,10 @@ class Label extends TkinterWidgetBase{
getRequirements(){
const requirements = super.getRequirements()
if (this.getAttrValue("imageUpload"))
requirements.push(`pillow`)
requirements.push("pillow")
return requirements
}
@@ -72,14 +73,15 @@ class Label extends TkinterWidgetBase{
const config = convertObjectToKeyValueString(this.getConfigCode())
const image = this.getAttrValue("imageUpload")
let labelInitialization = `tk.Label(master=${parent}, text="${labelText}")`
let labelInitialization = `${variableName} = tk.Label(master=${parent}, text="${labelText}")`
const code = []
if (image.name){
if (image?.name){
code.push(`${variableName}_img = Image.open(${getPythonAssetPath(image.name, "image")})`)
code.push(`${variableName}_img = ImageTk.PhotoImage(${variableName}_img)`)
labelInitialization = `tk.Label(master=${parent}, image="${variableName}_img", text="${labelText}")`
// code.push("\n")
labelInitialization = `${variableName} = tk.Label(master=${parent}, image="${variableName}_img", text="${labelText}")`
}
// code.push("\n")

View File

@@ -42,7 +42,6 @@ class OptionMenu extends TkinterWidgetBase{
}
}
console.log("attrs1: ", this.state.attrs)
}
componentDidMount(){
@@ -71,7 +70,7 @@ class OptionMenu extends TkinterWidgetBase{
const toolBarAttrs = super.getToolbarAttrs()
const attrs = this.state.attrs
console.log("attrs: ", attrs)
return ({
id: this.__id,
widgetName: toolBarAttrs.widgetName,