我试图重用预定义区域,但在使用sikuli.setW()
将其分配给一个新变量时出现了Nonetype错误。这是我的密码:
import math
import sikuli
self.screen_reg = sikuli.Screen(0)
self.monitor_reg = self.screen_reg
self.leftreg = sikuli.Region(
self.monitor_reg.x,
self.monitor_reg.y,
int(math.floor(self.monitor_reg.w/2)),
self.monitor_reg.h)
self.rightreg = sikuli.Region(
self.monitor_reg.x + int(math.floor(self.monitor_reg.w/2)),
self.monitor_reg.y,
int(math.floor(self.monitor_reg.w/2)),
self.monitor_reg.h)
self.leftreg.highlight(3) <=== working
self.quarter = self.leftreg.setW(int(math.floor(self.leftreg.w/2)))
self.quarter.highlight(3) <====== didnt work;
error: NoneType object has no attribute highlight
如果I print type(quarter)
,则返回NoneType
。你知道吗
如果我把它改成:
self.leftreg.highlight(3)
self.leftreg.setW(int(math.floor(self.leftreg.w/2)))
self.leftreg.highlight(3)
很好用。我错过了什么?谢谢你的帮助。你知道吗
>;我错过了什么?
对象方法不能有返回类型。你知道吗
以下是Sikuli source code的节选
setW的返回类型是void。也就是说,它不返回任何内容,而您希望它返回一个区域。你知道吗
正确的方法是:
相关问题 更多 >
编程相关推荐