Skip to content

bpo-34964: Make Tkinter sources more readable by adding blank lines. #9822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
537 changes: 533 additions & 4 deletions Lib/tkinter/__init__.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Lib/tkinter/commondialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from tkinter import *


class Dialog:

command = None
Expand Down
2 changes: 2 additions & 0 deletions Lib/tkinter/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def __init__(self, master=None, cnf={}, **kw):
*cnf['strings']))
try: Widget.destroy(self)
except TclError: pass

def destroy(self): pass


def _test():
d = Dialog(None, {'title': 'File Modified',
'text':
Expand Down
4 changes: 3 additions & 1 deletion Lib/tkinter/dnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def finish(self, event, commit=0):
source.dnd_end(target, event)



# ----------------------------------------------------------------------
# The rest is here for testing and demonstration purposes only!

Expand Down Expand Up @@ -265,6 +264,7 @@ def where(self, canvas, event):
def dnd_end(self, target, event):
pass


class Tester:

def __init__(self, root):
Expand Down Expand Up @@ -299,6 +299,7 @@ def dnd_commit(self, source, event):
x, y = source.where(self.canvas, event)
source.attach(self.canvas, x, y)


def test():
root = tkinter.Tk()
root.geometry("+1+1")
Expand All @@ -317,5 +318,6 @@ def test():
i3.attach(t3.canvas)
root.mainloop()


if __name__ == '__main__':
test()
10 changes: 8 additions & 2 deletions Lib/tkinter/filedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def ok_command(self):
self.quit(file)



# For the following classes and modules:
#
# options (all have default values):
Expand Down Expand Up @@ -341,6 +340,7 @@ def _fixresult(self, widget, result):
return self._fixresult(widget, widget.tk.splitlist(result))
return _Dialog._fixresult(self, widget, result)


class SaveAs(_Dialog):
"Ask for a filename to save as"

Expand Down Expand Up @@ -369,16 +369,19 @@ def _fixresult(self, widget, result):
#
# convenience stuff


def askopenfilename(**options):
"Ask for a filename to open"

return Open(**options).show()


def asksaveasfilename(**options):
"Ask for a filename to save as"

return SaveAs(**options).show()


def askopenfilenames(**options):
"""Ask for multiple filenames to open

Expand All @@ -390,6 +393,7 @@ def askopenfilenames(**options):

# FIXME: are the following perhaps a bit too convenient?


def askopenfile(mode = "r", **options):
"Ask for a filename to open, and returned the opened file"

Expand All @@ -398,6 +402,7 @@ def askopenfile(mode = "r", **options):
return open(filename, mode)
return None


def askopenfiles(mode = "r", **options):
"""Ask for multiple filenames and return the open file
objects
Expand All @@ -423,12 +428,12 @@ def asksaveasfile(mode = "w", **options):
return open(filename, mode)
return None


def askdirectory (**options):
"Ask for a directory, and return the file name"
return Directory(**options).show()



# --------------------------------------------------------------------
# test stuff

Expand Down Expand Up @@ -475,5 +480,6 @@ def test():
saveasfilename=asksaveasfilename()
print("saveas", saveasfilename.encode(enc))


if __name__ == '__main__':
test()
8 changes: 8 additions & 0 deletions Lib/tkinter/messagebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,39 @@ def _show(title=None, message=None, _icon=None, _type=None, **options):
# In others we get a Tcl_Obj.
return str(res)


def showinfo(title=None, message=None, **options):
"Show an info message"
return _show(title, message, INFO, OK, **options)


def showwarning(title=None, message=None, **options):
"Show a warning message"
return _show(title, message, WARNING, OK, **options)


def showerror(title=None, message=None, **options):
"Show an error message"
return _show(title, message, ERROR, OK, **options)


def askquestion(title=None, message=None, **options):
"Ask a question"
return _show(title, message, QUESTION, YESNO, **options)


def askokcancel(title=None, message=None, **options):
"Ask if operation should proceed; return true if the answer is ok"
s = _show(title, message, QUESTION, OKCANCEL, **options)
return s == OK


def askyesno(title=None, message=None, **options):
"Ask a question; return true if the answer is yes"
s = _show(title, message, QUESTION, YESNO, **options)
return s == YES


def askyesnocancel(title=None, message=None, **options):
"Ask a question; return true if the answer is yes, None if cancelled."
s = _show(title, message, QUESTION, YESNOCANCEL, **options)
Expand All @@ -113,6 +120,7 @@ def askyesnocancel(title=None, message=None, **options):
return None
return s == YES


def askretrycancel(title=None, message=None, **options):
"Ask if operation should be retried; return true if the answer is yes"
s = _show(title, message, WARNING, RETRYCANCEL, **options)
Expand Down
2 changes: 2 additions & 0 deletions Lib/tkinter/scrolledtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from tkinter import Frame, Text, Scrollbar, Pack, Grid, Place
from tkinter.constants import RIGHT, LEFT, Y, BOTH


class ScrolledText(Text):
def __init__(self, master=None, **kw):
self.frame = Frame(master)
Expand Down Expand Up @@ -50,5 +51,6 @@ def example():
stext.focus_set()
stext.mainloop()


if __name__ == "__main__":
example()
10 changes: 8 additions & 2 deletions Lib/tkinter/simpledialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import tkinter # used at _QueryDialog for tkinter._default_root


class SimpleDialog:

def __init__(self, master,
Expand Down Expand Up @@ -119,7 +120,6 @@ class Dialog(Toplevel):
'''

def __init__(self, parent, title = None):

'''Initialize a dialog.

Arguments:
Expand Down Expand Up @@ -324,9 +324,11 @@ def validate(self):

class _QueryInteger(_QueryDialog):
errormessage = "Not an integer."

def getresult(self):
return self.getint(self.entry.get())


def askinteger(title, prompt, **kw):
'''get an integer from the user

Expand All @@ -341,11 +343,14 @@ def askinteger(title, prompt, **kw):
d = _QueryInteger(title, prompt, **kw)
return d.result


class _QueryFloat(_QueryDialog):
errormessage = "Not a floating point value."

def getresult(self):
return self.getdouble(self.entry.get())


def askfloat(title, prompt, **kw):
'''get a float from the user

Expand All @@ -360,6 +365,7 @@ def askfloat(title, prompt, **kw):
d = _QueryFloat(title, prompt, **kw)
return d.result


class _QueryString(_QueryDialog):
def __init__(self, *args, **kw):
if "show" in kw:
Expand All @@ -378,6 +384,7 @@ def body(self, master):
def getresult(self):
return self.entry.get()


def askstring(title, prompt, **kw):
'''get a string from the user

Expand All @@ -393,7 +400,6 @@ def askstring(title, prompt, **kw):
return d.result



if __name__ == '__main__':

def test():
Expand Down