merge

Simple tool to quickly merge datasets for statistical analysis
Log | Files | Refs | README | LICENSE

commit 01717494f13e40a78eddc34640df5b192eade471
parent 58356b34ac917bd7084566c48ea681d25f28e9ca
Author: Nick Econopouly <wry@mm.st>
Date:   Fri,  6 Mar 2020 16:35:39 -0500

Add dummy gtk window

Diffstat:
Mmain.go | 58+++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/main.go b/main.go @@ -9,10 +9,44 @@ import ( "github.com/360EntSecGroup-Skylar/excelize" "github.com/knieriem/odf/ods" "encoding/csv" + "github.com/gotk3/gotk3/gtk" + "github.com/gotk3/gotk3/gdk" ) const EXPORT_BASE_FILENAME = "merged" +func windowSetup() *gtk.Window { + + os.Setenv("GSETTINGS_SCHEMA_DIR", ".\\share\\glib-2.0\\schemas") + + // Set up GTK + gtk.Init(&os.Args) + + window, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL) + if err != nil { + log.Fatal("Unable to create window:", err) + } + window.SetTitle("Merge Datasets") + window.Connect("destroy", func() { + gtk.MainQuit() + }) + + window.SetName("main-window") // for css selector + + // set up css stylesheet + screen, err := gdk.ScreenGetDefault() + if err != nil { + log.Fatal("can't get default screen") + } + mRefProvider, _ := gtk.CssProviderNew() + if err := mRefProvider.LoadFromPath("style.css"); err != nil { + log.Println(err) + } + gtk.AddProviderForScreen(screen, mRefProvider, gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + + return window +} + func pullExcel(path string) [][]string { var rows [][]string f, err := excelize.OpenFile(path) @@ -163,7 +197,7 @@ func main() { for name, data := range raws { datasets[name] = ImportDataset(name, data) } - + // merge them into a single Dataset var dataset Dataset dataset.height = 1 // row of terms, even though it's empty @@ -172,6 +206,28 @@ func main() { mergeDatasets(&dataset,d) } + + window := windowSetup() + + mergeButton, err := gtk.ButtonNewWithLabel("Merge Datasets!") + if err != nil { + log.Fatal("Unable to create mergeButton", err) + } + + _, err = mergeButton.Connect("clicked", func() { // export dataset exportDataset(&dataset, "merged.xlsx") + }) + + // store everything in a grid + mainBox, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5) + if err != nil { + log.Fatal("Unable to create grid: ", err) + } + + mainBox.PackStart(mergeButton, false, false, 0) + window.Add(mainBox) + window.ShowAll() + gtk.Main() } +