本文整理汇总了Python中Tkinter.Tk.clipboard_clear方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.clipboard_clear方法的具体用法?Python Tk.clipboard_clear怎么用?Python Tk.clipboard_clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.clipboard_clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_text
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def copy_text(text):
# http://stackoverflow.com/a/4203897/166700
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(text)
r.destroy()
示例2: copy_helper
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [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()
示例3: copyToClipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [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()
示例4: print_to_clipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def print_to_clipboard(string):
from Tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(string)
r.destroy()
示例5: copyToClipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def copyToClipboard(cstr):
from Tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(cstr)
r.destroy()
示例6: set_clipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def set_clipboard(text, datatype=None):
"""
Arg datatype currently not used. Will generally assumed to be unicode text.
From http://stackoverflow.com/questions/579687/how-do-i-copy-a-string-to-the-clipboard-on-windows-using-python
"""
if 'xerox' in sys.modules.keys():
xerox.copy(text)
elif 'pyperclip' in sys.modules.keys():
pyperclip.copy(text)
elif 'gtk' in sys.modules.keys():
clipboard = gtk.clipboard_get()
text = clipboard.set_text(text)
elif 'win32clipboard' in sys.modules.keys():
wcb = win32clipboard
wcb.OpenClipboard()
wcb.EmptyClipboard()
# wcb.SetClipboardText(text) # doesn't work
# SetClipboardData Usage:
# >>> wcb.SetClipboardData(<type>, <data>)
# wcb.SetClipboardData(wcb.CF_TEXT, text.encode('utf-8')) # doesn't work
wcb.SetClipboardData(wcb.CF_UNICODETEXT, unicode(text)) # works
wcb.CloseClipboard() # User cannot use clipboard until it is closed.
else:
# If code is run from within e.g. an ipython qt console, invoking Tk root's mainloop() may hang the console.
r = Tk()
# r.withdraw()
r.clipboard_clear()
r.clipboard_append(text)
r.mainloop() # the Tk root's mainloop() must be invoked.
r.destroy()
示例7: copyToClipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def copyToClipboard(self, text):
from Tkinter import Tk
w = Tk()
w.withdraw()
w.clipboard_clear()
w.clipboard_append(text)
w.destroy()
示例8: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [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)
示例9: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [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()
示例10: PutAddressIntoClipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def PutAddressIntoClipboard(address):
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(address)
r.destroy()
return
示例11: setClipboardText
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def setClipboardText(s):
from Tkinter import Tk
text = str(s)
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(text)
r.destroy()
示例12: copy_code
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def copy_code(event):
# Copies the source code to clipboard
from Tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(copy_text)
r.destroy()
示例13: copy
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def copy(string, **kwargs):
"""Copy given string into system clipboard."""
window = Tk()
window.withdraw()
window.clipboard_clear()
window.clipboard_append(string)
window.destroy()
return
示例14: BDF
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def BDF(bus, device, function):
value = "0x%08X" % (pciexbar | bus << 20 | device << 15 | function << 12)
print value
c = Tk()
c.withdraw()
c.clipboard_clear()
c.clipboard_append(value)
c.destroy()
示例15: copyToClipboard
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import clipboard_clear [as 别名]
def copyToClipboard(self):
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append("Enviromental Benefit\t%\nFlow-Frequency Index\t" + str(self.module.FF) +
"\nVolume Reduction Index\t" + str(self.module.VR) +
"\nFiltered Flow Volume Index\t" +str(self.module.FV) +
"\nWater Quality Index\t" + str(self.module.WQ) + "\n")