Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[82ddff]: plugins / browser.py Maximize Restore History

Download this file

browser.py    78 lines (61 with data), 2.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#system imports
import os
import stat
import sys
#site-packages imports
import wx
#local imports
import filehistory
class FilesystemBrowser(wx.Panel):
def __init__(self, parent, root, pathnames=[], maxlen=0):
wx.Panel.__init__(self, parent)
self.root = root
self.sizer = sizer = wx.BoxSizer(wx.VERTICAL)
self.button = wx.Button(self, -1, "Pathmark...")
wx.EVT_BUTTON(self, self.button.GetId(), self.OnButton)
sizer.Add(self.button, 0, wx.EXPAND)
self.browser = wx.GenericDirCtrl(self, -1, style=wx.DIRCTRL_SHOW_FILTERS, filter=_pype.wildcard, defaultFilter=0)
self.browser.ShowHidden(1)
tree = self.browser.GetTreeCtrl()
tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate, tree)
sizer.Add(self.browser, 1, wx.EXPAND)
#create menu
self.m = wx.Menu()
np = wx.NewId()
self.m.Append(np, "Add Selected Path")
wx.EVT_MENU(self, np, self.OnNewPathmark)
self.op = filehistory.FileHistory(self, callback=[self.chdir, self.browser.SetPath], seq=pathnames,maxlen=maxlen)
self.rp = filehistory.FileHistory(self, remove=1, callback=[self.op.ItemRemove], seq=pathnames,maxlen=maxlen,
delmsg=('Are you sure you want to delete the pathmark?\n%s', "Delete Pathmark?"))
self.op.callback.append(self.rp.ItemAdd)
self.m.AppendMenu(wx.NewId(), "Choose Path", self.op)
self.m.AppendSeparator()
self.m.AppendMenu(wx.NewId(), "Remove Path", self.rp)
self.sizer.Fit(self)
self.SetSizer(self.sizer)
def chdir(self, path):
self.root.config.pop('lastpath', None)
_pype.current_path = path
def gethier(self):
p = self.browser.GetFilePath()
## print "Path:", p
return p
def OnActivate(self, evt):
fn = self.gethier()
try:
st = os.stat(fn)[0]
if stat.S_ISREG(st):
self.root.OnDrop([fn])
except:
evt.Skip()
def OnNewPathmark(self, evt):
fn = self.gethier()
try:
st = os.stat(fn)[0]
if stat.S_ISDIR(st):
self.op.ItemAdd(fn)
self.rp.ItemAdd(fn)
except:
evt.Skip()
def OnButton(self, evt):
self.PopupMenu(self.m, self.button.GetPositionTuple())