Why the hitbox of the CheckBox so small? - kivy

Im making a multiple option checkbox with a tittle of what clicking that checkbox does, the problem is that I cant check them and after struggling I found that some checkbox have like 2 or 3 pixels in which they can be clicked.
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
Window.size = (300, 500)
navigation_helper = """
MDScreen:
name: 'user_screen'
MDBoxLayout:
orientation: "vertical"
pos_hint: {"top": 1}
adaptive_height: True
padding: (0, "100dp" , 0, 0)
MDGridLayout:
cols:2
size_hint: (0.9,1)
pos_hint: {"center_x":0.5, "center_y": 0.5}
padding: (0,"200dp",0,0)
spacing: ("-80dp","40dp")
MDLabel:
text: "Ejercicio Semanal"
bold: True
pos_hint: {"left": 1, "top": 1}
size_hint: (None,1)
width: "128dp"
Widget:
BoxLayout:
orientation:"horizontal"
spacing: "-90dp"
MDLabel:
text: "Sedentario"
size_hint: (None,1)
width: "110dp"
MDCheckbox:
id: "sedentary_cb"
group: "exercise_cb"
size: "100dp", "100dp"
BoxLayout:
orientation:"horizontal"
MDLabel:
text: "Bajo(1-3)"
size_hint: (None,1)
width: "70dp"
MDCheckbox:
id: "low_cb"
group: "exercise_cb"
BoxLayout:
orientation:"horizontal"
spacing: "-90dp"
MDLabel:
text: "Moderado (3-5)"
size_hint: (None,1)
width: "110dp"
MDCheckbox:
id: "moderated_cb"
group: "exercise_cb"
BoxLayout:
orientation:"horizontal"
MDLabel:
text: "Alto (6-7)"
size_hint: (None,1)
width: "70dp"
MDCheckbox:
id: "high_cb"
group: "exercise_cb"
BoxLayout:
orientation:"horizontal"
spacing: "-90dp"
MDLabel:
text: "Pro (2 por día)"
size_hint: (None,1)
width: "110dp"
MDCheckbox:
id: "pro_cb"
group: "exercise_cb"
"""
class DemoApp(MDApp):
def build(self):
self.theme_cls.theme_style = ("Dark")
screen = Builder.load_string(navigation_helper)
return screen
DemoApp().run()`
I tried enabling all checkbox, but the found out it is something with the hitbox

Related

AttributeError: ' object has no attribute 'current'

Error: AttributeError: 'NoneType' object has no attribute 'current'.
'sign in' button should transition to 'home' page, but gives an error instead. please help me understand what's wrong here. i have several codes and i get different error every time:
it used to run perfect till i split login and home screens into two separate kv files and change the python code. it seems im doing something wrong.
from kivymd.app import MDApp
from kivy.core.window import Window
from kivy.lang.builder import Builder
from kivymd.uix.screen import MDScreen
from kivymd.uix.screenmanager import MDScreenManager
Window.size = [320, 600]
class ShopApp(MDApp):
def build(self):
self.load_all_kv_files()
return
def load_all_kv_files(self):
sm = MDScreenManager()
sm.add_widget(Builder.load_file('login.kv'))
sm.add_widget(Builder.load_file('home.kv'))
return sm
ShopApp().run()
kv file
MDScreen:
name: 'shop'
md_bg_color: 1, 1, 1, 1
background_normal: ''
MDLabel:
text: 'Welcome'
bold: True
font_size: 30
background_normal: ''
pos_hint: {'center_x': 0.55, 'center_y': 0.9}
theme_text_color: 'Custom'
text_color: [0/255, 0/255, 0/255, 1]
MDFloatLayout:
id: GREEN
pos_hint: {'center_y': 0.35}
size_hint: 1, 0.7
canvas:
Color:
rgba:[0/255, 147/255, 114/255, 1]
RoundedRectangle:
pos: self.pos
size: self.size
radius: [35, 35, 0, 0 ]
MDFloatLayout:
id: WHITE
size_hint: 0.85, 0.7
pos_hint: {'center_x': 0.5, 'center_y': 0.45}
canvas:
Color:
rgb: 1, 1, 1, 1
RoundedRectangle:
size: self.size
pos: self.pos
radius: [25]
MDFloatLayout:
id: USERNAME
size_hint: .85, .14
pos_hint: {'center_x': .5, 'center_y': 0.8}
canvas:
Color:
rgb: [255/255, 147/255, 114/255, 1]
RoundedRectangle:
size: self.size
pos: self.pos
radius: [15]
TextInput:
hint_text: "Username"
size_hint: 1, None
pos_hint: {'center_x': .5, 'center_y': .5}
height: self.minimum_height
multiline: False
cursor_width: '2sp'
cursor_color: 1, 1, 1, 1
foreground_color: [0/255, 147/255, 114/255, 1]
background_color: 0, 0, 0, 0
padding: 15
MDFloatLayout:
id: PASSWORD
size_hint: .85, .14
pos_hint: {'center_x': .5, 'center_y': 0.6}
canvas:
Color:
rgb: [255/255, 147/255, 114/255, 1]
RoundedRectangle:
size: self.size
pos: self.pos
radius: [15]
TextInput:
hint_text: "Password"
password: True
size_hint: 1, None
pos_hint: {'center_x': .5, 'center_y': .5}
height: self.minimum_height
multiline: False
cursor_width: '2sp'
cursor_color: 1, 1, 1, 1
foreground_color: [0/255, 147/255, 114/255, 1]
background_color: 0, 0, 0, 0
padding: 15
MDTextButton:
text: "Forgot password?"
font_size: 15
theme_text_color: 'Custom'
text_color: [0/255, 147/255, 114/255, 1]
pos_hint: {'center_x': 0.35, 'center_y': 0.48}
Button:
text: "Sign In"
font_size: "15sp"
size_hint: .4, .11
pos_hint: {'center_x': 0.5, 'center_y': 0.35}
background_color: 0, 0, 0, 0
on_press: root.manager.current = 'home_screen'
canvas.before:
Color:
rgba: [0/255, 147/255, 114/255, 1]
RoundedRectangle:
pos: self.pos
size: self.size
radius: [13]
Button:
text: "Sign Up"
font_size: "15sp"
halign: 'left'
size_hint: .4, .11
pos_hint: {'center_x': 0.5, 'center_y': 0.2}
background_color: 0, 0, 0, 0
on_press: screen_manager.current = 'sign_up'
canvas.before:
Color:
rgba: [255/255, 147/255, 114/255, 1]
RoundedRectangle:
pos: self.pos
size: self.size
radius: [13]
MDFloatLayout:
id: ORANGE
pos_hint: {'center_x': 0.5, 'center_y': 0.7}
size_hint: 0.9, 0.15
canvas:
Color:
rgba: [255/255, 147/255, 114/255, 1]
RoundedRectangle:
pos: self.pos
size: self.size
radius: [40]
MDLabel:
text: 'Login'
bold: True
font_size: 35
background_normal: ''
pos_hint: {'center_x': 0.85, 'center_y': 0.5}
theme_text_color: 'Custom'
text_color: 1, 1, 1, 1
MDScreen:
name: 'home_screen'
md_bg_color: 1, 1, 1, 1
background_normal: ''
I guess your root widget does not have an object named manager.
on_press: root.manager.current = 'home_screen'
this code refers to root which will return an object reference to your widget - possibly a Screen or some object that inherits Screen.
you need the above code to return a reference to your screen manager. this is probably what your other line here does.
on_press: screen_manager.current = 'sign_up'
you can use app.something to reach a method in your app and you can use root.something to reach a method in your widget class instance.
it will help you to retain a reference to your screen manager object in your app like this:
def load_all_kv_files(self):
# create and retain a reference to my Screen Manager object
self.sm = MDScreenManager()
self.sm.add_widget(Builder.load_file('login.kv'))
self.sm.add_widget(Builder.load_file('home.kv'))
return self.sm
but you also need your build method to return a reference to your top level widget.
def build(self):
_ = self.load_all_kv_files()
return _

pos_hit do not move along the y-axis and i dont seem to know why

So, i've been trying to position a label in my kv file but it only moves along the x-axis with this code:
<HomePage>:
md_bg_color: [34/255, 0/255, 64/255, 1]
background_normal: ''
MDBoxLayout:
orientation: 'vertical'
MDBoxLayout:
padding: '5dp'
adaptive_height: True
MDLabel:
text: 'Shop'
bold: True
font_size: 50
theme_text_color: 'Custom'
background_normal: ''
color: [0/255, 186/255, 198/255, 1]
pos_hint: {'x':.13, 'y':.18}
MDTextField:
mode: 'round'
text: 'username'
i dont understand how this is posible.

Can't alter size of BoxLayouts in ScrollView Kivy

I'm having trouble spacing my BoxLayouts out on the below screen. I have to put size_hint_y: None for each of the BoxLayouts otherwise everything overlaps each other. However, I can't work out how to change the size so I have just set them all to None or 1. The image is also overlapping the MDTextField first name.
I'm not sure what I'm doing wrong
import kivy
from kivymd.app import MDApp
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivymd.uix.selectioncontrol import MDCheckbox
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivymd.uix.label import MDLabel
from kivymd.uix.button import MDRaisedButton
from kivy.core.window import Window
Window.size = (381, 470)
Window.clearcolor = (1,1,1,1)
class UserDetails(Screen):
pass
class WindowManager(ScreenManager):
pass
class MyApp(MDApp):
def build(self):
kv = Builder.load_file("kivy.kv")
self.sm = WindowManager()
screens = [UserDetails(name="user_details")]
for screen in screens:
self.sm.add_widget(screen)
self.sm.current = "user_details"
return self.sm
<UserDetails>
name: "user_details"
GridLayout:
cols: 1
ScrollView:
id: grid
BoxLayout:
orientation: 'vertical'
id: layout
padding: 15
spacing: 15
size_hint: 1, None
height: self.minimum_height
BoxLayout:
size_hint_y: None
orientation: "vertical"
MDLabel:
size_hint_y: 1
halign: "center"
text: "PERSONAL DETAILS"
canvas.before:
Color:
rgba: 1,0,0,1
Rectangle:
size: self.size
pos: self.pos
BoxLayout:
size_hint_y: None
AsyncImage:
source: "image.png"
BoxLayout:
size_hint_y: 1
BoxLayout:
size_hint_y: None
cols: 1
orientation: "vertical"
padding: 15
MDTextField:
id: first_name
hint_text: "First Name"
MDTextField:
id: last_name
hint_text: "Last Name"
MDTextField:
id: date_of_birth
hint_text: "Date of Birth"
BoxLayout:
size_hint_y: None
MDCheckbox:
group: "gender"
id: male
MDCheckbox:
group: "gender"
id: female
MDCheckbox:
group: "gender"
id: unknown
BoxLayout:
size_hint_y: None
cols: 1
Label:
MDRaisedButton:
pos_hint: {"top": 0.8}
md_bg_color: 1,0,0,1
text: "Submit"
Label:
When you use size_hint_y: None and height: self.minimum_height for a BoxLayout, then the height of the BoxLayout is calculated by summing the heights of the children. A child with size_hint_y: None and no value set for height will get counted as 0 toward the minimum height of the BoxLayout. So you need to set heights for all the children.
Also, you have several case where you have a Layout with just one child. You can normally replace that arrangement with just the child.
Here is how I would modify your kv:
<UserDetails>
name: "user_details"
ScrollView:
id: grid
BoxLayout:
orientation: 'vertical'
id: layout
padding: 15
spacing: 15
size_hint: 1, None
height: self.minimum_height
MDLabel:
size_hint_y: None
height: self.texture_size[1]
halign: "center"
text: "PERSONAL DETAILS"
canvas.before:
Color:
rgba: 1,0,0,1
Rectangle:
size: self.size
pos: self.pos
AsyncImage:
size_hint_y: None
height: 100
source: "image.png"
BoxLayout:
size_hint_y: None
height: self.minimum_height
cols: 1
orientation: "vertical"
padding: 15
MDTextField:
id: first_name
hint_text: "First Name"
size_hint_y: None
height: 50
MDTextField:
id: last_name
hint_text: "Last Name"
size_hint_y: None
height: 50
MDTextField:
id: date_of_birth
hint_text: "Date of Birth"
size_hint_y: None
height: 50
BoxLayout:
size_hint_y: None
height: 40
MDCheckbox:
group: "gender"
id: male
MDCheckbox:
group: "gender"
id: female
MDCheckbox:
group: "gender"
id: unknown
MDRaisedButton:
size_hint_y: None
height: 40
pos_hint: {'center_x':0.5}
md_bg_color: 1,0,0,1
text: "Submit"

highcharts how to divide axis into 2

I have 2 axis both on the same side, they are both taking up the entire axis and so the labels are overlapping and the graphs are crossing. What I'd like is to allocate 2/3 of the the space on top for the first series and 1/3 for the 2nd, so graphically looks like
|-
|
|
|
|
|-
|
|
|-
The values could be anything for either series, point is they only have a certain amount of the graph to work with. Any way to achieve this?
yAxis: [
{
offset: -6,
title: {
text: 'two',
align: 'high',
rotation: 0,
offset: 8,
y: -6,
x: 20,
style: {
fontSize: '7px'
}
},
plotLines: [{
value: 0,
color: 'orange',
width: 1,
zIndex: 5,
dashStyle: 'Solid'
}],
opposite: true,
//minorGridLineColor: 'green',
gridLineColor: 'black'
},
{
offset: -6,
title: {
text: 'one',
align: 'high',
rotation: 0,
offset: 8,
y: -6,
x: 20,
style: {
fontSize: '7px'
}
},
plotLines: [ {
value: 0,
color: 'orange',
width: 1,
zIndex: 5,
dashStyle: 'Solid'
}],
opposite: true,
gridLineColor: 'black'
}

how can I make highstock flags stay put

In jsfiddle I'd like the little green circles to stay put when hovered over.
In HighStock, when hovering over flags, how can I make them stay put (without trying to come to foreground)?
//
Generally you cannot use points with the same x value inside single serie. You need to use separated series like here: http://jsfiddle.net/5pXfM/5/
{
type: 'flags',
data: [{
x: Date.UTC(2011, 2, 10),
title: ' ',
text: 'Do not move'
}],
onSeries: 'dataseries',
shape: 'circlepin',
color: '#5F86B3',
fillColor: 'rgba(50, 255, 50, .75)',
y: -10,
stackDistance: 5
},{
type: 'flags',
data: [{
x: Date.UTC(2011, 2, 10),
title: ' ',
text: 'Do not move'
}],
onSeries: 'dataseries',
shape: 'circlepin',
color: '#5F86B3',
fillColor: 'rgba(50, 255, 50, .75)',
y: -30,
stackDistance: 5
}

Resources