gui builder work around
#1
Hey gusy i dont know how many of you out there are using the visibility tag with HasFocus() but i found that it has issues with gui builder. I narowed it down to the setCondVisibility function where it executes self.win.controls[key]['control'].setVisible(xbmc.getCondVisibility(visible)).
When you use HasFocus() visibility = Control.HasFocus(id). For some reason this should return true but it doesnt. This is my work around for this. It is not the best but at least it works until they can update it.

def setCondVisibility(self):
if (not self.fastMethod):
self.lines[self.lineno + 1] = 'setting up visibility...'
t = len(self.win.controls)
pattern1 = 'control.hasfocus\(([0-9]+)\)'
pattern2 = 'control.isvisible\(([0-9]+)\)'
for cnt, key in enumerate(self.win.controls.keys()):
if (not self.fastMethod): self.dlg.update(int((float(self.pct1) / float(t) * (cnt + 1)) + self.pct), self.lines[0], self.lines[1], self.lines[2])
try:
visible = self.win.controls[key]['visible']
visibleChanged = False
# fix Control.HasFocus(id) visibility condition
items = re.findall(pattern1, visible)
for item in items:
xbmc.output(str(self.win.getFocus().getId())+" == "+str(self.win.controls[int(item)]['control'].getId())+"\n")
visibleChanged = True
xbmc.output("This is the Key: "+str(key)+"\n")
self.win.controls[key]['control'].setVisible(self.win.getFocus() == self.win.controls[int(item)]['control'])
if (len(items) > 0): continue
# fix Control.IsVisible(id) visibility condition
items = re.findall(pattern2, visible)
for item in items:
visibleChanged = True
if (self.win.controls.has_key(self.navigation[int(item)][0])):
actualId = self.win.controls[self.navigation[int(item)][0]]['controlId']
visible = re.sub(pattern2, 'control.isvisible(%d)' % actualId, visible)
# set the controls new visible condition
if (visibleChanged): self.win.controls[key]['visible'] = visible
# set the controls initial visibility
self.win.controls[key]['control'].setVisible(xbmc.getCondVisibility(visible))
except: pass
self.debugWrite('setCondVisibility', True)


Just a little heads up! Thanks to everyone that made guibuilder possible!
Reply
#2
could you post it in a code window or even upload it ?

thanks in advance
asciii
Reply
#3
Yes, Control.HasFocus() does not work currently, but you should still set the command, for when it does work.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#4
Sorry about that there is the code again.
Code:
def setCondVisibility(self):
        if (not self.fastMethod):
            self.lines[self.lineno + 1]    = 'setting up visibility...'
            t = len(self.win.controls)
        pattern1     = 'control.hasfocus\(([0-9]+)\)'
        pattern2     = 'control.isvisible\(([0-9]+)\)'
        for cnt, key in enumerate(self.win.controls.keys()):
            if (not self.fastMethod): self.dlg.update(int((float(self.pct1) / float(t) * (cnt + 1)) + self.pct), self.lines[0], self.lines[1], self.lines[2])
            try:
                visible = self.win.controls[key]['visible']
                visibleChanged = False
                # fix Control.HasFocus(id) visibility condition
                items = re.findall(pattern1, visible)
                for item in items:
            xbmc.output(str(self.win.getFocus().getId())+" == "+str(self.win.controls[int(item)]['control'].getId())+"\n")
                 visibleChanged = True                    
            xbmc.output("This is the Key: "+str(key)+"\n")
            self.win.controls[key]['control'].setVisible(self.win.getFocus() == self.win.controls[int(item)]['control'])
        if (len(items) > 0): continue
                # fix Control.IsVisible(id) visibility condition
                items = re.findall(pattern2, visible)
                for item in items:
                    visibleChanged = True
                    if (self.win.controls.has_key(self.navigation[int(item)][0])):
                        actualId = self.win.controls[self.navigation[int(item)][0]]['controlId']
                        visible = re.sub(pattern2, 'control.isvisible(%d)' % actualId, visible)
                # set the controls new visible condition
                if (visibleChanged): self.win.controls[key]['visible'] = visible
                # set the controls initial visibility
                self.win.controls[key]['control'].setVisible(xbmc.getCondVisibility(visible))
            except: pass
        self.debugWrite('setCondVisibility', True)

Just a work around till the getCondVisibility is fixed for hasFocus.
Reply
#5
Quote:added: xbmcgui.getCurrentWindowDialogID() method to python.
changed: xbmc.getCondVisibility() method now passes the current active window or windowdialog id. (Fixes Control.HasFocus() condition in python) Thanks jmarshall again.

Fixed in SVN, thanks for bringing this up.

I'm curious, was this not working for you in a WindowDialog. A Window should have worked.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#6
No i was using my own script. I didnt know about the windows dialog script until i was almost done with mine. I find out about the guibuilder from the accuweather.
Reply
#7
No, i meant in your script was it xbmcgui.Window or xbmcgui.WindowDialog?

Doesn't matter thats all irrelevant now.

theres a new method just added:

Quote:added: setVisibleCondition() to python. This allow XBMC to take care of a controls visibility.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#8
oh heheh sorry for my ignorence.

It was xbmcgui.Window .

Thanks for helping getting this bug pushed through. That was like a 1 day turnaroundSmile
Reply
#9
@Nuka1195

could you please post a little example how to use the newly added function?

thx
asciii
Reply

Logout Mark Read Team Forum Stats Members Help
gui builder work around0