Sublime Forum

Color picker - color insertion

#1

The #1 feature I’d love to see added to Sublime Text 2:
Shift+Cmd+C to open the Color Picker (TextMate’s “Insert Color”); clicking the “OK” button insert the selected color value in place.

Use case: selecting a color (ex. #3F3F3F) in a CSS file, and then pressing Shift+Cmd+C, opens up the Color Picker with the #3F3F3F color pre-selected. Any new color picked within the color picker will replace the selected color in the code.

Example:

0 Likes

#2

+1
but maybe with an extra tab showing different representations like hex, decimal, etc. more like the standard color picker allows.

0 Likes

#3

This could easily be achieved if we had more access to the GUI of Sublime.

0 Likes

#4

I’d also love to see this happen. It’s a huge time saver when you edit a lot of CSS by hand, and is something I use a lot in TextMate.

[quote=“meno”]+1
but maybe with an extra tab showing different representations like hex, decimal, etc. more like the standard color picker allows.[/quote]

The TextMate command opens the standard OS X color picker. If you need to paste in hex directly while the color picker is open, you can install Hex Color Picker (which affects the color picker system-wide).

0 Likes

#5

Yup,

+1 !

It would help with these enormous CSS files i have been working on.

Thanks !

0 Likes

#6

If I could get Tkinter and tkColorChoose to import properly, I think this will do exactly what everyone is after!

[code]import sublime, sublime_plugin
from Tkinter import *
from tkColorChooser import askcolor

class ColorPicker(sublime_plugin.WindowCommand):
def run(self):
getBgColor(self)

def getBgColor(self):
(triple, hexstr) = askColor()
if hexstr:
try:
if self.window.active_view():
self.window.active_view().run_command(“insert_hex”, {“hex” : hexstr})
except ValueError:
pass

class InsertHex(sublime_plugin.TextCommand):
def run(self, edit, hex):
self.view.replace(edit, region, str(hex))[/code]
Running getBgColor() without the Sublime functions produces the color picker, but as soon as it becomes a plugin, the module is no longer imported :frowning:

Edit: Fixed indent issue, but still no Tkinter import :frowning:

0 Likes

#7

The Tkinter modules aren’t included in the version of Python distributed with Sublime Text to save on download size - I assumed no one would want to use it :slight_smile:

0 Likes

#8

If that Tkinter code works as advertised, I’d gladly take a slightly heavier binary. Having a color chooser available would be a huge help in editing CSS in ST2.

0 Likes

#9

Is it possible to provide an additional download that could add Tkinter to the default install (maybe with a sublime-package file)? I personally have no need for a colour picker but would appreciate having Tkinter available for other plugins

0 Likes

#10

Please, please, oh please include Tkinter!

The things we could make from it would be amazing!

I desperately need a colour picker and my plugin would be final with Tkinter installed.

0 Likes

#11

I’d need to fix the colour code insertion since I gave up when I found out Tkinter isn’t included.

But it would take two minutes to fix it :smile:

0 Likes

#12

Any word on this, after purchasing this is probably the one thing that gave me frowny face :frowning:

0 Likes

#13

I emailed Jon about getting Tkinter installed into Sublime (manually) but after half an hour I couldn’t get it to work. Too many dependencies. And I’m not a Python developer by trade :smile:

0 Likes

#14

thanks for the update! cut and paste from a colorpicker it is then :frowning:

0 Likes

#15

I’ve tried again, but I got nowhere :frowning:

0 Likes

#16

[quote=“jbrooksuk”]

I emailed Jon about getting Tkinter installed into Sublime (manually) but after half an hour I couldn’t get it to work. Too many dependencies. And I’m not a Python developer by trade :smile:[/quote]

If you have a standard Python installation on you computer, why not directly calling a colorpicker from it ?
Look at Python2x\Tools\pynche\pyColorChooser.py for an example.
You could make a plugin that call the colorpicker and get the value back using stdout output (print) or clipboard.

Note that any colorpicker software that could copy the result to the clipboard work for this task.

0 Likes

#17

+1ing this. A huge feature for me. I’m using Sublime on linux.

0 Likes

#18

i think a colour pallet would be great

something similar to text mate for the mac, so could have transparent background etc would look great!!

0 Likes

#19

No color picker, but this is semi-related and pretty handy:

0 Likes

#20

I uploaded my plugin to GitHub, so you can install it with the Package Manager plugin by wbond.

Every now and then I still play around with the Tkinter stuff and an actual color picker. Shame it doesn’t always work.

0 Likes