Error: "Invalid property type" while checking TextInput - kivy-language

I'm trying to check if user's TextInput is empty but getting error "Invalid property type". I'm programming in kivy.
My kv code:
<Label>
font_size: self.height * .15
background_color: (59/255,191/255,174/255,1)
canvas.before:
Color:
rgba: self.background_color
Rectangle:
size: self.size
pos: self.pos
color: (0/255,0/255,0/255,1)
<TextInput>
multiline: False
input_filter: "int"
font_size: self.height * .15
background_normal: ""
background_color: (192/255,251/255,243/255,1)
color: (0/255,0/255,0/255,1)
<Button>
font_size: self.height * .25
color: (0/255,0/255,0/255,1)
pos_hint: {'center_x': .5}
size_hint: (1, .3)
background_normal: ""
background_color: (8/255, 122/255, 111/255, 1)
<MyLayout>
BoxLayout:
orientation: 'vertical'
size: root.width, root.height
padding: 1
spacing: 1
TextInput:
id: calc_output
text: "waiting for data..."
halign: 'center'
valign: 'center'
font_size: self.height * .20
color: (0/255,0/255,0/255,1)
background_normal: ""
background_color: (1,1,1,1)
size_hint: (1, .3)
GridLayout:
cols: 1
size: root.width, root.height
GridLayout:
cols: 2
padding: 1
spacing: 1
Label:
text: "Broj rođenih"
TextInput:
id: N
Label:
text: "Broj umrlih"
TextInput:
id: M
Label:
text: "Broj stanovnika prve godine"
TextInput:
id: bspg
Label:
text: "Broj stanovnika druge godine"
TextInput:
id: bsdg
Button:
text: "Definiraj tip općeg kretanja stanovništva"
on_press: root.tipopceg()
I tried to check it with:
if - else
while not
try - except
if len()...
Everything I tried I would put in this part of code:
<TextInput>
multiline: False
input_filter: "int"
while not id:
print("You forgot...")
break
or inside every TextInput
Label:
text: "Broj rođenih"
TextInput:
id: N
while not N:
print("You forgot...")
break
but every time I get same error. Since I'm new in this world of programming, I guess I made some minor mistake why program doesn't recognize "id" of every user's TextInput and return error.
Any thoughts?

I don't know if I'm missing something here as well, but ain't kivy a library ? I think the whole purpose of kivy is to make a interface in a more practical way and separated from your logic statements, so the kivy language is made only for interface creation. In that case, I think you are supposed to write your logic part using python, and then call your widgets if you want to make any operation with their properties.
I suggest you take the user input through python, and then use it to define a property of the widget:
self.userinput = TextInput(multiline=False)
Now you can take the property TextInput.text as the actual text inputed by the user. You can check if it's blank with:
if len(self.userinput.text) == 0:
#do something

Related

Creating shape or marks in custom indicator, (tradingview charting library (pinejs))

is there any way to create shape or create marks on chart in custom indicator using tradingview charting library. I am using this way to create custom indicators. Thanks in advance.
Yes you can. Here is the guide.
For the callouts/Markers on chart you can follow this guide in the JS API.
https://github.com/tradingview/charting_library/wiki/JS-Api#gettimescalemarkssymbolinfo-from-to-ondatacallback-resolution
For getmarks you can do this
getMarks: (symbolInfo, startDate, endDate, onDataCallback, resolution) => {
var Arr = [
{
id: 1,
time: 1551448800000 / 1000,
color: 'blue',
text: 'Hello world',
label: 'B',
labelFontColor: 'yellow',
minSize: 20
},
]
onDataCallback(Arr);
console.log("=====getMarks running");
},
It will plot the marks above the bars as shown in the below image.
For Timescalemarks.
getTimescaleMarks: (symbolInfo,startDate,endDate,onDataCallback,resolution) => {
onDataCallback([
{
id: 1,
time: / 1000,
color: 'Turquoise',
label: 'The test you want to show on marker',
minSize: 20,
tooltip:[
"Information you want to print",
]
},
]);
})
The Time scale marks will look like this. And they will be plotted below the bars.
And for the shapes like circles and arrows you can follow this documentation. And use the createMultipointShape(points, options) methos to plot your shapes.
https://github.com/tradingview/charting_library/wiki/Chart-Methods#createmultipointshapepoints-options

Using vue-ellipse-progress component, is there any way where I can have two different colors for same circle indicating high and low value?

I want to indicate the high/low in the circle where I can display the different color if the progress value exceeds 60. Eg, if my value is 80 then till 60 it should show green color and remaining 20 should be in red color. Is it possible to achieve this using vue-ellipse-progress?
<vue-ellipse-progress
:progress="myvariable"
:angle="-90"
color="#1565C0"
emptyColor="#BBDEFB"
:size="180"
:thickness="10"
emptyThickness="15%"
fontColor="black"
dot="10 white"
>
<span>{{myvariable}} </span>
</vue-ellipse-progress>
Got one solution to this. By adding gradient to the color attribute helps to show the colors accordingly.
:color = "gradient"
gradient: {
radial: false,
colors: [
{
color: '#1565C0',
offset: 80,
opacity: '1',
},
{
color: 'red',
offset: 40,
opacity: '1',
},
]
}

Correct syntax for highchart API yAxis label style in coffeescript?

Javascript/Coffeescript newb here. I have recently been fiddling with a highcharts dual meter api in coffeescript. I'm trying to change change the style of my labels (i.e. color, font-size). I've looked at examples in the highchart website (Highchart API Reference) by translating javascript to coffeescript can be a bit finicky. The syntax below appears to be incorrect and I was just wondering what's the correct syntax for styling labels.
Coffeescript:
#chart = undefined
labels = {0: '0s', 5: '0.5s', 10: '1s', 15: '10s', 20: '20s'}
.
yAxis: [{
min: 0
max: 20
minorTickPosition: 'outside'
tickPosition: 'outside'
minorTickLength: 13
tickLength: 15
labels:
enabled: true
formatter: -> labels[#value]`
style:
'font-size': '20px'
'color': '#00ff00'`
I haven't used HighCharts, but I can help with Coffeescript syntax.
The CSS object from the docs you linked to would look like this in Coffee:
style =
color: '#6D869F'
fontWeight: 'bold'
The yAxis array you posted shouldn't have that first curly bracket and needs the last square brack. It should look like this:
yAxis: [
min: 0
max: 20
minorTickPosition: 'outside'
tickPosition: 'outside'
minorTickLength: 13
tickLength: 15
labels:
enabled: true
formatter: -> labels[#value]
style:
'font-size': '20px'
'color': '#00ff00'
]
That will give you an array with an object inside.
If you need an array with multiple objects you can use this:
yAxis: [
{
min: 0
max: 20
minorTickPosition: 'outside'
tickPosition: 'outside'
minorTickLength: 13
tickLength: 15
labels:
enabled: true
formatter: -> labels[#value]
style:
'font-size': '20px'
'color': '#00ff00'
}
{
min: 0
max: 20
minorTickPosition: 'outside'
tickPosition: 'outside'
minorTickLength: 13
tickLength: 15
labels:
enabled: true
formatter: -> labels[#value]
style:
'font-size': '20px'
'color': '#00ff00'
}
]

Dojo charting: Can i change the color of the line based on the value?

I have a working chart with Dojo 1.8.
chart1 = new dojox.charting.Chart2D("chart1");
chart1.addPlot("default", {type: "Lines", ...
chart1.addSeries("Series A", [{ x: 1, y: 2.3, tooltip: "Value 1"}, ...
My data from the series gets displayed correctly as line and the whole line (series) gets the color 'Green'.
I know how to change the color for the whole series, but would it be possible that the line changes its color based on the data values? Lets assume the x-axis is a time axis and I need the line (series) to be green for until today, and then red for the future values.
Would this be possible and how ?
(I am using markers for the values. If these could change based on the value it would be enough)
I found something something like this in the documentation:
chart.addSeries("Series A", [
{y: 4, color: "red"},
{y: 2, color: "green"},
{y: 1, color: "blue"},
{y: 1, text: "Other", **color: "white", fontColor: "red"**}
]);
But it only works for PIE-charts and not for LINES-charts.
Thank you in advance.
You could try this http://jsfiddle.net/jUS54/
Use styleFunc in the addPlot method for change the markers colors:
var chart1 = new Chart("simplechart");
chart1.addPlot("default", {type: Lines, markers:true, styleFunc: function(item {
if(item <= 2){
return { fill : "red" };
}else if(item > 3){
return { fill: "green" };
}
return {};
}});
You can change the color by adding 'fill' to your chart data. Basically, loop through your input data deciding what to set your fill too while constructing the JSON for chartData.
var chartData = [{y: 10000,fill: "red"},{y:9200,fill: "yellow"},{y:11811,fill: "green"},{y:12000,fill: "blue"},{y:7662,fill: "blue"},{y:13887,fill: "black"},{y:14200,fill: "gray"},{y:12222,fill: "purple"},{y:12000,fill: "green"},{y:10009,fill: "purple"},{y:11288,fill: "green"},{y:12099,fill: "blue"}];
http://jsfiddle.net/goinoff/QnNk2/1/

Sencha Touch chart - How to add label/value in line chart

I am using Sencha Touch charts 1.0.0 for my project. I would like to add values on each point in my line chart (as in image). I tried the same approach in this question for column chart, but it didn't work out.
I had the same problem with you. But i find a solution instead for that. You can add marker at each node of line and when you click on marker a popup will show detail information as you want. This's my code may help you :
-Add marker in cofig of series :
type: 'line',
title: 'Clickeds : ' + total[4] + ' ( ' + Math.round(arrInfo[4]) + '% )',
highlightCfg: { scale : 0.7 },
xField: 'Date', yField: 'Clks',
style : {
stroke: 'rgb(50, 185, 150)',
miterLimit : 3,
lineCap: 'miter',
lineWidth: 2
}
,
marker:{
type: 'image',
src: 'resources/images/square.png',
width: 24,
height: 24,
x: -12,
y: -12,
scale: 0.5,
fx: {
duration: 200
}
}
Handle event when you click on node, you add listeners to config of chart : `listeners: {
itemtap: function( series, item, event, eOpts ){
//handle your code here.
}`
Regards,
(Sorry for bad english.)