Kivy ScrollView does not fill the entire window - python

I am trying to write a Kivy file that includes a scrollview below the MDToolBar and above MDBottomNavigation. I cannot get the ScrollView content to fill the entire screen below the ToolBar and above the BottomNav. It only fills have the window vertical span. If I eliminate the toolbar and bottom nave the scrollview fills the entire vertical span without a problem. Any tips on getting the scrollview contents to fill the completely would be appreciated. I tried changing indentation and that did not work. Thanks in advance.
Screenshot
# WINDOW MANAGER
WindowManager:
MainWindow:
AboutWindow:
<MainWindow>:
name: "main"
BoxLayout:
orientation: "vertical"
MDToolbar:
title: "Solar Weather"
MDLabel:
id: sub_title
text: "SUB TITLE"
halign: "center"
size_hint: (1,0.2)
ScrollView:
size: self.size
GridLayout:
size_hint_y: None
height: self.minimum_height
width: self.minimum_width
cols: 2
spacing: "20dp"
padding: "20dp"
# SOLAR FLUX BOX #
MDCard:
orientation: "vertical"
padding: "8dp"
size_hint: 1, None
height: "210dp"
elevation: 5
MDLabel:
id: flux
text: "Solar Wind"
halign: "center"
MDLabel:
id: flux_value_id
text: ""
halign: "center"
MDLabel:
id: flux_time_id
text: ""
halign: "center"
MDRaisedButton:
text: "Refresh"
pos_hint: {"x":0}
size_hint: 1,1
md_bg_color: app.theme_cls.primary_color
on_release: root.calc_solar_flux()
MDRaisedButton:
text: "Details"
pos_hint: {"x":0}
size_hint: 1,1
md_bg_color: app.theme_cls.primary_color
on_release: root.calc_solar_flux()
MDCard:
orientation: "vertical"
padding: "8dp"
size_hint: 1, None
height: "210dp"
elevation: 5
MDCard:
orientation: "vertical"
padding: "8dp"
size_hint: 1, None
height: "210dp"
elevation: 5
MDCard:
orientation: "vertical"
padding: "8dp"
size_hint: 1, None
height: "210dp"
elevation: 5
MDLabel:
text: "Solar Wind"
halign: "center"
MDRaisedButton:
text: "Go Back"
md_bg_color: app.theme_cls.primary_color
on_release:
root.manager.current = "main"
root.manager.transition.direction = "right"
MDBottomNavigation:
MDBottomNavigationItem:
name: 'Dark'
text: "Dark Theme"
icon: 'brightness-2'
on_tab_release: root.dark_theme()
MDBottomNavigationItem:
name: 'Light'
text: "Light Theme"
icon: 'brightness-5'
on_tab_release: root.light_theme()
MDBottomNavigationItem:
name: 'info'
text: "About"
icon: 'information'
on_tab_release:
root.manager.current = "about"
root.manager.transition.direction = "left"
MDBottomNavigationItem:
name: 'option 2'
text: "Relaod"
icon: 'reload'
#: include about.kv

I hope this helps someone else. I had to rewrite the kv file fairly extensively but it works.
# WINDOW MANAGER
WindowManager:
MainWindow:
AboutWindow:
<MainWindow>:
name: "main"
BoxLayout:
orientation: "vertical"
MDLabel:
id: title
text: "SOLAR WEATHER"
halign: "left"
size_hint: (1,0.1)
padding_x: 20
pos_hint: {"x":0.0,"y":0.9}
md_bg_color: app.theme_cls.primary_dark
MDLabel:
id: sub_title
text: "SUB TITLE"
halign: "center"
size_hint: (1,0.1)
pos_hint: {"x":0.0,"y":0.8}
ScrollView:
size: self.size
pos_hint: {"x":0,"y":0.1}
GridLayout:
size_hint_y: None
height: self.minimum_height
width: self.minimum_width
cols: 2
spacing: "20dp"
padding: "20dp"
# SOLAR FLUX BOX #
MDCard:
orientation: "vertical"
padding: "8dp"
spacing: "8dp"
size_hint: 1, None
height: "210dp"
elevation: 5
MDLabel:
id: flux
text: "SOLAR FLUX"
halign: "center"
MDLabel:
id: flux_value_id
markup: True
text: ""
halign: "center"
MDLabel:
id: flux_time_id
text: ""
halign: "center"
MDRaisedButton:
text: "Refresh"
pos_hint: {"x":0}
size_hint: 1,1
md_bg_color: app.theme_cls.primary_color
on_release: root.calc_solar_flux()
MDRaisedButton:
text: "Details"
pos_hint: {"x":0}
size_hint: 1,1
md_bg_color: app.theme_cls.primary_color
on_release: root.calc_solar_flux()
# SUN SPOT NUMBER BOX #
MDCard:
orientation: "vertical"
padding: "8dp"
spacing: "8dp"
size_hint: 1, None
height: "210dp"
elevation: 5
MDLabel:
id: ssn
text: "SUN SPOT NUMBER"
halign: "center"
MDLabel:
id: ssn_value_id
markup: True
text: ""
halign: "center"
MDLabel:
id: ssn_date_id
text: ""
halign: "center"
MDRaisedButton:
text: "Refresh"
pos_hint: {"x":0}
size_hint: 1,1
md_bg_color: app.theme_cls.primary_color
on_release: root.calc_sunspot_number()
MDRaisedButton:
text: "Details"
pos_hint: {"x":0}
size_hint: 1,1
md_bg_color: app.theme_cls.primary_color
on_release: root.calc_sunspot_number()
MDCard:
orientation: "vertical"
padding: "8dp"
size_hint: 1, None
height: "210dp"
elevation: 5
MDCard:
orientation: "vertical"
padding: "8dp"
spacing: "8dp"
size_hint: 1, None
height: "210dp"
elevation: 5
MDLabel:
text: "Solar Wind"
halign: "center"
MDRaisedButton:
text: "Go Back"
md_bg_color: app.theme_cls.primary_color
on_release:
root.manager.current = "main"
root.manager.transition.direction = "right"
GridLayout:
size_hint_y: None
height: self.minimum_height
width: self.minimum_width
cols: 3
spacing: "80dp"
padding: "20dp"
MDIconButton:
name: "Dark"
text: "Dark Theme"
icon: "brightness-2"
on_release: root.dark_theme()
md_bg_color: app.theme_cls.primary_dark
MDIconButton:
id: light_theme_icon
name: "Light"
text: "Light Theme"
icon: "brightness-5"
on_release: root.light_theme()
md_bg_color: app.theme_cls.primary_dark
MDIconButton:
name: "info"
text: "About"
icon: "information"
on_release:
root.manager.current = "about"
md_bg_color: app.theme_cls.primary_dark
#: include about.kv

Related

From a Popup I need to enter to an external function from my kv kivy

Good day everyone! I created a function and this is located on my screen "Contact" called "resetcampos" in my main.py, then I created a Popup in my kv.file. I need to access my function "resetcampos" from my Button that I have in the Popup. what should I write where it's written "on_press: -----" for accesing to my function "resetcampos" that is in my main.py?
py.main
from tokenize import Number
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.core.spelling import Spelling
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.config import Config
from kivy.properties import StringProperty, NumericProperty
from kivy.uix.recycleview import RecycleView
from kivy.uix.recycleboxlayout import RecycleBoxLayout
from kivy.uix.scrollview import ScrollView
import smtplib
Config.set('graphics', 'width', 360)
Config.set('graphics', 'height', 640)
kv= Builder.load_file('test6.kv')
class MyLayout(Widget):
pass
def spinner_clicked(self,value):
pass
#sm= ScreenManager()
#screen= Screen(name='second')
#self.ids.Label1.text= f'You selected: {value}'
#Define a RecycleView
class RV (Screen):
pass
#Definine our different screens
class FirstWindow(Screen):
#Variables Shopping Cart
var1= StringProperty("images/shoppingcart.png")
var2= StringProperty("images/shoppingcart2.png")
#Functions Items
def list_tornillo(self):
tornillo= self.ids.input_tornillo.text
#tornillo1= str(float(tornillo) * 0.1) if tornillo else "0.0"
tornillo1= str(round(float(tornillo) * 0.1,2)) if tornillo else "0.0"
tornillo2= tornillo1 + "0"
self.ids.label_tornillo.text= tornillo2
def list_andamio(self):
andamio= self.ids.input_andamio.text
andamiod= andamio.isdigit()
if andamiod == True:
andamio1= str(round(float(andamio) * 180,2)) if andamio else "0.0"
andamio2= andamio1 + "0"
self.ids.label_andamio.text= andamio2
else:
self.ids.input_andamio.text= "0"
def list_vigueta(self):
vigueta= self.ids.input_vigueta.text
vigueta1= str(round(float(vigueta) * 200,2)) if vigueta else "0.0"
vigueta2= vigueta1 + "0"
self.ids.label_vigueta.text= vigueta2
def list_perno(self):
perno= self.ids.input_perno.text
perno1= str(round(float(perno) * 0.20,2)) if perno else "0.0"
perno2= perno1 + "0"
self.ids.label_perno.text= perno2
def list_tuerca(self):
tuerca= self.ids.input_tuerca.text
tuerca1= str(round(float(tuerca) * 0.35,2)) if tuerca else "0.0"
tuerca2= tuerca1 + "0"
self.ids.label_tuerca.text= tuerca2
#self.ids.input_tornillo.text= self.ids.label_tornillo.text
def press_on(self):
self.ids.input_tornillo.text= self.ids.label_tornillo.text
#self.ids.my_label.text= "You Pressed the Button"
#self.ids.Shoppingcart1.source= self.var2
def press_off(self):
self.ids.Shoppingcart1.source= self.var1
class SecondWindow(Screen):
pass
class ThirdWindow(Screen):
pass
class FourthWindow(Screen):
def message(self):
pass
def resetcampos (self):
#self.window_manager.get_screen("Contact").ids.nombre.text = "" - Enter another class
self.ids.nombre.text = ""
self.ids.telefono.text = ""
self.ids.correo.text = ""
self.ids.asunto.text = ""
self.ids.mensaje.text = ""
class WindowManager(ScreenManager):
pass
class AwesomeApp(App):
def build(self):
return MyLayout()
if __name__ == '__main__':
AwesomeApp().run()
Kv.Main
<MyLayout>
BoxLayout:
orientation:"vertical"
size: root.width, root.height
GridLayout:
cols:3
rows:3
size_hint: 1,None
height: 65
Spinner:
id: spinner_id
text: "Menu"
values: ["Catalogue","Buy","Payment Methods", "Contact"]
on_text: root.spinner_clicked(spinner_id.text)
on_text: window_manager.current = self.text # uses an id defined in the WindowManager section
#on_text: root.manager.current= "second" - Just work in Screens
Image:
source: 'images/ferrepluslogo2.png'
Button:
text:"Buy"
WindowManager:
id: window_manager
FirstWindow:
SecondWindow:
ThirdWindow:
FourthWindow:
<FirstWindow>:
name: "Catalogue"
BoxLayout:
orientation:'vertical'
pos_hint: {'top': 1}
size: root.width, root.height
size_hint_y: .55
GridLayout:
size:(root.width, root.height)
size_hint_x: None
size_hint_y: None
cols:4
height: self.minimum_height
Label:
text: "Items"
#font_size: 25
Label:
text: "Number"
Label:
text: "Price"
Label:
text: "Add to Cart"
ScrollView:
size_hint_y: .80
pos_hint: {'x':0, 'y': .11}
do_scroll_x: True
do_scroll_y: True
GridLayout:
size:root.width, root.height
size_hint_x: None
size_hint_y: None
cols:4
#height: self.minimum_height
#Label:
# text: "Items"
#font_size: 25
#Label:
# text: "Number"
#Label:
# text: "Price"
#Label:
# text: "Add to Cart"
Label:
text: "Tornillos"
text_size: self.size
halign: 'center'
valign: 'bottom'
Image:
id: image_tornillos
allow_stretch: True
keep_ratio: True
size_hint: 0.2,0.2
width: 60
height: 80
#pos_hint: {'center_x':1, 'center_y':1}
source: "images/tornillo.png"
center_x: self.parent.center_x
center_y: self.parent.center_y+10
TextInput:
id: input_tornillo
text: ""
halign: "right"
font_size: 18
multiline: True
on_text: root.list_tornillo()
#size_hint: (1, .15)
Label:
id: label_tornillo
text: "0.0"
#text: root.ids.input_tornillo.text*2
Button:
id: shopping1
#text: "Hello"
#font_size: 32
allow_stretch: True
keep_ratio: True
size_hint: .25,.30
pos_hint: {'center_x':0.5, 'center_y':0.5}
background_color: 0,0,0,0
#on_press: root.press_on()
#on_release: root.press_off()
on_press: root.ids.Shoppingcart1.source= root.var2
on_release: root.ids.Shoppingcart1.source= root.var1
Image:
id: Shoppingcart1
allow_stretch: True
keep_ratio: True
size_hint: 0.5,0.5
width: 60
height: 60
pos_hint: {'center_x':0.5, 'center_y':0.5}
source: root.var1
center_x: self.parent.center_x
center_y: self.parent.center_y
#------------------------
Label:
text: "Andamios"
text_size: self.size
halign: 'center'
valign: 'bottom'
Image:
id: image_andamios
allow_stretch: True
keep_ratio: True
size_hint: 0.2,0.2
width: 60
height: 80
#pos_hint: {'center_x':1, 'center_y':1}
source: "images/Andamios.png"
center_x: self.parent.center_x
center_y: self.parent.center_y
TextInput:
id: input_andamio
text: ""
halign: "right"
font_size: 18
#size_hint: (1, .15)
on_text: root.list_andamio()
Label:
id: label_andamio
text: "0.0"
Button:
id: shopping2
#text: "Hello"
#font_size: 32
allow_stretch: True
keep_ratio: True
size_hint: .25,.30
pos_hint: {'center_x':0.5, 'center_y':0.5}
background_color: 0,0,0,0
#on_press: root.press_on()
#on_release: root.press_off()
on_press: root.ids.Shoppingcart2.source= root.var2
on_release: root.ids.Shoppingcart2.source= root.var1
Image:
id: Shoppingcart2
allow_stretch: True
keep_ratio: True
size_hint: 0.5,0.5
width: 60
height: 60
pos_hint: {'center_x':0.5, 'center_y':0.5}
source: "images/shoppingcart.png"
center_x: self.parent.center_x
center_y: self.parent.center_y
#-----------------------------------------------------------
#Image:
# id: image_viguetas
# allow_stretch: True
# keep_ratio: True
# size_hint: 0.2,0.2
# width: 40
# height: 60
# #pos_hint: {'center_x':1, 'center_y':1}
# source: "images/viguetas.jpg"
# center_x: self.parent.center_x
# center_y: self.parent.center_y
Label:
text: "Viguetas"
text_size: self.size
halign: 'center'
valign: 'bottom'
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: "images/viguetas.jpg"
TextInput:
id: input_vigueta
text: ""
halign: "right"
font_size: 18
#size_hint: (1, .15)
on_text: root.list_vigueta()
Label:
id: label_vigueta
text: "0.0"
Button:
id: shopping3
#text: "Hello"
#font_size: 32
allow_stretch: True
keep_ratio: True
size_hint: .25,.30
pos_hint: {'center_x':0.5, 'center_y':0.5}
background_color: 0,0,0,0
#on_press: root.press_on()
#on_release: root.press_off()
on_press: root.ids.Shoppingcart3.source= root.var2
on_release: root.ids.Shoppingcart3.source= root.var1
Image:
id: Shoppingcart3
allow_stretch: True
keep_ratio: True
size_hint: 0.5,0.5
width: 60
height: 60
pos_hint: {'center_x':0.5, 'center_y':0.5}
source: "images/shoppingcart.png"
center_x: self.parent.center_x
center_y: self.parent.center_y
#------------------------------------------------------------
#Image:
# id: image_pernos
# allow_stretch: True
# keep_ratio: True
# size_hint: 0.2,0.2
# width: 40
# height: 60
# #pos_hint: {'center_x':1, 'center_y':1}
# source: "images/pernos.png"
# center_x: self.parent.center_x
# center_y: self.parent.center_y
Label:
text: "Pernos"
text_size: self.size
halign: 'center'
valign: 'bottom'
canvas.before:
Rectangle:
pos: self.center_x-39, self.center_y-21
#pos: self.pos
size: 77,50
source: "images/pernos.png"
TextInput:
id: input_perno
text: ""
halign: "right"
font_size: 18
#size_hint: (1, .15)
on_text: root.list_perno()
Label:
text: "0.0"
id: label_perno
Button:
id: shopping4
#text: "Hello"
#font_size: 32
allow_stretch: True
keep_ratio: True
size_hint: .25,.30
pos_hint: {'center_x':0.5, 'center_y':0.5}
background_color: 0,0,0,0
#on_press: root.press_on()
#on_release: root.press_off()
on_press: root.ids.Shoppingcart4.source= root.var2
on_release: root.ids.Shoppingcart4.source= root.var1
Image:
id: Shoppingcart4
allow_stretch: True
keep_ratio: True
size_hint: 0.5,0.5
width: 60
height: 60
pos_hint: {'center_x':0.5, 'center_y':0.5}
source: "images/shoppingcart.png"
center_x: self.parent.center_x
center_y: self.parent.center_y
#------------------------------------------------------------
Label:
text: "Tuercas"
text_size: self.size
halign: 'center'
valign: 'bottom'
canvas.before:
Rectangle:
pos: self.center_x-39, self.center_y-21
#pos: self.pos
size: 77,50
source: "images/tuercas.png"
TextInput:
id: input_tuerca
text: ""
halign: "right"
font_size: 18
#size_hint: (1, .15)
on_text: root.list_tuerca()
Label:
id: label_tuerca
text: "0.0"
Button:
id: shopping5
#text: "Hello"
#font_size: 32
allow_stretch: True
keep_ratio: True
size_hint: .25,.30
pos_hint: {'center_x':0.5, 'center_y':0.5}
background_color: 0,0,0,0
#on_press: root.press_on()
#on_release: root.press_off()
on_press: root.ids.Shoppingcart5.source= root.var2
on_release: root.ids.Shoppingcart5.source= root.var1
Image:
id: Shoppingcart5
allow_stretch: True
keep_ratio: True
size_hint: 0.5,0.5
width: 60
height: 60
pos_hint: {'center_x':0.5, 'center_y':0.5}
source: "images/shoppingcart.png"
center_x: self.parent.center_x
center_y: self.parent.center_y
#----------------------------------------------
Label:
text: "Tejas"
text_size: self.size
halign: 'center'
valign: 'bottom'
canvas.before:
Rectangle:
pos: self.center_x-39, self.center_y-21
#pos: self.pos
size: 77,50
source: "images/Teja.png"
TextInput:
id: input_teja
text: ""
halign: "right"
font_size: 18
#size_hint: (1, .15)
Label:
text: "0.0"
Button:
id: shopping6
#text: "Hello"
#font_size: 32
allow_stretch: True
keep_ratio: True
size_hint: .25,.30
pos_hint: {'center_x':0.5, 'center_y':0.5}
background_color: 0,0,0,0
#on_press: root.press_on()
#on_release: root.press_off()
on_press: root.ids.Shoppingcart6.source= root.var2
on_release: root.ids.Shoppingcart6.source= root.var1
Image:
id: Shoppingcart6
allow_stretch: True
keep_ratio: True
size_hint: 0.5,0.5
width: 60
height: 60
pos_hint: {'center_x':0.5, 'center_y':0.5}
source: "images/shoppingcart.png"
center_x: self.parent.center_x
center_y: self.parent.center_y
#----------------------------------------------
Label:
text: "Tableros"
text_size: self.size
halign: 'center'
valign: 'bottom'
canvas.before:
Rectangle:
pos: self.center_x-39, self.center_y-21
#pos: self.pos
size: 77,50
source: "images/tableros.png"
TextInput:
id: input_tablero
text: ""
halign: "right"
font_size: 18
#size_hint: (1, .15)
Label:
text: "0.0"
Button:
id: shopping7
#text: "Hello"
#font_size: 32
allow_stretch: True
keep_ratio: True
size_hint: .25,.30
pos_hint: {'center_x':0.5, 'center_y':0.5}
background_color: 0,0,0,0
#on_press: root.press_on()
#on_release: root.press_off()
on_press: root.ids.Shoppingcart7.source= root.var2
on_release: root.ids.Shoppingcart7.source= root.var1
Image:
id: Shoppingcart7
allow_stretch: True
keep_ratio: True
size_hint: 0.5,0.5
width: 60
height: 60
pos_hint: {'center_x':0.5, 'center_y':0.5}
source: "images/shoppingcart.png"
center_x: self.parent.center_x
center_y: self.parent.center_y
#-------------------------------------------
Button:
text:""
background_color: 0,0,0,0
Button:
text:""
background_color: 0,0,0,0
Button:
text:""
background_color: 0,0,0,0
Button:
text:""
background_color: 0,0,0,0
#------------------------------------------------------------
<RV>:
ScrollView:
size_hint_y: .73
pos_hint: {'x':0, 'y': .11}
do_scroll_x: True
do_scroll_y: True
GridLayout:
size:(root.width, root.height)
size_hint_x: None
size_hint_y: None
cols:2
height: self.minimum_height
Button:
text:"las"
Button:
text:"cosas"
Button:
text:"de la vida"
Button:
text:"las"
Button:
text:"cosas"
Button:
text:"de la vida"
<SecondWindow>:
name: "Buy"
BoxLayout:
orientation: "vertical"
size: root.width, root.height
Label:
text: "Buy Screen"
font_size: 32
<ThirdWindow>:
name: "Payment Methods"
BoxLayout:
orientation: "vertical"
size: root.width, root.height
Label:
text: "Payment Methods Screen"
font_size: 32
<FourthWindow>:
name: "Contact"
BoxLayout:
orientation: "vertical"
#pos_hint: {'top': 1}
#size: root.width, root.height
#size_hint_y: .55
Label:
id:Escribir
text:" Escríbenos:"
pos_hint: {'top': 1}
size: root.width, root.height
size_hint_y: .55
font_size: 20
bold: True
#----
#text_size: self.size
#valign: 'center'
#halign: 'left'
GridLayout:
#padding: 15
cols:2
#size_hint: None,None
#height: 65
#size_hint: .7,1
BoxLayout:
size_hint: 0.5,1
orientation:"vertical"
Label:
text:"Nombre:"
Label:
text:"Telefono:"
Label:
text:"Email:"
Label:
text:"Asunto:"
BoxLayout:
padding: [0,0,10,0] #left, top, right, bottom
orientation:"vertical"
TextInput:
text: ""
id: nombre
TextInput:
text: ""
id: telefono
TextInput:
text: ""
id:correo
TextInput:
text: ""
id: asunto
GridLayout:
cols:2
#size_hint: .7,1
Label:
text:"Mensaje:"
size_hint: .5,1
BoxLayout:
orientation:"vertical"
padding: [0,0,10,0]
TextInput:
id:mensaje
BoxLayout:
orientation:"vertical"
Label:
text: ""
pos_hint: {'top': 1}
size: root.width, root.height
size_hint_y: .55
GridLayout:
cols:3
Label:
text: ""
Button:
text:"Enviar Mensaje"
on_press: root.message()
on_press: Factory.MyPopup().open()
Label:
text: ""
Label:
text:""
Label:
text: " Contacto:"
font_size: 20
bold: True
#pos_hint: {'top': 1}
#size: root.width, root.height
#size_hint_y: .55
GridLayout:
cols: 2
BoxLayout:
orientation:"vertical"
#size_hint: .3,1
Label:
text:" Telefono:"
size_hint: .2,1
Label:
text:"Email:"
BoxLayout:
orientation:"vertical"
padding: [0,0,90,0]
Label:
text:"198797978"
Label:
text:"washington#hotmail.com"
Label:
text: ""
Label:
text: ""
#:import Factory kivy.factory.Factory
<MyPopup#Popup>
auto_dismiss: False
size_hint: 0.8,0.2
pos_hint: {"x": 0.1, "top":0.9}
title: "Atención"
BoxLayout:
orientation:"vertical"
size: root.width, root.height
Label:
text: "Su mensaje fue enviado exitosamente"
font_size: 15
Button:
text:"Cerrar"
font_size: 15
on_release: root.dismiss()
on_press: main.FourthWindow.resetcampos()
#on_press: window_manager.resetcampos()

How to align the top row properly, I tried a few different things not working... image given below

.KV code part
MDGridLayout:
cols: 4
adaptive_height: True
#md_bg_color: app.theme_cls.primary_color
MDIcon:
halign: "center"
icon: 'magnify'
pos_hint: {"x": .00}
size_hint:
MDTextField:
id: symbol_field
hint_text: " Search by STOCK KEY"
pos_hint: {"x": .05}
on_text_validate: root.Pressed()
required: True
helper_text_mode: "on_error"
helper_text: ""
MDIconButton:
halign: "center"
icon: "arrow-right-thick"
pos_hint: {"x": .90}
on_press: root.Pressed()
MDIconButton: #new
halign: 'center'
icon: 'cog'
pos_hint: {'x': .95}
on_press: root.settings()
The weird alignment not able to change it The top bar
It should be like:
'label' [0-0.05] 'text-field' [0.05-0.90] 'button' [0.90-0.95] 'button' [0.95-1]
You can try this one, it is not using MDGridLayout (the nature of the Grid, alingment is really hard to do), in this example I am using FloatLayouts plus BoxLayouts plus canvas:
Screen:
canvas:
Color:
rgba: [0,0,0,.1]
Rectangle:
pos: self.pos
size: self.size
#START
FloatLayout:
BoxLayout:
pos_hint: {"center_x": .5, "center_y": 1.4}
padding: dp(15)
#Control the background here jbsidis
canvas.after:
Color:
rgba: [1,1,1,1]
RoundedRectangle:
pos: self.pos[0],self.pos[1] #-dp(15)
size: self.size[0],dp(80)
radius: [dp(8),dp(8),dp(8),dp(8)]
#source: "jbsidis_background.png"
BoxLayout:
pos_hint: {"center_x": .4, "center_y": 1.0}
size_hint: .8,None
spacing: dp(3)
MDIconButton:
pos_hint: {"center_x": .1, "center_y": .25}
halign: "center"
icon: 'magnify'
FloatLayout:
BoxLayout:
pos_hint: {"center_x": .7, "center_y": .5}
MDTextField:
id: symbol_field
hint_text: " Search by STOCK KEY"
#on_text_validate: root.Pressed()
required: True
helper_text_mode: "on_error"
helper_text: ""
MDIconButton:
halign: "center"
icon: "arrow-right-thick"
#on_press: root.Pressed()
MDIconButton:
halign: 'center'
icon: 'pencil'
#on_press: root.settings()
Here is the image (the one in the left side):

PYTHON + KIVYMD / KIVY | Scrollview is only on half the screen but works as normal when used in a navigation drawer

Here is a picture of the problem. As you can see the left side picture has a fully working scrollview, the rightside picture on the other hand is only displaying the scrollview on the bottom half of the screen.
Not sure whats wrong here. Ive tried moving the intendent levels back and forth, for some reason it refuses to put anything above the equator
Snippit of the KV code from the not working part:
Screen:
container: container
BoxLayout:
id: container
orientation: 'vertical'
MDToolbar:
title: "TRYM"
anchor_title: "center"
# right_action_items: [["check", lambda x: app.show_alert_dialog_save(), 'Save']]
left_action_items: [["keyboard-backspace", lambda x: app.show_alert_dialog_back(), 'Back']]
Widget:
ScreenManager:
id: screen_manager
Screen:
name: 'innlogget_trym_alarm'
id: trym
MDBottomNavigation:
MDBottomNavigationItem:
name: 'alarm_trym'
text: 'Alarm'
icon: 'alarm'
on_tab_release: text: 'Alarm'
MDLabel:
text: 'Currently no alarm active'
pos_hint: {"center_x": .5, "center_y": .8}
halign: 'center'
MDFloatingActionButton:
id: trym_time_picker
name: 'trym'
icon: "alarm-plus"
opposite_colors: False
elevation_normal: 8
pos_hint: {"center_x": .9, "center_y": .2}
on_release:
app.show_time_picker('trym')
MDBottomNavigationItem:
name: 'instillinger_trym'
text: 'Instillinger'
icon: 'tools'
# on_tab_release: screen_manager.current = "settings_list_view"
MDLabel:
ScrollView:
MDList:
OneLineIconListItem:
text: "Oppgrader til premium"
on_release:
print("Click!")
IconLeftWidget:
icon: "lock-outline"
TwoLineIconListItem:
text: "Tilkoblingsinnstillinger"
secondary_text: "Endre IP og port for klientsiden"
on_release:
app.show_confirmation_dialog()
IconLeftWidget:
icon: "lan-connect"
TwoLineIconListItem:
text: "Alarminstillinger"
secondary_text: "Konfigurer forsinket eller for tidlig handling"
on_release:
print("Click!")
IconLeftWidget:
icon: "account-clock"
Snippit of the KV code from the working part:
MDNavigationDrawer:
id: nav_draw
orientation: "vertical"
padding: "8dp"
spacing: "8dp"
AnchorLayout:
anchor_x: "center"
size_hint_y: None
height: avatar.height
Image:
id: avatar
size_hint: None, None
size: "56dp", "56dp"
source: "untitled.jpg"
MDLabel:
halign: 'center'
anchor_x: "right"
text: "AnySched"
font_style: "Button"
size_hint_y: None
height: self.texture_size[1]
MDLabel:
text: ""
font_style: "Caption"
size_hint_y: None
height: self.texture_size[1]
ScrollView:
MDList:
OneLineAvatarListItem:
on_press:
nav_draw.set_state("close")
app.next_screen('trym')
text: "Trym"
IconLeftWidget:
icon: "account-box"
OneLineAvatarListItem:
on_press:
nav_draw.set_state("close")
screen_manager.current = "lucas"
So I found the problem (posting incase anyone else gets the same issue).
Screen:
container: container
BoxLayout:
id: container
orientation: 'vertical'
MDToolbar:
title: "TRYM"
anchor_title: "center"
# right_action_items: [["check", lambda x: app.show_alert_dialog_save(), 'Save']]
left_action_items: [["keyboard-backspace", lambda x: app.show_alert_dialog_back(), 'Back']]
Widget: # <----- After removing this the ScrollView fills the whole screen not just half :)
ScreenManager:
id: screen_manager
Screen:
name: 'innlogget_trym_alarm'
id: trym
MDBottomNavigation:

KivyMD Remove a Expansion Panel

I'm having trouble finding the solution in how to remove an expansion panel which inside of it it contains TwoLineAvatarListItem with a IconLeftWidget, and below that is a MDCard with two MDlabels for text. I've tried to use self.root.ids.remove_widget() but it does not do anything. I've tried many ways and have not found the solution. Here is the code please feel free to view. Thanks
kv. file
<Content>:
adaptive_height: True
#size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
TwoLineAvatarListItem:
text: "Message"
secondary_text: 'to: #gmail.com'
IconLeftWidget:
icon: 'email'
MDCard:
orientation: "vertical"
padding: "8dp"
size_hint: None, None
size: "280dp", "180dp"
pos_hint: {"center_x": .5, "center_y": .5}
MDLabel:
text: "Title"
theme_text_color: "Secondary"
size_hint_y: None
height: self.texture_size[1]
MDSeparator:
height: "1dp"
MDLabel:
text: "Body"
ScreenManager:
Screen:
id: messages
name: 'messages'
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: "Messages Center"
elevation:8
MDIconButton:
icon: 'arrow-left'
on_press: screen_manager.current = "main_app_screen"
theme_text_color: 'Custom'
md_bg_color: app.theme_cls.primary_color
ScrollView:
GridLayout:
cols: 1
size_hint_y: None
height: self.minimum_height
id: box
.py python file
class DemoApp(MDApp):
def on_start(self):
for i in range(10):
panel = MDExpansionPanel(
icon=f"{images_path}folder.png",
content=Content(),
panel_cls=MDExpansionPanelTwoLine(
text='',
secondary_text=str(i) + ' email: xxxxx#gmail.com',))
self.root.ids.box.add_widget(panel)
DemoApp().run()
<Content>:
[...]
MDCard:
[...]
MDRaisedButton:
text: "REMOVE"
on_release: app.remove(root)
[...]
class DemoApp(MDApp):
[...]
def remove(self, content):
self.root.ids.box.remove_widget(content.parent)

ScrollView in a anchorlayout. python. kivy

practice screen
This is from the .py file
The screens are controlled by screen manager as you can see
class Practice_Page(Screen):
pass
class PracticeList(BoxLayout):
def practicelist(ScrollView):
practicelist.bind(minimum_height=layout.setter('height'))
.KV file:
<Practice_page>:
canvas.before:
Rectangle:
pos: self.pos
size: self.size
source: 'background1.png'
AnchorLayout:
anchor_x: 'center'
anchor_y: 'center'
PracticeList:
size: 900,30
size_hint: None,None
do_scroll_x: False
BoxLayout:
orientation: 'vertical'
padding: 10
cols: 1
Button:
text: 'The Real Number System'
on_press: root.manager.current = 'open_topics'
Button:
text: 'Absolute Value'
on_press: root.manager.current = 'open_practice'
Button:
text: 'Operations W/ Integers & Fractions'
on_press: root.manager.current = 'open_topics'
Button:
text: 'Operations W/ Zero'
on_press: root.manager.current = 'open_formulas'
I have about 30 more buttons. I have no idea what I'm doing wrong, any help or suggestions will be very helpful.
AnchorLayout:
anchor_x: 'center'
anchor_y: 'center'
ScrollView:
#size: 900,30
size: self.size
#do_scroll_x: False
GridLayout:
# orientation: 'vertical'
#padding: 10
size_hint_y: None
height: self.minimum_height
cols: 1
Button:
size_hint_y: None
text: 'The Real Number System'
on_press: root.manager.current = 'open_topics'
Button:
size_hint_y: None
text: 'Absolute Value'
on_press: root.manager.current = 'open_practice'
Button:
size_hint_y: None
text: 'Operations W/ Integers & Fractions'
on_press: root.manager.current = 'open_topics'
Button:
size_hint_y: None
text: 'Operations W/ Zero'
on_press: root.manager.current = 'open_formulas'
##MORE BTNS
For anyone who needs it.

Categories