Created
October 24, 2018 05:47
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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