You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"payload":{"allShortcutsEnabled":false,"fileTree":{"Lib/tkinter":{"items":[{"name":"__init__.py","path":"Lib/tkinter/__init__.py","contentType":"file"},{"name":"__main__.py","path":"Lib/tkinter/__main__.py","contentType":"file"},{"name":"colorchooser.py","path":"Lib/tkinter/colorchooser.py","contentType":"file"},{"name":"commondialog.py","path":"Lib/tkinter/commondialog.py","contentType":"file"},{"name":"constants.py","path":"Lib/tkinter/constants.py","contentType":"file"},{"name":"dialog.py","path":"Lib/tkinter/dialog.py","contentType":"file"},{"name":"dnd.py","path":"Lib/tkinter/dnd.py","contentType":"file"},{"name":"filedialog.py","path":"Lib/tkinter/filedialog.py","contentType":"file"},{"name":"font.py","path":"Lib/tkinter/font.py","contentType":"file"},{"name":"messagebox.py","path":"Lib/tkinter/messagebox.py","contentType":"file"},{"name":"scrolledtext.py","path":"Lib/tkinter/scrolledtext.py","contentType":"file"},{"name":"simpledialog.py","path":"Lib/tkinter/simpledialog.py","contentType":"file"},{"name":"ttk.py","path":"Lib/tkinter/ttk.py","contentType":"file"}],"totalCount":13},"Lib":{"items":[{"name":"__phello__","path":"Lib/__phello__","contentType":"directory"},{"name":"_pyrepl","path":"Lib/_pyrepl","contentType":"directory"},{"name":"asyncio","path":"Lib/asyncio","contentType":"directory"},{"name":"collections","path":"Lib/collections","contentType":"directory"},{"name":"concurrent","path":"Lib/concurrent","contentType":"directory"},{"name":"ctypes","path":"Lib/ctypes","contentType":"directory"},{"name":"curses","path":"Lib/curses","contentType":"directory"},{"name":"dbm","path":"Lib/dbm","contentType":"directory"},{"name":"email","path":"Lib/email","contentType":"directory"},{"name":"encodings","path":"Lib/encodings","contentType":"directory"},{"name":"ensurepip","path":"Lib/ensurepip","contentType":"directory"},{"name":"html","path":"Lib/html","contentType":"directory"},{"name":"http","path":"Lib/http","contentType":"directory"},{"name":"idlelib","path":"Lib/idlelib","contentType":"directory"},{"name":"importlib","path":"Lib/importlib","contentType":"directory"},{"name":"json","path":"Lib/json","contentType":"directory"},{"name":"logging","path":"Lib/logging","contentType":"directory"},{"name":"multiprocessing","path":"Lib/multiprocessing","contentType":"directory"},{"name":"pathlib","path":"Lib/pathlib","contentType":"directory"},{"name":"pydoc_data","path":"Lib/pydoc_data","contentType":"directory"},{"name":"re","path":"Lib/re","contentType":"directory"},{"name":"site-packages","path":"Lib/site-packages","contentType":"directory"},{"name":"sqlite3","path":"Lib/sqlite3","contentType":"directory"},{"name":"sysconfig","path":"Lib/sysconfig","contentType":"directory"},{"name":"test","path":"Lib/test","contentType":"directory"},{"name":"tkinter","path":"Lib/tkinter","contentType":"directory"},{"name":"tomllib","path":"Lib/tomllib","contentType":"directory"},{"name":"turtledemo","path":"Lib/turtledemo","contentType":"directory"},{"name":"unittest","path":"Lib/unittest","contentType":"directory"},{"name":"urllib","path":"Lib/urllib","contentType":"directory"},{"name":"venv","path":"Lib/venv","contentType":"directory"},{"name":"wsgiref","path":"Lib/wsgiref","contentType":"directory"},{"name":"xml","path":"Lib/xml","contentType":"directory"},{"name":"xmlrpc","path":"Lib/xmlrpc","contentType":"directory"},{"name":"zipfile","path":"Lib/zipfile","contentType":"directory"},{"name":"zoneinfo","path":"Lib/zoneinfo","contentType":"directory"},{"name":"__future__.py","path":"Lib/__future__.py","contentType":"file"},{"name":"__hello__.py","path":"Lib/__hello__.py","contentType":"file"},{"name":"_aix_support.py","path":"Lib/_aix_support.py","contentType":"file"},{"name":"_android_support.py","path":"Lib/_android_support.py","contentType":"file"},{"name":"_apple_support.py","path":"Lib/_apple_support.py","contentType":"file"},{"name":"_collections_abc.py","path":"Lib/_collections_abc.py","contentType":"file"},{"name":"_colorize.py","path":"Lib/_colorize.py","contentType":"file"},{"name":"_compat_pickle.py","path":"Lib/_compat_pickle.py","contentType":"file"},{"name":"_compression.py","path":"Lib/_compression.py","contentType":"file"},{"name":"_ios_support.py","path":"Lib/_ios_support.py","contentType":"file"},{"name":"_markupbase.py","path":"Lib/_markupbase.py","contentType":"file"},{"name":"_opcode_metadata.py","path":"Lib/_opcode_metadata.py","contentType":"file"},{"name":"_osx_support.py","path":"Lib/_osx_support.py","contentType":"file"},{"name":"_py_abc.py","path":"Lib/_py_abc.py","contentType":"file"},{"name":"_pydatetime.py","path":"Lib/_pydatetime.py","contentType":"file"},{"name":"_pydecimal.py","path":"Lib/_pydecimal.py","contentType":"file"},{"name":"_pyio.py","path":"Lib/_pyio.py","contentType":"file"},{"name":"_pylong.py","path":"Lib/_pylong.py","contentType":"file"},{"name":"_sitebuiltins.py","path":"Lib/_sitebuiltins.py","contentType":"file"},{"name":"_strptime.py","path":"Lib/_strptime.py","contentType":"file"},{"name":"_threading_local.py","path":"Lib/_threading_local.py","contentType":"file"},{"name":"_weakrefset.py","path":"Lib/_weakrefset.py","contentType":"file"},{"name":"abc.py","path":"Lib/abc.py","contentType":"file"},{"name":"antigravity.py","path":"Lib/antigravity.py","contentType":"file"},{"name":"argparse.py","path":"Lib/argparse.py","contentType":"file"},{"name":"ast.py","path":"Lib/ast.py","contentType":"file"},{"name":"base64.py","path":"Lib/base64.py","contentType":"file"},{"name":"bdb.py","path":"Lib/bdb.py","contentType":"file"},{"name":"bisect.py","path":"Lib/bisect.py","contentType":"file"},{"name":"bz2.py","path":"Lib/bz2.py","contentType":"file"},{"name":"cProfile.py","path":"Lib/cProfile.py","contentType":"file"},{"name":"calendar.py","path":"Lib/calendar.py","contentType":"file"},{"name":"cmd.py","path":"Lib/cmd.py","contentType":"file"},{"name":"code.py","path":"Lib/code.py","contentType":"file"},{"name":"codecs.py","path":"Lib/codecs.py","contentType":"file"},{"name":"codeop.py","path":"Lib/codeop.py","contentType":"file"},{"name":"colorsys.py","path":"Lib/colorsys.py","contentType":"file"},{"name":"compileall.py","path":"Lib/compileall.py","contentType":"file"},{"name":"configparser.py","path":"Lib/configparser.py","contentType":"file"},{"name":"contextlib.py","path":"Lib/contextlib.py","contentType":"file"},{"name":"contextvars.py","path":"Lib/contextvars.py","contentType":"file"},{"name":"copy.py","path":"Lib/copy.py","contentType":"file"},{"name":"copyreg.py","path":"Lib/copyreg.py","contentType":"file"},{"name":"csv.py","path":"Lib/csv.py","contentType":"file"},{"name":"dataclasses.py","path":"Lib/dataclasses.py","contentType":"file"},{"name":"datetime.py","path":"Lib/datetime.py","contentType":"file"},{"name":"decimal.py","path":"Lib/decimal.py","contentType":"file"},{"name":"difflib.py","path":"Lib/difflib.py","contentType":"file"},{"name":"dis.py","path":"Lib/dis.py","contentType":"file"},{"name":"doctest.py","path":"Lib/doctest.py","contentType":"file"},{"name":"enum.py","path":"Lib/enum.py","contentType":"file"},{"name":"filecmp.py","path":"Lib/filecmp.py","contentType":"file"},{"name":"fileinput.py","path":"Lib/fileinput.py","contentType":"file"},{"name":"fnmatch.py","path":"Lib/fnmatch.py","contentType":"file"},{"name":"fractions.py","path":"Lib/fractions.py","contentType":"file"},{"name":"ftplib.py","path":"Lib/ftplib.py","contentType":"file"},{"name":"functools.py","path":"Lib/functools.py","contentType":"file"},{"name":"genericpath.py","path":"Lib/genericpath.py","contentType":"file"},{"name":"getopt.py","path":"Lib/getopt.py","contentType":"file"},{"name":"getpass.py","path":"Lib/getpass.py","contentType":"file"},{"name":"gettext.py","path":"Lib/gettext.py","contentType":"file"},{"name":"glob.py","path":"Lib/glob.py","contentType":"file"},{"name":"graphlib.py","path":"Lib/graphlib.py","contentType":"file"},{"name":"gzip.py","path":"Lib/gzip.py","contentType":"file"},{"name":"hashlib.py","path":"Lib/hashlib.py","contentType":"file"},{"name":"heapq.py","path":"Lib/heapq.py","contentType":"file"},{"name":"hmac.py","path":"Lib/hmac.py","contentType":"file"},{"name":"imaplib.py","path":"Lib/imaplib.py","contentType":"file"},{"name":"inspect.py","path":"Lib/inspect.py","contentType":"file"},{"name":"io.py","path":"Lib/io.py","contentType":"file"},{"name":"ipaddress.py","path":"Lib/ipaddress.py","contentType":"file"},{"name":"keyword.py","path":"Lib/keyword.py","contentType":"file"},{"name":"linecache.py","path":"Lib/linecache.py","contentType":"file"},{"name":"locale.py","path":"Lib/locale.py","contentType":"file"},{"name":"lzma.py","path":"Lib/lzma.py","contentType":"file"},{"name":"mailbox.py","path":"Lib/mailbox.py","contentType":"file"},{"name":"mimetypes.py","path":"Lib/mimetypes.py","contentType":"file"},{"name":"modulefinder.py","path":"Lib/modulefinder.py","contentType":"file"},{"name":"netrc.py","path":"Lib/netrc.py","contentType":"file"},{"name":"ntpath.py","path":"Lib/ntpath.py","contentType":"file"},{"name":"nturl2path.py","path":"Lib/nturl2path.py","contentType":"file"},{"name":"numbers.py","path":"Lib/numbers.py","contentType":"file"},{"name":"opcode.py","path":"Lib/opcode.py","contentType":"file"},{"name":"operator.py","path":"Lib/operator.py","contentType":"file"},{"name":"optparse.py","path":"Lib/optparse.py","contentType":"file"},{"name":"os.py","path":"Lib/os.py","contentType":"file"},{"name":"pdb.py","path":"Lib/pdb.py","contentType":"file"},{"name":"pickle.py","path":"Lib/pickle.py","contentType":"file"},{"name":"pickletools.py","path":"Lib/pickletools.py","contentType":"file"},{"name":"pkgutil.py","path":"Lib/pkgutil.py","contentType":"file"},{"name":"platform.py","path":"Lib/platform.py","contentType":"file"},{"name":"plistlib.py","path":"Lib/plistlib.py","contentType":"file"},{"name":"poplib.py","path":"Lib/poplib.py","contentType":"file"},{"name":"posixpath.py","path":"Lib/posixpath.py","contentType":"file"},{"name":"pprint.py","path":"Lib/pprint.py","contentType":"file"},{"name":"profile.py","path":"Lib/profile.py","contentType":"file"},{"name":"pstats.py","path":"Lib/pstats.py","contentType":"file"},{"name":"pty.py","path":"Lib/pty.py","contentType":"file"},{"name":"py_compile.py","path":"Lib/py_compile.py","contentType":"file"},{"name":"pyclbr.py","path":"Lib/pyclbr.py","contentType":"file"},{"name":"pydoc.py","path":"Lib/pydoc.py","contentType":"file"},{"name":"queue.py","path":"Lib/queue.py","contentType":"file"},{"name":"quopri.py","path":"Lib/quopri.py","contentType":"file"},{"name":"random.py","path":"Lib/random.py","contentType":"file"},{"name":"reprlib.py","path":"Lib/reprlib.py","contentType":"file"},{"name":"rlcompleter.py","path":"Lib/rlcompleter.py","contentType":"file"},{"name":"runpy.py","path":"Lib/runpy.py","contentType":"file"},{"name":"sched.py","path":"Lib/sched.py","contentType":"file"},{"name":"secrets.py","path":"Lib/secrets.py","contentType":"file"},{"name":"selectors.py","path":"Lib/selectors.py","contentType":"file"},{"name":"shelve.py","path":"Lib/shelve.py","contentType":"file"},{"name":"shlex.py","path":"Lib/shlex.py","contentType":"file"},{"name":"shutil.py","path":"Lib/shutil.py","contentType":"file"},{"name":"signal.py","path":"Lib/signal.py","contentType":"file"},{"name":"site.py","path":"Lib/site.py","contentType":"file"},{"name":"smtplib.py","path":"Lib/smtplib.py","contentType":"file"},{"name":"socket.py","path":"Lib/socket.py","contentType":"file"},{"name":"socketserver.py","path":"Lib/socketserver.py","contentType":"file"},{"name":"sre_compile.py","path":"Lib/sre_compile.py","contentType":"file"},{"name":"sre_constants.py","path":"Lib/sre_constants.py","contentType":"file"},{"name":"sre_parse.py","path":"Lib/sre_parse.py","contentType":"file"},{"name":"ssl.py","path":"Lib/ssl.py","contentType":"file"},{"name":"stat.py","path":"Lib/stat.py","contentType":"file"},{"name":"statistics.py","path":"Lib/statistics.py","contentType":"file"},{"name":"string.py","path":"Lib/string.py","contentType":"file"},{"name":"stringprep.py","path":"Lib/stringprep.py","contentType":"file"},{"name":"struct.py","path":"Lib/struct.py","contentType":"file"},{"name":"subprocess.py","path":"Lib/subprocess.py","contentType":"file"},{"name":"symtable.py","path":"Lib/symtable.py","contentType":"file"},{"name":"tabnanny.py","path":"Lib/tabnanny.py","contentType":"file"},{"name":"tarfile.py","path":"Lib/tarfile.py","contentType":"file"},{"name":"tempfile.py","path":"Lib/tempfile.py","contentType":"file"},{"name":"textwrap.py","path":"Lib/textwrap.py","contentType":"file"},{"name":"this.py","path":"Lib/this.py","contentType":"file"},{"name":"threading.py","path":"Lib/threading.py","contentType":"file"},{"name":"timeit.py","path":"Lib/timeit.py","contentType":"file"},{"name":"token.py","path":"Lib/token.py","contentType":"file"},{"name":"tokenize.py","path":"Lib/tokenize.py","contentType":"file"},{"name":"trace.py","path":"Lib/trace.py","contentType":"file"},{"name":"traceback.py","path":"Lib/traceback.py","contentType":"file"},{"name":"tracemalloc.py","path":"Lib/tracemalloc.py","contentType":"file"},{"name":"tty.py","path":"Lib/tty.py","contentType":"file"},{"name":"turtle.py","path":"Lib/turtle.py","contentType":"file"},{"name":"types.py","path":"Lib/types.py","contentType":"file"},{"name":"typing.py","path":"Lib/typing.py","contentType":"file"},{"name":"uuid.py","path":"Lib/uuid.py","contentType":"file"},{"name":"warnings.py","path":"Lib/warnings.py","contentType":"file"},{"name":"wave.py","path":"Lib/wave.py","contentType":"file"},{"name":"weakref.py","path":"Lib/weakref.py","contentType":"file"},{"name":"webbrowser.py","path":"Lib/webbrowser.py","contentType":"file"},{"name":"zipapp.py","path":"Lib/zipapp.py","contentType":"file"},{"name":"zipimport.py","path":"Lib/zipimport.py","contentType":"file"}],"totalCount":188},"":{"items":[{"name":".azure-pipelines","path":".azure-pipelines","contentType":"directory"},{"name":".devcontainer","path":".devcontainer","contentType":"directory"},{"name":".github","path":".github","contentType":"directory"},{"name":"Android","path":"Android","contentType":"directory"},{"name":"Doc","path":"Doc","contentType":"directory"},{"name":"Grammar","path":"Grammar","contentType":"directory"},{"name":"Include","path":"Include","contentType":"directory"},{"name":"InternalDocs","path":"InternalDocs","contentType":"directory"},{"name":"Lib","path":"Lib","contentType":"directory"},{"name":"Mac","path":"Mac","contentType":"directory"},{"name":"Misc","path":"Misc","contentType":"directory"},{"name":"Modules","path":"Modules","contentType":"directory"},{"name":"Objects","path":"Objects","contentType":"directory"},{"name":"PC","path":"PC","contentType":"directory"},{"name":"PCbuild","path":"PCbuild","contentType":"directory"},{"name":"Parser","path":"Parser","contentType":"directory"},{"name":"Programs","path":"Programs","contentType":"directory"},{"name":"Python","path":"Python","contentType":"directory"},{"name":"Tools","path":"Tools","contentType":"directory"},{"name":"iOS","path":"iOS","contentType":"directory"},{"name":".coveragerc","path":".coveragerc","contentType":"file"},{"name":".editorconfig","path":".editorconfig","contentType":"file"},{"name":".gitattributes","path":".gitattributes","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".mailmap","path":".mailmap","contentType":"file"},{"name":".pre-commit-config.yaml","path":".pre-commit-config.yaml","contentType":"file"},{"name":".readthedocs.yml","path":".readthedocs.yml","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"Makefile.pre.in","path":"Makefile.pre.in","contentType":"file"},{"name":"README.rst","path":"README.rst","contentType":"file"},{"name":"aclocal.m4","path":"aclocal.m4","contentType":"file"},{"name":"config.guess","path":"config.guess","contentType":"file"},{"name":"config.sub","path":"config.sub","contentType":"file"},{"name":"configure","path":"configure","contentType":"file"},{"name":"configure.ac","path":"configure.ac","contentType":"file"},{"name":"install-sh","path":"install-sh","contentType":"file"},{"name":"pyconfig.h.in","path":"pyconfig.h.in","contentType":"file"}],"totalCount":37}},"fileTreeProcessingTime":30.269339,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":81598961,"defaultBranch":"main","name":"cpython","ownerLogin":"python","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2017-02-10T19:23:51.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/1525981?v=4","public":true,"private":false,"isOrgOwned":true},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"3.13","listCacheKey":"v0:1746633766.0","canEdit":false,"refType":"branch","currentOid":"1dbb644a5b458aebc48022d2c28d16dfd8ae0d73"},"path":"Lib/tkinter/simpledialog.py","currentUser":null,"blob":{"rawLines":["#","# An Introduction to Tkinter","#","# Copyright (c) 1997 by Fredrik Lundh","#","# This copyright applies to Dialog, askinteger, askfloat and asktring","#","# fredrik@pythonware.com","# http://www.pythonware.com","#","\"\"\"This modules handles dialog boxes.","","It contains the following public symbols:","","SimpleDialog -- A simple but flexible modal dialog box","","Dialog -- a base class for dialogs","","askinteger -- get an integer from the user","","askfloat -- get a float from the user","","askstring -- get a string from the user","\"\"\"","","from tkinter import *","from tkinter import _get_temp_root, _destroy_temp_root","from tkinter import messagebox","","","class SimpleDialog:",""," def __init__(self, master,"," text='', buttons=[], default=None, cancel=None,"," title=None, class_=None):"," if class_:"," self.root = Toplevel(master, class_=class_)"," else:"," self.root = Toplevel(master)"," if title:"," self.root.title(title)"," self.root.iconname(title)",""," _setup_dialog(self.root)",""," self.message = Message(self.root, text=text, aspect=400)"," self.message.pack(expand=1, fill=BOTH)"," self.frame = Frame(self.root)"," self.frame.pack()"," self.num = default"," self.cancel = cancel"," self.default = default"," self.root.bind('\u003cReturn\u003e', self.return_event)"," for num in range(len(buttons)):"," s = buttons[num]"," b = Button(self.frame, text=s,"," command=(lambda self=self, num=num: self.done(num)))"," if num == default:"," b.config(relief=RIDGE, borderwidth=8)"," b.pack(side=LEFT, fill=BOTH, expand=1)"," self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window)"," self.root.transient(master)"," _place_window(self.root, master)",""," def go(self):"," self.root.wait_visibility()"," self.root.grab_set()"," self.root.mainloop()"," self.root.destroy()"," return self.num",""," def return_event(self, event):"," if self.default is None:"," self.root.bell()"," else:"," self.done(self.default)",""," def wm_delete_window(self):"," if self.cancel is None:"," self.root.bell()"," else:"," self.done(self.cancel)",""," def done(self, num):"," self.num = num"," self.root.quit()","","","class Dialog(Toplevel):",""," '''Class to open dialogs.",""," This class is intended as a base class for custom dialogs"," '''",""," def __init__(self, parent, title = None):"," '''Initialize a dialog.",""," Arguments:",""," parent -- a parent window (the application window)",""," title -- the dialog title"," '''"," master = parent"," if master is None:"," master = _get_temp_root()",""," Toplevel.__init__(self, master)",""," self.withdraw() # remain invisible for now"," # If the parent is not viewable, don't"," # make the child transient, or else it"," # would be opened withdrawn"," if parent is not None and parent.winfo_viewable():"," self.transient(parent)",""," if title:"," self.title(title)",""," _setup_dialog(self)",""," self.parent = parent",""," self.result = None",""," body = Frame(self)"," self.initial_focus = self.body(body)"," body.pack(padx=5, pady=5)",""," self.buttonbox()",""," if self.initial_focus is None:"," self.initial_focus = self",""," self.protocol(\"WM_DELETE_WINDOW\", self.cancel)",""," _place_window(self, parent)",""," self.initial_focus.focus_set()",""," # wait for window to appear on screen before calling grab_set"," self.wait_visibility()"," self.grab_set()"," self.wait_window(self)",""," def destroy(self):"," '''Destroy the window'''"," self.initial_focus = None"," Toplevel.destroy(self)"," _destroy_temp_root(self.master)",""," #"," # construction hooks",""," def body(self, master):"," '''create dialog body.",""," return widget that should have initial focus."," This method should be overridden, and is called"," by the __init__ method."," '''"," pass",""," def buttonbox(self):"," '''add standard button box.",""," override if you do not want the standard buttons"," '''",""," box = Frame(self)",""," w = Button(box, text=\"OK\", width=10, command=self.ok, default=ACTIVE)"," w.pack(side=LEFT, padx=5, pady=5)"," w = Button(box, text=\"Cancel\", width=10, command=self.cancel)"," w.pack(side=LEFT, padx=5, pady=5)",""," self.bind(\"\u003cReturn\u003e\", self.ok)"," self.bind(\"\u003cEscape\u003e\", self.cancel)",""," box.pack()",""," #"," # standard button semantics",""," def ok(self, event=None):",""," if not self.validate():"," self.initial_focus.focus_set() # put focus back"," return",""," self.withdraw()"," self.update_idletasks()",""," try:"," self.apply()"," finally:"," self.cancel()",""," def cancel(self, event=None):",""," # put focus back to the parent window"," if self.parent is not None:"," self.parent.focus_set()"," self.destroy()",""," #"," # command hooks",""," def validate(self):"," '''validate the data",""," This method is called automatically to validate the data before the"," dialog is destroyed. By default, it always validates OK."," '''",""," return 1 # override",""," def apply(self):"," '''process the data",""," This method is called automatically to process the data, *after*"," the dialog is destroyed. By default, it does nothing."," '''",""," pass # override","","","# Place a toplevel window at the center of parent or screen","# It is a Python implementation of ::tk::PlaceWindow.","def _place_window(w, parent=None):"," w.wm_withdraw() # Remain invisible while we figure out the geometry"," w.update_idletasks() # Actualize geometry information",""," minwidth = w.winfo_reqwidth()"," minheight = w.winfo_reqheight()"," maxwidth = w.winfo_vrootwidth()"," maxheight = w.winfo_vrootheight()"," if parent is not None and parent.winfo_ismapped():"," x = parent.winfo_rootx() + (parent.winfo_width() - minwidth) // 2"," y = parent.winfo_rooty() + (parent.winfo_height() - minheight) // 2"," vrootx = w.winfo_vrootx()"," vrooty = w.winfo_vrooty()"," x = min(x, vrootx + maxwidth - minwidth)"," x = max(x, vrootx)"," y = min(y, vrooty + maxheight - minheight)"," y = max(y, vrooty)"," if w._windowingsystem == 'aqua':"," # Avoid the native menu bar which sits on top of everything."," y = max(y, 22)"," else:"," x = (w.winfo_screenwidth() - minwidth) // 2"," y = (w.winfo_screenheight() - minheight) // 2",""," w.wm_maxsize(maxwidth, maxheight)"," w.wm_geometry('+%d+%d' % (x, y))"," w.wm_deiconify() # Become visible at the desired location","","","def _setup_dialog(w):"," if w._windowingsystem == \"aqua\":"," w.tk.call(\"::tk::unsupported::MacWindowStyle\", \"style\","," w, \"moveableModal\", \"\")"," elif w._windowingsystem == \"x11\":"," w.wm_attributes(type=\"dialog\")","","# --------------------------------------------------------------------","# convenience dialogues","","class _QueryDialog(Dialog):",""," def __init__(self, title, prompt,"," initialvalue=None,"," minvalue = None, maxvalue = None,"," parent = None):",""," self.prompt = prompt"," self.minvalue = minvalue"," self.maxvalue = maxvalue",""," self.initialvalue = initialvalue",""," Dialog.__init__(self, parent, title)",""," def destroy(self):"," self.entry = None"," Dialog.destroy(self)",""," def body(self, master):",""," w = Label(master, text=self.prompt, justify=LEFT)"," w.grid(row=0, padx=5, sticky=W)",""," self.entry = Entry(master, name=\"entry\")"," self.entry.grid(row=1, padx=5, sticky=W+E)",""," if self.initialvalue is not None:"," self.entry.insert(0, self.initialvalue)"," self.entry.select_range(0, END)",""," return self.entry",""," def validate(self):"," try:"," result = self.getresult()"," except ValueError:"," messagebox.showwarning("," \"Illegal value\","," self.errormessage + \"\\nPlease try again\","," parent = self"," )"," return 0",""," if self.minvalue is not None and result \u003c self.minvalue:"," messagebox.showwarning("," \"Too small\","," \"The allowed minimum value is %s. \""," \"Please try again.\" % self.minvalue,"," parent = self"," )"," return 0",""," if self.maxvalue is not None and result \u003e self.maxvalue:"," messagebox.showwarning("," \"Too large\","," \"The allowed maximum value is %s. \""," \"Please try again.\" % self.maxvalue,"," parent = self"," )"," return 0",""," self.result = result",""," return 1","","","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",""," Arguments:",""," title -- the dialog title"," prompt -- the label text"," **kw -- see SimpleDialog class",""," Return value is an integer"," '''"," 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",""," Arguments:",""," title -- the dialog title"," prompt -- the label text"," **kw -- see SimpleDialog class",""," Return value is a float"," '''"," d = _QueryFloat(title, prompt, **kw)"," return d.result","","","class _QueryString(_QueryDialog):"," def __init__(self, *args, **kw):"," if \"show\" in kw:"," self.__show = kw[\"show\"]"," del kw[\"show\"]"," else:"," self.__show = None"," _QueryDialog.__init__(self, *args, **kw)",""," def body(self, master):"," entry = _QueryDialog.body(self, master)"," if self.__show is not None:"," entry.configure(show=self.__show)"," return entry",""," def getresult(self):"," return self.entry.get()","","","def askstring(title, prompt, **kw):"," '''get a string from the user",""," Arguments:",""," title -- the dialog title"," prompt -- the label text"," **kw -- see SimpleDialog class",""," Return value is a string"," '''"," d = _QueryString(title, prompt, **kw)"," return d.result","","","if __name__ == '__main__':",""," def test():"," root = Tk()"," def doit(root=root):"," d = SimpleDialog(root,"," text=\"This is a test dialog. \""," \"Would this have been an actual dialog, \""," \"the buttons below would have been glowing \""," \"in soft pink light.\\n\""," \"Do you believe this?\","," buttons=[\"Yes\", \"No\", \"Cancel\"],"," default=0,"," cancel=2,"," title=\"Test Dialog\")"," print(d.go())"," print(askinteger(\"Spam\", \"Egg count\", initialvalue=12*12))"," print(askfloat(\"Spam\", \"Egg weight\\n(in tons)\", minvalue=1,"," maxvalue=100))"," print(askstring(\"Spam\", \"Egg label\"))"," t = Button(root, text='Test', command=doit)"," t.pack()"," q = Button(root, text='Quit', command=t.quit)"," q.pack()"," t.mainloop()",""," test()"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/python/cpython/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"simpledialog.py","displayUrl":"https://github.com/python/cpython/blob/3.13/Lib/tkinter/simpledialog.py?raw=true","headerInfo":{"blobSize":"11.5 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"6e5b025","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fblob%2F3.13%2FLib%2Ftkinter%2Fsimpledialog.py","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"441","truncatedSloc":"328"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Python","languageID":303,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/python/cpython/blob/3.13/Lib/tkinter/simpledialog.py","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/python/cpython/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/python/cpython/raw/refs/heads/3.13/Lib/tkinter/simpledialog.py","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":4,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":"/python/.github/blob/5a0a7cb55767fb3667fe2391bcb66bda638edcb4/FUNDING.yml","showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"SimpleDialog","kind":"class","ident_start":618,"ident_end":630,"extent_start":612,"extent_end":2345,"fully_qualified_name":"SimpleDialog","ident_utf16":{"start":{"line_number":30,"utf16_col":6},"end":{"line_number":30,"utf16_col":18}},"extent_utf16":{"start":{"line_number":30,"utf16_col":0},"end":{"line_number":85,"utf16_col":24}}},{"name":"__init__","kind":"function","ident_start":641,"ident_end":649,"extent_start":637,"extent_end":1815,"fully_qualified_name":"SimpleDialog.__init__","ident_utf16":{"start":{"line_number":32,"utf16_col":8},"end":{"line_number":32,"utf16_col":16}},"extent_utf16":{"start":{"line_number":32,"utf16_col":4},"end":{"line_number"
5E33
:62,"utf16_col":40}}},{"name":"go","kind":"function","ident_start":1825,"ident_end":1827,"extent_start":1821,"extent_end":1980,"fully_qualified_name":"SimpleDialog.go","ident_utf16":{"start":{"line_number":64,"utf16_col":8},"end":{"line_number":64,"utf16_col":10}},"extent_utf16":{"start":{"line_number":64,"utf16_col":4},"end":{"line_number":69,"utf16_col":23}}},{"name":"return_event","kind":"function","ident_start":1990,"ident_end":2002,"extent_start":1986,"extent_end":2128,"fully_qualified_name":"SimpleDialog.return_event","ident_utf16":{"start":{"line_number":71,"utf16_col":8},"end":{"line_number":71,"utf16_col":20}},"extent_utf16":{"start":{"line_number":71,"utf16_col":4},"end":{"line_number":75,"utf16_col":35}}},{"name":"wm_delete_window","kind":"function","ident_start":2138,"ident_end":2154,"extent_start":2134,"extent_end":2271,"fully_qualified_name":"SimpleDialog.wm_delete_window","ident_utf16":{"start":{"line_number":77,"utf16_col":8},"end":{"line_number":77,"utf16_col":24}},"extent_utf16":{"start":{"line_number":77,"utf16_col":4},"end":{"line_number":81,"utf16_col":34}}},{"name":"done","kind":"function","ident_start":2281,"ident_end":2285,"extent_start":2277,"extent_end":2345,"fully_qualified_name":"SimpleDialog.done","ident_utf16":{"start":{"line_number":83,"utf16_col":8},"end":{"line_number":83,"utf16_col":12}},"extent_utf16":{"start":{"line_number":83,"utf16_col":4},"end":{"line_number":85,"utf16_col":24}}},{"name":"Dialog","kind":"class","ident_start":2354,"ident_end":2360,"extent_start":2348,"extent_end":5632,"fully_qualified_name":"Dialog","ident_utf16":{"start":{"line_number":88,"utf16_col":6},"end":{"line_number":88,"utf16_col":12}},"extent_utf16":{"start":{"line_number":88,"utf16_col":0},"end":{"line_number":225,"utf16_col":23}}},{"name":"__init__","kind":"function","ident_start":2483,"ident_end":2491,"extent_start":2479,"extent_end":3730,"fully_qualified_name":"Dialog.__init__","ident_utf16":{"start":{"line_number":95,"utf16_col":8},"end":{"line_number":95,"utf16_col":16}},"extent_utf16":{"start":{"line_number":95,"utf16_col":4},"end":{"line_number":144,"utf16_col":30}}},{"name":"destroy","kind":"function","ident_start":3740,"ident_end":3747,"extent_start":3736,"extent_end":3892,"fully_qualified_name":"Dialog.destroy","ident_utf16":{"start":{"line_number":146,"utf16_col":8},"end":{"line_number":146,"utf16_col":15}},"extent_utf16":{"start":{"line_number":146,"utf16_col":4},"end":{"line_number":150,"utf16_col":39}}},{"name":"body","kind":"function","ident_start":3934,"ident_end":3938,"extent_start":3930,"extent_end":4152,"fully_qualified_name":"Dialog.body","ident_utf16":{"start":{"line_number":155,"utf16_col":8},"end":{"line_number":155,"utf16_col":12}},"extent_utf16":{"start":{"line_number":155,"utf16_col":4},"end":{"line_number":162,"utf16_col":12}}},{"name":"buttonbox","kind":"function","ident_start":4162,"ident_end":4171,"extent_start":4158,"extent_end":4647,"fully_qualified_name":"Dialog.buttonbox","ident_utf16":{"start":{"line_number":164,"utf16_col":8},"end":{"line_number":164,"utf16_col":17}},"extent_utf16":{"start":{"line_number":164,"utf16_col":4},"end":{"line_number":180,"utf16_col":18}}},{"name":"ok","kind":"function","ident_start":4696,"ident_end":4698,"extent_start":4692,"extent_end":4968,"fully_qualified_name":"Dialog.ok","ident_utf16":{"start":{"line_number":185,"utf16_col":8},"end":{"line_number":185,"utf16_col":10}},"extent_utf16":{"start":{"line_number":185,"utf16_col":4},"end":{"line_number":197,"utf16_col":25}}},{"name":"cancel","kind":"function","ident_start":4978,"ident_end":4984,"extent_start":4974,"extent_end":5145,"fully_qualified_name":"Dialog.cancel","ident_utf16":{"start":{"line_number":199,"utf16_col":8},"end":{"line_number":199,"utf16_col":14}},"extent_utf16":{"start":{"line_number":199,"utf16_col":4},"end":{"line_number":204,"utf16_col":22}}},{"name":"validate","kind":"function","ident_start":5182,"ident_end":5190,"extent_start":5178,"extent_end":5409,"fully_qualified_name":"Dialog.validate","ident_utf16":{"start":{"line_number":209,"utf16_col":8},"end":{"line_number":209,"utf16_col":16}},"extent_utf16":{"start":{"line_number":209,"utf16_col":4},"end":{"line_number":216,"utf16_col":27}}},{"name":"apply","kind":"function","ident_start":5419,"ident_end":5424,"extent_start":5415,"extent_end":5632,"fully_qualified_name":"Dialog.apply","ident_utf16":{"start":{"line_number":218,"utf16_col":8},"end":{"line_number":218,"utf16_col":13}},"extent_utf16":{"start":{"line_number":218,"utf16_col":4},"end":{"line_number":225,"utf16_col":23}}},{"name":"_place_window","kind":"function","ident_start":5753,"ident_end":5766,"extent_start":5749,"extent_end":6880,"fully_qualified_name":"_place_window","ident_utf16":{"start":{"line_number":230,"utf16_col":4},"end":{"line_number":230,"utf16_col":17}},"extent_utf16":{"start":{"line_number":230,"utf16_col":0},"end":{"line_number":256,"utf16_col":61}}},{"name":"_setup_dialog","kind":"function","ident_start":6887,"ident_end":6900,"extent_start":6883,"extent_end":7124,"fully_qualified_name":"_setup_dialog","ident_utf16":{"start":{"line_number":259,"utf16_col":4},"end":{"line_number":259,"utf16_col":17}},"extent_utf16":{"start":{"line_number":259,"utf16_col":0},"end":{"line_number":264,"utf16_col":38}}},{"name":"_QueryDialog","kind":"class","ident_start":7228,"ident_end":7240,"extent_start":7222,"extent_end":9013,"fully_qualified_name":"_QueryDialog","ident_utf16":{"start":{"line_number":269,"utf16_col":6},"end":{"line_number":269,"utf16_col":18}},"extent_utf16":{"start":{"line_number":269,"utf16_col":0},"end":{"line_number":333,"utf16_col":16}}},{"name":"__init__","kind":"function","ident_start":7259,"ident_end":7267,"extent_start":7255,"extent_end":7594,"fully_qualified_name":"_QueryDialog.__init__","ident_utf16":{"start":{"line_number":271,"utf16_col":8},"end":{"line_number":271,"utf16_col":16}},"extent_utf16":{"start":{"line_number":271,"utf16_col":4},"end":{"line_number":282,"utf16_col":44}}},{"name":"destroy","kind":"function","ident_start":7604,"ident_end":7611,"extent_start":7600,"extent_end":7673,"fully_qualified_name":"_QueryDialog.destroy","ident_utf16":{"start":{"line_number":284,"utf16_col":8},"end":{"line_number":284,"utf16_col":15}},"extent_utf16":{"start":{"line_number":284,"utf16_col":4},"end":{"line_number":286,"utf16_col":28}}},{"name":"body","kind":"function","ident_start":7683,"ident_end":7687,"extent_start":7679,"extent_end":8068,"fully_qualified_name":"_QueryDialog.body","ident_utf16":{"start":{"line_number":288,"utf16_col":8},"end":{"line_number":288,"utf16_col":12}},"extent_utf16":{"start":{"line_number":288,"utf16_col":4},"end":{"line_number":300,"utf16_col":25}}},{"name":"validate","kind":"function","ident_start":8078,"ident_end":8086,"extent_start":8074,"extent_end":9013,"fully_qualified_name":"_QueryDialog.validate","ident_utf16":{"start":{"line_number":302,"utf16_col":8},"end":{"line_number":302,"utf16_col":16}},"extent_utf16":{"start":{"line_number":302,"utf16_col":4},"end":{"line_number":333,"utf16_col":16}}},{"name":"_QueryInteger","kind":"class","ident_start":9022,"ident_end":9035,"extent_start":9016,"extent_end":9158,"fully_qualified_name":"_QueryInteger","ident_utf16":{"start":{"line_number":336,"utf16_col":6},"end":{"line_number":336,"utf16_col":19}},"extent_utf16":{"start":{"line_number":336,"utf16_col":0},"end":{"line_number":340,"utf16_col":44}}},{"name":"errormessage","kind":"constant","ident_start":9055,"ident_end":9067,"extent_start":9055,"extent_end":9087,"fully_qualified_name":"_QueryInteger.errormessage","ident_utf16":{"start":{"line_number":337,"utf16_col":4},"end":{"line_number":337,"utf16_col":16}},"extent_utf16":{"start":{"line_number":337,"utf16_col":4},"end":{"line_number":337,"utf16_col":36}}},{"name":"getresult","kind":"function","ident_start":9097,"ident_end":9106,"extent_start":9093,"extent_end":9158,"fully_qualified_name":"_QueryInteger.getresult","ident_utf16":{"start":{"line_number":339,"utf16_col":8},"end":{"line_number":339,"utf16_col":17}},"extent_utf16":{"start":{"line_number":339,"utf16_col":4},"end":{"line_number":340,"utf16_col":44}}},{"name":"askinteger","kind":"function","ident_start":9165,"ident_end":9175,"extent_start":9161,"extent_end":9459,"fully_qualified_name":"askinteger","ident_utf16":{"start":{"line_number":343,"utf16_col":4},"end":{"line_number":343,"utf16_col":14}},"extent_utf16":{"start":{"line_number":343,"utf16_col":0},"end":{"line_number":355,"utf16_col":19}}},{"name":"_QueryFloat","kind":"class","ident_start":9468,"ident_end":9479,"extent_start":9462,"extent_end":9617,"fully_qualified_name":"_QueryFloat","ident_utf16":{"start":{"line_number":358,"utf16_col":6},"end":{"line_number":358,"utf16_col":17}},"extent_utf16":{"start":{"line_number":358,"utf16_col":0},"end":{"line_number":362,"utf16_col":47}}},{"name":"errormessage","kind":"constant","ident_start":9499,"ident_end":9511,"extent_start":9499,"extent_end":9543,"fully_qualified_name":"_QueryFloat.errormessage","ident_utf16":{"start":{"line_number":359,"utf16_col":4},"end":{"line_number":359,"utf16_col":16}},"extent_utf16":{"start":{"line_number":359,"utf16_col":4},"end":{"line_number":359,"utf16_col":48}}},{"name":"getresult","kind":"function","ident_start":9553,"ident_end":9562,"extent_start":9549,"extent_end":9617,"fully_qualified_name":"_QueryFloat.getresult","ident_utf16":{"start":{"line_number":361,"utf16_col":8},"end":{"line_number":361,"utf16_col":17}},"extent_utf16":{"start":{"line_number":361,"utf16_col":4},"end":{"line_number":362,"utf16_col":47}}},{"name":"askfloat","kind":"function","ident_start":9624,"ident_end":9632,"extent_start":9620,"extent_end":9908,"fully_qualified_name":"askfloat","ident_utf16":{"start":{"line_number":365,"utf16_col":4},"end":{"line_number":365,"utf16_col":12}},"extent_utf16":{"start":{"line_number":365,"utf16_col":0},"end":{"line_number":377,"utf16_col":19}}},{"name":"_QueryString","kind":"class","ident_start":9917,"ident_end":9929,"extent_start":9911,"extent_end":10402,"fully_qualified_name":"_QueryString","ident_utf16":{"start":{"line_number":380,"utf16_col":6},"end":{"line_number":380,"utf16_col":18}},"extent_utf16":{"start":{"line_number":380,"utf16_col":0},"end":{"line_number":396,"utf16_col":31}}},{"name":"__init__","kind":"function","ident_start":9953,"ident_end":9961,"extent_start":9949,"extent_end":10164,"fully_qualified_name":"_QueryString.__init__","ident_utf16":{"start":{"line_number":381,"utf16_col":8},"end":{"line_number":381,"utf16_col":16}},"extent_utf16":{"start":{"line_number":381,"utf16_col":4},"end":{"line_number":387,"utf16_col":48}}},{"name":"body","kind":"function","ident_start":10174,"ident_end":10178,"extent_start":10170,"extent_end":10344,"fully_qualified_name":"_QueryString.body","ident_utf16":{"start":{"line_number":389,"utf16_col":8},"end":{"line_number":389,"utf16_col":12}},"extent_utf16":{"start":{"line_number":389,"utf16_col":4},"end":{"line_number":393,"utf16_col":20}}},{"name":"getresult","kind":"function","ident_start":10354,"ident_end":10363,"extent_start":10350,"extent_end":10402,"fully_qualified_name":"_QueryString.getresult","ident_utf16":{"start":{"line_number":395,"utf16_col":8},"end":{"line_number":395,"utf16_col":17}},"extent_utf16":{"start":{"line_number":395,"utf16_col":4},"end":{"line_number":396,"utf16_col":31}}},{"name":"askstring","kind":"function","ident_start":10409,"ident_end":10418,"extent_start":10405,"extent_end":10697,"fully_qualified_name":"askstring","ident_utf16":{"start":{"line_number":399,"utf16_col":4},"end":{"line_number":399,"utf16_col":13}},"extent_utf16":{"start":{"line_number":399,"utf16_col":0},"end":{"line_number":411,"utf16_col":19}}},{"name":"test","kind":"function","ident_start":10736,"ident_end":10740,"extent_start":10732,"extent_end":11736,"fully_qualified_name":"test","ident_utf16":{"start":{"line_number":416,"utf16_col":8},"end":{"line_number":416,"utf16_col":12}},"extent_utf16":{"start":{"line_number":416,"utf16_col":4},"end":{"line_number":438,"utf16_col":20}}},{"name":"doit","kind":"function","ident_start":10776,"ident_end":10780,"extent_start":10772,"extent_end":11575,"fully_qualified_name":"doit","ident_utf16":{"start":{"line_number":418,"utf16_col":12},"end":{"line_number":418,"utf16_col":16}},"extent_utf16":{"start":{"line_number":418,"utf16_col":8},"end":{"line_number":433,"utf16_col":49}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/python/cpython/branches":{"post":"uWlyjQi-BMlmWmRIBA6TOQjlvSDGbAG9IIIh19iVDBQ-JaojijjilvztwB7wQXALrASMg6Cq4lntenzU9rfkMw"},"/repos/preferences":{"post":"bqtHK2EbiHhKpDAQrwrt4jd5bl5nNRetSm6rEn9OwvNnCk8yWqg42AKpFlwbrryB3RtMgp3fTEYCaypCATNo1A"}}},"title":"cpython/Lib/tkinter/simpledialog.py at 3.13 · python/cpython","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1ae9fa256942.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}