You Are Here:

Community: Developer Discussion Boards

Reply « Previous Thread | Next Thread »

#1 Old Red face Topwindow background color - 2008-04-02, 14:49

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
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.
Reply With Quote

#2 Old Re: Topwindow background color - 2008-04-02, 18:56

Join Date: Oct 2007
Posts: 2,845
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
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.
Reply With Quote

#3 Old Re: Topwindow background color - 2008-04-02, 20:07

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
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
Reply With Quote

#4 Old Re: Topwindow background color - 2008-04-02, 20:29

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
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)]
Reply With Quote

#5 Old Re: Topwindow background color - 2008-04-03, 05:30

Join Date: Dec 2007
Posts: 134
Location: India
kandyfloss's Avatar
kandyfloss
Offline
Regular Contributor
The code Bogdan gives is to change the colour of the window.

Quote:
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
Reply With Quote

#6 Old Re: Topwindow background color - 2008-04-03, 07:46

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
The code of bogdan.galiceanu works fine, but if i put him into a function does not work.
The topwindow does not appear.
Reply With Quote

#7 Old Re: Topwindow background color - 2008-04-03, 12:42

Join Date: Dec 2007
Posts: 134
Location: India
kandyfloss's Avatar
kandyfloss
Offline
Regular Contributor
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
Reply With Quote

#8 Old Re: Topwindow background color - 2008-04-03, 14:35

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
I've added this line and now works fine!

Code:
image.clear(background)
Reply With Quote

#9 Old Re: Topwindow background color - 2008-04-16, 13:28

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
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.
Reply With Quote

#10 Old Re: Topwindow background color - 2008-04-16, 13:38

Join Date: Oct 2007
Posts: 2,845
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
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 14:08.
Reply With Quote

#11 Old Re: Topwindow background color - 2008-04-16, 14:19

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
Now i've this error:

Code:
Exception:  an integer is required
Reply With Quote

#12 Old Re: Topwindow background color - 2008-04-16, 14:28

Join Date: Oct 2007
Posts: 2,845
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
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
Reply With Quote

#13 Old Re: Topwindow background color - 2008-04-16, 14:32

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
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 15:18.
Reply With Quote

#14 Old Re: Topwindow background color - 2008-04-16, 21:54

Join Date: Dec 2005
Posts: 54
ikaroweb80
Offline
Regular Contributor
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
Reply With Quote

#15 Old Re: Topwindow background color - 2008-04-18, 08:30

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
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)
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting background color for a custom listbox hubbabubba General Symbian C++ 2 2008-06-20 10:30
Custom background color for CEikRichTextEditor vtulai Symbian User Interface 2 2007-04-05 14:49
Dynamic change background color s2005 General Symbian C++ 0 2005-11-03 22:37
Urgent : Changing the background color of the status pane and control pane prbhat Symbian User Interface 1 2004-11-25 04:42
CEikEdwin with background color opsaxell Symbian User Interface 0 2004-06-02 10:37

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia