PDA

View Full Version : Text Entry Widget


madtw
2004-03-26, 07:31
can anyone tell me if the text entry widget is exposed via the xbmcgui module in python? *i took a look at the python.txt file mentioned in an earlier message but didn't see anything about it in there. *if you're wondering which widget i'm talking about, it is the location search widget used in the weather settings screen.

this would be very handy to have available. *i'd like to use something like it to be able configure the hostname, database, user, password for accessing the mythtv database. *also, it would be handy in a schedule search screen for searching the mythtv television schedule or recorded shows.

if it isn't possible, then i think i might try to write a custom window in python to be able to enter text.

alx5962
2004-03-26, 09:39
i requested it, so i hope darkie will hear me http://www.xboxmediaplayer.de/forums/non-cgi/emoticons/wink.gif

but for now it's not included

darkie
2004-03-26, 10:27
alx5962, i heard you :)
and keyboard support in python will be added. i'll try to do it today.

alx5962
2004-03-26, 11:02
alx5962, i heard you :)
and keyboard support in python will be added. i'll try to do it today.
darkie you are my idol :lol:

dop
2004-03-26, 11:13
as we are currently talking about features in this thread, will there be a 'list' control? there is already a select dialog but i wanted to add a list to my normal window.

i could of course create one from scratch, but if it's on the todo list.. :).

darkie
2004-03-26, 22:01
just added your keyboard to cvs

example of how to use it

import xbmc

keyboard = xbmc.keyboard('name')
keyboard.domodal()

if (keyboard.isconfirmed())
*print keyboard.gettext()
else
*print 'user canceled'

alx5962
2004-03-26, 23:03
thank you :)
now i expect to see a cvs release very soon !

darkie
2004-04-06, 18:19
as we are currently talking about features in this thread, will there be a 'list' control? there is already a select dialog but i wanted to add a list to my normal window.

i could of course create one from scratch, but if it's on the todo list.. .
just added one to cvs for you
check windowexample.py on how you can use it

nlemoz
2004-04-07, 05:02
seeing as easter seems to have come early over here, a function like:

getlabellength(font,string)

that would return the length of a text label using this font with this text. alternately, a 'text box' that automatically split lines at a certain (pixel) width (but only at specific characters eg spaces) and returned the total lines used would be good.

would make life much easier writing for multiple resolutions and laying out text.

nlemoz
2004-04-07, 05:03
seeing as easter seems to have come early over here, a function like:

getlabellength(font,string)

that would return the length of a text label using this font with this text. alternately, a 'text box' that automatically split lines at a certain (pixel) width (but only at specific characters eg spaces) and returned the total lines used would be good.

would make life much easier writing for multiple resolutions and laying out text.

darkie
2004-04-07, 19:43
that would return the length of a text label using this font with this text. alternately, a 'text box' that automatically split lines at a certain (pixel) width (but only at specific characters eg spaces) and returned the total lines used would be good.
a textbox has been added 3 days ago or so,
see readme_python.txt for details

madtw
2004-04-08, 05:03
getlabellength(font,string)

that would return the length of a text label using this font with this text. alternately, a 'text box' that automatically split lines at a certain (pixel) width (but only at specific characters eg spaces) and returned the total lines used would be good.

hmmm... i was just going to start figuring out how many horizontal pixels each character in font14 and font16 takes up. i already wrote a function to split a string into multiple lines at white space characters but it does it based on string length instead of actual pixel length. having a function like the one you mentioned above would definitely be handy... or a function that returned font attributes (e.g. pixel height of font, base line pixel height, character pixel widths, etc.) would be useful. then python utility functions can be written to do whatever calculations are needed.

madtw
2004-04-08, 10:00
here is a class that i put together by trial and error for handling font14 character widths... i haven't done other fonts yet.


class fontattr:
def ( self, name ):
if name == "font14":
self.initfont14()
else:
raise gui.exception, "unsupported font '" + name + "'"
self.name = name

def initfont14( self ):
self.height = 14
self.width = [ \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
# sp ! " # $ % & '
0, 0, 6, 6, 8, 14, 10, 19, 13, 4,
#( ) * + , - . / 0 1
7, 7, 24, 14, 6, 7, 6, 7, 10, 10,
#2 3 4 5 6 7 8 9 : ;
10, 10, 10, 10, 10, 10, 10, 10, 7, 7,
#< = > ? @ a b c d e
14, 14, 14, 9, 17, 11, 11, 11, 13, 11,
#f g h i j k l m n o
10, 13, 13, 7, 8, 11, 9, 15, 13, 13,
#p q r s t u v w x y
10, 13, 12, 11, 11, 12, 11, 17, 11, 11,
#z [ \ ] ^ _ ` a b c
11, 7, 7, 7, 14, 10, 10, 10, 11, 9,
#d e f g h i j k l m
11, 10, 6, 11, 11, 4, 5, 9, 4, 16,
#n o p q r s t u v w
11, 10, 11, 11, 7, 8, 6, 11, 9, 14,
#x y z { | } ~
9, 9, 8, 9, 7, 9, 14
]

def getwidth( self, c ):
return self.width[ord(c)]

No0ne
2004-04-10, 12:48
where can i find the readme_python.txt file at?

alx5962
2004-04-10, 14:01
where can i find the readme_python.txt file at?
check xbmc cvs -> /docs/

jastorino
2004-04-11, 01:21
i have just started using python and i am trying to use the controlbutton widget. i noticed that when i add a button, it doesn't look like a button, it simply looks like a label blending into the background until i select it, at which time it looks like a button.

i am simply using "controlbutton(posx, posy, sizex, sizey, font)"

can someone suggest the right way of making the button visible when not selected?

also, i noticed in this post that there were changes made to python and added to cvs as recent as april 6th, but the only version i found in cvs is approx 2 months old (ver 1.3).
is that the latest up to date version?

thanks for your help.

No0ne
2004-04-13, 16:22
your default button color is probably the same as your background color therefore it blends in possibly.

madtw
2004-04-14, 05:00
have you tried supplying a focus texture and a no focus texture? here is the relevant info from the python_readme.txt.

xbmcgui.controlbutton(int x, int y, int width, int height[, string text, string texturefocus, string texture nofocus])

the texturefocus and texturenofocus parameters will probably need to be full paths to the texture files unless you are reusing the textures in texture.xpr (i.e. q:\skin\mediacenter\media\buttonfocus.png). you can call xbmc.getskindir() instead of hard coding "mediacenter" in the path if you like...