Problems with GUI
#1
Question 
Hi there,

I created my first add-on (which works) but I have problems with the GUI. I used

Code:
class FirstTry(xbmcgui.Window):
  def __init__ (self):
    xbmc.log('init class')
    height = 35
    width = 500
    left = (self.getWidth() - width)/2
    top  = (self.getHeight() - height*5)/2
    
    self.button1=xbmcgui.ControlRadioButton(left, top+0*height, width, height, 'text 1')
    self.addControl(self.button1)

which creates a window that exceeds the screen (the screen gets complete dark and the radiobutton is displayed somewhere in the middle). Is there any possibility to adjust the size of the created dialog?

thanks in advance

Sebastian
Reply
#2
(2014-04-09, 06:48)cadguru Wrote: Hi there,

I created my first add-on (which works) but I have problems with the GUI. I used

Code:
class FirstTry(xbmcgui.Window):
  def __init__ (self):
    xbmc.log('init class')
    height = 35
    width = 500
    left = (self.getWidth() - width)/2
    top  = (self.getHeight() - height*5)/2
    
    self.button1=xbmcgui.ControlRadioButton(left, top+0*height, width, height, 'text 1')
    self.addControl(self.button1)

which creates a window that exceeds the screen (the screen gets complete dark and the radiobutton is displayed somewhere in the middle). Is there any possibility to adjust the size of the created dialog?

thanks in advance

Sebastian

First, you didn't create a dialog per se. For modal dialogs you need to use xbmcgui.WindowDialog class. But the main problem is that both xbmcgui.Window and xbmcgui.WindowDialog classes are merely basic containers without any visual elements whatsoever. So what you've got is completely normal behavior unless you add some visual decorations to your dialog.
I'd recommend to consider my PyXBMCt mini-framework: http://forum.xbmc.org/showthread.php?tid=174859
It includes ready-to-use container and control classes to create your own addon UI using Python only and shares the same principles as "real" desktop GUI frameworks.
Reply
#3
Hi Roman,

I will give it a try. Is there also a possibility to create "radiobuttons" with images instead of pure text?

tia

Sebastian
Reply
#4
(2014-04-09, 12:49)cadguru Wrote: Hi Roman,

I will give it a try. Is there also a possibility to create "radiobuttons" with images instead of pure text?

tia

Sebastian

I'm not sure what you mean. RadioButton control is decorated with 4 texture images: unfocused background, focused background, button off and button on. In case of pure xbmcgui.ControlRadioButton class you need to provide all those 4 textures explicitly. PyXBMCt includes all necessary texture images for its controls, that's why they are "ready-to-use".
Reply
#5
Hi Roman,

I want to use my own images and have problems with setting the images. Do you have an example for this?

tia

Sebastian
Reply
#6
(2014-04-09, 16:19)cadguru Wrote: Hi Roman,

I want to use my own images and have problems with setting the images. Do you have an example for this?

tia

Sebastian

You can see how it's done in PyXBMCt code.
Also you can read the documentation for xbmcgui.ControlRadioButton class.

Basically, you need to provide full paths to your texture image files (e.g. PNG) via 6 keyword arguments:
Quote:focusTexture: string - filename for focus texture.
noFocusTexture: string - filename for no focus texture.
focusOnTexture: string - filename for radio focused/checked texture.
noFocusOnTexture: string - filename for radio not focused/checked texture.
focusOffTexture: string - filename for radio focused/unchecked texture.
noFocusOffTexture: string - filename for radio not focused/unchecked texture.
If you textures and paths are correct, you should get something like this:
[Your text goes here ʘ]
Agruments 1-2 are for general background - unfocused and focused: [ ]
Arguments 4-6 are for the button 'knob' itself: ʘ. focus and noFocus textures for the 'knob' can be the same.
Please note that this call signature is for Gotham. In Frodo and earlier xbmcgui.ControlRadioButton has different constructor signature and requires only 4 keyword arguments for textures.
Reply
#7
Hi Roman,

thanks to you and PyXBMCt, my project seems to be on its way... I still struggle with the xbmcgui documentation. I ask the questions here because it is not PyXBMCt related. If I should start another post just let me know.

I created something like:
Code:
def set_controls(self):
    xbmc.log('set_controls')
    self.buttonSteam=RadioButton('',
      focusTexture=os.path.join(__addondir__, 'resources', 'MenuItemFO.png'),
      noFocusTexture=os.path.join(__addondir__, 'resources', 'MenuItemNF.png'),
      TextureRadioFocus=os.path.join(__addondir__, 'resources', 'slice_1_1.png'),
      TextureRadioNoFocus=os.path.join(__addondir__, 'resources', 'slice_0_1.png'))
    self.placeControl(self.buttonSteam, 0, 0)
    self.buttonSteam.setRadioDimension(1, 0, 150, 150)
    self.connect(self.buttonSteam, self.button_onClick)
    
    self.buttonLight=RadioButton('',
      focusTexture=os.path.join(__addondir__, 'resources', 'MenuItemFO.png'),
      noFocusTexture=os.path.join(__addondir__, 'resources', 'MenuItemNF.png'),
      TextureRadioFocus=os.path.join(__addondir__, 'resources', 'slice_1_2.png'),
      TextureRadioNoFocus=os.path.join(__addondir__, 'resources', 'slice_0_2.png'))
    self.placeControl(self.buttonLight, 0, 1)
    self.buttonLight.setRadioDimension(2, 0, 150, 150)
    self.connect(self.buttonLight, self.button_onClick)

which shows the textures as wanted but the textures are a bit of. If I use setRadioDimension(0,0,150,150) the first button is completly on the edge of the window. If I change the values to (1, 0, 150, 150) the texture is moved around 7pixels to the right and there is always an offset between the TextureRadioFocus and the FocusTexture. I hope I could make myself clear. Do you have any idea to that?

tia

Sebastian
Reply
#8
(2014-04-13, 10:32)cadguru Wrote: Hi Roman,

thanks to you and PyXBMCt, my project seems to be on its way... I still struggle with the xbmcgui documentation. I ask the questions here because it is not PyXBMCt related. If I should start another post just let me know.


which shows the textures as wanted but the textures are a bit of. If I use setRadioDimension(0,0,150,150) the first button is completly on the edge of the window. If I change the values to (1, 0, 150, 150) the texture is moved around 7pixels to the right and there is always an offset between the TextureRadioFocus and the FocusTexture. I hope I could make myself clear. Do you have any idea to that?

tia

Sebastian

UI coordinate grid resolution is 1280x720 regardless of your actual display resolution, so 1 pixel in UI grid may correspond to several pixels on you display, if its resolution is bigger that UI coordinate grid, e.g. 1920x1080.
Honestly, haven't tried to customize RadioButton and never used setRadioDimension(). 4textures that I've found in XBMC's default skin.confluence rescources seemed to me as good fit, so I used them for PyXBMCt's RadioButton.
As for offset between the TextureRadioFocus and the FocusTexture, TextureRadioFocus is for radio 'knob' (round thingy that shows checked/unckeced status), so I guess the offset is used to place TextureRadioFocus on the right spot at the right side of the RadioButton.
Reply

Logout Mark Read Team Forum Stats Members Help
Problems with GUI0