32
loading...
This website collects cookies to deliver better user experience
main.py
, add the following code:from kivymd.app import MDApp
from kivymd.uix.list import OneLineIconListItem, IconLeftWidget
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "Purple"
def add_item(self, text):
new_list_item = OneLineIconListItem(text=text)
new_list_item.add_widget(
IconLeftWidget(icon = "language-python")
)
self.root.ids.listcontainer.add_widget(new_list_item)
self.root.ids.listinput.text = ''
if __name__ == "__main__":
app = MainApp()
app.run()
main.kv
add the following lines:MDBoxLayout:
orientation: 'vertical'
id: box
MDToolbar:
title: 'SampleApp'
pos_hint: {'top': 1}
MDTextField:
id: listinput
hint_text: 'Add Item'
mode: 'rectangle'
size_hint_x: .9
pos_hint: {'center_x': .5}
text_validate_unfocus: False
on_text_validate: app.add_item(listinput.text)
ScrollView:
MDList:
id: listcontainer
!wget https://github.com/HeaTTheatR/KivyMD-data/raw/master/install-kivy-buildozer-dependencies.sh
!chmod +x install-kivy-buildozer-dependencies.sh
!./install-kivy-buildozer-dependencies.sh
!sudo apt update
!sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev
!pip install --upgrade Cython==0.29.19 virtualenv
!buildozer init
requirements = python3,kivy==2.0.0,https://github.com/kivymd/KivyMD/archive/master.zip,sdl2_ttf==2.0.15,pillow
Note: If your application requires special permissions such as internet or storage, scroll down to android.permissions
:
Uncomment the android.permissions line and add the permissions. For a full list of all the available permissions, check out this link.
!buildozer -v android debug
buildozer -v android deploy run logcat
which displays the logs so that you can search through them to identify errors. You can't do that on colab but you can if you're on Linux(perhaps your should just switch to linux😁).adb install name-of-the-app.apk
adb logcat