From f130a1f9484a3976d8ea6ceb59bb801bec5804fb Mon Sep 17 00:00:00 2001 From: markochk <36880601+markochk@users.noreply.github.com> Date: Thu, 24 Feb 2022 19:02:06 +0100 Subject: [PATCH 1/4] Fix adding label alongside switch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c7a679..45a589d 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ A label is like a basic line of text ```python self.label = Gtk.Label(label="A switch") -self.switch_box.append(self.switch) +self.switch_box.append(self.label) self.switch_box.set_spacing(5) # Add some spacing ``` From 1727c88c18101e6a24508e7b7155b874c0933644 Mon Sep 17 00:00:00 2001 From: markochk <36880601+markochk@users.noreply.github.com> Date: Thu, 24 Feb 2022 19:05:13 +0100 Subject: [PATCH 2/4] Replace dw with self.dw in Cairo introduction because self.dw is needed in the following section --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 45a589d..a570089 100644 --- a/README.md +++ b/README.md @@ -414,18 +414,18 @@ To draw with Cairo we use the [***DrawingArea***](https://docs.gtk.org/gtk4/clas ```python - dw = Gtk.DrawingArea() + self.dw = Gtk.DrawingArea() # Make it fill the available space (It will stretch with the window) - dw.set_hexpand(True) - dw.set_vexpand(True) + self.dw.set_hexpand(True) + self.dw.set_vexpand(True) # Instead, If we didn't want it to fill the available space but wanted a fixed size - #dw.set_content_width(100) - #dw.set_content_height(100) + #self.dw.set_content_width(100) + #self.dw.set_content_height(100) - dw.set_draw_func(self.draw, None) - self.box3.append(dw) + self.dw.set_draw_func(self.draw, None) + self.box3.append(self.dw) def draw(self, area, c, w, h, data): # c is a Cairo context From a18c773ab560fe79387585fd80e3ddf38fc858e4 Mon Sep 17 00:00:00 2001 From: markochk <36880601+markochk@users.noreply.github.com> Date: Thu, 24 Feb 2022 19:06:59 +0100 Subject: [PATCH 3/4] Add missing statement in an EventControllerMotion example --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a570089..8bc584f 100644 --- a/README.md +++ b/README.md @@ -514,6 +514,7 @@ See also: [EventControllerMotion](https://docs.gtk.org/gtk4/class.EventControlle ```python evk = Gtk.EventControllerMotion.new() evk.connect("motion", self.mouse_motion) + self.add_controller(evk) def mouse_motion(self, motion, x, y): print(f"Mouse moved to {x}, {y}") ``` From c95536e44317c9f2e123b82e5b8d3820b771a7f1 Mon Sep 17 00:00:00 2001 From: markochk <36880601+markochk@users.noreply.github.com> Date: Thu, 24 Feb 2022 19:09:13 +0100 Subject: [PATCH 4/4] Gdk is imported a little bit earlier than mentioned --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8bc584f..1e2ca5d 100644 --- a/README.md +++ b/README.md @@ -526,7 +526,7 @@ See also: [EventControllerKey](https://docs.gtk.org/gtk4/class.EventControllerKe evk.connect("key-pressed", self.key_press) self.add_controller(evk) # add to window def key_press(self, event, keyval, keycode, state): - if keyval == Gdk.KEY_q and state & Gdk.ModifierType.CONTROL_MASK: + if keyval == Gdk.KEY_q and state & Gdk.ModifierType.CONTROL_MASK: # Add Gdk to your imports. i.e. from gi import Gdk self.close() ```