Skip to content

Instantly share code, notes, and snippets.

@matham
Created October 24, 2018 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matham/54b90075061be07e0e522c318b4db989 to your computer and use it in GitHub Desktop.
Save matham/54b90075061be07e0e522c318b4db989 to your computer and use it in GitHub Desktop.
Shows how to use a kivy matrix to acomplish the same that scatter does (ignoring the touch transfomration).
from kivy.uix.scatter import Scatter
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.app import runTouchApp
kv = """
#:import Matrix kivy.graphics.transformation.Matrix
BoxLayout:
Scatter:
id: scatter
auto_bring_to_front: False
on_size: print(self.size)
on_transform:
other.mat = Matrix().translate(-other.x, -other.y, 0)
other.mat = self.transform.multiply(other.mat)
Label:
size: self.parent.size
pos: 0, 0
text: "Hello"
Widget:
id: other
mat: Matrix()
canvas.before:
PushMatrix
MatrixInstruction:
matrix: self.mat
canvas.after:
PopMatrix
Label:
size: self.parent.size
pos: self.parent.pos
text: "Hello2"
"""
if __name__ == '__main__':
runTouchApp(Builder.load_string(kv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment