79 lines
1.8 KiB
Go
79 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"fmt"
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/app"
|
|
"fyne.io/fyne/v2/widget"
|
|
)
|
|
func readFileLBL(file_path string) {
|
|
file, err := os.Open(file_path)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer file.Close()
|
|
|
|
reader := bufio.NewReader(file)
|
|
for {
|
|
line, err := reader.ReadString('\n')
|
|
if err != nil {
|
|
if err.Error() == "EOF" {
|
|
// If it's EOF, we can just break the loop
|
|
break
|
|
}
|
|
fmt.Println("Error reading file:", err)
|
|
return
|
|
}
|
|
fmt.Print(line) // Output the line
|
|
}
|
|
}
|
|
|
|
func parseGcode(){
|
|
|
|
}
|
|
func main() {
|
|
//Create a new app instance
|
|
a := app.New()
|
|
//Create a new Window on the app instance
|
|
w := a.NewWindow("GCode Renderer")
|
|
|
|
//Create the menu bar items for the render window
|
|
renderMenuItem := fyne.NewMenuItem("Load", func() { readFileLBL("./test.gcode") })
|
|
|
|
//Create the render menu bar and add its items
|
|
renderMenuBar := fyne.NewMainMenu(fyne.NewMenu("File",renderMenuItem))
|
|
w.SetMainMenu(renderMenuBar)
|
|
|
|
//instantiate gc_render as a Label widget
|
|
gc_render := widget.NewLabel("GCODE RENDER HERE")
|
|
|
|
//update the window with the gc_render widget
|
|
w.SetContent(gc_render)
|
|
|
|
//Resize w1 to 480x640
|
|
w.Resize(fyne.NewSize(640, 480))
|
|
|
|
//Set the first window visable
|
|
w.Show()
|
|
|
|
//Create a new Window on the app instance to show the gcode being rendered in w
|
|
w1 := a.NewWindow("GCode Visualizer")
|
|
|
|
//instantiate gc_vis as a Label widget
|
|
gc_vis := widget.NewLabel("GCODE TO BE RENDERED HERE")
|
|
|
|
//update the window with the gc_vis widget
|
|
w1.SetContent(gc_vis)
|
|
|
|
//Resize w1 to 480x640
|
|
w1.Resize(fyne.NewSize(480, 640))
|
|
|
|
//Set the second window visable
|
|
w1.Show()
|
|
|
|
//Run the above defined app instance
|
|
a.Run()
|
|
}
|