Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2..../idlelib
File: aboutDialog.py
"""About Dialog for IDLE
[0] Fix | Delete
[1] Fix | Delete
"""
[2] Fix | Delete
import os
[3] Fix | Delete
from sys import version
[4] Fix | Delete
from Tkinter import *
[5] Fix | Delete
from idlelib import textView
[6] Fix | Delete
[7] Fix | Delete
class AboutDialog(Toplevel):
[8] Fix | Delete
"""Modal about dialog for idle
[9] Fix | Delete
[10] Fix | Delete
"""
[11] Fix | Delete
def __init__(self, parent, title, _htest=False):
[12] Fix | Delete
"""
[13] Fix | Delete
_htest - bool, change box location when running htest
[14] Fix | Delete
"""
[15] Fix | Delete
Toplevel.__init__(self, parent)
[16] Fix | Delete
self.configure(borderwidth=5)
[17] Fix | Delete
# place dialog below parent if running htest
[18] Fix | Delete
self.geometry("+%d+%d" % (
[19] Fix | Delete
parent.winfo_rootx()+30,
[20] Fix | Delete
parent.winfo_rooty()+(30 if not _htest else 100)))
[21] Fix | Delete
self.bg = "#707070"
[22] Fix | Delete
self.fg = "#ffffff"
[23] Fix | Delete
self.CreateWidgets()
[24] Fix | Delete
self.resizable(height=FALSE, width=FALSE)
[25] Fix | Delete
self.title(title)
[26] Fix | Delete
self.transient(parent)
[27] Fix | Delete
self.grab_set()
[28] Fix | Delete
self.protocol("WM_DELETE_WINDOW", self.Ok)
[29] Fix | Delete
self.parent = parent
[30] Fix | Delete
self.buttonOk.focus_set()
[31] Fix | Delete
self.bind('<Return>',self.Ok) #dismiss dialog
[32] Fix | Delete
self.bind('<Escape>',self.Ok) #dismiss dialog
[33] Fix | Delete
self.wait_window()
[34] Fix | Delete
[35] Fix | Delete
def CreateWidgets(self):
[36] Fix | Delete
release = version[:version.index(' ')]
[37] Fix | Delete
frameMain = Frame(self, borderwidth=2, relief=SUNKEN)
[38] Fix | Delete
frameButtons = Frame(self)
[39] Fix | Delete
frameButtons.pack(side=BOTTOM, fill=X)
[40] Fix | Delete
frameMain.pack(side=TOP, expand=TRUE, fill=BOTH)
[41] Fix | Delete
self.buttonOk = Button(frameButtons, text='Close',
[42] Fix | Delete
command=self.Ok)
[43] Fix | Delete
self.buttonOk.pack(padx=5, pady=5)
[44] Fix | Delete
#self.picture = Image('photo', data=self.pictureData)
[45] Fix | Delete
frameBg = Frame(frameMain, bg=self.bg)
[46] Fix | Delete
frameBg.pack(expand=TRUE, fill=BOTH)
[47] Fix | Delete
labelTitle = Label(frameBg, text='IDLE', fg=self.fg, bg=self.bg,
[48] Fix | Delete
font=('courier', 24, 'bold'))
[49] Fix | Delete
labelTitle.grid(row=0, column=0, sticky=W, padx=10, pady=10)
[50] Fix | Delete
#labelPicture = Label(frameBg, text='[picture]')
[51] Fix | Delete
#image=self.picture, bg=self.bg)
[52] Fix | Delete
#labelPicture.grid(row=1, column=1, sticky=W, rowspan=2,
[53] Fix | Delete
# padx=0, pady=3)
[54] Fix | Delete
byline = "Python's Integrated DeveLopment Environment" + 5*'\n'
[55] Fix | Delete
labelDesc = Label(frameBg, text=byline, justify=LEFT,
[56] Fix | Delete
fg=self.fg, bg=self.bg)
[57] Fix | Delete
labelDesc.grid(row=2, column=0, sticky=W, columnspan=3, padx=10, pady=5)
[58] Fix | Delete
labelEmail = Label(frameBg, text='email: idle-dev@python.org',
[59] Fix | Delete
justify=LEFT, fg=self.fg, bg=self.bg)
[60] Fix | Delete
labelEmail.grid(row=6, column=0, columnspan=2,
[61] Fix | Delete
sticky=W, padx=10, pady=0)
[62] Fix | Delete
labelWWW = Label(frameBg, text='https://docs.python.org/' +
[63] Fix | Delete
version[:3] + '/library/idle.html',
[64] Fix | Delete
justify=LEFT, fg=self.fg, bg=self.bg)
[65] Fix | Delete
labelWWW.grid(row=7, column=0, columnspan=2, sticky=W, padx=10, pady=0)
[66] Fix | Delete
Frame(frameBg, borderwidth=1, relief=SUNKEN,
[67] Fix | Delete
height=2, bg=self.bg).grid(row=8, column=0, sticky=EW,
[68] Fix | Delete
columnspan=3, padx=5, pady=5)
[69] Fix | Delete
labelPythonVer = Label(frameBg, text='Python version: ' +
[70] Fix | Delete
release, fg=self.fg, bg=self.bg)
[71] Fix | Delete
labelPythonVer.grid(row=9, column=0, sticky=W, padx=10, pady=0)
[72] Fix | Delete
tkVer = self.tk.call('info', 'patchlevel')
[73] Fix | Delete
labelTkVer = Label(frameBg, text='Tk version: '+
[74] Fix | Delete
tkVer, fg=self.fg, bg=self.bg)
[75] Fix | Delete
labelTkVer.grid(row=9, column=1, sticky=W, padx=2, pady=0)
[76] Fix | Delete
py_button_f = Frame(frameBg, bg=self.bg)
[77] Fix | Delete
py_button_f.grid(row=10, column=0, columnspan=2, sticky=NSEW)
[78] Fix | Delete
buttonLicense = Button(py_button_f, text='License', width=8,
[79] Fix | Delete
highlightbackground=self.bg,
[80] Fix | Delete
command=self.ShowLicense)
[81] Fix | Delete
buttonLicense.pack(side=LEFT, padx=10, pady=10)
[82] Fix | Delete
buttonCopyright = Button(py_button_f, text='Copyright', width=8,
[83] Fix | Delete
highlightbackground=self.bg,
[84] Fix | Delete
command=self.ShowCopyright)
[85] Fix | Delete
buttonCopyright.pack(side=LEFT, padx=10, pady=10)
[86] Fix | Delete
buttonCredits = Button(py_button_f, text='Credits', width=8,
[87] Fix | Delete
highlightbackground=self.bg,
[88] Fix | Delete
command=self.ShowPythonCredits)
[89] Fix | Delete
buttonCredits.pack(side=LEFT, padx=10, pady=10)
[90] Fix | Delete
Frame(frameBg, borderwidth=1, relief=SUNKEN,
[91] Fix | Delete
height=2, bg=self.bg).grid(row=11, column=0, sticky=EW,
[92] Fix | Delete
columnspan=3, padx=5, pady=5)
[93] Fix | Delete
idle_v = Label(frameBg, text='IDLE version: ' + release,
[94] Fix | Delete
fg=self.fg, bg=self.bg)
[95] Fix | Delete
idle_v.grid(row=12, column=0, sticky=W, padx=10, pady=0)
[96] Fix | Delete
idle_button_f = Frame(frameBg, bg=self.bg)
[97] Fix | Delete
idle_button_f.grid(row=13, column=0, columnspan=3, sticky=NSEW)
[98] Fix | Delete
idle_about_b = Button(idle_button_f, text='README', width=8,
[99] Fix | Delete
highlightbackground=self.bg,
[100] Fix | Delete
command=self.ShowIDLEAbout)
[101] Fix | Delete
idle_about_b.pack(side=LEFT, padx=10, pady=10)
[102] Fix | Delete
idle_news_b = Button(idle_button_f, text='NEWS', width=8,
[103] Fix | Delete
highlightbackground=self.bg,
[104] Fix | Delete
command=self.ShowIDLENEWS)
[105] Fix | Delete
idle_news_b.pack(side=LEFT, padx=10, pady=10)
[106] Fix | Delete
idle_credits_b = Button(idle_button_f, text='Credits', width=8,
[107] Fix | Delete
highlightbackground=self.bg,
[108] Fix | Delete
command=self.ShowIDLECredits)
[109] Fix | Delete
idle_credits_b.pack(side=LEFT, padx=10, pady=10)
[110] Fix | Delete
[111] Fix | Delete
# License, et all, are of type _sitebuiltins._Printer
[112] Fix | Delete
def ShowLicense(self):
[113] Fix | Delete
self.display_printer_text('About - License', license)
[114] Fix | Delete
[115] Fix | Delete
def ShowCopyright(self):
[116] Fix | Delete
self.display_printer_text('About - Copyright', copyright)
[117] Fix | Delete
[118] Fix | Delete
def ShowPythonCredits(self):
[119] Fix | Delete
self.display_printer_text('About - Python Credits', credits)
[120] Fix | Delete
[121] Fix | Delete
# Encode CREDITS.txt to utf-8 for proper version of Loewis.
[122] Fix | Delete
# Specify others as ascii until need utf-8, so catch errors.
[123] Fix | Delete
def ShowIDLECredits(self):
[124] Fix | Delete
self.display_file_text('About - Credits', 'CREDITS.txt', 'utf-8')
[125] Fix | Delete
[126] Fix | Delete
def ShowIDLEAbout(self):
[127] Fix | Delete
self.display_file_text('About - Readme', 'README.txt', 'ascii')
[128] Fix | Delete
[129] Fix | Delete
def ShowIDLENEWS(self):
[130] Fix | Delete
self.display_file_text('About - NEWS', 'NEWS.txt', 'utf-8')
[131] Fix | Delete
[132] Fix | Delete
def display_printer_text(self, title, printer):
[133] Fix | Delete
printer._Printer__setup()
[134] Fix | Delete
text = '\n'.join(printer._Printer__lines)
[135] Fix | Delete
textView.view_text(self, title, text)
[136] Fix | Delete
[137] Fix | Delete
def display_file_text(self, title, filename, encoding=None):
[138] Fix | Delete
fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename)
[139] Fix | Delete
textView.view_file(self, title, fn, encoding)
[140] Fix | Delete
[141] Fix | Delete
def Ok(self, event=None):
[142] Fix | Delete
self.grab_release()
[143] Fix | Delete
self.destroy()
[144] Fix | Delete
[145] Fix | Delete
if __name__ == '__main__':
[146] Fix | Delete
import unittest
[147] Fix | Delete
unittest.main('idlelib.idle_test.test_helpabout', verbosity=2, exit=False)
[148] Fix | Delete
from idlelib.idle_test.htest import run
[149] Fix | Delete
run(AboutDialog)
[150] Fix | Delete
[151] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function