Ini menunjukkan cara menggunakan file .kv secara implisit untuk aplikasi Anda. Anda akan melihat tombol layar penuh berlabel "Halo dari test.kv".
Setelah Kivy membuat instance subclass dari App, Kivy secara implisit mencari file .kv. File test.kv dipilih karena nama subclass App adalah TestApp, yang berarti bahwa kivy harus mencoba memuat "test.kv". File itu berisi Widget root.
Program ini adalah berasal dari Kivy.org yang akan dijalankan di Python 2.7.18
Listing Program app_with_kv :
''' Application built from a .kv file ================================== This shows how to implicitly use a .kv file for your application. You should see a full screen button labelled "Hello from test.kv". After Kivy instantiates a subclass of App, it implicitly searches for a .kv file. The file test.kv is selected because the name of the subclass of App is TestApp, which implies that kivy should try to load "test.kv". That file contains a root Widget. ''' import kivy kivy.require('1.0.7') from kivy.app import App class TestApp(App): pass if __name__ == '__main__': TestApp().run()
Listing Program Test.kv :#:kivy 1.0 Button: text: 'Hello from test.kv'
Untuk file .kv kita save dengan menggunakak notepad++ . setelah masuk notepad++, klik new ,Copy paste listing program test.kv di notepad++, save dengan test.kv, simpan di folder yang sama Python27 atau folder yang sesuai untuk python yang anda gunakan.
Lalu buka file app_with_kv.py , jalankan run module.
Hasilnya adalah sebagai berikut :
0 Response to "Membuat sebuah .KV File Aplikasi dengan Kivy "
Post a Comment