9
9
__author__ = "Campbell Barton"
10
10
__url__ = ["blender", "blenderartists.org"]
11
11
__version__ = "1.0"
14
13
This script opens the current image in an external application for editing.
17
16
Choose an image for editing in the UV/Image view.
19
To configure the application to open the image with, hold Shift as you click on
22
For first time users try running the default application for your operating system.
23
If the application does not open you can type in the full path.
24
You can choose that the last entered application will be saved as a default.
26
* Note, default commants for opening an image are "start" for win32 and "open" for macos.
27
This will use the system default assosiated application.
18
To configure the application to open the image with, hold Shift as you
19
click on this menu item.
21
For first time users try running the default application for your
22
operating system. If the application does not open you can type in
23
the full path. You can choose that the last entered application will
24
be saved as a default.
26
* Note, default commants for opening an image are "start" for win32
27
and "open" for macos. This will use the system default associated
30
31
# ***** BEGIN GPL LICENSE BLOCK *****
48
49
# ***** END GPL LICENCE BLOCK *****
49
50
# --------------------------------------------------------------------------
53
from Blender import Image, sys, Draw, Registry
54
57
import sys as py_sys
55
58
platform = py_sys.platform
57
Draw.PupMenu('Error, python not installed')
60
Draw.PupMenu('Error: Recent version of Python not installed.')
61
from Blender import Image, sys, Draw, Registry
63
def os_run(appstring, filename):
65
Run the app, take into account different python versions etc
66
looks like python 2.6 wants a list for
69
# evil trick, temp replace spaces so we can allow spaces in filenames
70
# also allows multiple instances of %f
71
appstring = appstring.replace(' ', '\t')
72
appstring = appstring.replace('%f', filename)
73
appstring = appstring.split('\t')
75
print ' '.join(appstring)
77
try: # only python 2.6 wants a list?
78
p = subprocess.Popen(appstring)
80
p = subprocess.Popen(' '.join(appstring))
63
83
def edit_extern(image=None):
66
86
image = Image.GetCurrent()
68
88
if not image: # Image is None
69
Draw.PupMenu('ERROR: You must select an active Image.')
89
Draw.PupMenu('ERROR: Please select active Image.')
72
92
Draw.PupMenu('ERROR: Image is packed, unpack before editing.')
95
115
pupblock.append('first time, set path.')
96
116
if platform == 'win32':
97
appstring = 'start "" /B "%f"'
117
# Example of path to popular image editor... ;-)
118
# appstring = '"C:\\Program Files\\Adobe\\Photoshop CS\\photoshop.exe" "%f"'
119
# Have to add "cmd /c" to make sure we're using Windows shell.
120
appstring = 'cmd /c start "" /B "%f"'
98
121
elif platform == 'darwin':
99
122
appstring = 'open "%f"'
101
appstring = 'gimp-remote "%f"'
124
appstring = 'gimp %f'
103
126
appstring_but = Draw.Create(appstring)
104
127
save_default_but = Draw.Create(0)
106
pupblock.append(('editor: ', appstring_but, 0, 48, 'Path to application, %f will be replaced with the image path.'))
129
pupblock.append(('editor: ', appstring_but, 0, 99, 'Path to application, %f will be replaced with the image path.'))
107
130
pupblock.append(('Set Default', save_default_but, 'Store this path in the blender registry.'))
109
132
# Only configure if Shift is held,
118
141
Registry.SetKey('ExternalImageEditor', {'path':appstring}, True)
120
143
if appstring.find('%f') == -1:
121
Draw.PupMenu('ERROR: The comment you entered did not contain the filename ("%f")')
144
Draw.PupMenu('ERROR: No filename specified! ("%f")')
124
147
# -------------------------------
126
appstring = appstring.replace('%f', imageFileName)
127
print '\tediting image with command "%s"' % appstring
149
os_run(appstring, imageFileName)
135
if __name__ == '__main__' and os != None:
b'\\ No newline at end of file'
157
if __name__ == '__main__' and subprocess: