Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(164518)

Side by Side Diff: Lib/idlelib/IOBinding.py

Issue 15363: Idle/tkinter ~x.py 'save as' fails. closes idle
Patch Set: Created 5 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import os 1 import os
2 import types 2 import types
3 import shlex 3 import shlex
4 import sys 4 import sys
5 import codecs 5 import codecs
6 import tempfile 6 import tempfile
7 import tkinter.filedialog as tkFileDialog 7 import tkinter.filedialog as tkFileDialog
8 import tkinter.messagebox as tkMessageBox 8 import tkinter.messagebox as tkMessageBox
9 import re 9 import re
10 from tkinter import * 10 from tkinter import *
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 def askopenfile(self): 493 def askopenfile(self):
494 dir, base = self.defaultfilename("open") 494 dir, base = self.defaultfilename("open")
495 if not self.opendialog: 495 if not self.opendialog:
496 self.opendialog = tkFileDialog.Open(master=self.text, 496 self.opendialog = tkFileDialog.Open(master=self.text,
497 filetypes=self.filetypes) 497 filetypes=self.filetypes)
498 filename = self.opendialog.show(initialdir=dir, initialfile=base) 498 filename = self.opendialog.show(initialdir=dir, initialfile=base)
499 return filename 499 return filename
500 500
501 def defaultfilename(self, mode="open"): 501 def defaultfilename(self, mode="open"):
502 if self.filename: 502 if self.filename:
503 return os.path.split(self.filename) 503 dirname, base = os.path.split(self.filename)
storchaka 2014/10/12 11:40:28 Either dirname and basename or dir and base for co
504 if base.startswith('~') and sys.platform[:3] == 'win':
storchaka 2014/10/12 11:40:28 base.startswith('~') but sys.platform[:3] == 'win'
505 # Fix Tcl/Tk Tilde Substitution problem on Windows
506 base = './' + base # Escape the tilde
storchaka 2014/10/12 11:40:28 Or rather os.path.join(os.path.curdir, base).
507 return dirname, base
504 elif self.dirname: 508 elif self.dirname:
505 return self.dirname, "" 509 return self.dirname, ""
506 else: 510 else:
507 try: 511 try:
508 pwd = os.getcwd() 512 dirname = os.getcwd()
509 except OSError: 513 except OSError:
510 pwd = "" 514 dirname = ""
511 return pwd, "" 515 return dirname, ""
512 516
513 def asksavefile(self): 517 def asksavefile(self):
514 dir, base = self.defaultfilename("save") 518 dir, base = self.defaultfilename("save")
515 if not self.savedialog: 519 if not self.savedialog:
516 self.savedialog = tkFileDialog.SaveAs( 520 self.savedialog = tkFileDialog.SaveAs(
517 master=self.text, 521 master=self.text,
518 filetypes=self.filetypes, 522 filetypes=self.filetypes,
519 defaultextension=self.defaultextension) 523 defaultextension=self.defaultextension)
520 filename = self.savedialog.show(initialdir=dir, initialfile=base) 524 filename = self.savedialog.show(initialdir=dir, initialfile=base)
521 return filename 525 return filename
(...skipping 24 matching lines...) Expand all
546 550
547 text = Text(root) 551 text = Text(root)
548 text.pack() 552 text.pack()
549 text.focus_set() 553 text.focus_set()
550 editwin = MyEditWin(text) 554 editwin = MyEditWin(text)
551 io = IOBinding(editwin) 555 io = IOBinding(editwin)
552 556
553 if __name__ == "__main__": 557 if __name__ == "__main__":
554 from idlelib.idle_test.htest import run 558 from idlelib.idle_test.htest import run
555 run(_io_binding) 559 run(_io_binding)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+