Skip to content

Instantly share code, notes, and snippets.

@ilovetogetspamed
Created March 15, 2017 15:52
Show Gist options
  • Save ilovetogetspamed/bd35deb43fe69401c0fc330b4b6c9195 to your computer and use it in GitHub Desktop.
Save ilovetogetspamed/bd35deb43fe69401c0fc330b4b6c9195 to your computer and use it in GitHub Desktop.
Still Not working
#!/usr/bin/env python
from kivy.base import runTouchApp
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.checkbox import CheckBox
class NetworkConfig(BoxLayout):
def __init__(self, *args, **kwargs):
super(NetworkConfig, self).__init__(*args, **kwargs)
def on_checkbox_active(self, checkbox, value):
if value:
print('The checkbox', checkbox, 'is active')
else:
print('The checkbox', checkbox, 'is inactive')
class UseDHCP(CheckBox):
pass
widget = Builder.load_string("""
NetworkConfig:
orientation: 'vertical'
cols: 1
# rows: 1
canvas:
Color:
rgba: 0.3, 0.3, 0.3, 1
Rectangle:
size: self.size
pos: self.pos
Label:
text: '[b]Network Configuration[/b]'
markup: True
size_hint_y: 0.1
background_normal: None
GridLayout:
rows: 8
padding: dp(8)
spacing: dp(16)
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 1
cols: 2
size_hint_y: 0.9
Label:
text: "Host Name"
TextInput:
id: hostname
multiline: False
hint_text: 'hostname@example.com'
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 2
cols: 2
size_hint_y: 0.1
Label:
text: 'Automatic setup using DHCP'
UseDHCP:
id: inet_use_dhcp
value: True
active: True
on_active: root.on_checkbox_active(self, self.state)
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 1
cols: 2
Label:
text: "IP Address"
TextInput:
id: inet_address
multiline: False
hint_text: '192.168.1.100'
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 1
cols: 2
Label:
text: "Network Mask"
TextInput:
id: inet_mask
multiline: False
hint_text: '255.255.255.0'
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 1
cols: 2
Label:
text: "Default Gateway"
TextInput:
id: inet_bcast
multiline: False
hint_text: '192.168.1.1'
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 1
cols: 2
Label:
text: "DNS 1"
TextInput:
id: inet_dns1
multiline: False
hint_text: 'dns1@example.com'
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 1
cols: 2
Label:
text: "DNS 2"
TextInput:
id: inet_dns2
multiline: False
hint_text: 'dns2@example.com'
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 1
cols: 2
Label:
text: "DNS 3"
TextInput:
id: inet_dns3
multiline: False
hint_text: 'dns3@example.com'
""")
runTouchApp(widget)
#!/usr/bin/env python
from kivy.base import runTouchApp
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.checkbox import CheckBox
class NetworkConfig(BoxLayout):
def __init__(self, *args, **kwargs):
super(NetworkConfig, self).__init__(*args, **kwargs)
def on_checkbox_active(self, checkbox, value):
if value:
print('The checkbox', checkbox, 'is active')
else:
print('The checkbox', checkbox, 'is inactive')
class UseDHCP(CheckBox):
pass
widget = Builder.load_string("""
NetworkConfig:
orientation: 'vertical'
cols: 1
rows: 1
Label:
text: '[b]Network Configuration[/b]'
markup: True
size_hint_y: 0.1
background_normal: None
GridLayout:
cols: 1
GridLayout:
padding: dp(8)
spacing: dp(16)
rows: 2
cols: 2
size_hint_y: 0.1
Label:
text: 'Automatic setup using DHCP'
UseDHCP:
id: use_dhcp
active: True
on_active: root.on_checkbox_active(self, self.state)
""")
runTouchApp(widget)
@ilovetogetspamed
Copy link
Author

Fixed:

tshirtman: cfo64nc: it's a size issue, the checkbox row seems to small to easily click on
[12:04pm] tshirtman: if i remove the size_hint_y: 0.1, it works
[12:05pm] tshirtman: in such cases, don't use size_hint, set the heights to the value they require
[12:06pm] tshirtman: boxlayout/gridlayout's minimum_size are useful for that
[12:06pm] tshirtman: (you need to set the sizes of their children, for that to work, of course)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment