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
Harvinder Offline
Junior Member
Posts: 20
Joined: May 2015
Reputation: 0
Post: #196
(2016-02-11 16:06)Roman_V_M Wrote:  
(2016-02-11 12:23)Harvinder Wrote:  Hi guys,

Im new to Python GUI with PYXBMCT, I've managed to created the layout with the buttons and images etc exactly where I want them to be etc. The part I'm stuck on is making the buttons do something.

Im using the self.connect(self.example_button, lambda: XXXXXXX) functions but not quite sure how to use it?

I have a horizontal navigation menu at the top and when you click the first button on the left I want it to display content such as image/button/info in the blank space below, I believe this is called multi-frame/window but how do I go about it?

If anybody could help me Id appreciate it allot.

Ive also looked at youtube tutorials for tkinter and tried to apply the method to pyxbmct but can't get it to work.

Thanks in Advance.

Have you read the documentation and examples for PyXBMCt? connect method accepts a function/method object that you want to execute if a Control is activated. lambda is used in special cases and you need to understand what you are doing.

With PyXBMCt you can emulate tabbed layout by creating sets of controls that are shown/hidden when a "tab" button is clicked, using their setVisible() methods.

Also, PyXBMCt is closer to PyQt as the name implies.

Hi Roman, thanks for the reply.

Yes I have viewed the startup guide and the documentation over at: http://romanvm.github.io/PyXBMCt/

I have created "Buttons" for the horizontal navigation at the top using "self.example_button = pyxbmct.Button('example')" refer to the image below:

EXAMPLE IMAGE

I will watch some tutorials on PyQt as see If I can get the buttons to work.

Thanks again.
find quote
Roman_V_M Offline
Skilled Python Coder
Posts: 801
Joined: Jun 2011
Reputation: 30
Location: Kyiv, Ukraine
Post: #197
(2016-02-11 16:23)Harvinder Wrote:  Hi Roman, thanks for the reply.

Yes I have viewed the startup guide and the documentation over at: http://romanvm.github.io/PyXBMCt/

I have created "Buttons" for the horizontal navigation at the top using "self.example_button = pyxbmct.Button('example')" refer to the image below:

EXAMPLE IMAGE

I will watch some tutorials on PyQt as see If I can get the buttons to work.

Thanks again.

PyQt tutorials will be overkill for your purpose, because PyQt is complex and developed for different purposes. Yes, PyXBMCt was influenced by PyQt, but they are not the same.

As for your scenario, as I said, you need to create sets of Controls (a set may include only one Control) that are displayed when you activate your "tabs".
Naturally, you need to connect your top buttons to function(s) that show/hide those sets of Controls by calling setVisible() method of each control.
Just to be clear: Controls may overlap and even be placed at the same spot, and by calling setVisible() of individual Controls you can show/hide them, e.g. show one Control and hide another. An invisible Control is not deleted, it still exists but is hidden and can be shown again.

AMD A4-3300 + AsRock A75M-ITX - Kodi 15.x on Windows 10
Acer IconiaTab A510 - Kodi 14.2 for Android
find quote
Harvinder Offline
Junior Member
Posts: 20
Joined: May 2015
Reputation: 0
Post: #198
(2016-02-11 16:44)Roman_V_M Wrote:  
(2016-02-11 16:23)Harvinder Wrote:  Hi Roman, thanks for the reply.

Yes I have viewed the startup guide and the documentation over at: http://romanvm.github.io/PyXBMCt/

I have created "Buttons" for the horizontal navigation at the top using "self.example_button = pyxbmct.Button('example')" refer to the image below:

EXAMPLE IMAGE

I will watch some tutorials on PyQt as see If I can get the buttons to work.

Thanks again.

PyQt tutorials will be overkill for your purpose, because PyQt is complex and developed for different purposes. Yes, PyXBMCt was influenced by PyQt, but they are not the same.

As for your scenario, as I said, you need to create sets of Controls (a set may include only one Control) that are displayed when you activate your "tabs".
Naturally, you need to connect your top buttons to function(s) that show/hide those sets of Controls by calling setVisible() method of each control.
Just to be clear: Controls may overlap and even be placed at the same spot, and by calling setVisible() of individual Controls you can show/hide them, e.g. show one Control and hide another. An invisible Control is not deleted, it still exists but is hidden and can be shown again.

Thanks, I've made some progress now. Im using the OOP method but having trouble with hiding controls using setVisible() method.

By setting the visibility in each of the tabs controls would make the code very repetitive so in order to try and make it efficient, I created a "def hide_controls()" and then listed all the controls that I would want to hide except the controls that make up the main navigation etc. However after calling in the "def hide_controls()" it doesn't display the controls that I want visible. Ive checked the error log and it says that the hide_control() isn't define globally?

I thought it would be easier to hide all the control I don't need to create a blank slate and then just re-enable the ones I wanted visible.

E.G Click a tab button > it HIDES all controls > I then enable controls I want visible.

Any ways to get around this? Or is there a different way of coding it to reduce repetition in the code.

Thanks again.
find quote
Roman_V_M Offline
Skilled Python Coder
Posts: 801
Joined: Jun 2011
Reputation: 30
Location: Kyiv, Ukraine
Post: #199
(Yesterday 02:46)Harvinder Wrote:  By setting the visibility in each of the tabs controls would make the code very repetitive so in order to try and make it efficient, I created a "def hide_controls()" and then listed all the controls that I would want to hide except the controls that make up the main navigation etc. However after calling in the "def hide_controls()" it doesn't display the controls that I want visible. Ive checked the error log and it says that the hide_control() isn't define globally?

Probably that is because it isn't defined globally indeed. Scope and names visibility are fundamental things in Python, and you need to know this and LEGB rule if you want to get somewhere.

Quote:I thought it would be easier to hide all the control I don't need to create a blank slate and then just re-enable the ones I wanted visible.

E.G Click a tab button > it HIDES all controls > I then enable controls I want visible.

Any ways to get around this? Or is there a different way of coding it to reduce repetition in the code.

Thanks again.

You cannot avoid repetition because you have to call setVisible on each Control you want to show or hide. Unfortunately, there is no –∑ythonic Group Control that would allow to control several items at once (technically, there is, but it does not work).
But I've suggested you to divide your Controls into sets or groups and control those groups individually, that is showing one group while hiding others, instead of working with all controls at once.

Or forget about PyXBMCt and try to create a skinned UI with xbmcgui.WindowXMLDialog. Skinned UIs are better suited for complex scenarios like yours.

AMD A4-3300 + AsRock A75M-ITX - Kodi 15.x on Windows 10
Acer IconiaTab A510 - Kodi 14.2 for Android
find quote
Post Reply