From 7764cb2204f45dff66c97611a84faa41ed4ca206 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 20 Dec 2021 14:17:37 +0000 Subject: rescribe: add "Choose PDF" button, and make chosen dir/file section a label rather than an entry --- cmd/rescribe/gui.go | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'cmd/rescribe') diff --git a/cmd/rescribe/gui.go b/cmd/rescribe/gui.go index 36d9b3a..eb91a49 100644 --- a/cmd/rescribe/gui.go +++ b/cmd/rescribe/gui.go @@ -103,21 +103,27 @@ func startGui(log log.Logger, cmd string, training string, systess bool, tessdir var gobtn *widget.Button - dir := widget.NewEntry() - dir.SetPlaceHolder("Folder to process") - dir.OnChanged = func(s string) { - // TODO: also check if string is a directory, and only enable if so - if dir.Text != "" { - gobtn.Enable() - } else { - gobtn.Disable() - } - } + dir := widget.NewLabel("") - openbtn := widget.NewButtonWithIcon("Choose folder", theme.FolderOpenIcon(), func() { + dirIcon := widget.NewIcon(theme.FolderIcon()) + + folderBtn := widget.NewButtonWithIcon("Choose folder", theme.FolderOpenIcon(), func() { dialog.ShowFolderOpen(func(uri fyne.ListableURI, err error) { if err == nil && uri != nil { dir.SetText(uri.Path()) + dirIcon.SetResource(theme.FolderIcon()) + gobtn.Enable() + } + }, myWindow) + }) + + pdfBtn := widget.NewButtonWithIcon("Choose PDF", theme.FileTextIcon(), func() { + dialog.ShowFileOpen(func(uri fyne.URIReadCloser, err error) { + if err == nil && uri != nil { + uri.Close() + dir.SetText(uri.URI().Path()) + dirIcon.SetResource(theme.FileTextIcon()) + gobtn.Enable() } }, myWindow) }) @@ -187,9 +193,11 @@ func startGui(log log.Logger, cmd string, training string, systess bool, tessdir }) gobtn.Disable() - diropener := container.New(layout.NewGridLayout(2), dir, openbtn) + choices := container.New(layout.NewGridLayout(2), folderBtn, pdfBtn) + + chosen := container.New(layout.NewBorderLayout(nil, nil, dirIcon, nil), dirIcon, dir) - content := container.NewVBox(diropener, gobtn, progressBar, logarea) + content := container.NewVBox(choices, chosen, gobtn, progressBar, logarea) myWindow.SetContent(content) -- cgit v1.2.1-24-ge1ad