load into table and struct update
crispy-caesus crispy@crispy-caesus.eu
Fri, 28 Mar 2025 17:38:36 +0100
3 files changed,
5 insertions(+),
8 deletions(-)
M
main.go
→
main.go
@@ -15,7 +15,7 @@
func tableView(w fyne.Window, category string) { items := loadCategory(category) - table := widget.NewTableWithHeaders( + table := widget.NewTable( func() (int, int) { return len(items), 5 },@@ -31,7 +31,7 @@ label.SetText(items[id.Row].name.String)
case 1: label.SetText(items[id.Row].artist.String) case 2: - label.SetText(strconv.FormatFloat(items[id.Row].price, 'f', 2, 64) + " " + items[id.Row].currency.String) + label.SetText(strconv.FormatFloat(items[id.Row].price, 'f', 2, 64) + " " + "€") case 3: label.SetText(items[id.Row].seller.String) case 4:@@ -39,12 +39,10 @@ label.SetText(items[id.Row].purchase_date.String)
} }, ) - /* table.SetColumnWidth(0, 100) table.SetColumnWidth(1, 100) table.SetColumnWidth(2, 100) table.SetColumnWidth(3, 100) - */ /* headers := []string{"Name", "Price", "Seller", "Purchase Date"}@@ -54,6 +52,7 @@ table.UpdateHeader(widget.TableCellID{Row: -1, Col: i},
widget.NewLabel(header)) } */ + editForm := widget.NewForm() nameEntry := widget.NewEntry()@@ -109,6 +108,7 @@ ))
} func main() { + a := app.New() w := a.NewWindow("Hello World")
M
sql.go
→
sql.go
@@ -20,13 +20,12 @@
func createTables(db *sql.DB, tableName string) (err error) { switch tableName { case "music": - _, err = db.Exec(`CREATE TABLE IF NOT EXISTS purchase ( + _, err = db.Exec(`CREATE TABLE IF NOT EXISTS music ( id INTEGER PRIMARY KEY AUTOINCREMENT, external_ids TEXT, name TEXT NOT NULL, artist TEXT NOT NULL, price FLOAT, - currency TEXT, seller TEXT, note TEXT, purchase_date TEXT);`)@@ -67,7 +66,6 @@ &result.external_ids,
&result.name, &result.artist, &result.price, - &result.currency, &result.seller, &result.note, &result.purchase_date)
M
structs.go
→
structs.go
@@ -8,7 +8,6 @@ external_ids sql.NullString
name sql.NullString artist sql.NullString price float64 - currency sql.NullString seller sql.NullString note sql.NullString purchase_date sql.NullString