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

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

Issue 15363: Idle/tkinter ~x.py 'save as' fails. closes idle
Patch Set: Created 7 years, 4 months 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 sys 3 import sys
4 import codecs 4 import codecs
5 import tempfile 5 import tempfile
6 import tkinter.filedialog as tkFileDialog 6 import tkinter.filedialog as tkFileDialog
7 import tkinter.messagebox as tkMessageBox 7 import tkinter.messagebox as tkMessageBox
8 import re 8 import re
9 from tkinter import * 9 from tkinter import *
10 from tkinter.simpledialog import askstring 10 from tkinter.simpledialog import askstring
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 def askopenfile(self): 490 def askopenfile(self):
491 dir, base = self.defaultfilename("open") 491 dir, base = self.defaultfilename("open")
492 if not self.opendialog: 492 if not self.opendialog:
493 self.opendialog = tkFileDialog.Open(master=self.text, 493 self.opendialog = tkFileDialog.Open(master=self.text,
494 filetypes=self.filetypes) 494 filetypes=self.filetypes)
495 filename = self.opendialog.show(initialdir=dir, initialfile=base) 495 filename = self.opendialog.show(initialdir=dir, initialfile=base)
496 return filename 496 return filename
497 497
498 def defaultfilename(self, mode="open"): 498 def defaultfilename(self, mode="open"):
499 if self.filename: 499 if self.filename:
500 return os.path.split(self.filename) 500 dir, base = os.path.split(self.filename)
501 elif self.dirname: 501 elif self.dirname:
502 return self.dirname, "" 502 dir, base = self.dirname, ""
503 else: 503 else:
504 try: 504 try:
505 pwd = os.getcwd() 505 pwd = os.getcwd()
506 except os.error: 506 except os.error:
507 pwd = "" 507 pwd = ""
508 return pwd, "" 508 dir, base = pwd, ""
509 if base.startswith('~') and sys.platform[:3] == 'win':
510 # Fix Tcl/Tk Tilde Substitution problem on Windows
asvetlov 2012/07/20 18:57:53 I think mentioning http://www.tcl.tk/man/tcl/TclCm
511 base = '\\' + base # escape the tilde
512 return dir, base
509 513
510 def asksavefile(self): 514 def asksavefile(self):
511 dir, base = self.defaultfilename("save") 515 dir, base = self.defaultfilename("save")
512 if not self.savedialog: 516 if not self.savedialog:
513 self.savedialog = tkFileDialog.SaveAs( 517 self.savedialog = tkFileDialog.SaveAs(
514 master=self.text, 518 master=self.text,
515 filetypes=self.filetypes, 519 filetypes=self.filetypes,
516 defaultextension=self.defaultextension) 520 defaultextension=self.defaultextension)
517 filename = self.savedialog.show(initialdir=dir, initialfile=base) 521 filename = self.savedialog.show(initialdir=dir, initialfile=base)
518 return filename 522 return filename
(...skipping 26 matching lines...) Expand all
545 self.text.event_generate("<<save-copy-of-window-as-file>>") 549 self.text.event_generate("<<save-copy-of-window-as-file>>")
546 text = Text(root) 550 text = Text(root)
547 text.pack() 551 text.pack()
548 text.focus_set() 552 text.focus_set()
549 editwin = MyEditWin(text) 553 editwin = MyEditWin(text)
550 io = IOBinding(editwin) 554 io = IOBinding(editwin)
551 root.mainloop() 555 root.mainloop()
552 556
553 if __name__ == "__main__": 557 if __name__ == "__main__":
554 test() 558 test()
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+