Skip to content

Commit dc0d571

Browse files
bpo-34964: Make Tkinter sources more readable by adding blank lines. (pythonGH-9822)
1 parent 2d6097d commit dc0d571

File tree

8 files changed

+565
-9
lines changed

8 files changed

+565
-9
lines changed

Lib/tkinter/__init__.py

Lines changed: 533 additions & 4 deletions
Large diffs are not rendered by default.

Lib/tkinter/commondialog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from tkinter import *
1212

13+
1314
class Dialog:
1415

1516
command = None

Lib/tkinter/dialog.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ def __init__(self, master=None, cnf={}, **kw):
1919
*cnf['strings']))
2020
try: Widget.destroy(self)
2121
except TclError: pass
22+
2223
def destroy(self): pass
2324

25+
2426
def _test():
2527
d = Dialog(None, {'title': 'File Modified',
2628
'text':

Lib/tkinter/dnd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ def finish(self, event, commit=0):
201201
source.dnd_end(target, event)
202202

203203

204-
205204
# ----------------------------------------------------------------------
206205
# The rest is here for testing and demonstration purposes only!
207206

@@ -265,6 +264,7 @@ def where(self, canvas, event):
265264
def dnd_end(self, target, event):
266265
pass
267266

267+
268268
class Tester:
269269

270270
def __init__(self, root):
@@ -299,6 +299,7 @@ def dnd_commit(self, source, event):
299299
x, y = source.where(self.canvas, event)
300300
source.attach(self.canvas, x, y)
301301

302+
302303
def test():
303304
root = tkinter.Tk()
304305
root.geometry("+1+1")
@@ -317,5 +318,6 @@ def test():
317318
i3.attach(t3.canvas)
318319
root.mainloop()
319320

321+
320322
if __name__ == '__main__':
321323
test()

Lib/tkinter/filedialog.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ def ok_command(self):
264264
self.quit(file)
265265

266266

267-
268267
# For the following classes and modules:
269268
#
270269
# options (all have default values):
@@ -341,6 +340,7 @@ def _fixresult(self, widget, result):
341340
return self._fixresult(widget, widget.tk.splitlist(result))
342341
return _Dialog._fixresult(self, widget, result)
343342

343+
344344
class SaveAs(_Dialog):
345345
"Ask for a filename to save as"
346346

@@ -369,16 +369,19 @@ def _fixresult(self, widget, result):
369369
#
370370
# convenience stuff
371371

372+
372373
def askopenfilename(**options):
373374
"Ask for a filename to open"
374375

375376
return Open(**options).show()
376377

378+
377379
def asksaveasfilename(**options):
378380
"Ask for a filename to save as"
379381

380382
return SaveAs(**options).show()
381383

384+
382385
def askopenfilenames(**options):
383386
"""Ask for multiple filenames to open
384387
@@ -390,6 +393,7 @@ def askopenfilenames(**options):
390393

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

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

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

405+
401406
def askopenfiles(mode = "r", **options):
402407
"""Ask for multiple filenames and return the open file
403408
objects
@@ -423,12 +428,12 @@ def asksaveasfile(mode = "w", **options):
423428
return open(filename, mode)
424429
return None
425430

431+
426432
def askdirectory (**options):
427433
"Ask for a directory, and return the file name"
428434
return Directory(**options).show()
429435

430436

431-
432437
# --------------------------------------------------------------------
433438
# test stuff
434439

@@ -475,5 +480,6 @@ def test():
475480
saveasfilename=asksaveasfilename()
476481
print("saveas", saveasfilename.encode(enc))
477482

483+
478484
if __name__ == '__main__':
479485
test()

Lib/tkinter/messagebox.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,32 +78,39 @@ def _show(title=None, message=None, _icon=None, _type=None, **options):
7878
# In others we get a Tcl_Obj.
7979
return str(res)
8080

81+
8182
def showinfo(title=None, message=None, **options):
8283
"Show an info message"
8384
return _show(title, message, INFO, OK, **options)
8485

86+
8587
def showwarning(title=None, message=None, **options):
8688
"Show a warning message"
8789
return _show(title, message, WARNING, OK, **options)
8890

91+
8992
def showerror(title=None, message=None, **options):
9093
"Show an error message"
9194
return _show(title, message, ERROR, OK, **options)
9295

96+
9397
def askquestion(title=None, message=None, **options):
9498
"Ask a question"
9599
return _show(title, message, QUESTION, YESNO, **options)
96100

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

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

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

123+
116124
def askretrycancel(title=None, message=None, **options):
117125
"Ask if operation should be retried; return true if the answer is yes"
118126
s = _show(title, message, WARNING, RETRYCANCEL, **options)

Lib/tkinter/scrolledtext.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from tkinter import Frame, Text, Scrollbar, Pack, Grid, Place
1717
from tkinter.constants import RIGHT, LEFT, Y, BOTH
1818

19+
1920
class ScrolledText(Text):
2021
def __init__(self, master=None, **kw):
2122
self.frame = Frame(master)
@@ -50,5 +51,6 @@ def example():
5051
stext.focus_set()
5152
stext.mainloop()
5253

54+
5355
if __name__ == "__main__":
5456
example()

Lib/tkinter/simpledialog.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import tkinter # used at _QueryDialog for tkinter._default_root
3030

31+
3132
class SimpleDialog:
3233

3334
def __init__(self, master,
@@ -119,7 +120,6 @@ class Dialog(Toplevel):
119120
'''
120121

121122
def __init__(self, parent, title = None):
122-
123123
'''Initialize a dialog.
124124
125125
Arguments:
@@ -324,9 +324,11 @@ def validate(self):
324324

325325
class _QueryInteger(_QueryDialog):
326326
errormessage = "Not an integer."
327+
327328
def getresult(self):
328329
return self.getint(self.entry.get())
329330

331+
330332
def askinteger(title, prompt, **kw):
331333
'''get an integer from the user
332334
@@ -341,11 +343,14 @@ def askinteger(title, prompt, **kw):
341343
d = _QueryInteger(title, prompt, **kw)
342344
return d.result
343345

346+
344347
class _QueryFloat(_QueryDialog):
345348
errormessage = "Not a floating point value."
349+
346350
def getresult(self):
347351
return self.getdouble(self.entry.get())
348352

353+
349354
def askfloat(title, prompt, **kw):
350355
'''get a float from the user
351356
@@ -360,6 +365,7 @@ def askfloat(title, prompt, **kw):
360365
d = _QueryFloat(title, prompt, **kw)
361366
return d.result
362367

368+
363369
class _QueryString(_QueryDialog):
364370
def __init__(self, *args, **kw):
365371
if "show" in kw:
@@ -378,6 +384,7 @@ def body(self, master):
378384
def getresult(self):
379385
return self.entry.get()
380386

387+
381388
def askstring(title, prompt, **kw):
382389
'''get a string from the user
383390
@@ -393,7 +400,6 @@ def askstring(title, prompt, **kw):
393400
return d.result
394401

395402

396-
397403
if __name__ == '__main__':
398404

399405
def test():

0 commit comments

Comments
 (0)