-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GTK 4 examples #122
base: master
Are you sure you want to change the base?
Add GTK 4 examples #122
Conversation
Thanks for the examples. I can not promise when I will find time to review unfortunately. For the with construct, I left it out with some purpose, as it is not a core of Nim language, so not all people may know it, and get more confused. They may think that it is a gintro macro. My strategy for examples is generally to make understanding simple, not that much to make the code look fine. And for some examples I kept the C layout by intent, even if a nimified version would look better. For the GTK4 book I relaxed this, but then I wrote that in the text. Will see how I can use your modifications. For listbox I know not much about it, I read about listview and treeview in 2008 in the Krause gtk2 book but forgot all, and still found no time to learn again. |
No since now it can't be imported without
Method cascading is a very popular concept, found in Pascal, Smalltalk, VB, Dark, Vala, Ruby, many functional languages, etc.
now there is a Readme in which you can explain it in one example: var x = "yay"
with x:
add "abc"
add "efg" same as var x = "yay"
x.add "abc"
x.add "efg
Im sure it also improves the understanding of the code too, making it easier to group actions into groups with objects when you write it, and less distracts the focus of attention when you read it. |
@StefanSalewski the last example with adwaita doesnt work with ARC. P.S. I continue to study nim, so far I'm just delighted. The most important problem is the quality of nimsuggest, you can practically assume that there is no auto-completion, since you still have to look at the documentation for everything. |
@StefanSalewski Just found great tutorial for GTK 4, may be it will help you with your GTK 4 book |
Now there are adw.Application. So need to fix all adwaita examples error: |
with window: | ||
title = "GTK4 & Nim" | ||
defaultSize = (200, 200) | ||
child = mainBox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You wanna do content = mainBox
here I think. Source: https://gitlab.gnome.org/GNOME/libadwaita/-/blob/main/src/adw-window.c#L206-211
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this exactly. Another example uses setChild
which does not work with Adwaita. content = mainBox
is the exact right way.
Added a simplified version of headerbar, I think this version looks very overcomplicated for someone who will just look for how to implement CSD.
Added an example of a ListBox with different Control widgets
Added simple hello word from your book.
I used
with
which makes the code much more readable.README with screenshots of examples to simplify the search for beginners.