×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Red face Topwindow background color

    Hi
    It's possible to change the background color of the Topwindow?
    This is a piece of my code
    Code:
    screen = TopWindow.TopWindow()
    screen.background_color = 0xff0000
    This change the color of the corner but not the color background.

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Topwindow background color

    It works for me. Here is what I tried (almost identical to the wiki article):
    Code:
    import TopWindow
    from graphics import *
    import appuifw
    import e32
     
    height = 29
    width = 130
    top = 59
    left = 110
    window = TopWindow.TopWindow()
    image = Image.new((width,height))
    window.add_image(image, (width,height))
    #If only width and height are specified, the image will not be resized.
    #In order to resize the image the final coordinates must be specified as well:
    #window.add_image(image, (width,height,x2,y2))
    window.size = (width, height)
    window.corner_type = 'square'
    window.position = (left,top)
    window.background_color = 0xffa130
     
    def exit():
    	window.hide()
    	app_lock.signal()
     
    app_lock = e32.Ao_lock()
    window.show()
     
    appuifw.app.exit_key_handler = exit
    app_lock.wait()
    This displays a light-blue rectangle. I don't understand why yours wouldn't work.

  3. #3
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Re: Topwindow background color

    Looking at your code, I noticed that this piece of code was in the wrong position:

    Code:
    screen.add_image(img, (5,5,174,45))
    I put the after this piece of code and therefore did not work:

    Code:
    window.size = (width, height)
    window.corner_type = 'square'
    window.position = (left,top)
    window.background_color = 0xffa130

  4. #4
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Re: Topwindow background color

    If i add this code to try the topwindow he does not work:

    Code:
    def topwindow():
    	height = 29
    	width = 130
    	top = 59
    	left = 30
    	window = TopWindow.TopWindow()
    	image = Image.new((width,height))
    	window.add_image(image, (width,height))
    	#If only width and height are specified, the image will not be resized.
    	#In order to resize the image the final coordinates must be specified as well:
    	#window.add_image(image, (width,height,x2,y2))
    	window.size = (width, height)
    	window.corner_type = 'square'
    	window.position = (left,top)
    	window.background_color = 0xffa130
            window.show()
    
    appuifw.app.menu = [(u"Top",topwindow)]

  5. #5
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    133

    Re: Topwindow background color

    The code Bogdan gives is to change the colour of the window.

    window.background_color = 0xffa130
    Do you mean to change the window colour or the Background colour of the window?

    You will have to work on native extensions for the latter.
    Kandyfloss

    V 7.0642.0
    18-10-06
    RH-51
    Nokia 7610

  6. #6
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Re: Topwindow background color

    The code of bogdan.galiceanu works fine, but if i put him into a function does not work.
    The topwindow does not appear.

  7. #7
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    133

    Re: Topwindow background color

    Quote Originally Posted by ikaroweb80 View Post
    The code of bogdan.galiceanu works fine, but if i put him into a function does not work.
    The topwindow does not appear.
    Thats because you have deployed a menu.

    Try to implement this with a selection list.

    Code:
    def top():
    	height = 29
    	width = 130
    	top = 59
    	left = 30
    	window = TopWindow.TopWindow()
    	image = Image.new((width,height))
    	window.add_image(image, (width,height))
    	#If only width and height are specified, the image will not be resized.
    	#In order to resize the image the final coordinates must be specified as well:
    	#window.add_image(image, (width,height,x2,y2))
    	window.size = (width, height)
    	window.corner_type = 'square'
    	window.position = (left,top)
    	window.background_color = 0xffa130
                  window.show()
    
    L = [u'Top']
    # create the selection list
    index = appuifw.selection_list(choices=L , search_field=1)
    
    # use the result of the selection to trigger some action (here we just print something)
    
    if index == 0:
    	top()
    Kandyfloss

    V 7.0642.0
    18-10-06
    RH-51
    Nokia 7610

  8. #8
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Re: Topwindow background color

    I've added this line and now works fine!

    Code:
    image.clear(background)

  9. #9
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Re: Topwindow background color

    I'm try this code:

    Code:
    def top():
    	height = 29
    	width = 130
    	top = 59
    	left = 30
    	window = TopWindow.TopWindow()
    	image = Image.new((width,height))
    	window.add_image(image, (width,height))
    	#If only width and height are specified, the image will not be resized.
    	#In order to resize the image the final coordinates must be specified as well:
    	#window.add_image(image, (width,height,x2,y2))
    	window.size = (width, height)
    	window.corner_type = 'square'
    	window.position = (left,top)
    	window.background_color = 0xffa130
                  window.show()
    
    L = [u'Top']
    # create the selection list
    index = appuifw.selection_list(choices=L , search_field=1)
    
    # use the result of the selection to trigger some action (here we just print something)
    
    if index == 0:
    	top()
    I've a rgb color and the window.background_color accept only hex color, how can convert rgb to hex?

    I've tried with this code:

    Code:
    r = color[0]
    g = color[1]
    b = color[2]
    border = "%02X%02X%02X" % (r, g, b)
    border = "0x" + border 
    screen.background_color = eval(bordo)
    But the color that showed it's different from the rgb value.

  10. #10
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Topwindow background color

    Quote Originally Posted by ikaroweb80 View Post
    I've a rgb color and the window.background_color accept only hex color, how can convert rgb to hex?

    I've tried with this code:

    Code:
    r = color[0]
    g = color[1]
    b = color[2]
    border = "%02X%02X%02X" % (r, g, b)
    border = "0x" + border 
    screen.background_color = eval(bordo)
    But the color that showed it's different from the rgb value.
    I've searched the net and found this algorithm:
    Code:
    def tohex(r,g,b):
    	hexchars="0123456789ABCDEF"
    	return "0x"+hexchars[r/16]+hexchars[r%16]+hexchars[g/16]+hexchars[g%16]+hexchars[b/16]+hexchars[b%16]
    Last edited by bogdan.galiceanu; 2008-04-16 at 13:08.

  11. #11
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Re: Topwindow background color

    Now i've this error:

    Code:
    Exception:  an integer is required

  12. #12
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Topwindow background color

    In what line do you get that error? If it was in the function I provided, here is an example of how to use it:
    Code:
    >>>print tohex(12,230,73)
    0x0CE649

  13. #13
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Re: Topwindow background color

    Code:
    hexchars="0123456789ABCDEF"
    bord = "0x"+hexchars[r/16]+hexchars[r%16]+hexchars[g/16]+hexchars[g%16]+hexchars[b/16]+hexchars[b%16]
    screen.background_color = bord
    My rgb color
    rgb color=153 255 0

    The hex color converted
    hex color= 0x99FF00

    I've tried with this code:
    Code:
    rgb = r+g+b
    screen.background_color = rgb
    But the color showed it's different from the rgb color.
    Last edited by ikaroweb80; 2008-04-16 at 14:18.

  14. #14
    Regular Contributor
    Join Date
    Dec 2005
    Posts
    54

    Re: Topwindow background color

    I've this hex color returned from the function tohex, but when i try to set background.color with this hex he give this error:

    Code:
    >>> 0xFF33FF
    Exception:  an integer is required

  15. #15
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Topwindow background color

    Quote Originally Posted by ikaroweb80 View Post
    Code:
    hexchars="0123456789ABCDEF"
    bord = "0x"+hexchars[r/16]+hexchars[r%16]+hexchars[g/16]+hexchars[g%16]+hexchars[b/16]+hexchars[b%16]
    screen.background_color = bord
    The error means exactly what it says: "Exception: an integer is required". The result of conversion is a text string, not a number. You need to convert it to number beforehands.

    The code from bogdan.galiceanu was correct, but you seem to have skipped over one part:

    Code:
    window.background_color = eval(bord)

Similar Threads

  1. Setting background color for a custom listbox
    By hubbabubba in forum Symbian
    Replies: 2
    Last Post: 2008-06-20, 09:30
  2. Custom background color for CEikRichTextEditor
    By vtulai in forum Symbian User Interface
    Replies: 2
    Last Post: 2007-04-05, 13:49
  3. Dynamic change background color
    By s2005 in forum Symbian
    Replies: 0
    Last Post: 2005-11-03, 21:37
  4. Replies: 1
    Last Post: 2004-11-25, 03:42
  5. CEikEdwin with background color
    By opsaxell in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-06-02, 09:37

Posting Permissions

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