Kivy with Python tutorial Part 3 - The Kivy .kv Language

preview_player
Показать описание
In this Kivy application development tutorial, we cover the Kivy (.kv) language. The idea of the .kv files is to separate your presentation from your logic.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

I see many people have commented on the text: line with Hello World and 1+1. Many had ways they solved it, but nobody mentioned why it was an error. So my two cents: Separated by a comma, the two expressions became a tuple, not a str.

RufusVidS
Автор

For those of you having trouble with .kv file


say the name of your class is testApp(App)

your .kv file must be named test.kv!!

pretty much just name it after the word before App(App)

cloudboysmusic
Автор

"Hello" +"World" + str(1+2) works well when you use '+' between World and str(1+2) instead of ', '.

GoktugAsc
Автор

I love the dog sleeping in the background... :)

maraffio
Автор

<Label>
    text: 'Hello' + ' World ' + str(1+1)
;)

olinadciram
Автор

i was saving the kv file inside python and it saved as .kv.py this video saved me.

pawanps
Автор

thanks for these tutorials!
the comma was the problem, to include it we can type: text: "Hello World" + ", " + str(1+1)

MiledRizk
Автор

Hi mr. kinsley
your tutorials are amazing
I learned too much from them.
I have some questions regarding kivy and kv language.
1. I tried to use pure python to add label and buttons to a gridlayout, but it gives error "Label has no attribute 'fbind' "; but when I do it in pure kv it works fine. is this a bug? what can I do to overcome this problem?
2. unfortunately I found kivy a little bit late, so I have designed my app in Gtk 3.0 and in python 3.6 instead. now that the code is complete I tried to compile it for windows but I these two are not compatible in windows (they are good in linux). that's why I'm trying to convert it to kivy.
do you know a methods equivalent to Gtk.Frame and Gtk.Headerbar in kivy?
3. suppose we have a class with some variables in it like this:
class myclass(BoxLayout):
x=5
def __init__(self, **kwargs):
y=6
self.z=7

how to access these variables inside kv file? variable x can be accessed through root.x, but the others I don't know how
thank you in advance
and thank you for your great tutorial videos

shoaibmirzaei
Автор

Hi. I'm new to python. I did what you did, and it did run with no error but the text didn't show. It was just all black and no text in it.
[INFO ] [Logger ] Record log in
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [OSC ] using <thread> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'2.1.0 - Build 8.15.10.2993'>
[INFO ] [GL ] OpenGL vendor <b'Intel'>
[INFO ] [GL ] OpenGL renderer <b'Intel(R) HD Graphics'>
[INFO ] [GL ] OpenGL parsed version: 2, 1
[INFO ] [GL ] Shading version <b'1.20 - Intel Build 8.15.10.2993'>
[INFO ] [GL ] Texture max size <8192>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Shader ] fragment shader: <b'No errors.'>
[INFO ] [Shader ] vertex shader: <b'No errors.'>
[INFO ] [Shader ] program: <No errors.>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Base ] Start application main loop

Thanks. Please help :)

toysforbiggals
Автор

sentdex??oh finally got you. Thanx a lot .

khalidyuosif
Автор

in .kv you can do
text: 'Hello' ' World', python will concatenate it.
and to have integers in "text" property you can use formatting. text: 'Hello' 'World' '%s' % 1 or ".format" whichever way you prefer.

AnuragBisht
Автор

sublime text users. if you have package manger installed you cna install kivy syntax colouring. which makes you life a whole lot easier.

MirrorsEdgeGamer
Автор

nice tutorial bro I didn't know that you could make kind of files using just Notepad thanks men

joefvchannel
Автор

Awesome! Thanks, exactly what I was looking for.

LabGecko
Автор

Can I use kivy to use any python library to develop an android app?

aravinddasam
Автор

Adding a integer to the text worked for me, just replace the ', ' with an +. 

Like this : 
text: "Hello World" + str(2+4)

gideons
Автор

how to fix your simplekivy.kv not found? i cannot run the program sir.

iqbal-kharisma
Автор

Why does the simplekivy.kv dont have to be mentioned in the .py file?

torbenwiesbach
Автор

Can you use any text editor, I'm programming off a raspberry pi and have yet to be able to install any new text editors.

archanamaynard
Автор

The problem is text: 'Hello World'+ str(1+1)
and not
text: 'Hello World', str(1+1)

JohnEvanDizaro