我正在寻找一种在An error occurred while loading the map layer 'default': Postgis Plugin: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Connection string: ' dbname=gis connect_timeout=4'
encountered during parsing of layer 'landcover-low-zoom' in Layer at line 755 of '/home/betrieb /src/openstreetmap-carto/mapnik.xml'
中复制所选文本并将其自动粘贴到tkinter.scrolledtext
中的方法。
意味着,每次用户选择文本时,它将自动添加到Entry
中。
有什么建议吗?专门介绍如何获取所选文本。
答案 0 :(得分:1)
您可以使用从selection
小部件生成的text
事件添加到您的entry
小部件。
import tkinter as tk
from tkinter import scrolledtext as tkst
root = tk.Tk()
txt = tkst.ScrolledText(root)
txt.insert(tk.END, "This is a test phrase")
txt.pack()
entry = tk.Entry(root)
entry.pack()
def select_event(event):
try:
entry.delete(0, tk.END)
entry.insert(0, txt.get(tk.SEL_FIRST, tk.SEL_LAST))
except tk.TclError:
pass
txt.bind("<<Selection>>", select_event)
root.mainloop()