Checkbox, dropdow-list errors and data is not scrolling on x-axis

56 views
Skip to first unread message

falex

unread,
Dec 15, 2019, 7:31:54 AM12/15/19
to Kivy users support
 I want  to develop an android app which will be able to upload data, analyze and visualize it. After learning Python and kivy, I write a script which will able to upload analyze and visualize the data. It's time to finalize the app and do some designing  using checkboxes and dropdown list. Previously, the code was uploading the data and also visualizing it successfully. But I was unable to perform multiple functions on a single code so for that I used checkboxes and dropdown-list options and from last month I am working on the script but unable to solve the errors on my own.  The issues which I am having:
  1. checkboxes and drop-down list code error
  2. I want to present  data in decent tabulated format
  3. the script is not supporting  x-axis scrolling while it doing y axis scrolling.
I will be really thankful if this group will help me as my project deadline is coming very soon and I am struggling alot from last month due to the above mentioned errors. I am attaching the files kindly consider it.
Thankyou in advance.
editor.kv
script.py

Elliot Garbus

unread,
Dec 15, 2019, 7:55:01 AM12/15/19
to kivy-...@googlegroups.com

Please create a minimum runnable example that shows your issue.  I do not have all of your dependencies installed.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/cde304ad-a140-4c6e-a8cf-c5ed3f12cb97%40googlegroups.com.

 

falex

unread,
Dec 16, 2019, 12:29:06 AM12/16/19
to Kivy users support
Thank you, for the response Elliot. I am attaching files which are running without any errors. Moreover, I attached a file (functions-checkbox-dropdown-list) which I need to implement  and create check-boxes 
& drop-down-list. The user will upload the file and select check-boxes at a same time and a/c to the user selection the file will be presented in tabulated form.
Queries:
  1. Check-boxes and drop-down list code error
  2. Want to present  data in decent tabulated format
  1. the script is not supporting  x-axis scrolling while it doing y axis scrolling.
On Sunday, 15 December 2019 17:55:01 UTC+5, Elliot Garbus wrote:

Please create a minimum runnable example that shows your issue.  I do not have all of your dependencies installed.

 

From: falex
Sent: Sunday, December 15, 2019 5:32 AM
To: Kivy users support
Subject: [kivy-users] Checkbox, dropdow-list errors and data is not scrollingon x-axis

 

 I want  to develop an android app which will be able to upload data, analyze and visualize it. After learning Python and kivy, I write a script which will able to upload analyze and visualize the data. It's time to finalize the app and do some designing  using checkboxes and dropdown list. Previously, the code was uploading the data and also visualizing it successfully. But I was unable to perform multiple functions on a single code so for that I used checkboxes and dropdown-list options and from last month I am working on the script but unable to solve the errors on my own.  The issues which I am having:

  1. checkboxes and drop-down list code error
  2. I want to present  data in decent tabulated format
  3. the script is not supporting  x-axis scrolling while it doing y axis scrolling.

I will be really thankful if this group will help me as my project deadline is coming very soon and I am struggling alot from last month due to the above mentioned errors. I am attaching the files kindly consider it.

Thankyou in advance.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

editor.kv
functions-checkbox-dropdown-list.py
script.py

Elliot Garbus

unread,
Dec 16, 2019, 8:34:39 AM12/16/19
to kivy-...@googlegroups.com

Please strip this down to a minimal kivy example.

I use a simple environment for helping with kivy.  Limit your example to kivy and the standard library.  I suspect you will need to also send a data file.

No Pandas, no Cufflink, No Ploty…  

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/f2cdd8fa-289a-47c4-8146-808f19613b89%40googlegroups.com.

 

Message has been deleted

falex

unread,
Dec 16, 2019, 11:59:04 AM12/16/19
to Kivy users support
Hi Elliot,
I attached the revised files hope it will be considerable. I like to tell you that I am working on a complex and big data, I have attached  sample of it (data.txt). In previous files, I have attached the complete code in which I am getting issues, using Pandas I clean and print the file and by accessing d/f columns I created d/f functions which I want user will be selected with the help of checkboxes and dropdown list. Thankyou in advance for your time.
data.txt
editor.kv
script.py

Elliot Garbus

unread,
Dec 16, 2019, 6:10:43 PM12/16/19
to Kivy users support
The attached files have been changed to add a checkbox into a recycle view.  You will need to create a list property to hold the state of the checkbox, if that is required.
In editor a class is created that holds the checkbox and a label:

<CheckLabel@BoxLayout>:          # *** Create a new class to display the data
check_label: 'Initial'
CheckBox:
size_hint_x: 1
Label:
id: cl_id
size_hint_x: 5
text: root.check_label
text_size: self.size
halign: 'left'
valign: 'middle'

<RV@RecycleView>:
viewclass: 'CheckLabel' # *** set the view class ***
scroll_type: ['bars','content']
bar_width: dp(15)
# do_scroll_x: True
RecycleBoxLayout:
default_size: None, dp(50)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'

In editor the data class is modified to change the property in CheckLabel:
def load(self, path, filename):
with open(os.path.join(path, filename[0])) as stream:
lines = stream.readlines()
self.dismiss_popup()
self.rv_data = [{'check_label': line} for line in lines] # *** change the data ***

In editor I also changed the background color using the canvas.  The checkbox is hard to see on my machine with a black background.
Happy to answer any questions.

editor.kv
script.py

falex

unread,
Dec 17, 2019, 3:23:03 AM12/17/19
to Kivy users support
Hi, thanks for the help. The thing is that I am working with pandas and the real issue I was struggling with how to implement check boxes on Pandas data because the checkbox support string data. For that I do change the datatype into string. Now, I try to write a code with the help of code you have send to me. I am sorry, to say this again while I know you don't have pandas dependencies if it is possible just have a look and kindly let me know if possible where I am going wrong. Just attaching the portion where I do amendment.
   
#script.py  
    def load(self, path, filename):
 
       
with open(os.path.join(path, filename[0])) as stream:

            lines
= [l for l in stream if not l.startswith('**')]
       
self.a=pd.read_csv(io.StringIO(''.join(lines)),dtype={'*A': str, 'B': int, 'C': str, 'D': str, 'E': str},sep='\t').rename(columns={'*A': 'A'})
       
self.pandaf1() #it will print complete data
       
       
self.dismiss_popup()
       
   
def func_1(self): #when user select checkbox1 this function will run
       
return self.a[self.a.C == "|"]


   
def pandaf1(self):
       
self.panda2rv(self.a)


   
def panda2rv(self, frame):
        lines
=[]
        tl
=frame.to_string().split("\n")
       
for i in range(len(tl)):
            temp
=str(tl[i])
            lines
.append({'text':temp})
 
       
self.rv_data = [{'func_1': line} for line in lines]  #what should I change here to print func_1.

###.kv file###

<CheckLabel@BoxLayout>:          # *** Create a new class to display the data
    check_label: 'Initial'
    CheckBox:
        size_hint_x: 1
    Label:
        id: cl_id
        size_hint_x: 5
        text: root.func_1
        text_size: self.size
        halign: 'left'

        valign: 'middle'...


Elliot Garbus

unread,
Dec 17, 2019, 1:29:41 PM12/17/19
to kivy-...@googlegroups.com

I don’t understand what you are trying to achieve.

 

When you click the checkbox, you want the text on the label to change?  Would it un-change if you unclicked it?  Is this correct?  Let me know and I can add it to the example.

 

Here is some info on the recycleview so you can better understand how it works.

<RV@RecycleView>:
  
 viewclass: 'CheckLabel'         #  *** set the view class ***
The viewclass specifies the class for the item in the recycle list. The number of items created matches the number that are visible on the screen.  Those viewclass items are recycled and have new data put on them, creating the illusion of a long list.  The data comes from a list of dictionaries.  The key from the dictionary is applied to provide data to the viewclass.
 
<CheckLabel@BoxLayout>:          # *** Create a new class to display the data
   
check_label: 'Initial'
   
CheckBox:
       
size_hint_x: 1
   
Label:
       
id: cl_id
       
size_hint_x: 5
       
text: root.check_label
       
text_size: self.size
        halign
: 'left'
       
valign: 'middle'
 

The kv code creates a kivy object property check_label.  I use this value to set the text value of the label in the CheckLabel instance.   The dictioary in the recycle view data attribute, uses this attribute in the key of the dictionary to set the text on the label:

1.       Check-boxes and drop-down list code error

2.       Want to present  data in decent tabulated format

3.       the script is not supporting  x-axis scrolling while it doing y axis scrolling.

On Sunday, 15 December 2019 17:55:01 UTC+5, Elliot Garbus wrote:

Please create a minimum runnable example that shows your issue.  I do not have all of your dependencies installed.

 

From: falex
Sent: Sunday, December 15, 2019 5:32 AM
To: Kivy users support
Subject: [kivy-users] Checkbox, dropdow-list errors and data is not scrollingon x-axis

 

 I want  to develop an android app which will be able to upload data, analyze and visualize it. After learning Python and kivy, I write a script which will able to upload analyze and visualize the data. It's time to finalize the app and do some designing  using checkboxes and dropdown list. Previously, the code was uploading the data and also visualizing it successfully. But I was unable to perform multiple functions on a single code so for that I used checkboxes and dropdown-list options and from last month I am working on the script but unable to solve the errors on my own.  The issues which I am having:

1.       checkboxes and drop-down list code error

2.       I want to present  data in decent tabulated format

3.       the script is not supporting  x-axis scrolling while it doing y axis scrolling.

I will be really thankful if this group will help me as my project deadline is coming very soon and I am struggling alot from last month due to the above mentioned errors. I am attaching the files kindly consider it.

Thankyou in advance.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/cde304ad-a140-4c6e-a8cf-c5ed3f12cb97%40googlegroups.com.

 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/f2cdd8fa-289a-47c4-8146-808f19613b89%40googlegroups.com.

 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/08c22e83-a8bd-4b47-ae9e-d8ad413dca59%40googlegroups.com.

 

falex

unread,
Dec 18, 2019, 2:12:45 AM12/18/19
to Kivy users support
Hi Elliot,

I have successfully write a code which is uploading big data and also printing all the functions. Now,  I want that the user will select the functions of there need and for that I am required to use checkboxes and dropdown list. 

Objective: 
The user first have to select functions(checkboxes and drop-down options) and then upload data file.Once, the data file is uploaded on backend python code will clean data and print the data in tabulated form according to selected functions(checkboxes). 

Issues:
1. When I run basic code (without checkbox code) it prints the data but doesn't have x axis  scrolling,
2. I don't understand after reading and watching so much tutorials that how to implement checkboxes/dropdown-list code with the created functions.
3. As I clean and processed data with Pandas and then convert the data type into string as (rv data) is supporting string datatype. So, when I print data it is not printing in proper tabulated format.
I hope my query will be clear. Looking for your assistance. I have uploaded all the scripts in previous emails.
design.png

Elliot Garbus

unread,
Dec 18, 2019, 12:12:36 PM12/18/19
to kivy-...@googlegroups.com

I’m still trying to understand how I can help:

 

Issues:

  1. When I run basic code (without checkbox code) it prints the data but doesn't have x axis  scrolling,

Do you want to be able to scroll in both the x and y direction in your recycleview?

 

  1. I don't understand after reading and watching so much tutorials that how to implement checkboxes/dropdown-list code with the created functions.
  1. The code I attached previously demonstrated how to add a checkbox to the recycleview.  Did you have a question?  When the box is checked what do you want to have happen?  Do you just want to run a function or do you want that function to modify the recycle view?

 

  1. As I clean and processed data with Pandas and then convert the data type into string as (rv data) is supporting string datatype. So, when I print data it is not printing in proper tabulated format.
  1. How is the data ‘printing’  how do you want the data to print?  Do you want the data to print or are you describing how you want it to  look in the RecycleView.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/ad13752c-2b6e-4b62-bdd4-9ed6064c2eed%40googlegroups.com.

 

falex

unread,
Dec 19, 2019, 12:42:18 AM12/19/19
to Kivy users support

Issues:

  1. When I run basic code (without checkbox code) it prints the data but doesn't have x axis  scrolling,

Do you want to be able to scroll in both the x and y direction in your recycleview?

 >>Yes.

  1. I don't understand after reading and watching so much tutorials that how to implement checkboxes/dropdown-list code with the created functions.
    The code I attached previously demonstrated how to add a checkbox to the recycleview.  Did you have a question?  When the box is checked what do you want to have happen?  Do you just want to run a function or do you want that function to modify the recycle view?

 >>The code you have send is uploading & printing the text and at the start of each line there is a checkbox.


What I required: Let's say we have A-Z column in a table which have been uploaded by user, now the user is interested to see only F,H,I column data from the uploaded file. For this purpose we have created a function (func_a) which will print only F,H,I column data. When the user uploaded the file and checked the box  (func_a) it will only print the data store in func_a rather than printing the huge file. In same way we create d/f functions for printing and visualizing the data.

  1. As I clean and processed data with Pandas and then convert the data type into string as (rv data) is supporting string datatype. So, when I print data it is not printing in proper tabulated format.
    How is the data ‘printing’  how do you want the data to print?  Do you want the data to print or are you describing how you want it to  look in the RecycleView.
>>Consider attached file.
data-print.pdf

Elliot Garbus

unread,
Dec 19, 2019, 8:51:08 AM12/19/19
to kivy-...@googlegroups.com

Got it.

 

  1. To scroll in the x direction you will need to set the size of the widgets in the scroll view in the x direction.

 

  1. In the class CheckLabel, add on_active to the checkbox.  You will use self.active to choose a screen, you will create 2 screens to hold the 2 sets of data you want to display.  See: https://kivy.org/doc/stable/api-kivy.uix.screenmanager.html?highlight=screenmanager#module-kivy.uix.screenmanager to learn about screen managers.

 

  1. In the CheckLabel class put 2 screens, each screen has a label for each column of data to be displayed.  Add dictionary elements in your data_table for each column in your data.

 

  1. You will need to split your columns of data into a list and then put each field on a separate label.  You can do this with the string method split.  See: https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str

 

str.split(sep=Nonemaxsplit=-1)

Return a list of the words in the string, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done (thus, the list will have at most maxsplit+1 elements). If maxsplit is not specified or -1, then there is no limit on the number of splits (all possible splits are made).

If sep is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, '1,,2'.split(',') returns ['1', '', '2']). The sep argument may consist of multiple characters (for example, '1<>2<>3'.split('<>') returns ['1', '2', '3']). Splitting an empty string with a specified separator returns [''].

 

If I have time later today, I will demonstrate these changes.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/7d2ce168-b32d-48fd-b7e3-a161cb4b9c2d%40googlegroups.com.

 

Elliot Garbus

unread,
Dec 19, 2019, 11:07:57 PM12/19/19
to Kivy users support
Code attached.
One of the tricky things about recycleviews... you need to keep in mind that the same widgets are being used over and over (recycled) so the state can not be stored in the widget.  In this example I store the state of the checkbox in a list called  checked.  The state of the all the checkboxes stored in this list.  The state of the widget is restored from this list. 

A few other comments:
s = line.replace('\n','').split('\t')  # remove returns and split into cols
I used the python string method replace to remove the new line from each line, and split was used to split the tab delimited column data into items in a list.

I created an index and stored it in the rv_data list.  This was a quick way to get the index for the data in this row.

self.rv_data = [{'col_a': c[0],
'col_b': c[1],
'col_c': c[2],
'col_d': c[3],
'col_e': c[4],
'col_f': c[5],
'index': i} for i,c in enumerate(columns)]

Created the the list checked that stores the state of the checkboxes.
self.checked = [False for c in columns] 

A ScreenManager is used to select the 3 columns of data to display:
CheckBox:
size_hint: None,None
size: (50,50)
active: app.root.checked[root.index] # state of the checkbox is stored in checked[]
on_active:
app.root.checked[root.index] = self.active
sm.current = 'a-c' if not self.active else 'd-f'
ScreenManager:
id: sm
transition: NoTransition()
ThreeColumns:
name:'a-c'
col_1: root.col_a
col_2: root.col_b
col_3: root.col_c
ThreeColumns:
name:'d-f'
col_1: root.col_d
col_2: root.col_e
col_3: root.col_f

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+unsubscribe@googlegroups.com.

script.py
editor.kv
Reply all
Reply to author
Forward
0 new messages