Forum Archive

Color picker

Webmaster4o

Is there a way to display a color picker with UI? Like the one built into pythonista? I know tkinter has one built in...

dgelessus

You mean like the built-in ColorMixer example? ;)

I know, it's not a color picker with a fancy color wheel, but it does the job.

Webmaster4o

Right. I was thinking a little more complex than that, like this one:

techteej

I requested this to be added to the dialogs module, but alas - nothing of it.

Webmaster4o

Ok. Hopefully it will. Omz obviously has some kind of code at can be used in multiple places, it appears in the image picker, in the UI builder, and in other places. I'd love to see it put in dialogs

Phuket2

I know nothing for nothing and maybe less than that. But I think there must be a native color picker/s in iOS. Then if someone, makes a wrapper with objc_utils, I think it should be possible.

MartinPacker

The problem with a picker like that is how on earth do you remember which shade you picked last time?

Almost all the drawing packages I've ever used suffer from the same problem - 2 items end up nearly the same colour but not quite.

I solved it in an HTML 5 Canvas app with the dojo picker by embedding it in a pane with a "the colours in this picture are" grid,

Something you might like to factor in if designing something.

Phuket2

If I was good enough to implement it, I think I would return a list of tuples and a index. Each tuple would represent a color model, RGB, HLS, CMYK etc. the index would indicate what Color model was selected as the other values will be mostly be approximations. Then when calling the function/method call it with the same index and the corresponding tuple. Of course means you need to save the vars between calls. But this is normal. just my idea.

MartinPacker

Right @Phuket2 but I was referring to how a colour picker should help you be consistent in your picking. So a "recent picks" palette as part of the UI element would be handy. Wondering if Roll Your Own isn't required.

JonB

https://github.com/jsbain/uicomponents/blob/master/colorpicker.py

Start of a simple chooser, similar to the built in one above. I got a little sloppy, so you cannot quite get to pure white :). Also a real class would have a done button, delegate callbacks, and a "shield" so it can act modally, but this gives the basic idea.

My intention was to store recently selected colors and display those as well.

JonB

ywangd

@JonB The color picker looks great. It can be potentially used as the UI for customisation of stash color theme. This is something I'd like to support in future developments. It may take a while though as I have other issues to fix first. But I guess most importantly is to have an official 1.6 releas to ensure efforts are not to be wasted ...

techteej

@JonB Why not improve upon the existing sample code?

JonB

folks seemed to want the color box style picker, rather than a triple slider approach.
Another option would be a webview with something like
http://antelle.github.io/small-color-picker/

MartinPacker

Colourbox is where you want the choices constrained (eg "recents" or "not too many for you to confidently choose") whereas sliders is a good way of being precise.

I suspect most use cases want the former, but a few want the precision of the latter.

ccc

Or a tabbed view that delivers both.

MartinPacker

Agreed @ccc

techteej

@JonB I was thinking of code that I had found a while ago as a normal color picker (one with box style) but it turned out to not be sample code and now forget where I found it!

Webmaster4o

@JonB can we use objc_util to get into Pythonista's color picker and present it elsewhere?

lukaskollmer

@Webmaster4o I remember the post was Editorial related

Webmaster4o

@lukaskollmer which post?

lukaskollmer

@Webmaster4o I can't find it right now. The class you're looking for is OMColorPickerViewController