Advertisement
Guest User

Untitled

a guest
Jun 24th, 2023
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import xbmcgui
  2. from resources.scripts.GetAllSportsScript import get_sports
  3.  
  4. def create_sport_buttons(window):
  5. # Get the sports data from the GetAllSportsScript.py
  6. sports_data = get_sports()
  7.  
  8. # Loop through the sports data and create buttons dynamically
  9. for index, sport in enumerate(sports_data):
  10. button_id = 'SportButton{}'.format(index + 1)
  11. button_label = sport['name']
  12.  
  13. # Create the button control
  14. button = xbmcgui.ControlButton(id=button_id, label=button_label)
  15.  
  16. # Add the button to the window
  17. window.addControl(button)
  18.  
  19.  
  20. def show_all_sports():
  21. # Create the window
  22. window = xbmcgui.Window(13001)
  23.  
  24. # Create sport buttons in the window
  25. create_sport_buttons(window)
  26.  
  27. # Show the window
  28. window.doModal()
  29.  
  30. # Close the window once it's no longer needed
  31. del window
  32.  
  33.  
  34. # Entry point of the script
  35. if __name__ == '__main__':
  36. # Call the function to show all sports
  37. show_all_sports()
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement