Skip to content
Permalink
b6f72ecdfe
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
158 lines (139 sloc) 3.54 KB
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen
from kivy.properties import ObjectProperty,StringProperty
from kivymd.uix.boxlayout import MDBoxLayout
from kivy.clock import mainthread
Builder.load_string('''
<Home>:
name:'home'
BoxLayout:
orientation:'vertical'
padding:dp(20)
spacing:dp(20)
MDLabel:
text: ' Python Network Connection Services'
font_style:'H4'
adaptive_height:True
halign:'center'
MDBoxLayout:
adaptive_height:True
size_hint_y:None
height:dp(60)
Button:
text:'Home'
id:home
background_color:0,0,1,1
on_release:app.go('home',self)
Button:
text:'Responses'
background_color:.5,.5,.5,.5
on_release:app.go('responses',self)
id:res
Button:
text:'Logs'
background_color:.5,.5,.5,.5
on_release:app.go('logs',self)
id:log
ScreenManager:
id:mngr
Screen:
name:'home'
MDBoxLayout:
orientation:'vertical'
MDLabel:
text:'Devices'
adaptive_height:True
halign:'center'
font_style:'H5'
GridLayout:
cols:4
id:grid
MDLabel:
text:'Apply Commands:'
adaptive_height:True
halign:'center'
font_style:'H5'
Widget:
size_hint_y:.2
BoxLayout:
size_hint_y:None
height:dp(80)
Button:
text:'Shutdown Client'
on_release:app.sendCommand('Close')
Button:
text:'Get User'
on_release:app.sendCommand('Users')
Button:
text:'Get Client Device Info'
on_release:app.sendCommand('Info')
Screen:
name:'logs'
MDBoxLayout:
orientation:'vertical'
MDBoxLayout:
adaptive_height:True
Label:
adaptive_height:True
MDIconButton:
icon:'delete'
pos_hint:{'right':1}
on_release:logs.text = ''
MDBoxLayout:
md_bg_color:.5,.5,.5,.8
ScrollView:
MDLabel:
id:logs
adaptive_height:True
font_size:dp(14)
markup:True
Screen:
name:'responses'
MDBoxLayout:
orientation:'vertical'
MDBoxLayout:
adaptive_height:True
Label:
adaptive_height:True
MDIconButton:
icon:'delete'
pos_hint:{'right':1}
on_release:res.text = ''
MDBoxLayout:
md_bg_color:.5,.5,.5,.8
ScrollView:
MDLabel:
id:res
adaptive_height:True
font_size:dp(14)
markup:True
<MyCheckbox>:
spacing:dp(10)
adaptive_height:True
MDCheckbox:
size_hint: None, None
size: "48dp", "48dp"
pos_hint: {'center_x': .5, 'center_y': .5}
on_active:app.on_checkbox_active(root,*args)
MDLabel:
text:root.text
adaptive_height:True
pos_hint: {'center_x': .5, 'center_y': .5}
''')
class MyCheckbox(MDBoxLayout):
text = StringProperty('')
socket = ObjectProperty()
class Home(Screen):
@mainthread
def addLogs(self,txt):
self.ids.logs.text += txt
@mainthread
def addRes(self,txt):
self.ids.res.text += txt
if __name__ == '__main__':
from kivymd.app import MDApp
class HomeApp(MDApp):
active = ObjectProperty()
def build(self):
return Home()
HomeApp().run()