Creating a Control Label Overwrites Text on the main GUI
#1
If I create a xbmcgui.ControlLabel it overwrites some of the text, particularly the time in the top right corner, two elements underneath the Kodi logo on the top left corner and the "Your library is currently empty..." text in unused menus.

This overwriting happens even if the control is not added using xbmcgui.Window.addControl

It seems that this is occurs usually with the first label that is created by the script - but not always.

I have tested this using Windows 10 with kodi 20.2 (though it occurs on previous versions at least down to 19 also)

The code below illustrates the problem (even if the line self.addControl(self.heading.timeCtrl) is commented out, the problem still occurs):


from datetime import datetime
import xbmcgui


def main():
    displayRecordingList = UiLines()
    displayRecordingList.createBookingsLines()
    displayRecordingList.controlBooking('DO_MODAL')


class UiLines:

    def __init__(self):
        self.bookingLines = BookingDisplay()
        self._bookingsLines = []

    def createBookingsLines(self):
        self._bookingsLines = self.bookingLines.createBookingDisplay()

    def controlBooking(self, control):
        if control == 'SHOW':
            self.bookingLines.show()
        elif control == 'DO_MODAL':
            self.bookingLines.doModal()
        elif control == 'CLOSE':
            self.bookingLines.close()


class BookingDisplay(xbmcgui.Window):
    def __init__(self):
        super().__init__()
        self.heading = CreateHeader()

    def createBookingDisplay(self):
        self.displayAndInitialise()
        return self

    def displayAndInitialise(self):
        self.heading.drawHeading()
        self.addControl(self.heading.timeCtrl)


class CreateHeader:

    def __init__(self):
        self.timeCtrl = xbmcgui.ControlLabel(100, 0, 500, 20, "", alignment=0x00000001)

    def drawHeading(self):
        self.timeCtrl.setLabel(datetime.now().strftime('%A %d %B %H:%M'))


if __name__ == "__main__":
    main()


Any ideas as to what is causing this?
Reply
#2
(2023-09-25, 04:56)BillBrowne Wrote: If I create a xbmcgui.ControlLabel it overwrites some of the text, particularly the time in the top right corner, two elements underneath the Kodi logo on the top left corner and the "Your library is currently empty..." text in unused menus.

This overwriting happens even if the control is not added using xbmcgui.Window.addControl

It seems that this is occurs usually with the first label that is created by the script - but not always.

I have tested this using Windows 10 with kodi 20.2 (though it occurs on previous versions at least down to 19 also)

The code below illustrates the problem (even if the line self.addControl(self.heading.timeCtrl) is commented out, the problem still occurs):

I didn't go through all of your code but I ran into a similar problem last week.  I moved everything to a single class and used the setVisible tag to determine when I wanted to and didn't want to have a control visible.  Here's my current code with three controls which overlap by design but I manage when I want the overlap (key 11 clicked).  One thing I determined is that the order of creating the controls with addControls determines the layering.  Here's a sample of the output.  In this case the user chit the I (key 11) on the keyboard (or remote) and the background image appears with the text control on top.  I could have wiped out the entire background image by setting the self.icontrol controlImage to False. 

Note that f you want to create a control but not have it initially visible then set visible to false before creating the control.  This can be seen in lines 667-671 in the link above.

Maybe this will help.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#3
Thanks for your thoughts.  I have tracked down the root cause:

If, after a label is created but before the label is added, the label text is changed, this text will overwrite the Gui text

Solution is to either set the text at label creation or to set the text after the label is added.

The following code works correctly:

Code:
from datetime import datetime
import xbmcgui


def main():
    displayRecordingList = UiLines()
    displayRecordingList.createBookingsLines()
    displayRecordingList.controlBooking('DO_MODAL')


class UiLines:

    def __init__(self):
        self.bookingLines = BookingDisplay()
        self._bookingsLines = []

    def createBookingsLines(self):
        self._bookingsLines = self.bookingLines.createBookingDisplay()

    def controlBooking(self, control):
        if control == 'SHOW':
            self.bookingLines.show()
        elif control == 'DO_MODAL':
            self.bookingLines.doModal()
        elif control == 'CLOSE':
            self.bookingLines.close()


class BookingDisplay(xbmcgui.Window):
    def __init__(self):
    super().__init__()
    self.heading = CreateHeader()

    def createBookingDisplay(self):
        self.displayAndInitialise()
        return self

    def displayAndInitialise(self):
        # Changing the order of these two lines causes elements of GUI to be overwritten
        self.addControl(self.heading.timeCtrl)
        self.heading.changeLabel()


class CreateHeader:

    def __init__(self):
        self.timeCtrl = xbmcgui.ControlLabel(100, 10, 500, 20, 'Another Control')

    def changeLabel(self):
        self.timeCtrl.setLabel(datetime.now().strftime('%A %d %B %H:%M'))


if __name__ == "__main__":
main()
Reply
#4
(2023-09-26, 00:22)BillBrowne Wrote: Thanks for your thoughts.  I have tracked down the root cause:

If, after a label is created but before the label is added, the label text is changed, this text will overwrite the Gui text

Solution is to either set the text at label creation or to set the text after the label is added.

Great work.  I have found that with controls,  order or operation is very important.  Speaking of which I've been trying to get control setAnimations to work with no luck.   I think it is another order of operation thing too.   I've been trying to find a working example.  I need to dig around more.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply

Logout Mark Read Team Forum Stats Members Help
Creating a Control Label Overwrites Text on the main GUI0