本文整理汇总了Python中Tkinter.Tk.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.destroy方法的具体用法?Python Tk.destroy怎么用?Python Tk.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_helper
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def copy_helper(text):
'''I have no idea what I'm doing here, but it seems to work ¯\_(ツ)_/¯'''
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(text)
r.destroy()
示例2: get_file
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def get_file(self):
root = Tk()
root.withdraw()
root.update()
input_file = tkFileDialog.askopenfilename(parent=root)
root.destroy()
return input_file
示例3: __get_clipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def __get_clipboard(self):
self.logger.info('Getting clipboard contents')
list_to_csv = [("COMPUTER_NAME", "TYPE", "DATA")]
r = None
try:
r = Tk() # Using Tk instead because it supports exotic characters
data = r.selection_get(selection='CLIPBOARD')
r.destroy()
list_to_csv.append((self.computer_name, 'clipboard', unicode(data)))
except:
if r: # Verify that r exists before calling destroy
r.destroy()
win32clipboard.OpenClipboard()
clip = win32clipboard.EnumClipboardFormats(0)
while clip:
try:
format_name = win32clipboard.GetClipboardFormatName(clip)
except win32api.error:
format_name = "?"
self.logger.info('format ' + unicode(clip) + ' ' + unicode(format_name))
if clip == 15: # 15 seems to be a list of filenames
filenames = win32clipboard.GetClipboardData(clip)
for filename in filenames:
list_to_csv.append((self.computer_name, 'clipboard', filename))
clip = win32clipboard.EnumClipboardFormats(clip)
win32clipboard.CloseClipboard()
return list_to_csv
示例4: csv_clipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def csv_clipboard(self):
"""Exports the clipboard contents"""
# TODO : what happens if clipboard contents is a CSV string ?
self.logger.info('Getting clipboard contents')
with open(self.output_dir + '\\' + self.computer_name + '_clipboard.csv', 'wb') as output:
csv_writer = get_csv_writer(output)
write_to_csv(["COMPUTER_NAME", "TYPE", "DATA"], csv_writer)
try:
r = Tk() # Using Tk instead because it supports exotic characters
data = r.selection_get(selection='CLIPBOARD')
r.destroy()
write_to_csv([self.computer_name, 'clipboard', unicode(data)], csv_writer)
except:
r.destroy()
win32clipboard.OpenClipboard()
clip = win32clipboard.EnumClipboardFormats(0)
while clip:
try:
format_name = win32clipboard.GetClipboardFormatName(clip)
except win32api.error:
format_name = "?"
self.logger.info('format ' + unicode(clip) + ' ' + unicode(format_name))
if clip == 15: # 15 seems to be a list of filenames
filenames = win32clipboard.GetClipboardData(clip)
for filename in filenames:
write_to_csv([self.computer_name, 'clipboard', filename], csv_writer)
clip = win32clipboard.EnumClipboardFormats(clip)
win32clipboard.CloseClipboard()
record_sha256_logs(self.output_dir + '\\' + self.computer_name + '_clipboard.csv',
self.output_dir + '\\' + self.computer_name + '_sha256.log')
示例5: copyToClipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def copyToClipboard(s):
# (Doesn't work in python 3, so we use python 2)
root = Tk()
root.withdraw()
root.clipboard_clear()
root.clipboard_append(s)
root.destroy()
示例6: copyToClipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def copyToClipboard(cstr):
from Tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(cstr)
r.destroy()
示例7: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def main():
aList = []
check = 'y'
clipOut = ""
print ""
print "***************************"
print "* Calendar List Builder *"
print "* Updated: 09/13/2013 *"
print "***************************"
# year = getValidIntYear('CALENDAR YEAR (ie. 2013-2015,13)', 2013 , 2015)
dat = datetime.datetime.now()
year = int( dat.strftime('%Y') )
print "Today: ", dat.strftime('%A, %m/%d/%Y')
while check == 'y':
print ""
print "[ Group Header ]"
dt = getdt(year)
#print dt
header = dt + ", Eastern Time"
#print "Group header: ", header
print "[ Time Slots ]"
openTimes = buildCalTimes()
aList.append(header)
for each in openTimes:
aList.append(dt + ', ' + each)
check = raw_input("Is there another date to add - Yes/No(Default) ?")
if check == 'y':
aList.append("")
print ""
print "[ Return List ]"
print ""
for each in aList:
print each
clipOut = '\n'.join(aList)
print ""
# Clipboard stuff
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(clipOut)
print "List copied to clipboard. Press enter to quit."
check = raw_input("")
r.destroy()
exit(0)
示例8: copy_text
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def copy_text(text):
# http://stackoverflow.com/a/4203897/166700
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(text)
r.destroy()
示例9: getPath
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def getPath():
root = Tk()
root.withdraw()
InputPath = askdirectory(title="Choose Converting Picture Input Path")
OutputPath = askdirectory(title="Choose Converting Picture Output Path")
root.destroy()
return InputPath, OutputPath
示例10: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--l", default=24, metavar='password_length', help="password length, default is 24")
parser.add_argument("--p", action='store_true', help="use punctuation")
args = parser.parse_args()
# print args.l
# print args.p
# Assemble base alphabet and generate password
myrg = random.SystemRandom()
alphabet = string.ascii_letters + string.digits
if args.p:
alphabet += string.punctuation
pw = str().join(myrg.choice(alphabet) for _ in range(int(args.l)))
print pw
# put password in clipboard
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(pw)
r.destroy()
示例11: projetoMalha
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def projetoMalha():
global sistemaVar
a = 0
if len(sistemaVar["arqMalha"]) > 0:
print u"usar o último arquivo[S/n]?",
if raw_input() == "n":
a = 1
else:
a = 1
if a == 1:
try:
mainTkinter = Tk()
sistemaVar["arqMalha"] = askopenfilename()
mainTkinter.destroy()
if len(sistemaVar["arqMalha"]) > 0:
print "usando,"
print sistemaVar["arqMalha"]
atualizaArquivoConf()
else:
print u"erro: erro na seleção do arquivo"
return -1
except:
print u"erro: no arquivo de configuração do projeto"
return -1
try:
malhaAterramento.lerArquivoProjeto(sistemaVar["arqMalha"], debug=fDebug())
# malhaAterramento.mostraDadosProjeto()
malhaAterramento.projetaMalhaAterramento(debug=fDebug())
malhaAterramento.exibeResultados()
except:
print u"erro: problema no projeto da malha"
示例12: csv_clipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def csv_clipboard(self):
''' Exports the clipboard contents '''
# TODO check if it is the same for older windows
self.logger.info('Getting clipboard contents')
with open(self.output_dir + '\\' + self.computer_name + '_clipboard.csv', 'wb') as output:
csv_writer = get_csv_writer(output)
#output.write('"Computer Name"|"Type"|Data"\n')
try:
r = Tk() # Using Tk instead because it supports exotic characters
data = r.selection_get(selection='CLIPBOARD')
r.destroy()
#data = win32clipboard.GetClipboardData().decode('utf_8')
write_to_csv([self.computer_name, 'String data in clipboard', unicode(data)], csv_writer)
except:
r.destroy()
win32clipboard.OpenClipboard()
clip = win32clipboard.EnumClipboardFormats(0)
while clip:
try: format_name = win32clipboard.GetClipboardFormatName(clip)
except win32api.error: format_name = "?"
self.logger.info('format ' + unicode(clip) + ' ' + unicode(format_name))
if clip == 15: # 15 seems to be a list of filenames
filenames = win32clipboard.GetClipboardData(clip)
for filename in filenames:
write_to_csv([self.computer_name, 'List of files in clipboard', filename], csv_writer)
clip = win32clipboard.EnumClipboardFormats(clip)
win32clipboard.CloseClipboard()
示例13: PutAddressIntoClipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def PutAddressIntoClipboard(address):
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(address)
r.destroy()
return
示例14: loaddeck
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def loaddeck(self):
root = Tk()
root.withdraw()
filename = askopenfilename(filetypes=[("Zip Archives",".zip")],initialdir=self.deckdir,title="Load Slide Deck",parent=root)
root.destroy()
if filename != "":
root = Tk()
root.withdraw()
password = askstring("Deck Password","Please enter the password for this zip file, or press cancel if you believe there isn't one:", parent=root)
root.destroy()
if filename:
try:
unzipped = ZipFile(filename)
self.clearscribbles()
if password != None:
unzipped.extractall(path=self.scribblesdir,pwd=password)
else:
unzipped.extractall(path=self.scribblesdir,pwd="")
num_pages = 0
for x in os.listdir(self.scribblesdir):
if (os.path.splitext(x)[1] == ".png"):
num_pages += 1
self.send(["first",num_pages], "toSequencer")
self.send(chr(0) + "CLRTKR", "toTicker")
self.send("Deck loaded successfully","toTicker")
except Exception:
e = sys.exc_info()[1]
self.send(chr(0) + "CLRTKR", "toTicker")
self.send("Failed to open the deck specified. You may have entered the password incorrectly","toTicker")
示例15: get_clipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import destroy [as 别名]
def get_clipboard():
"""
Get content of OS clipboard.
"""
if 'xerox' in sys.modules.keys():
print "Returning clipboard content using xerox..."
return xerox.paste()
elif 'pyperclip' in sys.modules.keys():
print "Returning clipboard content using pyperclip..."
return pyperclip.paste()
elif 'gtk' in sys.modules.keys():
print "Returning clipboard content using gtk..."
clipboard = gtk.clipboard_get()
return clipboard.wait_for_text()
elif 'win32clipboard' in sys.modules.keys():
wcb = win32clipboard
wcb.OpenClipboard()
try:
data = wcb.GetClipboardData(wcb.CF_TEXT)
except TypeError as e:
print e
print "No text in clipboard."
wcb.CloseClipboard() # User cannot use clipboard until it is closed.
return data
else:
print "locals.keys() is: ", sys.modules.keys().keys()
print "falling back to Tk..."
r = Tk()
r.withdraw()
result = r.selection_get(selection="CLIPBOARD")
r.destroy()
print "Returning clipboard content using Tkinter..."
return result