widget.Entry insert some word is very log
hanjiangjiaolong opened this issue · comments
Checklist
- I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
- This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
widget.Entry insert some word is very log
How to reproduce
Put a large amount of text into widget.Entry
Screenshots
No response
Example code
import (
"bytes"
"encoding/base64"
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
"image"
"image/jpeg"
)
func Img2Base64(myWindow fyne.Window, myApp fyne.App) *fyne.Container {
// 图片预览区域
imageCanvas := canvas.NewImageFromResource(nil)
imageCanvas.FillMode = canvas.ImageFillOriginal
// Base64 文本显示区域
base64Entry := widget.NewEntry()
base64Entry.MultiLine = true
// 选择图片按钮
selectButton := widget.NewButton("Select Image", func() {
dialog.ShowFileOpen(func(reader fyne.URIReadCloser, err error) {
if err == nil && reader != nil {
defer reader.Close()
img, _, err := image.Decode(reader)
if err != nil {
dialog.ShowError(err, myWindow)
return
}
go func() {
base64Text := imageToBase64(img)
updateBase64Text(base64Text, base64Entry)
}()
}
}, myWindow)
})
// 布局
content := container.NewVBox(
selectButton,
container.NewHBox(
imageCanvas,
base64Entry,
),
)
return content
}
func updateBase64Text(text string, entry *widget.Entry) {
entry.SetText(text)
}
func imageToBase64(img image.Image) string {
buf := new(bytes.Buffer)
err := jpeg.Encode(buf, img, nil)
if err != nil {
fmt.Println(err)
return ""
}
return base64.StdEncoding.EncodeToString(buf.Bytes())
}
Fyne version
2.4.5
Go compiler version
1.22.3
Operating system and version
win10
Additional Information
No response
I don't understand what you mean. You have written the same thing under all questions more or less. Is the length of the Entry too long? Have you changed the scrolling setting?
My function is to open an image and write its base64 into a widget NewEntry() or widget.textarea, but a large number of base64 strings cause the interface to be particularly sluggish. The code is the example code I wrote
You mean that performance is bad? If that's the case then I think you might be encountering #2718.
When can I fix it
Can you confirm if this is or isn't the same as the issue linked above? If it is, I will close this as a duplicate.
As for any timelines for it to be fixed, I can't say. You'll see that the other issue has been open a while.
It does seem like a duplicate
Please note that it seems like you might be using the wrong component - do your users want to edit the Base64 of an image file?
Maybe a lighter weight component or one that is optimised for large content / long lines is the solution.
I just want to select an image, convert it to base64, and then copy the content of this base64. What do you think I should choose as a component
It sounds like displaying the content is not needed - just a "copy to clipboard" button would suffice...
you could always preview part of the conversion in a Label widget.
It sounds like a good idea, but some scenarios that require long text still have this issue. I hope it can be fixed soon