×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    101

    Right justify text in listbox

    I'd like to display text in a listbox so that one part of the string is against the left margin and another is against the right margin.

    As far as I can tell, listbox uses a variable width font, so that the simple method of inserting spaces in the middle of the string to push part of the string to the right will not work. It does not appear possible to change the font to a fixed width font (or to make any other changes to the font) without either rewriting listbox, creating a customized listbox on canvas or the like.

    Is there a simpler way to put a part of a string against the right margin?

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Right justify text in listbox

    Unfortunately no. Your only options are the ones you mentioned (rewriting Listbox/making a C++ extension or creating one on a canvas). There is an example of a listbox on canvas here, if it helps.

  3. #3
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    101

    Re: Right justify text in listbox

    I can't get that CanvasListBox demo to run on 1.9.6 emulator running under winXP. It stops at the "fh =" line in check_default_values. A note statement right before it displays, then nothing. A note statement in the for loop just before never displays, which is not a good sign

    Any ideas?

  4. #4
    Wiki Moderators
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,779

    Re: Right justify text in listbox

    Quote Originally Posted by foosion View Post
    I can't get that CanvasListBox demo to run on 1.9.6 emulator running under winXP. It stops at the "fh =" line in check_default_values. A note statement right before it displays, then nothing. A note statement in the for loop just before never displays, which is not a good sign

    Any ideas?
    From the same article,

    The code was tested only in Nokia E71 and Python 1.4.5.
    If you use 1.9.x, you might have to do some changes as it might not work out of the box.
    Pankaj Nathani
    www.croozeus.com

  5. #5
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    101

    Re: Right justify text in listbox

    It seems to work in 1.9.6 if you make the measure_text text string unicode

    - fh = -(graphics.Image.new((1,1)).measure_text("[qg_|^y",font=self.attrs['font_name'])[0][1])

    + fh = -(graphics.Image.new((1,1)).measure_text(u"[qg_|^y",font=self.attrs['font_name'])[0][1])
    Last edited by foosion; 2009-08-09 at 14:11.

  6. #6
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    101

    Re: Right justify text in listbox

    However, as far as I can tell, pys60 does not offer a fixed width font. I tried every font in available_fonts and none were fixed width. Am I missing something?

    This makes putting part of a string against the left margin and part against the right very difficult. The best I can think of is iteratively adding spaces in the middle of the string and measuring the coordinates of the right edge.

    EDIT: http://wiki.forum.nokia.com/index.ph..._get_GDR_fonts may help
    Last edited by foosion; 2009-08-09 at 14:56.

Similar Threads

  1. HELP! How to get the ListBox text?
    By joseph.m in forum Symbian
    Replies: 9
    Last Post: 2008-09-18, 06:20
  2. Can I change listbox item text?
    By aluzi in forum Symbian
    Replies: 6
    Last Post: 2008-03-25, 06:31
  3. Usage of sprites to swap text in the ListBox.
    By nms_pnr in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-10-30, 09:23
  4. No data text on empty listbox
    By kis_spn in forum Symbian
    Replies: 1
    Last Post: 2007-03-24, 11:44
  5. Replies: 0
    Last Post: 2004-11-24, 18:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •