Sublime Forum

Color Picker for Windows

#1

A Color Picker for Windows 32/64 that has no external dependencies.

Tested on Windows XP 32-bit and Windows 7 64-bit using Sublime 2 build 2165.

Screenshot:

Instructions and source code available at github.com/animehunter/SublimeC … indowsOnly

If you spot any bugs, please post here.

0 Likes

#2

Good job! It worked great here.

I think that finally adds one for all the OSs.

0 Likes

#3

Thanks for the feedback. :smile:

0 Likes

#4

Hi,

can you expand your plugin to allow us to use a pipette to choose the color from any element on the screen?

Regards,
Highend

0 Likes

#5

Due to the difficulty of customizing the Color editor dialog, I’ve decided not to implement the pipette feature for now.
As an alternative, I’ve came up with another method to choose a color from any pixels on the screen.

See the latest readme at my repository for more details.

0 Likes

#6

Ok, installed the updated files manually (package control didn’t list an upgrade for your plugin) and it’s working fine so far (ctrl + shift + alt + c).

Thanks a lot.

Regards,
Highend

0 Likes

#7

This plugin is absolutely awesome! :wink:
Thank you!

0 Likes

#8

This is perfect. Works like a charm!

Thank you.

0 Likes

#9

Now we have also a multi-platform plugin:

github.com/weslly/ColorPicker

thanks to @animehunter!

0 Likes

#10

[quote=“weslly”]Now we have also a multi-platform plugin:

github.com/weslly/ColorPicker

thanks to @animehunter![/quote]

Nice! I was going to suggest folding these two together. I kind of like having my platforms use the same plugins. It makes syncing settings and everything much easier.

0 Likes

#11

There is a way to call a third part color picker?
I found this plugin pretty userful but the standard windows color picker is awful an pretty useless! :cry:
Some basic functionality that I miss are input an hex code and see the color or target something on the screen and pick the color…for example a good picker program that I use is Pixeur, it would be perfect be able to override the default windows picker and open that one.

0 Likes

#12

Yes it is very possible. I have done a test to show it is possible. In this example I have simply used a local python on my machine with WxPython installed, and grabbed the 3rd party python color picker dialog from xoomer.virgilio.it/infinity77/AG … ialog.html called CubeColourDialog. I created a simple program that provides the CubeColourDialog Gui based off a demo they had posted:


[pre=#2D2D2D]import wx
import wx.lib.agw.cubecolourdialog as CCD
import json

Our normal wxApp-derived class, as usual

app = wx.App(0)

colourData = wx.ColourData()
dlg = CCD.CubeColourDialog(None, colourData)

if dlg.ShowModal() == wx.ID_OK:

# If the user selected OK, then the dialog's wx.ColourData will
# contain valid information. Fetch the data ...
colourData = dlg.GetColourData()
h, s, v, a = dlg.GetHSVAColour()

# ... then do something with it. The actual colour data will be
# returned as a three-tuple (r, g, b) in this particular case.
colour = colourData.GetColour()
r, g, b, alpha = colour.Red(), colour.Green(), colour.Blue(), colour.Alpha()
colors = {
    "rgba": (r, g, b, alpha),
    "hsva": (h, s, v, a)
}
print json.dumps(colors)

else:
print “{}”

Once the dialog is destroyed, Mr. wx.ColourData is no longer your

friend. Don’t use it again!

dlg.Destroy()

app.MainLoop()[/pre]

I compiled it as an EXE with pyinstaller pyinstaller.org/ and then accessed the executable via a sublime plugin and output the result in the debug panel.

[pre=#2D2D2D]import sublime
import sublime_plugin
import subprocess as sp
import os.path as path
import json

def check_output(command):
process = sp.Popen(command, shell=True, stdout=sp.PIPE, stderr=sp.STDOUT, universal_newlines=True)
output = process.communicate()
retcode = process.poll()
if retcode:
raise(sp.CalledProcessError(retcode, command, output=output0]))
return output0]

class ColorTestCommand(sublime_plugin.TextCommand):
def run(self, edit):
print(“ColorTest: Custom Color Dialog Feasibility Demo”)
cmd = path.join(sublime.packages_path(), “ColorTest”, “clr_pick.exe”)
colors = json.loads(check_output(cmd))
if “rgba” in colors and “hsva” in colors:
print(“ColorTest (rgba): r=%d, g=%d, b=%d, a=%d” % tuple(colors"rgba"]))
print(“ColorTest (hsva): h=%d, s=%d, v=%d, a=%d” % tuple(colors"hsva"]))
else:
print(“No color selected!”)[/pre]

Results:

>>> sublime.active_window().active_view().run_command("color_test") ColorTest: Custom Color Dialog Feasibility Demo ColorTest (rgba): r=67, g=188, b=117, a=255 ColorTest (hsva): h=145, s=163, v=188, a=255

It would be better if I threaded this and the dialog is a little buggy, but this shows you can create your own custom dialogs etc. and access them from sublime. You don’t have to create the executable in python like I did, but this just shows you can create your own custom gui to do stuff. I think this is an untapped approach that developers could really do some neat stuff with.

0 Likes

#13

thanks for the explanation facelessuser, i’ve managed to set my favourite picker in the plugin :smile:

0 Likes

#14

Glad I could help.

0 Likes