我需要将文本复制到以后使用 在按下(ctrl + c)时,会出现错误 所以我使用了bubble,但出现了同样的错误
***** ********的Python
from kivy.app import App
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
class Progress(Popup):
pass
class ScreenManagement(ScreenManager):
pass
class Func(Screen):
pass
presentation = Builder.load_file("try_.kv")
class MainApp(App):
Progress = Progress()
def build(self):
return presentation
if __name__ == "__main__":
MainApp().run()
***** KV档案*******
#:import Factory kivy.factory.Factory
# #:import Clipboard kivy.core.clipboard.Clipboard
<Progress>:
text: ""
separator_color: 0, 0, 0, 0
BoxLayout:
TextInput:
id: textinput
text: "Your Key is samphone"
copydata: 'text'
readonly: True
use_bubble: True
allow_copy: True
Button:
text: "Click"
on_release:
root.dismiss()
ScreenManagement:
Func:
<Func>:
BoxLayout:
Button:
text: "Click"
on_release:
Factory.Progress().open()
**** *****错误
文件 &#34; C:\用户\警长\应用程序数据\本地\程序\的Python \ Python35 \ lib中\站点包\ kivy \ UIX \ textinput.py&#34 ;, 第378行,在做 textinput.copy()文件&#34; C:\ Users \ Sherif \ AppData \ Local \ Programs \ Python \ Python35 \ lib \ site-packages \ kivy \ uix \ textinput.py&#34;, 第1712行,副本 return Clipboard.copy(self.selection_text)File&#34; C:\ Users \ Sherif \ AppData \ Local \ Programs \ Python \ Python35 \ lib \ site-packages \ kivy \ core \ clipboard__init __。py&#34;, 第73行,副本 self._copy(data)File&#34; C:\ Users \ Sherif \ AppData \ Local \ Programs \ Python \ Python35 \ lib \ site-packages \ kivy \ core \ clipboard__init __。py&#34;, 第87行,在_copy中 self.put(data,self._clip_mime_type)
文件 &#34; C:\用户\警长\应用程序数据\本地\程序\的Python \ Python35 \ lib中\站点包\ kivy \芯\剪贴板\ clipboard_winctypes.py&#34 ;, 第55行,放入 msvcrt.wcscpy_s(c_wchar_p(hCd),len(text),c_wchar_p(text))
ValueError:嵌入的空字符
答案 0 :(得分:0)
有关详细信息,请参阅以下示例:
from kivy.app import App
from kivy.uix.popup import Popup
from kivy.uix.screenmanager import ScreenManager, Screen
class Progress(Popup):
pass
class Func(Screen):
pass
class ScreenManagement(ScreenManager):
pass
class MainApp(App):
def build(self):
return ScreenManagement()
if __name__ == "__main__":
MainApp().run()
#:import Factory kivy.factory.Factory
<Progress>:
text: ""
separator_color: 0, 0, 0, 0
BoxLayout:
TextInput:
id: textinput
text: "Your Key is samphone"
readonly: True
allow_copy: True
copydata: self.text
Button:
text: "Click"
on_release:
root.dismiss()
<Func>:
BoxLayout:
Button:
text: "Click"
on_release:
Factory.Progress().open()
<ScreenManagement>:
Func:
答案 1 :(得分:0)
实际上,ValueError
这里只有3.5.4
而且只有#34;关于this pull request中CPython内部的最新(3.6.3
+和_PyUnicode_AsUnicode
+)更改,基本上对于我们的ctypes剪贴板意味着调用更改的API PyUnicode_AsUnicode
而不是原始{{1}}和described in the commit message:
_PyUnicode_AsUnicode()类似于 PyUnicode_AsUnicode(),但检查空字符..
它引发了一个错误。我花了一段时间才弄清楚这一点,因为我在发行说明中没有找到它,但是它已经在kivy#5579修复了,很快就会在主分支中找到。