本文整理汇总了Python中tkinter.Tk.clipboard_append方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.clipboard_append方法的具体用法?Python Tk.clipboard_append怎么用?Python Tk.clipboard_append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.clipboard_append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def copy(inputString):
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(inputString)
r.destroy()
示例2: clip
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def clip(password):
"""Instantiate a Tk() object to clip string in argument."""
tkhandle = Tk()
tkhandle.withdraw()
tkhandle.clipboard_clear()
tkhandle.clipboard_append(password)
print("\nPassword copied in CLEAR in your clipboard.\n")
示例3: add
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def add(str): # TODO: for linux adds some bad data, that breaks program (breaks even editor), but for windows worked
if _platform == "win32" or _platform == "win64":
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append('i can has clipboardz?')
r.destroy()
示例4: output
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def output(self, reportfile):
fp = open(reportfile, "w")
fp.write("<?xml version=\"1.0\" ?>\n")
fp.write("<UIMacro>\n")
r = Tk()
r.withdraw()
r.clipboard_clear()
items = ["Build", "Benchmark", "Scenario", "Test", "Index", "Key", "ResponseTime", "FPS"]
actions = self._Data.findall("UIAction")
for action in actions:
s = " <UIAction"
for item in items:
s += " %s=\"%s\"" %(item , action.get(item))
s += "/>\n"
fp.write(s)
#Send the data to the clipboard
line=action.get(items[0])
for item in items[1:]:
line += "\t" + action.get(item)
line += "\n"
r.clipboard_append(line)
r.destroy()
fp.write("</UIMacro>")
fp.close()
示例5: SystemNameClip
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
class SystemNameClip(object):
"""
A cross-platform wrapper for copying system names into
the clipboard such that they can be pasted into the E:D
galaxy search - which means forcing them into lower case
because E:D's search doesn't work with upper case
characters.
"""
def __init__(self):
self.tkroot = Tk()
self.tkroot.withdraw()
def strip(self, text, trailing):
if text.endswith(trailing):
text = text[:-len(trailing)].strip()
return text
def copy_text(self, text):
""" Copies the specified text into the clipboard. """
text = text.lower().strip()
text = self.strip(text, "(fix)")
text = self.strip(text, "(fixed)")
self.tkroot.clipboard_clear()
self.tkroot.clipboard_append(text.lower())
示例6: _and_print
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def _and_print(x):
from tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(x)
print(x)
示例7: do
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def do():
parser = argparse.ArgumentParser()
parser.add_argument('-r', '--remember', action="store_true")
parser.add_argument('-p', '--print', action="store_true")
parser.add_argument('-c', '--clear', action="store_true")
parser.add_argument('-e', '--edit', action="store_true")
parser.add_argument('-g', '--goto_clip', type=int)
args = parser.parse_args()
#print(args)
print('Using cache file: %s.' % cacheFile)
if not os.path.isfile(cacheFile):
fh = open(cacheFile, 'w')
fh.write('')
fh.close()
if args.print:
printStoredDirs()
exit(0)
if args.clear:
clearDirs()
exit(0)
if args.edit:
if platform.system().lower() == 'windows':
os.system('np ' + cacheFile)
else:
os.system('vim ' + cacheFile)
exit(0)
if args.remember:
rememberDirs()
printStoredDirs()
exit(0)
if args.goto_clip != None:
filec = getFileContent()
dir = filec[args.goto_clip]
if Tk is not None:
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(dir)
r.destroy()
else:
print('Tk not available, clipboard functions will not work.')
print("'%s' now in clipboard" % dir)
exit(0)
printStoredDirs()
示例8: copy
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def copy(text):
"""copy text to clipboard """
try:
root=Tk()
root.withdraw()
root.clipboard_append(text)
except Exception as e:
print ('Error: ',e)
finally:
root.destroy()
示例9: get_password
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def get_password (act):
if act in PASSWORDS:
r = Tk ()
r.withdraw ()
r.clipboard_clear ()
r.clipboard_append (PASSWORDS[act])
print('Password for ' + act + ' copied to clipboard.')
r.mainloop ()
else:
print('There is no account named ' + act)
示例10: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def main():
t=Tk()
t.withdraw()
text=t.clipboard_get()
#text="_example=2345..."
r=re.compile("(_[A-z]+(?==))")
m=list(set(r.findall(text)))
m=str(m).translate(str.maketrans("'",'"'))
print(m)
t.clipboard_clear()
t.clipboard_append(m)
t.destroy()
示例11: selector
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def selector(self, item, format = '%s', name = None):
try:
self.copy_timer = time.time()
copy = format % name if name is not None else item.data()
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append( copy )
r.destroy()
self.statusBar.showMessage( '<%s> copied to clipboard' % copy )
except:
self.statusBar.showMessage( 'Could not copy clipboard data' )
示例12: do_clip
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def do_clip(self, arg):
"""clip
=====
Saves last answer to clipboard.
"""
if self.last_answer != '':
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(self.last_answer)
print('"{}" saved to clip board.'.format(self.last_answer))
else:
print('Nothing to clip.')
示例13: testNameConversionKnownValues
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def testNameConversionKnownValues(self):
"""NameConversion should give known result with known input"""
for orig, expanded, zone in self.knownValues:
result = delijnosmlib.nameconversion(orig,zone)
if result != expanded:
print(orig + ' -> ' + result + ' -> ' + repr(expanded))
print(''' (500,0,r"''' + orig + '","' + expanded + '","01"),')
r = Tk()
# r.withdraw()
# r.clipboard_clear()
r.clipboard_append(result.split(' ')[-1].replace('straat','').replace('laan','').replace('plein','').replace('lei','').replace('steenweg','').replace('weg',''))
# r.destroy()
self.assertEqual(result, expanded)
开发者ID:PolyglotOpenstreetmap,项目名称:OSM_PublicTransportRoutes,代码行数:16,代码来源:name_conversion_unit_test.py
示例14: _output_page
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def _output_page(self):
ret = 0
if self.cliargs.save:
require_login(self.api)
try:
result = self.api.edit(self.cliargs.statistics_page, self.pageid,
self.text, self.timestamp, self.cliargs.summary, bot="1",
minor="1")
except APIError as err:
ret |= 1
else:
if result["result"].lower() != "success":
logger.exception("The page was not saved correctly")
ret |= 1
else:
logger.info("The page has been saved: do not forget to "
"double-check the diff")
ret |= 2
if self.cliargs.clipboard or ret is False:
if Tk:
w = Tk()
w.withdraw()
w.clipboard_clear()
w.clipboard_append(self.text)
# The copied text is lost once the script terminates
input("The updated page text has been copied to the "
"clipboard: paste it in the browser, then press Enter "
"to continue")
w.destroy()
ret |= 2
else:
logger.error("It has not been possible to copy the updated "
"text to the clipboard")
ret |= 1
# If no other action was chosen, always print the output, so that all
# the effort doesn't go wasted
if self.cliargs.print or ret == 0:
print(self.text)
return ret & 1
示例15: copyStrToClipboard
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_append [as 别名]
def copyStrToClipboard():
#def main():
from tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
'''
According Python issue 23760, I cannot copy to clipboard correctly
when r.destory() is called after r.clipboard_append() by Python 3.4.3 on Windows 8.
The issue happened to me, so this snippet call input() after r.clipboard_append().
http://bugs.python.org/issue23760
http://stackoverflow.com/questions/26321333/
'''
str = input("Please input string that be copied to clipboard:\n> ")
r.clipboard_append(str)
print('[!] Copied "{0}" to clipboard.'.format(str))
input('Please enter if you confirmed > ')
r.destroy()