PySide 剪贴板错误 - 对象没有属性 .setText
PySide clipboard error - object has no attribute .setText
我正在使用 PyCharm 编写我的代码 (Python 3.4)。
出于某种原因下面的代码 returns 错误:AttributeError: 'NoneType' object has no attribute 'setText'
我正在编写的代码将 运行 放在一个名为 Nuke 的程序中。我已经在里面测试了这段代码,它似乎 运行 没问题。将内容复制到系统剪贴板并查看其内容。
从我的大部分谷歌搜索来看,这似乎应该有效。我还没有找到任何替代品:(
如果我能在 PyCharm 中使用它会很有帮助!
from PySide import QtGui
cb = QtGui.QApplication.clipboard()
cb.setText("Yay") # set clipboard
print (cb.text()) # show current clipboard contents
提前致谢!
根据 doc:
The PySide.QtGui.QApplication object should already be constructed
before accessing the clipboard.
以下代码将起作用:
from PySide import QtGui
import sys
#construct app
app=QtGui.QApplication(sys.argv)
#then get the clipboard
cb = QtGui.QApplication.clipboard()
cb.setText("Yay") # set clipboard
print (cb.text())
我正在使用 PyCharm 编写我的代码 (Python 3.4)。
出于某种原因下面的代码 returns 错误:AttributeError: 'NoneType' object has no attribute 'setText'
我正在编写的代码将 运行 放在一个名为 Nuke 的程序中。我已经在里面测试了这段代码,它似乎 运行 没问题。将内容复制到系统剪贴板并查看其内容。 从我的大部分谷歌搜索来看,这似乎应该有效。我还没有找到任何替代品:(
如果我能在 PyCharm 中使用它会很有帮助!
from PySide import QtGui
cb = QtGui.QApplication.clipboard()
cb.setText("Yay") # set clipboard
print (cb.text()) # show current clipboard contents
提前致谢!
根据 doc:
The PySide.QtGui.QApplication object should already be constructed before accessing the clipboard.
以下代码将起作用:
from PySide import QtGui
import sys
#construct app
app=QtGui.QApplication(sys.argv)
#then get the clipboard
cb = QtGui.QApplication.clipboard()
cb.setText("Yay") # set clipboard
print (cb.text())