basic material design

This commit is contained in:
Yura 2024-09-16 00:31:05 +03:00
parent 2e6a0e0e60
commit 7c77a927b5
4 changed files with 54 additions and 32 deletions

View File

@ -96,6 +96,7 @@ fullscreen = 0
# (list) Permissions # (list) Permissions
# (See https://python-for-android.readthedocs.io/en/latest/buildoptions/#build-options-1 for all the supported syntaxes and properties) # (See https://python-for-android.readthedocs.io/en/latest/buildoptions/#build-options-1 for all the supported syntaxes and properties)
#android.permissions = android.permission.INTERNET, (name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=18) #android.permissions = android.permission.INTERNET, (name=android.permission.WRITE_EXTERNAL_STORAGE;maxSdkVersion=18)
android.permissions = android.permission.INTERNET
# (list) features (adds uses-feature -tags to manifest) # (list) features (adds uses-feature -tags to manifest)
#android.features = android.hardware.usb.host #android.features = android.hardware.usb.host

32
main.py
View File

@ -1,21 +1,21 @@
from kivy.lang import Builder from kivy.lang import Builder
from kivy.properties import ObjectProperty from kivy.properties import ObjectProperty
from kivy.app import App # from kivy.app import App
from kivy.uix.button import Button # from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout # from kivy.uix.gridlayout import GridLayout
from kivy.core.window import Window # from kivy.core.window import Window
import requests import requests
# from kivymd.app import MDApp from kivymd.app import MDApp
# from kivymd.theming import ThemeManager from kivymd.theming import ThemeManager
# from kivymd.uix.gridlayout import MDGridLayout from kivymd.uix.gridlayout import MDGridLayout
from kivymd.uix.button import MDButton, MDButtonText
# from kivymd.uix.label import MDLabel # from kivymd.uix.label import MDLabel
# from kivymd.uix.anchorlayout import MDAnchorLayout # from kivymd.uix.anchorlayout import MDAnchorLayout
# from kivymd.uix.boxlayout import MDBoxLayout from kivymd.uix.boxlayout import MDBoxLayout
# from kivymd.icon_definitions import md_icons # from kivymd.icon_definitions import md_icons
# from kivymd.uix.screen import MDScreen # from kivymd.uix.screen import MDScreen
@ -30,17 +30,17 @@ def isAvailable(ip):
try: try:
response = requests.get("http://" + ip, timeout=5) response = requests.get("http://" + ip, timeout=5)
# print("Yes") # print("Yes")
return "Yes" return "Works"
except requests.ConnectionError: except requests.ConnectionError:
# return False # return False
# print("No") # print("No")
return "NO" return "No"
except requests.exceptions.InvalidURL: except requests.exceptions.InvalidURL:
return "?" return "?"
class Container(GridLayout): class Container(MDGridLayout):
def checkAvailability(self): def checkAvailability(self):
openwrt = "10.1.0.1" openwrt = "10.1.0.1"
@ -56,13 +56,13 @@ class Container(GridLayout):
self.text_input_check.text = isAvailable(str(self.text_input.text)) self.text_input_check.text = isAvailable(str(self.text_input.text))
class MyApp(App): class MyApp(MDApp):
# theme_cls = ThemeManager() theme_cls = ThemeManager()
Title = 'Uptime Check' Title = 'Uptime Check'
def build(self): def build(self):
# self.theme_cls.theme_style = "Dark" self.theme_cls.theme_style = "Light"
# self.theme_cls.primary_palette = "Olive" # "Purple", "Red" self.theme_cls.primary_palette = "Green" # "Purple", "Red"
return Container() return Container()
MyApp().run() MyApp().run()

53
my.kv
View File

@ -1,11 +1,12 @@
<ItemLabel@Label>: <ItemLabel@MDLabel>:
font_size: '25sp' font_size: '25sp'
halign: 'left' halign: 'left'
valign: 'middle' valign: 'middle'
text_size: self.size text_size: self.size
<Container>: <Container>:
rows:3 rows:3
text_input: text_input text_input: text_input
@ -17,19 +18,30 @@
udongein_xyz: udongein_xyz udongein_xyz: udongein_xyz
AnchorLayout: MDAnchorLayout:
size_hint: 1, 0.15 size_hint: 1, 0.25
md_bg_color: app.theme_cls.backgroundColor
padding: [20, 0, 20, 0]
TextInput: MDTextField:
mode: "filled"
id: text_input id: text_input
font_size: '45sp' font_size: '40sp'
multiline: False multiline: False
input_type: 'number' #input_type: 'number'
MDTextFieldLeadingIcon:
icon: "web"
MDTextFieldHelperText:
text: "Enter ip or domain name"
GridLayout: MDGridLayout:
#adaptive_height: True
md_bg_color: app.theme_cls.backgroundColor
cols: 2 cols: 2
BoxLayout: MDBoxLayout:
orientation: 'vertical' orientation: 'vertical'
padding: [30, 0, 0, 0] padding: [30, 0, 0, 0]
@ -51,7 +63,7 @@
BoxLayout: MDBoxLayout:
orientation: 'vertical' orientation: 'vertical'
size_hint: 0.5, 1 size_hint: 0.5, 1
@ -81,15 +93,24 @@
markup: True markup: True
BoxLayout: MDBoxLayout:
size_hint: 0.9, 0.15 orientation: "horizontal"
size_hint_y: 0.20
padding: [30, 0, 30, 20] padding: [30, 0, 30, 20]
Button: md_bg_color: app.theme_cls.backgroundColor
text: 'Check connection'
font_size: 40 MDButton:
style: "tonal"
on_press:on_press: root.checkAvailability()
pos_hint_x: 60
MDButtonIcon:
icon: "check"
MDButtonText:
text: 'Check connection'
font_size: 40
on_release:
root.checkAvailability()