36
37
##wxversion.select('2.6')
40
#check with other encoding
41
##wx.SetDefaultPyEncoding('ISO8859-15')
40
44
import cPickle, webbrowser, os
53
57
from pyWx import dialogs
54
58
from pyWx import plugin
55
59
from clipboard import copy_text
60
from unicoding import exception_to_unicode
62
WX_ENCODING = wx.GetDefaultPyEncoding()
58
64
_('You can paste it as text into the properties of a new launcher.')
68
if wx.Platform != '__WXGTK__':
71
def set_theme(name='default'):
73
from pyWx.nuovext import Provider
74
wx.ArtProvider.Push(Provider())
77
self.icon = wx.EmptyIcon()
78
if sys.platform.startswith('win'):
79
image = images.ICON32GIF
82
self.icon.CopyFromBitmap(graphics.bitmap(image))
83
self.SetIcon(self.icon)
62
86
def findWindowById(id):
63
87
return wx.GetApp().GetTopWindow().FindWindowById(id)
108
132
def show_progress(self,title,parent_max,child_max=1,message=''):
109
133
dlg = dialogs.ProgressDialog(self,title,parent_max,child_max,message)
111
def show_progress_error(self,result,message,details,ignore=True):
135
def show_progress_error(self,result,message,ignore=True):
112
136
message += '\n\n'+_('See Tools>Show Log for more details.')
113
errorDlg = dialogs.ErrorDialog(self,message,details,ignore)
137
errorDlg = dialogs.ErrorDialog(self,message,ignore)
114
138
answer = errorDlg.ShowModal()
115
139
result['stop_for_errors'] = not errorDlg.future_errors.GetValue()
116
140
errorDlg.Destroy()
139
163
if os.path.exists(filename):
141
165
return api.open_actionlist(filename)
166
except KeyError, details:
168
_('Sorry, you need to install the %s action'
169
' for this action list.')\
170
%exception_to_unicode(details,WX_ENCODING))
143
173
self.show_error((
144
174
_('Sorry, the action list seems incompatible with\n')+\
154
184
'\n'.join(data['invalid labels'])
158
188
class Frame(DialogsMixin,dialogs.BrowseMixin,droplet.Mixin,paint.Mixin,
159
189
frame.Frame,FrameReceiver):
164
194
def __init__(self,actionlist,*args,**keyw):
165
195
frame.Frame.__init__(self,*args,**keyw)
197
self.EnableBackgroundPainting(self.empty)
170
201
self.on_menu_file_new()
173
204
self._description()
180
211
def _plugin(self):
181
212
plugin.install_frame(self)
184
if wx.Platform != '__WXGTK__':
185
self.set_theme('nuovext')
186
self.EnableBackgroundPainting(self.empty)
188
def set_theme(self,name='default'):
189
if name == 'nuovext':
190
from pyWx.nuovext import Provider
191
wx.ArtProvider.Push(Provider())
193
214
def _description(self):
194
215
self.show_description(False)
197
218
self.SetAsFileDropTarget(self.tree,self.on_drop)
201
#_ic.CopyFromBitmap(graphics.bitmap('ART_PASTE',(48,48)))
202
_ic.CopyFromBitmap(graphics.bitmap(images.ICON))
207
## self.menu_view_description.SetBitmap(
208
## graphics.bitmap('ART_TIP',(16,16)))
210
223
self.menu_file_export = self.menu_file_export_actionlist_to_clipboard.GetMenu()
266
279
def _toolBar(self):
267
280
self.tool_bitmap_size = (32,32)
268
self.frame_toolbar = wx.ToolBar(self, -1)
281
self.frame_toolbar = wx.ToolBar(self, -1,style=wx.TB_FLAT)
269
282
self.SetToolBar(self.frame_toolbar)
270
283
self.frame_toolbar.SetToolBitmapSize(self.tool_bitmap_size)
271
284
self.tools_item = []
272
self.add_tool('ART_FOLDER_OPEN',_("Open"),
285
self.add_tool('ART_FILE_OPEN',_("Open"),
273
286
_("Open an action list"),self.on_menu_file_open)
275
288
self.add_tool('ART_EXECUTABLE_FILE',_("Execute"),
353
def on_menu_file_export_droplet_actionlist_to_clipboard(self, event):
354
if self.is_save_not_ok(): return
355
copy_text(ct.COMMAND_DROP%self.filename)
356
self.show_info(' '.join([
357
_('The droplet command for this actionlist was copied to the clipboard.'),
360
def on_menu_file_export_droplet_recent_to_clipboard(self, event):
361
if self.is_save_not_ok(): return
362
copy_text(ct.COMMAND_RECENT)
363
self.show_info(' '.join([
364
_('The droplet command for this actionlist was copied to the clipboard.'),
367
def on_menu_file_export_droplet_inspector_to_clipboard(self, event):
368
if self.is_save_not_ok(): return
369
copy_text(ct.COMMAND_INSPECTOR)
366
def on_menu_file_export_actionlist_to_clipboard(self, event):
367
if self.is_save_not_ok(): return
368
copy_text(ct.COMMAND['DROP']%self.filename)
369
self.show_info(' '.join([
370
_('The droplet command for this actionlist was copied to the clipboard.'),
373
def on_menu_file_export_recent_to_clipboard(self, event):
374
if self.is_save_not_ok(): return
375
copy_text(ct.COMMAND['RECENT'])
376
self.show_info(' '.join([
377
_('The droplet command for this actionlist was copied to the clipboard.'),
380
def on_menu_file_export_inspector_to_clipboard(self, event):
381
if self.is_save_not_ok(): return
382
copy_text(ct.COMMAND['INSPECTOR'])
370
383
self.show_info(' '.join([
371
384
_('The droplet command for the image inspector was copied to the clipboard.'),
433
446
api.apply_actions(action_list,wx.GetApp().settings)
435
448
def on_menu_tools_image_inspector(self, event):
436
frame = imageInspector.SingleFrame(self,size=imageInspector.SIZE)
449
frame = imageInspector.SingleFrame(self,
450
size = imageInspector.SIZE,
439
454
def on_menu_tools_show_log(self,event):
457
472
'%s_%s'%(ct.TITLE,_('frame')) : self,
458
473
'%s_%s'%(ct.TITLE,_('actions')) : self.tree.export_forms,
462
478
self.shell.Show(event.IsChecked())
497
513
dlg = about.Dialog(self,
498
514
title = '%(version)s'%ct.INFO,
499
515
logo = graphics.bitmap(images.LOGO),
500
description = ct.INFO['description'],
516
description = _('PHoto bATCH Processor & Renamer'),
501
517
website = ct.INFO['url'],
502
518
credits = all_credits(),
503
519
license = ct.LICENSE,
556
572
method = self.on_drop,
557
573
label = self.droplet_label_format(os.path.splitext(
558
574
os.path.basename(self.filename))[0]),
559
label_colour= wx.BLUE,
560
label_pos = (35, 60),
575
label_colour= wx.Colour(156,166,165),
576
label_pos = (73, 40),
577
label_angle = 360-20,
562
578
pos = self.GetPosition(),
564
580
OnShow = self.on_show_droplet,
665
681
self.dirty = ('','*')[value]
685
def get_droplet_folder(self):
686
folder = self.show_dir_dialog(
687
defaultPath = self.get_setting('droplet_path'),
688
message=_('Choose the folder for the droplet'))
690
self.set_setting('droplet_path',folder)
693
def menu_file_export_droplet(self,method,*args,**keyw):
694
folder = self.get_droplet_folder()
698
create_phatch_droplet(self.filename,folder)
699
self.show_info(_('Phatch successfully created the droplet.'))
700
except Exception, details:
701
reason = exception_to_unicode(details,WX_ENCODING)
702
self.show_error(_('Phatch could not create the droplet:')+'\n\n'\
705
def install_menu_item(self,menu,name,label,method,tooltip="",
706
style=wx.ITEM_NORMAL):
708
item = wx.MenuItem(menu, -1,label, tooltip, style)
709
setattr(self,name,item)
710
menu.InsertItem(0,item)
712
method_name = 'on_'+name
713
method = new.instancemethod(method,self, self.__class__)
714
setattr(self, method_name, method)
716
self.Bind(wx.EVT_MENU, method,item)
668
720
#---Image Inspector
669
721
class ImageInspectorApp(wx.App):
670
722
def __init__(self,paths,*args,**keyw):
674
726
def OnInit(self):
675
727
wx.InitAllImageHandlers()
676
729
if not self.paths: self.paths = ['']
677
730
for path in self.paths:
678
731
frame = imageInspector.SingleFrame(None,filename=path,
679
732
size=imageInspector.SIZE)
681
735
self.SetTopWindow(frame)
725
779
self.SetTopWindow(frame)
728
def get_library_files(self):
782
def get_action_list_files(self):
729
783
global_library = glob.glob(os.path.join(
730
self.settings["PHATCH_LIBRARY_PATH"],'*'+ct.EXTENSION))
784
self.settings["PHATCH_ACTIONLISTS_PATH"],'*'+ct.EXTENSION))
731
785
local_library = glob.glob(os.path.join(
732
ct.LIBRARY_PATH,'*'+ct.EXTENSION))
786
ct.USER_ACTIONLISTS_PATH,'*'+ct.EXTENSION))
733
787
return global_library+local_library
735
789
def get_action_list(self,file_list):
736
790
if not file_list:
737
file_list = self.get_library_files()
791
file_list = self.get_action_list_files()
739
793
for f in file_list:
740
794
d[api.title(f)] = f