小编Him*_*sal的帖子

当从div中删除字符时,光标移动到contenteditable div的末尾

我正在创建自己的聊天应用程序,其中我使用内容可编辑div为聊天框.我正在实现提及功能,其中我提到的用户名包裹在span标签后跟一个空格( )但我的问题是当我删除空格时我的光标移动到div的末尾.

与空间

<html>

<head>
</head>

<body>
  <div contenteditable=true><span contenteditable='false'>UserName</span>&nbsp;</div>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

没有空间

<html>

<head>
</head>

<body>
  <div contenteditable=true><span contenteditable='false'>UserName</span></div>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

这就是我在代码中实现的方式,而且这个bug只发生在chrome中.

html javascript css html5 contenteditable

9
推荐指数
2
解决办法
654
查看次数

Tkinter代码在Windows上运行,但在Linux上运行

我在windows中编写了这段代码,但是当我将它复制到我的raspberry pi(运行Jessie Debian)时,它会给出运行时错误

我的代码:

from Tkinter import *
from PIL import ImageTk,Image
from time import sleep
import thread
root = Tk()
img=ImageTk.PhotoImage(Image.open("1.jpg").resize((root.winfo_screenwidth()-3,root.winfo_screenheight()-3)))
panel = Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
if __name__ == '__main__':
    thread.start_new_thread(root.mainloop,())
    for i in xrange(1,5):
        sleep(1)
        img2 = ImageTk.PhotoImage(Image.open(str(i)+".jpg").resize((root.winfo_screenwidth()-3,root.winfo_screenheight()-3)))
        panel.configure(image = img2)
        panel.image = img2
Run Code Online (Sandbox Code Playgroud)

在linux中执行时会出错:

Unhandled exception in thread started by <bound method Tk.mainloop of <Tkinter.Tk instance at 0x75b605d0>>
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1124, …
Run Code Online (Sandbox Code Playgroud)

python linux tkinter python-multithreading

1
推荐指数
1
解决办法
357
查看次数