本文整理汇总了Python中tkinter.Tk.clipboard_get方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.clipboard_get方法的具体用法?Python Tk.clipboard_get怎么用?Python Tk.clipboard_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Tk
的用法示例。
在下文中一共展示了Tk.clipboard_get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tkinter_clipboard_get
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
def tkinter_clipboard_get():
""" Get the clipboard's text using Tkinter.
This is the default on systems that are not Windows or OS X. It may
interfere with other UI toolkits and should be replaced with an
implementation that uses that toolkit.
"""
try:
from tkinter import Tk, TclError # Py 3
except ImportError:
try:
from Tkinter import Tk, TclError # Py 2
except ImportError:
raise TryNext("Getting text from the clipboard on this platform "
"requires Tkinter.")
root = Tk()
root.withdraw()
try:
text = root.clipboard_get()
except TclError:
raise ClipboardEmpty
finally:
root.destroy()
text = py3compat.cast_unicode(text, py3compat.DEFAULT_ENCODING)
return text
示例2: getClipBoardText
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
def getClipBoardText():
from tkinter import Tk
r = Tk()
# read the clipboard
c = r.clipboard_get()
return c
示例3: paste
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
def paste():
"""paste text from clipboad"""
try:
root=Tk()
root.withdraw()
return root.clipboard_get()
except Exception as e:
print ('Error: ',e)
finally:
root.destroy()
示例4: main
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [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()
示例5: g
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
def g():
r = Tk()
r.withdraw()
data = r.clipboard_get()
r.destroy()
return data
示例6: print
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
scenario_list_full.append(scenario_line_full)
scenario_list_full.sort()
# scenario_list_full.reverse()
print(scenario_list_full)
# print(scenario_count_dict)
# ========================输入区开始========================
dict_file_path = '/Users/alicewish/我的坚果云/userdict.txt' # 自定义词典路径
# ================读取剪贴板================
from tkinter import Tk
r = Tk()
read_text = r.clipboard_get()
text_readline = read_text.splitlines()
# print(text_readline)
# ================按行读取文本:with open(更好)================
status_readline = [] # 状态列表
cut_readline = [] # 分词列表
output_readline = [] # 输出列表
jieba.load_userdict(dict_file_path)
for i in range(len(text_readline)):
line = text_readline[i]
line = line.replace('……', '…')
print(line)
print(len(line))
示例7: Tk
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
from lxml import html
import requests, time
start_time = time.time() # 初始时间戳
# ================读取剪贴板================
from tkinter import Tk
r = Tk()
c = r.clipboard_get()
print(c)
print(type(c))
# ================运行时间计时================
run_time = time.time() - start_time
if run_time < 60: # 两位小数的秒
print("耗时:{:.2f}秒".format(run_time))
elif run_time < 3600: # 分秒取整
print("耗时:{:.0f}分{:.0f}秒".format(run_time // 60, run_time % 60))
else: # 时分秒取整
print("耗时:{:.0f}时{:.0f}分{:.0f}秒".format(run_time // 3600, run_time % 3600 // 60, run_time % 60))
示例8: Tk
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
import re
# ================读取剪贴板================
from tkinter import Tk
r = Tk()
clipboard_content = r.clipboard_get()
replaced = re.sub('<span id=".*" class="anchor"></span>', 'a', clipboard_content)
print(replaced)
示例9: ReadClipL
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
def ReadClipL():
from tkinter import Tk
r = Tk()
read_text = r.clipboard_get()
text_readline = read_text.splitlines()
return text_readline
示例10: ReadClip
# 需要导入模块: from tkinter import Tk [as 别名]
# 或者: from tkinter.Tk import clipboard_get [as 别名]
def ReadClip():
from tkinter import Tk
r = Tk()
read_text = r.clipboard_get()
return read_text