jonegil / gui-with-gio Goto Github PK
View Code? Open in Web Editor NEWTutorials for Gio, the GUI framework in Go.
Home Page: https://jonegil.github.io/gui-with-gio/
License: Other
Tutorials for Gio, the GUI framework in Go.
Home Page: https://jonegil.github.io/gui-with-gio/
License: Other
Add a license file such as GPL or MIT so that others can have their code from your tutorial series on github.
Without that license its debatable if they can legally be used or shared on github.
Thanks for the great tutorial by the way!
@jonegil let's leave this issue open until I conclude all Chapter 3 edits. Please reply with answers so I know what to do - thanks!
CH3 Q1: Read the following:
io/system - Provides high-level events that are sent from the window. Most important is the
system.FrameEvent
. It's effectively a list of operations that do one of two things: details how to handle input and describes what to display.
This is confusing. Does it do one thing or two things? Sounds like two. If its two then it doesn't do
one of two things
it does two things. If its one thing then it "details OR describes", not "details AND describes". I'm not sure which one is right.
Hi, I'm doing these tutorials, they are great.
But I think they are out of date, the Circle has been removed from the package gioui.org/op/clip
here:
gioui/gio@6534639
This is a copypasta from #12 and I'm moving it to an issue because I don't want it to get lost. I think we need to decide what to do, if anything. Until I understand your direction a bit more I feel uncomfortable suggesting which way to go.
The demo at the end of Chapter 1 does not contain an os.Exit(0) line. When the student clicks the window frame's X to exit the app, the window goes away but the process still hangs in the terminal.
Now, you may know that already and it may be intentional for all I know. If it is, I agree with your call, because I'm pretty sure the added complexity to get the os.Exit(0) line into the right place would defeat the goal of keeping this chapter SIMPLE.
BUT, if that IS your reason then my opinion is that you need to do an "information" or "warning" callout at the end of the chapter. The hung process looks bad and makes the project look bad for producing a "failed" demo. Providing just a sentence or two telling the student that "its intentional" and to use ctrl-c to exit the process eliminates this negative "broken" vibe.
Is this tutorial still up to date? I can't run the source code because several variables got marked as "declared and not used" and
select {
// listen for events in the window.
case e := <-w.Events():
^^^^^
// detect what type of event
switch e := e.(type) {
is undefined.
Sorry if this question is silly, I'm very new to Go and Gio UI.
Implementing a restriction on resizing the application window appears to be a sensible decision for this application.
Tutorial: Egg Timer
Page: Input Boiltime
Link : https://github.com/jonegil/gui-with-gio/blob/main/egg_timer/10_input_boiltime.md
I tried to follow the Chapter 10. There are missed code lines in section 2. The editor widget
:
boilDuration
is initialized. I assume it is extracted number from string boilDurationInput
.The button is garbled with traditional characters
Hi @jonegil, I noticed an issue in your teleprompter program on my HiDPI screen. Namely, no text is visible. :D
These lines (259-262) are the big problem: https://github.com/jonegil/gui-with-gio/blob/main/teleprompter/code/main.go#L259
You are converting a value measured in pixels into DP with a cast. On my HiDPI screen, this means that if the value was originally 200 Px, it's now 200 Dp which is 400 Px. Setting the margins so high made no space for text to appear between them on my screen, so I saw nothing.
It would be best to convert your codebase to work almost entirely in Dp and Sp. Raw pixel values are only for times when you need to directly invoke Ops (like clipping). Whenever working with layouts, try to use Dp (and Sp for text).
I tried to convert your codebase to doing this for you, but there are a few places that you're using an integer value to modify both text size and positioning of elements, and changing that led to design decisions I didn't want to make for you. I suggest that you redefine all of the values at the top of draw()
as one of the unit types and then handle the necessary conversions throughout your layout code. I'm happy to answer any questions you may have about how to do this.
Getting the following error when I try to run the Eggtimer Blank window. The window runs briefly and then immediately closes. I can run the hello test from gioui.org perfectly. so don't think it's a missing install.
`panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0xb0b91a]
goroutine 8 [running, locked to thread]:
gioui.org/app.(*Window).processEvent(0xc00020a000, {0xc44948, 0xc000206090}, {0xc42158?, 0xc000292000?})`
i know there's probably gonna be some bugs here and there, but i'm on a a verge to get an idea of mine into reality with golang, but i'm being restricted by the fact that i'm no getting the docs/examples to work, i feel like they are outdated and will only work with old versions , i couldn't get images to display, here's my code and bug report:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x666d80]
goroutine 19 [running]:
gioui.org/op/paint.NewImageOp({0x0, 0x0})
/home/david/go/pkg/mod/[email protected]/op/paint/paint.go:88 +0x1a0
main.Assemble(0xc000112008)
/home/david/projects/TileAlign/gfx.go:58 +0x2ca
main.main.func1()
/home/david/projects/TileAlign/gfx.go:35 +0x1f
created by main.main in goroutine 1
/home/david/projects/TileAlign/gfx.go:33 +0x1a
exit status 2
func Assemble(window *app.Window) error {
theme := material.NewTheme()
var ops op.Ops
for {
switch e := window.Event().(type) {
case app.DestroyEvent:
return e.Err
case app.FrameEvent:
// This graphics context is used for managing the rendering state.
gtx := app.NewContext(&ops, e)
// Define an large label with an appropriate text:
title := material.H1(theme, "Hello, Wrld")
//new image
img, _ := getImageFromFilePath("container.webp")
imageOp := paint.NewImageOp(img)
imageOp.Filter = paint.FilterNearest
imageOp.Add(&ops)
op.Affine(f32.Affine2D{}.Scale(f32.Pt(0, 0), f32.Pt(4, 4))).Add(&ops)
paint.PaintOp{}.Add(&ops)
// Change the color of the label.
maroon := color.NRGBA{R: 127, G: 0, B: 0, A: 255}
title.Color = maroon
// Change the position of the label.
title.Alignment = text.Middle
// Draw the label to the graphics context.
title.Layout(gtx)
// Pass the drawing operations to the GPU.
e.Frame(gtx.Ops)
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.