Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7748845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:53:21+00:00 2026-06-01T10:53:21+00:00

In WxWidget colors are represented by a RGB integer triplet. To interact with other

  • 0

In WxWidget colors are represented by a RGB integer triplet. To interact with other libraries using a [0.0-1.0] float triplet representation, a conversion is needed.

Is there such a conversion function already existing in WxPython, Numpy or Python ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:53:23+00:00Added an answer on June 1, 2026 at 10:53 am

    You can just divide each element by 255 (or 256 depending on whether you want the upper range to include or exclude 1):

    pax> python3
    Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
    [GCC 5.4.0 20160609] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    
    >>> rgbvar1 = [80,160,240] ; rgbvar1
    [80, 160, 240]
    
    >>> rgbvar2 = [x / 255.0 for x in rgbvar1] ; rgbvar2
    [0.3137254901960784, 0.6274509803921569, 0.9411764705882353]
    
    >>> rgbvar3 = [round(x * 255) for x in rgbvar2] ; rgbvar3
    [80, 160, 240]
    

    As you can see from rgbvar3, you can use a similar method to convert them back.

    To check that this works, the following may help:

    >>> for i in range(256):
    ...     j = i / 255.0
    ...     k = round(j * 255)
    ...     if i != k:
    ...         print('Bad at %d'%(i))
    ... 
    >>>
    

    The fact that it shows no errors for the expected possible input values (integers 0 through 255) means that the reverse operation should work okay.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i m using wxWidget and there i m using wxThread, some time things going
I have an wxWidget application built using C++. One of the functionalities of the
I'm using wxWidgets for a cross platform app. In this app, there is a
Is there a way in wxWidget to do alpha blending operations such as multiplying
i m just a beginner and i m using c++, wxwidget and mysql manually
i using wxWidget with Code:Blocks IDE and wxSmith GUI Builder. I want to create
When compiling my wxWidget HelloWorld application, I am getting the following errors: Warning 1
I'm looking into writing a wxWidget that displays a graphical node network, and therefore
I am using wxWidgets 2.9.2, when i use following code //ToolBar wxToolBar *mainTool =
I installed the wxWidgets source code, compiled it and am linking the libraries thus

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.