mirror of https://github.com/python/cpython.git
Added "Open File by Name" command which presens a filename dialog. If
the clipboard contains a filename that filename is used as the default.
This commit is contained in:
parent
d424836f3a
commit
611b9f6697
|
@ -70,6 +70,7 @@ def makeusermenus(self):
|
|||
m = Wapplication.Menu(self.menubar, "File")
|
||||
newitem = FrameWork.MenuItem(m, "New", "N", 'new')
|
||||
openitem = FrameWork.MenuItem(m, "Open"+ELIPSES, "O", 'open')
|
||||
openbynameitem = FrameWork.MenuItem(m, "Open File by Name"+ELIPSES, "D", 'openbyname')
|
||||
FrameWork.Separator(m)
|
||||
closeitem = FrameWork.MenuItem(m, "Close", "W", 'close')
|
||||
saveitem = FrameWork.MenuItem(m, "Save", "S", 'save')
|
||||
|
@ -210,6 +211,22 @@ def domenu_open(self, *args):
|
|||
if filename:
|
||||
self.openscript(filename)
|
||||
|
||||
def domenu_openbyname(self, *args):
|
||||
# Open a file by name. If the clipboard contains a filename
|
||||
# use that as the default.
|
||||
from Carbon import Scrap
|
||||
try:
|
||||
sc = Scrap.GetCurrentScrap()
|
||||
dft = sc.GetScrapFlavorData("TEXT")
|
||||
except Scrap.Error:
|
||||
dft = ""
|
||||
else:
|
||||
if not os.path.exists(dft):
|
||||
dft = ""
|
||||
filename = EasyDialogs.AskString("Open File Named:", default=dft, ok="Open")
|
||||
if filename:
|
||||
self.openscript(filename)
|
||||
|
||||
def domenu_new(self, *args):
|
||||
W.SetCursor('watch')
|
||||
import PyEdit
|
||||
|
|
Loading…
Reference in New Issue