Widget Creation is so slow what can i do for that

44 views
Skip to first unread message

Jaykishen Khemani

unread,
Jul 31, 2019, 11:31:36 AM7/31/19
to Kivy users support
i have done whole research on this topic actully i am creating a invoicing application for windows so basically when i scan barcode of any item it add that item in the list in the form of grid of text inputs just like in a spreadsheet it works fine for upto 5-10 rows but then it slow down i can't simply add a row because of calculation i have to pass whole list of barcode everytime i scan a barcode i have tries recycleview but then i can't reference any particular textinput because its in view class of recycle view though it is faster then widget creating everytime but no use please suggest me how can i improve my widget creation 

you can refer from the picture from top i scan the barcode
and row of text input gets gen rated below all working fine but problem is widget creation speed 
please help me in this 
thanks in advance
Screenshot (92).png

Elliot Garbus

unread,
Jul 31, 2019, 8:54:21 PM7/31/19
to kivy-...@googlegroups.com

Do you have a small example we can use to explore alternatives?

Have you profiled the code, are you certain the bottleneck is widget creation?

 

If you had a way to access each item in your ReCycleview would that solve the problem?  This is certainly possible.

--
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/2e57ae38-e7fd-4ecb-8bf2-66daef255dd0%40googlegroups.com.

 

Screenshot (92).png

Jaykishen Khemani

unread,
Aug 3, 2019, 7:47:16 AM8/3/19
to Kivy users support
yes if i can access each element of recycle view my problem can be solved  , sorry i dont have any small code from it you can suggest me the way to do it i will surely revert with the result 


On Thursday, August 1, 2019 at 6:24:21 AM UTC+5:30, Elliot Garbus wrote:

Do you have a small example we can use to explore alternatives?

Have you profiled the code, are you certain the bottleneck is widget creation?

 

If you had a way to access each item in your ReCycleview would that solve the problem?  This is certainly possible.

 

From: Jaykishen Khemani
Sent: Wednesday, July 31, 2019 8:31 AM
To: Kivy users support
Subject: [kivy-users] Widget Creation is so slow what can i do for that

 

i have done whole research on this topic actully i am creating a invoicing application for windows so basically when i scan barcode of any item it add that item in the list in the form of grid of text inputs just like in a spreadsheet it works fine for upto 5-10 rows but then it slow down i can't simply add a row because of calculation i have to pass whole list of barcode everytime i scan a barcode i have tries recycleview but then i can't reference any particular textinput because its in view class of recycle view though it is faster then widget creating everytime but no use please suggest me how can i improve my widget creation 

 

you can refer from the picture from top i scan the barcode

and row of text input gets gen rated below all working fine but problem is widget creation speed 

please help me in this 

thanks 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.

Elliot Garbus

unread,
Aug 3, 2019, 9:29:20 AM8/3/19
to kivy-...@googlegroups.com

Build a small example outside your program that has a ReCylceview with text inputs.  If you have trouble getting it working share it here, I’ll help.

 

I built a ReCycleview for a multi-select UI.  Each line item has a checkbox.  This is state that must be retained and displayed on the widget, much like your text box. 

 

A ReCycleview is displaying it’s data from a list of dictionaries on only the number of widgets required to be visible at one time. This is critical to understand – and why the ReCycleview is fast.  It is not creating widgets, it is reusing a small number of visible widgets. 

 

Every time a widget is visible in the view, the visible widget will apply the list of attributes from the items in the data list   Of course, the binding applies, so keeping a selected state in the widget does NOT work.

 

You want to have a text input in the widget.  This is state associated with the widget.   You want the (recycled) widget to show the correct state when the widget is used for another data item so you have to save that selected state outside of the widget.   

 

Save the widget state (the data for the text field) into a different list property, and just make the widget lookup that property when the widget’s key is updated. Put the ListProperty item as the text field of your TextInput

 

TextInpuut:

    text: your_list_property_that_holds_your_barcode_data[index]

 

You will have a list of attributes in the data list (a list of dictionaries) and a separate list for the data your barcode data.  The recycle view will display a rolling subset of your barcode data.  (I used DicitionaryProperty outside of the data list, and it also works effectively)

 

There is an example of RecycleView in the examples/widget directory.   You can use that as a quick starting point.

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/78bbbee7-98cc-4b2f-9b57-1d22165f5ca6%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages