Reputation: 319
so i read here that this kivy file should make my image 40x40: but all it changes is the position. How could I change the size? This needs to be in the .kv file.
code:
Kivy File
#kivy 1.7.2
Root:
Image:
source: 'torch.png'
size_hint_y: None
size_hint_x: None
height: dp(40)
width: dp(40)
Main Script:
from kivy.app import App
from kivy.uix.image import Image
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.factory import Factory
from kivy.properties import ObjectProperty
from kivy.core.window import Window
class Root(FloatLayout):
pass
class RPGApp(App):
pass
RPGApp().run()
Upvotes: 3
Views: 3271
Reputation: 29450
Don't you want dp
, not db
? This converts from units of density independent pixels, i.e. it should remain the same 'real' size on screens with different pixel densities.
If you just want your image to be 40 pixels square, you can omit the function altogether (i.e. height: 40
and width: 40
or just size: 40, 40
).
This is explained on kivy's metrics page.
Upvotes: 5