Kodi Community Forum
Help with dialog.ok - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Help with dialog.ok (/showthread.php?tid=71924)



Help with dialog.ok - itombs - 2010-04-11

Hi, I need to show a dialog with a variable numer of lines with an information.

I have a loop:

Code:
show = "\n"
for i in range (1, X):
        show=show+"lalala %i"%(i)



My idea is that my dialog.ok show:

Dialog title
lalala 1
lalala 2
lalala 3
...
lalala 4
[OK]




But, i dont know how i can do it.

Code:
dialog = xbmcgui.Dialog()
        ok=dialog.ok("Dialog title"%,show)



I know that show must be this stlye:
"lalala 1","lalala 2","lalala 3",...,"lalala 4"


So... i tried change the loop:

Code:
for i in range (1, X):
        show=show+"lalala %i"%(i)+","


or

Code:
for i in range (1, X):
        show=show+"lalala %i"%(i)+"\,\"



I need to know how i can make a dialog.ok with a varialbe number of lines.

Thanks in advance.


- rwparris2 - 2010-04-11

Dialog().ok(heading, line1[, line2, line3])

Is this what you're looking for?


- itombs - 2010-04-11

rwparris2 Wrote:Dialog().ok(heading, line1[, line2, line3])

Is this what you're looking for?
I know it, but problem is that i dont know how many lines i will have.


Code:
show = "\n"
for i in range (1, X):
        show=show+"lalala %i"%(i)



X is variable, when scraper is running and use the function I can know the value of X and the number of lines will be the value of X but, in my code I dont know the value of x


When i write Dialog().ok(heading, line1[, line2, line3]) i need know how many lines i will have but i dont know.

Thanks


- jmarshall - 2010-04-11

Just copy the lines to a fixed sized array of lines (initialized empty) and then call the 3 line version?


- itombs - 2010-04-11

jmarshall Wrote:Just copy the lines to a fixed sized array of lines (initialized empty) and then call the 3 line version?

If i call the 3 lines version, my dialog show 3 lines, no? I dont know how many lines will have to show.

And another problem is sometimes I need to show 8 lines.

X in range (1,8), it is possible with a dialog.ok or similar?


Thanks


- rwparris2 - 2010-04-11

itombs Wrote:If i call the 3 lines version, my dialog show 3 lines, no? I dont know how many lines will have to show.

And another problem is sometimes I need to show 8 lines.

X in range (1,8), it is possible with a dialog.ok or similar?


Thanks
I do not think 8 lines is possible with the standard "ok" dialog. You need to make your own dialog with windowxmldialog if that is the problem (not so easy if you're just getting started!). Depending on your needs, the "select" dialog may be an acceptable alternative.

If you can keep it standard you can make a list and let python know those are your args with the * character http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists

PHP Code:
show = list()
for 
i in range (1x):
        
show.append("lalala %i" %(i))
xbmcgui.Dialog().ok("Header", *show