首页 > 解决方案 > 有没有办法水平翻转kivy中的标签?

问题描述

就像你从镜子里看它一样。texture_size(-100,50)例如,不能只做,会保持笔直

标签: pythonuser-interfacekivy

解决方案


一个半hacky的方法是垂直翻转它然后旋转图像以具有与水平翻转相同的效果

蟒蛇文件:

class MirrorCamera(Camera):
    def _camera_loaded(self, *largs):
        self.texture = self._camera.texture            
        self.texture_size = list(self.texture.size)
        self.texture.flip_vertical()

基维文件:

<MirrorCamera>
    canvas.before:
        PushMatrix
        Translate:
            xy: (self.x + self.width / 2, self.y + self.height / 2)
        Rotate:
            angle: 180
            axis: (0, 0, 1.0)
        Translate:
            xy: (-self.x - self.width / 2, -self.y - self.height / 2)
    canvas.after:
        PopMatrix

推荐阅读