2018-03-01, 16:20
I'm trying to show 4 side-by-side pyxbmct.lists and sync the scrolling between them. However, I can't find a method that allows me to set the index of the lists. I know there is list.getSelectedPosition(), but no documentation on list.setSelectedPosition(), which I was hoping for. Is there any way that I can link the scrolling between the four lists?
Below is the sample code in which I try to accomplish simultaneous scrolling. Any help is appreciated.
Below is the sample code in which I try to accomplish simultaneous scrolling. Any help is appreciated.
python:
class Plays(pyxbmct.AddonFullWindow):
def __init__(self, title='NBA'):
super(Plays, self).__init__(title)
#Geometry(Width, Height, Rows, Columns)
#New Addon Windows always have 1280x720 grid
self.setGeometry(1280, 720, 27, 4)
teamheader = pyxbmct.Label('Team', alignment=pyxbmct.ALIGN_CENTER)
self.placeControl(teamheader, 0, 0)
timeheader = pyxbmct.Label('Time', alignment=pyxbmct.ALIGN_CENTER)
self.placeControl(timeheader, 0, 1)
playheader = pyxbmct.Label('Play', alignment=pyxbmct.ALIGN_CENTER)
self.placeControl(playheader, 0, 2)
scoreheader = pyxbmct.Label('Score', alignment=pyxbmct.ALIGN_CENTER)
self.placeControl(scoreheader, 0, 3)
self.listing1 = pyxbmct.List(_imageWidth=35, _imageHeight=35, _itemHeight=35)
self.placeControl(self.listing1, 1, 0, rowspan=26)
self.listing2 = pyxbmct.List(_imageWidth=35, _imageHeight=35, _itemHeight=35)
self.placeControl(self.listing2, 1, 1, rowspan=26)
self.listing3 = pyxbmct.List(_imageWidth=35, _imageHeight=35, _itemHeight=35)
self.placeControl(self.listing3, 1, 2, rowspan=26)
self.listing4 = pyxbmct.List(_imageWidth=35, _imageHeight=35, _itemHeight=35)
self.placeControl(self.listing4, 1, 3, rowspan=26)
self.connectEventList(
[pyxbmct.ACTION_MOVE_DOWN,
pyxbmct.ACTION_MOVE_UP,
pyxbmct.ACTION_MOUSE_WHEEL_DOWN,
pyxbmct.ACTION_MOUSE_WHEEL_UP,
pyxbmct.ACTION_MOUSE_MOVE],
self.list_update)
# Connect a key action (Backspace) to close the window.
self.connect(pyxbmct.ACTION_NAV_BACK, self.close)
def list_update(self):
try:
if self.getFocus() == self.listing1:
new_position = self.listing1.getSelectedPosition()
self.listing2.setSelectedPosition(new_position)
self.listing3.setSelectedPosition(new_position)
self.listing4.setSelectedPosition(new_position)
else:
pass
except (RuntimeError, SystemError):
pass
#row, column[, rowspan, columnspan]
def setup(self, obj):
image_items =
time_items =
play_items =
score_items =
for quarter in obj:
for play in quarter:
"""
list_item = xbmcgui.ListItem(label='%s %s %s' % (play['Time'], play['Play'], play['Score']))
list_item.setArt({'icon':play['Team']})
list_items.append(list_item)
"""
#placeholders.append('')
image_item = xbmcgui.ListItem(label='')
image_item.setArt({'icon':play['Team']})
image_items.append(image_item)
time_item = xbmcgui.ListItem(label=play['Time'])
time_items.append(time_item)
play_item = xbmcgui.ListItem(label=play['Play'])
play_items.append(play_item)
score_item = xbmcgui.ListItem(label=play['Score'])
score_items.append(score_item)
#self.listing.addItems(list_items)
self.listing1.addItems(image_items)
self.listing2.addItems(time_items)
self.listing3.addItems(play_items)
self.listing4.addItems(score_items)
pbp_list = nba.get_playbyplay(playbyplay_link)
if len(pbp_list) > 0:
playbyplay_window = playbyplay.Plays()
playbyplay_window.setup(pbp_list)
playbyplay_window.doModal()
del playbyplay_window