mirror of
https://github.com/Taiko2k/GTK4PythonTutorial.git
synced 2025-07-21 20:51:10 +02:00
tweaks
This commit is contained in:
22
README.md
22
README.md
@@ -599,8 +599,8 @@ Here we use:
|
|||||||
colour.parse("#e80e0e")
|
colour.parse("#e80e0e")
|
||||||
|
|
||||||
rect = Graphene.Rect() # Add Graphene to your imports. i.e. from gi import Graphene
|
rect = Graphene.Rect() # Add Graphene to your imports. i.e. from gi import Graphene
|
||||||
rect.__init__(10, 10, 40, 60) # x, y, w, h. # todo/help this seems like a hacky way of initiating,
|
rect.__init__(10, 10, 40, 60) # x, y, w, h. # todo/help this seems like a hacky way
|
||||||
# is there a better way?
|
|
||||||
s.append_color(colour, rect)
|
s.append_color(colour, rect)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -635,20 +635,22 @@ Fairly straightforward, see [append_border](https://docs.gtk.org/gtk4/method.Sna
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
texture = Gdk.Texture.new_from_filename("example.png")
|
texture = Gdk.Texture.new_from_filename("example.png")
|
||||||
# Warning: For the purposes of demonstration ive shown this declared in our drawing function, but of course
|
# Warning: For the purposes of demonstration ive shown this declared in our drawing function,
|
||||||
# you would REALLY need to define this somewhere else so that its only called once as we don't want to
|
# but of course you would REALLY need to define this somewhere else so that its only called
|
||||||
# reload/upload the data every draw call.
|
# once as we don't want to reload/upload the data every draw call.
|
||||||
|
|
||||||
# Tip: There are other functions to load image data from in memory pixel data
|
# Tip: There are other functions to load image data from in memory pixel data
|
||||||
|
|
||||||
rect = Graphene.Rect()
|
rect = Graphene.Rect()
|
||||||
rect.__init__(50, 50, texture.get_width(), texture.get_height()) # Warning: On a HiDPI display the logical and
|
rect.__init__(50, 50, texture.get_width(), texture.get_height()) # See warning below
|
||||||
s.append_texture(texture, rect) # physical measurements may differ in scale,
|
s.append_texture(texture, rect)
|
||||||
# typically, by a factor of 2. In most places
|
|
||||||
# we're dealing in logical units, but these
|
|
||||||
# methods give physical units.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Warning: On a HiDPI display the logical and physical measurements may differ in scale, typically by a factor of 2. In most places
|
||||||
|
we're dealing in logical units but these methods give physical units. So... you might not want to define the size of the rectangle
|
||||||
|
by the texture.
|
||||||
|
|
||||||
### Text
|
### Text
|
||||||
|
|
||||||
Text is drawn using Pango layouts. Pango is quite powerful and really needs a whole tutorial on its own, but here's
|
Text is drawn using Pango layouts. Pango is quite powerful and really needs a whole tutorial on its own, but here's
|
||||||
|
Reference in New Issue
Block a user