Removed some files, finished basic search, now some tweaks are left to do here

This commit is contained in:
HiszpanInk 2022-08-06 21:01:52 +02:00
parent c4e57392b6
commit 58173ba295
3 changed files with 17 additions and 9 deletions

Binary file not shown.

View file

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"strconv"
"fyne.io/fyne/v2/app" "fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
@ -22,7 +23,7 @@ type vehicle struct {
equipment string equipment string
} }
func getVehicleByNum(vehicleNum int) vehicle { func getVehicleByNum(vehicleNum int) string {
var retrievedData [10]string var retrievedData [10]string
//get data from website and insert it into array //get data from website and insert it into array
@ -52,26 +53,33 @@ func getVehicleByNum(vehicleNum int) vehicle {
ticket_machine: retrievedData[8], ticket_machine: retrievedData[8],
equipment: retrievedData[9], equipment: retrievedData[9],
} }
output_string := fmt.Sprintf(
return retrievedVehicle `%s %s
`, retrievedVehicle.producer, retrievedVehicle.model)
return output_string
} }
func main() { func main() {
a := app.New() a := app.New()
w := a.NewWindow("Hello") w := a.NewWindow("Hello")
output := widget.NewLabel("Numer taborowy pojazdu: ") output := widget.NewLabel("")
form := widget.NewForm( entry := widget.NewEntry()
widget.NewFormItem("search_number", widget.NewEntry()), form := &widget.Form{
) Items: []*widget.FormItem{ // we can specify items in the constructor
{Text: "Podaj numer taborowy pojazdu:", Widget: entry}},
}
form.OnSubmit = func() { form.OnSubmit = func() {
output.Text = "submitted" input, error := strconv.Atoi(entry.Text)
fmt.Println(error)
output.Text = getVehicleByNum(input)
output.Refresh() output.Refresh()
} }
w.SetContent(container.NewVBox( w.SetContent(container.NewVBox(
output,
form, form,
output,
)) ))
w.ShowAndRun() w.ShowAndRun()

Binary file not shown.