Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.lang import Builder
- from kivy.base import runTouchApp
- KV = '''
- <-ScaleButton@Button>:
- x_ratio: min(1, self.width / (self.texture_size[0] or 1))
- y_ratio: min(1, self.height / (self.texture_size[1] or 1))
- min_ratio: min(self.x_ratio or 1, self.y_ratio or 1)
- keep_ratio: False
- scale_x: (self.min_ratio or 1) if self.keep_ratio else self.x_ratio or 1
- scale_y: (self.min_ratio or 1) if self.keep_ratio else self.y_ratio or 1
- state_image: self.background_normal if self.state == 'normal' else self.background_down
- disabled_image: self.background_disabled_normal if self.state == 'normal' else self.background_disabled_down
- canvas:
- Color:
- rgba: self.background_color
- BorderImage:
- border: self.border
- pos: self.pos
- size: self.size
- source: self.disabled_image if self.disabled else self.state_image
- Color:
- rgba: 1, 1, 1, 1
- PushMatrix
- Scale:
- x: self.scale_x or 1
- y: self.scale_y or 1
- Rectangle:
- texture: self.texture
- size: self.texture_size
- pos:
- (
- int((self.center_x / (self.scale_x or 1)) - self.texture_size[0] / 2.),
- int((self.center_y / (self.scale_y or 1)) - self.texture_size[1] / 2.)
- )
- PopMatrix
- FloatLayout:
- ScaleButton:
- text: 'test ' * 5
- font_size: font_size.value
- size_hint: size_hint_x.value, size_hint_y.value
- pos_hint: {'center': (.5, .5)}
- keep_ratio: lock_ratio.active
- Slider:
- id: size_hint_y
- orientation: 'vertical'
- size_hint_x: None
- value: .5
- min: 0
- max: 1
- Slider:
- id: size_hint_x
- size_hint_y: None
- value: .5
- min: 0
- max: 1
- Slider:
- id: font_size
- orientation: 'vertical'
- size_hint_x: None
- value: 20
- min: 10
- max: 1000
- pos_hint: {'right': 1}
- BoxLayout:
- size: self.minimum_size
- size_hint: None, None
- pos_hint: {'center': (.5, .8)}
- CheckBox:
- id: lock_ratio
- size_hint: None, None
- size: 20, 20
- Label:
- text: 'lock ratio'
- size_hint: None, None
- size: self.texture_size
- ''' # noqa
- runTouchApp(Builder.load_string(KV))
Add Comment
Please, Sign In to add comment