PDA

View Full Version : gui builder work around


nate12o6
2007-03-04, 09:21
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!

asg
2007-03-04, 12:19
could you post it in a code window or even upload it ?

thanks in advance
asciii

Nuka1195
2007-03-04, 17:53
Yes, Control.HasFocus() does not work currently, but you should still set the command, for when it does work.

nate12o6
2007-03-04, 19:08
Sorry about that there is the code again.

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.

Nuka1195
2007-03-05, 03:34
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.

nate12o6
2007-03-05, 18:57
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.

Nuka1195
2007-03-06, 00:48
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:

added: setVisibleCondition() to python. This allow XBMC to take care of a controls visibility.

nate12o6
2007-03-06, 05:03
oh heheh sorry for my ignorence.

It was xbmcgui.Window .

Thanks for helping getting this bug pushed through. That was like a 1 day turnaround:)

asg
2007-03-06, 12:46
@Nuka1195

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

thx
asciii