Current Path: > > lib64 > python2.7 > lib-tk
Operation : Linux premium107.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 198.54.126.246 | Your IP: 216.73.216.181 Domains : 1034 Domain(s) Permission : [ 0755 ]
| Name | Type | Size | Last Modified | Actions |
|---|---|---|---|---|
| test | Directory | - | - | |
| Canvas.py | File | 7463 bytes | April 10 2024 04:58:34. | |
| Canvas.pyc | File | 15564 bytes | April 10 2024 04:58:44. | |
| Canvas.pyo | File | 15564 bytes | April 10 2024 04:58:44. | |
| Dialog.py | File | 1567 bytes | April 10 2024 04:58:34. | |
| Dialog.pyc | File | 1920 bytes | April 10 2024 04:58:44. | |
| Dialog.pyo | File | 1920 bytes | April 10 2024 04:58:44. | |
| FileDialog.py | File | 8831 bytes | April 10 2024 04:58:34. | |
| FileDialog.pyc | File | 9718 bytes | April 10 2024 04:58:44. | |
| FileDialog.pyo | File | 9718 bytes | April 10 2024 04:58:44. | |
| FixTk.py | File | 3018 bytes | April 10 2024 04:58:34. | |
| FixTk.pyc | File | 2092 bytes | April 10 2024 04:58:44. | |
| FixTk.pyo | File | 2030 bytes | April 10 2024 04:58:42. | |
| ScrolledText.py | File | 1836 bytes | April 10 2024 04:58:34. | |
| ScrolledText.pyc | File | 2664 bytes | April 10 2024 04:58:44. | |
| ScrolledText.pyo | File | 2664 bytes | April 10 2024 04:58:44. | |
| SimpleDialog.py | File | 3728 bytes | April 10 2024 04:58:34. | |
| SimpleDialog.pyc | File | 4339 bytes | April 10 2024 04:58:44. | |
| SimpleDialog.pyo | File | 4339 bytes | April 10 2024 04:58:44. | |
| Tix.py | File | 77215 bytes | April 10 2024 04:58:34. | |
| Tix.pyc | File | 96090 bytes | April 10 2024 04:58:44. | |
| Tix.pyo | File | 96090 bytes | April 10 2024 04:58:44. | |
| Tkconstants.py | File | 1493 bytes | April 10 2024 04:58:34. | |
| Tkconstants.pyc | File | 2246 bytes | April 10 2024 04:58:44. | |
| Tkconstants.pyo | File | 2246 bytes | April 10 2024 04:58:44. | |
| Tkdnd.py | File | 11488 bytes | April 10 2024 04:58:34. | |
| Tkdnd.pyc | File | 12825 bytes | April 10 2024 04:58:44. | |
| Tkdnd.pyo | File | 12825 bytes | April 10 2024 04:58:44. | |
| Tkinter.py | File | 160619 bytes | April 10 2024 04:58:34. | |
| Tkinter.pyc | File | 200191 bytes | April 10 2024 04:58:44. | |
| Tkinter.pyo | File | 200191 bytes | April 10 2024 04:58:44. | |
| tkColorChooser.py | File | 1784 bytes | April 10 2024 04:58:34. | |
| tkColorChooser.pyc | File | 1420 bytes | April 10 2024 04:58:44. | |
| tkColorChooser.pyo | File | 1420 bytes | April 10 2024 04:58:44. | |
| tkCommonDialog.py | File | 1418 bytes | April 10 2024 04:58:34. | |
| tkCommonDialog.pyc | File | 1516 bytes | April 10 2024 04:58:44. | |
| tkCommonDialog.pyo | File | 1516 bytes | April 10 2024 04:58:44. | |
| tkFileDialog.py | File | 5727 bytes | April 10 2024 04:58:34. | |
| tkFileDialog.pyc | File | 5161 bytes | April 10 2024 04:58:44. | |
| tkFileDialog.pyo | File | 5161 bytes | April 10 2024 04:58:44. | |
| tkFont.py | File | 6162 bytes | April 10 2024 04:58:34. | |
| tkFont.pyc | File | 7172 bytes | April 10 2024 04:58:44. | |
| tkFont.pyo | File | 7172 bytes | April 10 2024 04:58:44. | |
| tkMessageBox.py | File | 3687 bytes | April 10 2024 04:58:34. | |
| tkMessageBox.pyc | File | 3894 bytes | April 10 2024 04:58:44. | |
| tkMessageBox.pyo | File | 3894 bytes | April 10 2024 04:58:44. | |
| tkSimpleDialog.py | File | 7723 bytes | April 10 2024 04:58:34. | |
| tkSimpleDialog.pyc | File | 9113 bytes | April 10 2024 04:58:44. | |
| tkSimpleDialog.pyo | File | 9113 bytes | April 10 2024 04:58:44. | |
| ttk.py | File | 56173 bytes | April 10 2024 04:58:34. | |
| ttk.pyc | File | 62628 bytes | April 10 2024 04:58:44. | |
| ttk.pyo | File | 62628 bytes | April 10 2024 04:58:44. | |
| turtle.py | File | 139035 bytes | April 10 2024 04:58:34. | |
| turtle.pyc | File | 139577 bytes | April 10 2024 04:58:44. | |
| turtle.pyo | File | 139577 bytes | April 10 2024 04:58:44. |
#
# An Introduction to Tkinter
# tkSimpleDialog.py
#
# Copyright (c) 1997 by Fredrik Lundh
#
# fredrik@pythonware.com
# http://www.pythonware.com
#
# --------------------------------------------------------------------
# dialog base class
'''Dialog boxes
This module handles dialog boxes. It contains the following
public symbols:
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 *
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
'''
Toplevel.__init__(self, parent)
self.withdraw() # remain invisible for now
# If the master is not viewable, don't
# make the child transient, or else it
# would be opened withdrawn
if parent.winfo_viewable():
self.transient(parent)
if title:
self.title(title)
self.parent = parent
self.result = None
body = Frame(self)
self.initial_focus = self.body(body)
body.pack(padx=5, pady=5)
self.buttonbox()
if not self.initial_focus:
self.initial_focus = self
self.protocol("WM_DELETE_WINDOW", self.cancel)
if self.parent is not None:
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
parent.winfo_rooty()+50))
self.deiconify() # become visibile now
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)
#
# 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("<Return>", self.ok)
self.bind("<Escape>", 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
# --------------------------------------------------------------------
# convenience dialogues
class _QueryDialog(Dialog):
def __init__(self, title, prompt,
initialvalue=None,
minvalue = None, maxvalue = None,
parent = None):
if not parent:
import Tkinter
parent = Tkinter._default_root
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):
import tkMessageBox
try:
result = self.getresult()
except ValueError:
tkMessageBox.showwarning(
"Illegal value",
self.errormessage + "\nPlease try again",
parent = self
)
return 0
if self.minvalue is not None and result < self.minvalue:
tkMessageBox.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 > self.maxvalue:
tkMessageBox.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 int(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 float(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__":
root = Tk()
root.update()
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")
SILENT KILLER Tool