Kivy popup size relative to content - popup

I am trying to set the height of a popup in kivy so that it varies to fit its content. However, I cannot use height: self.minimum_height, as Popup has no attribute minimum_height.
I have also tried setting the height of the popup equal to the height of the content, but the result is far from ideal (and especially wouldn't be consistent across different screen sizes).
This is my code:
#:set row_height '35sp'
<ConfirmPopup#Popup>:
box: box
message: message
noButton: noButton
yesButton: yesButton
size_hint: .8, None
height: box.height + sp(80)
auto_dismiss: False
StackLayout:
id: box
orientation: 'lr-tb'
size_hint: 1, None
height: self.minimum_height
padding: main_padding
Label:
id: message
text: "" # This text is updated later from the py script
text_size: self.width, None
size_hint: None, None
width: self.parent.width
height: self.texture_size[1]
Label: # just empty space
size_hint: .15, None
Button:
id: noButton
size_hint: .3, None
height: row_height
Label:
size_hint: .1, None
Button:
id: yesButton
size_hint: .3, None
height: row_height
Label:
size_hint: .15, None

Related

get textinput value inside MDApp

Good afternoon, I have a great difficulty, which seems easy to solve.
The question is as follows:
I have my TextInput created this way, in my :
KV = """
WindowManager:
ScreenLogin:
ScreenPaginaInicial:
PaginaEntradas:
id: data_scr
ScreenInicioProducao:
PaginaMovInterna:
PaginaMovExterna:
PaginaEditarArtigoOriginalInterna:
PaginaEditarArtigoBob1Interna:
PaginaEditarArtigoBob2Interna:
PaginaEditarArtigoBob3Interna:
PaginaEditarArtigoOriginalExterna:
PaginaEditarArtigoBob1Externa:
PaginaEditarArtigoBob2Externa:
PaginaEditarArtigoBob3Externa:
<ScreenLogin>:
name: "ScreenLogin"
FloatLayout:
canvas.before:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
Image:
size_hint: .3, .3
pos_hint: {"center_x": .5, "center_y": .75}
source: 'G:\O meu disco\Gestao_Stocks\logo.png'
GridLayout:
cols: 1
spacing: 5
size_hint: .7, .37
pos_hint: {"center_x": .5, "center_y": .3}
Label:
text: "Utilizador"
size_hint_x: .3
text_size: self.size
halign: 'center'
valign: 'middle'
color: 0,0,0,1
allow_copy: True
TextInput:
id: utilizador
multiline: False
halign: 'center'
focus: True
size_hint_x: 5
"""
class PLASbritos(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.data_tables = None
def build(self):
return Builder.load_string(KV)
def login(self):
utilizador = self.root.ids.utilizador.text
print(utilizador)
password = '1'
#Implemesta regras para acesso. Exemplo:
if utilizador == '1' and password == '1':
.........................................
.........................................
........................................
else:
........................................
I would like to access the utilizador through the textinput(id: utilizador)
error:
AttributeError: 'super' object has no attribute '__getattr__'
I've already looked for all the information on google, I've seen videos on youtube, and I can't find anything. What seemed to be the easiest, is extremely difficult, if someone can help me, I am extremely grateful.
I thank you in advance for any attention you can give me.
I've already looked for all the information on google, inclusive in stackoverflow similiar problems, I've seen videos on youtube, and I can't find anything. What seemed to be the easiest, is extremely difficult, if someone can help me, I am extremely grateful.

KIVY popup - how do I dismiss it from a compound content

I am trying to create a Kivy popup for general use
From my code below you may see that I am a beginner
I am trying to understand the KIVY language, ids, kivy properties, how to apply rules and the interaction between the KV and Python files
I will appreciate your answers and comments, that may teach me
Ho do I dismiss the popup?
Thank you for your aid
===================================================================
My KV file
'''
<MB_Body>
id: id_body
size_hint: 0.9, 0.9
Label:
id: id_label
size_hint: (0.6, 0.2)
pos_hint: {'x': 0.2, 'top': 0.9}
text: 'Sibs text'
Button:
text: 'Dismiss'
size_hint: 0.8, 0.2
pos_hint: {'x': 0.1, 'y': 0.1}
on_release: root.dismiss_msgbox()
id: pop
auto_dismiss: False
size_hint: 0.6, 0.4
title: 'si8bs title'
canvas.before:
Color:
rgba: 0, 1, 0, 1
Rectangle:
size: self.size
pos: self.pos
MB_Body:
'''
##########################################################
My PY file:
'''
from kivy.app import App
from kivy.uix.popup import Popup
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import StringProperty, ObjectProperty
class MsgBox(Popup):
pass
class MB_Body(FloatLayout):
def dismiss_msgbox(self):
print('In Finis')
print(App.get_running_app())
dismiss() #---> This line is my problem. How do I dismiss the popup???????????
def showMsg(_title, _msg):
mb = MsgBox()
mb.title = _title
mb.content.ids.id_label.text = _msg
mypopup = mb
print(_msg)
mb.open()
'''

What is the correct way to extend MUI v5 component with additional components and styled utility?

What is the correct way to extend build-in components of MaterialUI v5? What I'd like to do:
Style the build-in component
Make a wrapper on top of my styled component with additional components
The current code:
import {Box, Link, LinkProps} from '#mui/material';
import {styled} from '#mui/material/styles';
const StyledLink = styled(Link)<LinkProps>({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
color: '#6b7688',
fontWeight: 500,
fontSize: '12.8px',
textTransform: 'uppercase',
textDecoration: 'none',
'&:hover, &.Mui-focusVisible': {
color: '#313bac',
transition: 'all 0.3s ease-in-out',
// LinkHoverElement
'& .MuiBox-root': {
backgroundColor: '#313bac',
},
},
});
const LinkHoverElement = styled(Box)({
width: '5px',
height: '5px',
marginBottom: '5px',
borderRadius: '50%',
backgroundColor: 'transparent',
});
const MenuLink = ({children, ...restProps}: LinkProps) => {
return (
<StyledLink {...restProps}>
<LinkHoverElement />
{children}
</StyledLink>
);
};
export default MenuLink;
It works, I also may use all props ('sx' prop as well)
<MenuLink
sx={{mx: '1rem'}}
key={page}
href={`#${page}`}>
{page}
</MenuLink>
seems like a 'god object', I've read documentation and uses this articles:
Reusable component
styled()
but haven't found an complicated example and feel like the code above isn't a best practice
The codesandbox example

Google charts - Main title and axis size

I'm trying to change the font size for the main title and axis titles but I cannot with this code:
var options = {
title: 'Ratio de supervivencia de aerolíneas europeas',
chartArea:{
top: 20,
bottom: 50,
height: '75%'
},
width: 800,
height: 600,
hAxis: {title: 'Nº total de aerolíneas históricas', titleFontSize: 24},
vAxis: {title: 'Ratio de supervivencia', format: 'percent', maxValue: 0.7, titleFontSize: 24},
bubble: {textStyle: {fontSize: 11}}
};
Could someone help me?
Thanks in advance & regards,
Luis
there is no option for --> titleFontSize
instead, use the option for --> titleTextStyle
e.g.
hAxis: {
titleTextStyle: {
fontSize: 24
}
}
see configuration options for more...

can't hide the tooltip (equation) on the trendline on a google chart

can you please help me hide the tooltip (equation) on the trendline on the google chart on this page ?
Thanks
Here are the chart options I am using :
var options = {
title: 'Weight of pro surfer vs. Volume of his pro model',
hAxis: {title: 'Weight (kg)', minValue: 53, maxValue: 100}, //55
vAxis: {title: 'Volume (l)'}, //, minValue: 20, maxValue: 40}, //20
legend: 'none',
colors: ['#000000'],
series: {
1: { color: '#06b4c8' },
2: { color: '#575e6a' }
},
legend: {position: 'top right', textStyle: {fontSize: 8}},
chartArea: {width: '60%'},
//tooltip:{trigger:'none'}, //it hides all tooltips on the whole graph
trendlines: { 0: {//type: 'exponential',
visibleInLegend: true,
color: 'grey',
lineWidth: 2,
opacity: 0.2,
tooltip:{trigger:'none'}, //does nothing
labelInLegend: 'Linear trendline\n(Performance)'
}
} // Draw a trendline for data series 0.
};
If I add tooltip:{trigger:'none'}, before trendlines it hides the tooltips of the whole graph.
It has been implemented but not documented yet:
trendlines: {0: {tooltip: false}}
Only solution I was able to make is replacing the text of the tooltips from trendline. This example makes use of jquery, so if you are able to use jquery you can use:
google.visualization.events.addListener(chart, 'onmouseover', function(e){
$('svg *:contains("* x")').each(function(){
$(this).text('')
})
})
If not, it should be possible to replicate with pure js, but that´s the main idea: find the tooltips that have the formula attached, and replace the text with nothing
Here is a working example: http://jsfiddle.net/juvian/aapdjbpt/