What am I missing?

Why does this code:[code]
#populute the navigation buttons
#get the list of windows
windows = system.gui.getWindowNames()
button = 1

#we only have 20 buttons
for path in windows:
if button < 20 and path[:8] == ‘Onelines’: #compare the first 8 chars only
selector = system.gui.getParentWindow(event).getComponent(“Button 1”)
def updateButton(selector, path):
selector.ButtonLabel = path[9:] #strip ‘Onelines:’
selector.WindowName = path
selector.visable = 1
system.gui.invokeLater(selector, path)
button += 1
[/code]produce this error[code]
Traceback (most recent call last):

File “event:internalFrameOpened”, line 9, in

TypeError: getComponent(): 1st arg can’t be coerced to int

Ignition v7.5.6 (b1317)
Java: Oracle Corporation 1.7.0_15
[/code]

is the function you are looking for in the util group. also i think you have to send the name of the function and you have to set defaults for the parameters because they cannot be passed in the call with invokeLater.

[code]#populute the navigation buttons
#get the list of windows
windows = system.gui.getWindowNames()
button = 1

#we only have 20 buttons
for path in windows:
if button < 20 and path[:8] == ‘Onelines’: #compare the first 8 chars only
selector = system.gui.getParentWindow(event).getComponent(“Button 1”)
def updateButton(selector=selector, path=path):
selector.ButtonLabel = path[9:] #strip ‘Onelines:’
selector.WindowName = path
selector.visable = 1
system.util.invokeLater(updateButton)
button += 1[/code]

Jonathan’s revisions are correct, and also you need to revise line 9 to include a rootContainer property reference:

selector = system.gui.getParentWindow(event).rootContainer.getComponent("Button 1")
1 Like

Thanks James,

The root container thing was the missing key.

And thank you Jonathan for solving my next problem before I even get to it. :thumb_left: