ControlLabel and xbmcgui
#1
Hello all:

i'm doing some things in python and it seems to need in some circunstancies some new features in xbmcgui such as string ControlLabel.getLabel().
I know... when someone create a new label he knows the text in this label, but in some cases it will be useful and would save use of innecessary global variables.

When you want to make a ControlLabel that dinamically and conditionally change its text you should make a variable to store that text and evaluate it. In some cases that variable needs to be a global variable. It should not be neccesary.

Thanks for read Smile and much many thanks for be there trying to understand what i mean

SAME (Sorry About My English)
Reply
#2
I think it's simple and you must only modify the file:

trunk/XBMC/guilib/GUILabelControl.cpp

adding ( i guess):

String CGUILabelControl::SetLabel(void)
{
return strLabel;
}

It could be useful since i'm trying to write on a standard usb keyboard and don't want to use On Screen Keyboard.
I'm doing something like:

def onAction(self, action):
key_code=action.getButtonCode()
ascii_code=key_code - KEY_VKEY
global msginputbox
if ascii_code < 256:
thechar=chr(ascii_code)
if key_code == (KEY_VKEY + 59): #Esc -> exit
self.close()
elif key_code == (KEY_VKEY + 45): #enter
self.addLine(msginputbox)
msginputbox=""
elif key_code == (KEY_VKEY + 40): #backspace
msginputbox=msginputbox[:len(msginputbox)-1]
else:
msginputbox+=thechar
self.lblinputbox.setLabel(msginputbox)
self.mymsg.setLabel(str(ascii_code))

I know... it's not complete. If i could get the label directly the variable msginputbox would be a local variable instead of a global variable and the code could be cleaner ( cleaner? )

Thx
Reply
#3
GetDescription() code should already to this in the label control.

You "just" have to add the python method to access that.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#4
Ups!
various corrections ...

String CGUILabelControl::GetLabel(void)
{
return strLabel;
}

heheh ... i wrote SetLabel before Tongue sorry

KEY_VKEY=61408 ( i use this value to... you know that)
Reply
#5
Code:
Index: xbmc/lib/libPython/xbmcmodule/controllabel.cpp
===================================================================
--- xbmc/lib/libPython/xbmcmodule/controllabel.cpp (revision 9759)
+++ xbmc/lib/libPython/xbmcmodule/controllabel.cpp (working copy)
@@ -133,8 +133,27 @@
     return Py_None;
   }

+  // getLabel() Method
+  PyDoc_STRVAR(getLabel__doc__,
+    "getLabel() -- Returns the text value for this label.\n"
+    "\n"
+    "example:\n"
+    "  - label = self.label.getLabel()\n");
+
+  PyObject* ControlLabel_GetLabel(ControlLabel *self, PyObject *args)
+  {
+    if (!self->pGUIControl) return NULL;
+    
+    PyGUILock();
+    const char *cLabel = self->strText.c_str();
+    PyGUIUnlock();
+
+    return Py_BuildValue("s", cLabel);
+  }
+
   PyMethodDef ControlLabel_methods[] = {
     {"setLabel", (PyCFunction)ControlLabel_SetLabel, METH_VARARGS, setLabel__doc__},
+    {"getLabel", (PyCFunction)ControlLabel_GetLabel, METH_VARARGS, getLabel__doc__},
     {NULL, NULL, 0, NULL}
   };
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#6
Indeed - commit away Wink
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#7
Thanks, Revision 9765
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#8
Nuka1195 thanks again. Great job.
That issues make XBMC a great mediacenter.

Thanks
Reply

Logout Mark Read Team Forum Stats Members Help
ControlLabel and xbmcgui0