Git Product home page Git Product logo

pyqt-colorpicker's Introduction

PyQt-ColorPicker

Circular ColorPicker for PyQt Python.

This is a new design PyQt ColorPicker for python.

The color circle is actually an image and the hue values are generated from finding the tangent of the distance of the mouse coordinates + center coordinates only within the colorpickerWheel class.

Make sure that all the files are in the same directory with the executable/script or change the "working_directory" variable.

Call the ColorPicker class like this (change the variables)

Colorpicker = ColorPicker(width=250, startupcolor=[0, 255, 255])  # HSV (0-360, 0-255, 0-255)

The colorcycle calls the function "onCurrentColorChanged" in "ColorPicker" class when the color changes. There it returns 3 arrays

hsv_color_array = color[0]  # (H(0-255), S(0-255), V(0-255))
hsv_color_array_base_360 = color[2]  # (H(0-360), S(0-100), V(0-100))
rgb_color_array = color[1]  # (R(0-255), G(0-255), B(0-255))

If you need to use HSV with other values like (H(0-1), S(0-1), V(0-1)) use a conversion like

hsv_color_array_base_1 = [hsv_color_array[0]/255, hsv_color_array[1]/255, hsv_color_array[2]/255]

If you change the width the mouseDot might seem a bit off, this can be fixed on the colorpickerWheel class initiation

Values that can be changed:

self.sliders = colorpicker_sliders(slidersWidgetWidth=self.width, spaceBetweenColorpickerAndSliders=0,
                                       spaceBetweenSliders=0)

####
#"colorpicker_sliders" class must be initiated before "colorpickerWheel" class because it is passed to "colorpickerWheel"
####

self.colorpickerWidget = colorpickerWheel(colorpickerSize=self.width, startupcolor=self.startup_color,
                                              mouseDot_size=30, mouseDotDistance_changer=2,
                                              centralColorWidget_size=55, centralColorWidget_radius=20,
                                              centerColorWidget_isCircle=True, sliders=self.sliders)

colorpickerSize=self.width	   by default is inherited when you initialize the ColorPicker class
startupcolor=self.startup_color    by default is inherited when you initialize the ColorPicker class
mouseDot_size=30		   changes the size of the mouse circle that moves around the circle
mouseDotDistance_changer=2	   changes the distance of mouseFot from the center
centralColorWidget_size=55	   changes the size of the color widget inside the circle
centralColorWidget_radius=20	   changes the border-radius of the color widget inside the circle
centerColorWidget_isCircle=True    if True sets the central color widget as a circle and ignores the value of centralColorWidget_radius
change_alpha_channel=True          if True changes the central color widget alpha channel (opacity) based on the value of brightness slider
sliders=self.sliders		   is default, do not remove unless you remove all functoions associated with sliders

You can get the updated values outside the class like this

print(ColorPicker.hsv_color_array)

Notice - If you use this as a widget set oboject names for QPushButtons and QSliders of parent because it affects the child widget.

pyqt-colorpicker's People

Contributors

omega0verride avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyqt-colorpicker's Issues

Paths not working on linux

The paths on the lines 184 & 441 are written with backslashes, with is only working on windows.
I think it is solvable with os.path.join().

Unclear instructions for using ColorPicker as QtWidget

I'm trying to implement ColorPicker widget into my design, but it's unclear from instructions how to do it:

"Notice - If you use this as a widget set oboject names for QPushButtons and QSliders of parent because it affects the child widget".

What names should I change and where?

Central Colour disappear when brightness set to 0

The central Colour Blob disappears when the brightness slider is dragged fully to the left.
I discovered, that the cause is that the brightness not only modifies the RGB-Value but also effects the alpha channel.

I would suggest that the alpha channel is defaulted to 1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.