Release - PyXBMCt: a Python framework for simple creating UI for XBMC addons

  Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Roman_V_M Offline
Team-Kodi Member
Posts: 1,022
Joined: Jun 2011
Reputation: 49
Location: Kyiv, Ukraine
Post: #241
(2016-10-01 17:11)unreal Wrote:  
(2016-10-01 14:23)Roman_V_M Wrote:  
(2016-10-01 09:34)unreal Wrote:  How do I open this menu with a kodi listitem?

I can open the menu at the beginning of the addon. But I wanna open it with a listitem.

You mean like in a media plugin? There is no difference where to use PyXBMCt - on the module lever or in functions. Just put your PyXBMCt-related code into the part of your plugin that is called by the respective ListItem.

That sounds really easy, but how would that look like. I'm more a java programmer then a python programmer. Maybe that is why is harder for me to implement. Let me give you a idea of our addon. We have a for loop that parses urls from a website. And we add to that a web url link.

Our code is really basic.

This has nothing to do with Java vs. Python. For me, Kodi-Python API looks more like Java than Python. If you want to create a media plugin to present your media content in Kodi then you are using a wrong approach because your code makes no sense to me (why playlists?). There are 2 sticky topics in this forum section with video and audio plugin examples (I made the video example, actually). Look at those examples and try to make something similar.

Raspberry PI 2 + LibreELEC 7 (Kodi 16)
Acer IconiaTab A510 + Kodi 14.2 for Android
find quote
unreal Offline
Junior Member
Posts: 7
Joined: Jun 2016
Reputation: 0
Post: #242
You mean the tutorials from zag?
(This post was last modified: 2016-10-02 19:48 by unreal.)
find quote
Roman_V_M Offline
Team-Kodi Member
Posts: 1,022
Joined: Jun 2011
Reputation: 49
Location: Kyiv, Ukraine
Post: #243
(2016-10-02 18:34)unreal Wrote:  You mean the tutorials from zag?

Yes (though the example video plugin was actually created by me). You need to create a proper plugin and then you can insert PyXBMCt-related stuff into one of your functions that are called depending on a plugin call URL and a query string. You don't see this URL (only in the Kodi log), it's used by Kodi internally and passed to a plugin in sys.argv. In this aspect a Kodi content plugin is very much like a web application that performs a set of actions (usually renders a certain web-page) depending on the provided URL and a query string (if any). Unlike a web-application, a plugin create a set of list items representing your media content or virtual folders that open lower level menus.

Raspberry PI 2 + LibreELEC 7 (Kodi 16)
Acer IconiaTab A510 + Kodi 14.2 for Android
find quote
Roman_V_M Offline
Team-Kodi Member
Posts: 1,022
Joined: Jun 2011
Reputation: 49
Location: Kyiv, Ukraine
Post: #244
Version 1.2.0 has been released to the Kodi repo. In this version a new Estuary-based skin was added in addition to the old Confluence-based one. You can see the new PyXBMCt skin on th the screenshots in the 1-st post of this topic.

By default a skin is selected depending on Kodi version: Estuary-based one for 17.0 Krypton and above, and Confluence-based for earlier versions. However, a skin can be set explicitly. More info is here: http://romanvm.github.io/script.module.p...tuary.html

Also this release includes a fix for a long-standing bug with broken connection management in Blank* classes.

Also note the new URL for PyXBMCt documentation: http://romanvm.github.io/script.module.pyxbmct/

Raspberry PI 2 + LibreELEC 7 (Kodi 16)
Acer IconiaTab A510 + Kodi 14.2 for Android
find quote
chris.jones1989 Offline
Junior Member
Posts: 3
Joined: Jun 2015
Reputation: 0
Post: #245
Hi There

I am trying to adjust the font size of controls such as list items , buttons , labels ect and can not seem to figure it out.
Also there a way to remove controls from the gui and then replace with another control so in other words remove a set of controls to make room for another set of controls

Any help would be much appreciated and great work thank you
find quote
Roman_V_M Offline
Team-Kodi Member
Posts: 1,022
Joined: Jun 2011
Reputation: 49
Location: Kyiv, Ukraine
Post: #246
(2016-10-25 03:05)chris.jones1989 Wrote:  Hi There

I am trying to adjust the font size of controls such as list items , buttons , labels ect and can not seem to figure it out.

Some Controls accept "font" argument that is a font alias from the current skin. For example, these are font aliases from Estuary skin.

However, it will work only in one skin. If a user changes skin, the default font from that skin will be used, so setting a specific font will only work if you are absolutely sure that your users will use only one skin or a limited set of skins.

Quote:Also there a way to remove controls from the gui and then replace with another control so in other words remove a set of controls to make room for another set of controls

Controls have SetVisible method that allows to hide and show Controls programmatically. Since Controls can occupy the same space inside a Kodi window, you can easily replace a Control or a group of Controls with another Control/Group by calling .setVisible(False)/setVisoible(True) for the respective Controls.

Raspberry PI 2 + LibreELEC 7 (Kodi 16)
Acer IconiaTab A510 + Kodi 14.2 for Android
find quote
chris.jones1989 Offline
Junior Member
Posts: 3
Joined: Jun 2015
Reputation: 0
Post: #247
Hi Roman

Thank you for your quick response it is much appreciated

so i have tried what you set by using the setVisible() on the control but i get the following error in the kodi log: AttributeError: 'List' object has no attribute 'setVisbile'

This is the line of code i used - self.liveTVList.setVisbile(False)

I am also struggling to get the s[/code]et text from and edit input i have tried the following but with no luck :
[code]
def setCredentials(self):
username = self.usernameINP.getText()
password = self.passwordINP.getText()
print '********\nUSERNAME: ' + username + '\nPassword: ' + password + '*********************'


Any Help would be appreciated
find quote
Roman_V_M Offline
Team-Kodi Member
Posts: 1,022
Joined: Jun 2011
Reputation: 49
Location: Kyiv, Ukraine
Post: #248
2 chris.jones1989


Sorry, but your description is very vague. setVisible method (sorry for a typo in my post above, but you have figured it yourself) does exist and it does work. Please provide your full code and detailed descriptions of errors your are getting, not just "no luck". For large code samples it's better to use some external pastebin site with proper syntax highlighting and all.

Raspberry PI 2 + LibreELEC 7 (Kodi 16)
Acer IconiaTab A510 + Kodi 14.2 for Android
find quote
Hellcube Offline
Junior Member
Posts: 11
Joined: Apr 2014
Reputation: 0
Post: #249
Button executes script on plugin load not when the button is pushed/clicked why?

button1 = pyxbmct.Button('MYLIGHT')
window.placeControl(button1, 0)
window.connect(button1, subprocess.Popen(["c:\curl.exe", "http://MYTESTURL.COM:80/lights.php?onoff1"]))

Maybe another better way to do it?
find quote
Roman_V_M Offline
Team-Kodi Member
Posts: 1,022
Joined: Jun 2011
Reputation: 49
Location: Kyiv, Ukraine
Post: #250
(2016-11-13 18:14)Hellcube Wrote:  Button executes script on plugin load not when the button is pushed/clicked why?

button1 = pyxbmct.Button('MYLIGHT')
window.placeControl(button1, 0)
window.connect(button1, subprocess.Popen(["c:\curl.exe", "http://MYTESTURL.COM:80/lights.php?onoff1"]))

Maybe another better way to do it?

Hint: the documentation is your friend.Smile

Raspberry PI 2 + LibreELEC 7 (Kodi 16)
Acer IconiaTab A510 + Kodi 14.2 for Android
find quote
Hellcube Offline
Junior Member
Posts: 11
Joined: Apr 2014
Reputation: 0
Post: #251
(2016-11-14 13:26)Roman_V_M Wrote:  
(2016-11-13 18:14)Hellcube Wrote:  Button executes script on plugin load not when the button is pushed/clicked why?

button1 = pyxbmct.Button('MYLIGHT')
window.placeControl(button1, 0)
window.connect(button1, subprocess.Popen(["c:\curl.exe", "http://MYTESTURL.COM:80/lights.php?onoff1"]))

Maybe another better way to do it?

Hint: the documentation is your friend.Smile

It is my friend from now on Smile
Thank You. You did a great framework, it works perfectly...

[Image: EeG38gx.jpg]
find quote
chris.jones1989 Offline
Junior Member
Posts: 3
Joined: Jun 2015
Reputation: 0
Post: #252
Hi

Just wondering if you could tell me if it is possible to add an image to a button using this framework. If so could you point me in the right direction.

Example:

I would like to use an image with a maintenance logo on it and use this as a button so i can have my own custom buttons.

Any help is much appreciated
(This post was last modified: 2017-01-04 01:58 by chris.jones1989.)
find quote
Roman_V_M Offline
Team-Kodi Member
Posts: 1,022
Joined: Jun 2011
Reputation: 49
Location: Kyiv, Ukraine
Post: #253
(2017-01-04 01:57)chris.jones1989 Wrote:  Hi

Just wondering if you could tell me if it is possible to add an image to a button using this framework. If so could you point me in the right direction.

Example:

I would like to use an image with a maintenance logo on it and use this as a button so i can have my own custom buttons.

Any help is much appreciated

pyxbmct.Button that is a thin wrapper around xbmcgui.ControlButton uses 2 image files that define its appearance (a text label is optional):
noFocusTexture: displayed when a Button is not focused
focusTexture: displayed when a Button is focused, that is when you navigate to it with a keyboard/remote or hover a mouse pointer over it.
PyXBMCt provides its own default textures but you can override them using these keyword arguments to the class constructor.

Raspberry PI 2 + LibreELEC 7 (Kodi 16)
Acer IconiaTab A510 + Kodi 14.2 for Android
find quote
Protocol-X Offline
Senior Member
Posts: 173
Joined: Aug 2016
Reputation: 4
Post: #254
(2017-01-04 13:58)Roman_V_M Wrote:  
(2017-01-04 01:57)chris.jones1989 Wrote:  Hi

Just wondering if you could tell me if it is possible to add an image to a button using this framework. If so could you point me in the right direction.

Example:

I would like to use an image with a maintenance logo on it and use this as a button so i can have my own custom buttons.

Any help is much appreciated

pyxbmct.Button that is a thin wrapper around xbmcgui.ControlButton uses 2 image files that define its appearance (a text label is optional):
noFocusTexture: displayed when a Button is not focused
focusTexture: displayed when a Button is focused, that is when you navigate to it with a keyboard/remote or hover a mouse pointer over it.
PyXBMCt provides its own default textures but you can override them using these keyword arguments to the class constructor.

Hi Roman_V, I noticed a typo in your documentation at line 473 if you view the source code.
After you create the control, you need to add it to the window with <code class="docutils literal"><span class="pre">palceControl()</span></code>.</p> Just giving you a heads up in case someone were to try to use it and get an exception,
find quote
Roman_V_M Offline
Team-Kodi Member
Posts: 1,022
Joined: Jun 2011
Reputation: 49
Location: Kyiv, Ukraine
Post: #255
@Protocol-X, thanks for noticing that!

Raspberry PI 2 + LibreELEC 7 (Kodi 16)
Acer IconiaTab A510 + Kodi 14.2 for Android
find quote
Post Reply