Re: [Rhythmbox-devel] How to get a specific source?



On Mon, Nov 23, 2009 at 3:24 PM, Jannik Heller <scrawl baseoftrash de> wrote:
>
> Hi,
>
> I want to get a specific source (radio source) in my Python plugin. By
> googling around, i found this one:
>
> http://www.mail-archive.com/rhythmbox-devel gnome org/msg04659.html
>
> for group in shell.props.sourcelist_model:
>    print 'Group name: ', group[2]
>    for source in group.iterchildren():
>        for props in source:
>            print props
>
> It gives the following output:
>
> Radio
> <__main__.RBIRadioSource object at 0x30904b0 (RBIRadioSource at 0x2681000)>
> <PangoAttrList at 0x2da9240>
> True
> False
>
> Unfortunately, the name property ("Radio") is translated in the user's language, so it seems rather ugly to use it to determine whether it's the radio source.
>
> Maybe there is even an easier way to get the radio source, or maybe i can check if the object is of type RBIRadioSource, but I don't know how to do this in Python.
>
> Any help is appreciated!

Try something like isinstance(source, RBIRadioSource), adjusted according
to how you have imported the reference to the RBIRadioSource class.

Peter


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]