controltextbox updating
#1
Hi all--

I'm hoping to add an artist biography of the artist playing inside of the RunXM interface. I've gotten it to the point where it will display the biography and scroll down/up, but one thing I didn't expect is that, unlike overwritting the information for the artist/song/album upon updates using SetLabel(), the controltextbox SetText() basically writes over itself when updated. So you basically end up seeing several layers of text.

To fix this, I was thinking of doing something like if X variable doesn't exist, perform these functions for the first run-through, and if it does exist to pass on updating the biography until the artist changes; at this point, perform a removeControl(), then reupdate the biography, and redisplay. However, I can't figure out how to do this in python, since if a variable doesn't exist, the script quits.

Is this something easy to fix, or is this not possible to accomplish?

Here's the code for the biography display. If you need anything else, let me know.

Code:
        search = urllib.urlencode({'m':'all','p':songData['artist']})
        artistURL = urllib.urlopen("http://search.music.yahoo.com/search/?" + search)
        #print "http://search.music.yahoo.com/search/?" + search
        SearchHTML = artistURL.read()
        target = '<a href="http://music.yahoo.com/ar-'
        if SearchHTML.find(target) != -1:
            SearchHTML = SearchHTML[SearchHTML.find(target) + len(target) :]
            data = SearchHTML[: SearchHTML.find('---')]
            print data

            if (data):
                artistBIO = urllib.urlopen("http://music.yahoo.com/ar-" + data + "-bio--")
                print "http://music.yahoo.com/ar-" + data + "-bio--"
                BioHTML = artistBIO.read()
                target = '<table cellpadding="5" cellspacing="0" border="0" width="401">'
                if BioHTML.find(target) != -1:
                    BioHTML = BioHTML[BioHTML.find(target) + len(target) :]
                    rawHTML = BioHTML[: BioHTML.find('</td>')]
                    #print rawHTML

                    target = '<td>'
                    if rawHTML.find(target) != -1:
                        biography = rawHTML[rawHTML.find(target) + len(target) :]
                        biography = str(biography)
                        biography = re.sub('<P>', '\n ', biography)
                        biography = re.sub('</P>', ' ', biography)
                        biography = re.sub('<p>', '\n', biography)
                        biography = re.sub('</p>', ' ', biography)
                        biography = re.sub('<BR>', '\n\n', biography)
                        #print biography

        self.BiographyTEXT = xbmcgui.ControlTextBox((int(screenX * .3)),(int((screenY * .2) * 2.25)),int(screenY),(int(screenX * .3)),"font12")
        self.addControl(self.BiographyTEXT)
        self.BiographyTEXT.setText(biography)
        self.setFocus(self.BiographyTEXT)
Reply
#2
Quote:controltextbox SetText() basically writes over itself when updated. So you basically end up seeing several layers of text.

Do you mean it appends the text? If they're rendering on top of each other than you have more than one textbox, simple as that.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
yourtextbox.reset() before filling it.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#4
@jmarshall

nope... the text isn't added to the end of the current textbox, it's written over the current textbox, like a second layer over the text.

@Nuka1195

ah ok. so the controltextbox.setText() doesn't work similar to the controllabel.setlabel() and overwrite whats there. reset() it is!!

easy enough!

thank you!
Reply
#5
In that case you have more than one textbox.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#6
I was stupid when I was writing the code for doing this, and, jmarshall, once you said I have more than one textbox, I laughed at myself. Then fixed it.

Nuka1195, thank you as well!

I've got it up and running now!
Reply

Logout Mark Read Team Forum Stats Members Help
controltextbox updating0