implement file save chooser
This commit is contained in:
parent
d5f150927b
commit
892a8d34e8
2 changed files with 14 additions and 6 deletions
17
main.go
17
main.go
|
|
@ -260,6 +260,17 @@ func main() {
|
|||
plotCanvas.ScaleMode = canvas.ImageScalePixels
|
||||
plotCanvas.Resize(fyne.NewSize(1920, 782))
|
||||
|
||||
buttonGenerateReport := widget.NewButton("Generate report", func() {
|
||||
|
||||
onChosen := func(f fyne.URIWriteCloser, err error) {
|
||||
recordtime, _ := time.Parse("2006/01/02 15:04", datetimeInput.Text)
|
||||
pdf.RenderPDF(f.URI().Path(), titleInput.Text, wavelengthInput.Text, pulsewidthInput.Text, fibertypeInput.Text, locationaInput.Text, locationbInput.Text, projectInput.Text, customerInput.Text, remarksInput.Text, &plotCanvas.Image, iorInput.Text, testerInput.Text, contactInfoInput.Text, fiberNoInput.Text, events, fiberLenInput.Text, recordtime)
|
||||
}
|
||||
dialog.ShowFileSave(onChosen, mainWindow)
|
||||
|
||||
})
|
||||
buttonGenerateReport.Disable()
|
||||
|
||||
buttonReadFile := widget.NewButton("Open .sor file", func() {
|
||||
onChosen := func(f fyne.URIReadCloser, err error) {
|
||||
if err != nil {
|
||||
|
|
@ -306,17 +317,13 @@ func main() {
|
|||
})
|
||||
|
||||
tabs.SelectIndex(1)
|
||||
buttonGenerateReport.Enable()
|
||||
|
||||
}
|
||||
dialog.ShowFileOpen(onChosen, mainWindow)
|
||||
|
||||
})
|
||||
|
||||
buttonGenerateReport := widget.NewButton("Generate report", func() {
|
||||
recordtime, _ := time.Parse("2006/01/02 15:04", datetimeInput.Text)
|
||||
pdf.RenderPDF(titleInput.Text, wavelengthInput.Text, pulsewidthInput.Text, fibertypeInput.Text, locationaInput.Text, locationbInput.Text, projectInput.Text, customerInput.Text, remarksInput.Text, &plotCanvas.Image, iorInput.Text, testerInput.Text, contactInfoInput.Text, fiberNoInput.Text, events, fiberLenInput.Text, recordtime)
|
||||
|
||||
})
|
||||
fileLayout := container.New(layout.NewVBoxLayout(), buttonReadFile, buttonGenerateReport)
|
||||
|
||||
tabs.Append(container.NewTabItem("File", fileLayout))
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
// renderPdf creates a report.pdf with sections similar to the sample.
|
||||
func RenderPDF(
|
||||
filepath string,
|
||||
title string,
|
||||
wavelength string,
|
||||
pulsewidth string,
|
||||
|
|
@ -90,7 +91,7 @@ func RenderPDF(
|
|||
{{"Link Length", link.LinkLengthM}, {"Loss", link.LossdB}},
|
||||
})
|
||||
|
||||
return pdf.OutputFileAndClose("report.pdf")
|
||||
return pdf.OutputFileAndClose(filepath)
|
||||
}
|
||||
|
||||
// ---- Helper drawing functions ----
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue