名称错误:名称“Logi”没有用 Sikuli 定义
我只是在尝试 Sikuli。我试图有一个“主”页面来调用包含一些类和一些定义的其他文件。但我收到以下错误:
[error] Arrêté [error] Une erreur est survenue à la ligne 13 [error] Message d'erreur : Traceback (most最近一次调用最后): File "C:\Users\gregory\AppData\Local\ Temp\sikuli-tmp2607956245912033896.py”,第 13 行,日志 = Logi() NameError:名称“Logi”未定义
我真的不知道为什么。
我的代码
main.sikuli
# Path to def
myScriptPath = "C:\\NOT_SCANNED\\Stockage\\SikuliProject\\"
if not myScriptPath in sys.path: sys.path.append(myScriptPath)
# Import File.sikuli
from loginLogout import *
from sikuli.Sikuli import *
# Call Def
if __name__ == "__main__":
log = Logi()
log.login()
log.logout()
loginLogout.sikuli
from sikuli.Sikuli import *
class Logi:
def login(self):
openApp("MyApp")
wait(5)
type("demo" + Key.TAB + "demo" + Key.TAB)
type("a", KEY_CTRL)
type("localhost")
click( )
wait(5)
wait( )
我注意到了一些事情。如果我将我的类命名为 foo ,它就可以了。我实在不明白。
预先感谢您的帮助。
好吧,我发现了一些东西。我在命名文件时犯了一些错误。问题似乎已经通过保存解决了,现在我不再遇到这个问题了。但我还有另外一个。现在,当我执行它时,我没有收到任何错误,但没有执行任何内容...
新代码:
main
# -*-coding:Latin-1 -*
# Path to def
myScriptPath = "C:\\NOT_SCANNED\\Stockage\\SikuliProject"
if not myScriptPath in sys.path: sys.path.append(myScriptPath)
# Import File.sikuli from sikuli.Sikuli import * from Logi import *
# Call Def
if __name__ == "__main__":
log = Logi()
log.login
Logi
from sikuli.Sikuli import *
class Logi:
def login(self):
openApp("MYAPP")
wait(5)
type("demo" + Key.TAB + "demo" + Key.TAB)
type("a", KEY_CTRL)
type("localhost")
click( )
wait(5)
wait( )
def logout(self):
click( )
wait( )
click( )
def openNewTab(self):
click( )
def createNewSingle(self):
click( )
click( )
rightClick( )
click( )
click( )
wait( )
click( )
type("test")
click( )
type("this is a test with Sikuli")
click( )
rightClick( )
click( )
click( )
wait( )
click( )
提前感谢您的帮助:)
I'm just trying Sikuli. I'm trying to have a "main" page that call others files containing some classes and some def. But I get following error:
[error] Arrêté [error] Une erreur est survenue à la ligne 13 [error] Message d'erreur : Traceback (most recent call last): File "C:\Users\gregory\AppData\Local\Temp\sikuli-tmp2607956245912033896.py", line 13, in log = Logi() NameError: name 'Logi' is not defined
I don't really know why.
My Code
main.sikuli
# Path to def
myScriptPath = "C:\\NOT_SCANNED\\Stockage\\SikuliProject\\"
if not myScriptPath in sys.path: sys.path.append(myScriptPath)
# Import File.sikuli
from loginLogout import *
from sikuli.Sikuli import *
# Call Def
if __name__ == "__main__":
log = Logi()
log.login()
log.logout()
loginLogout.sikuli
from sikuli.Sikuli import *
class Logi:
def login(self):
openApp("MyApp")
wait(5)
type("demo" + Key.TAB + "demo" + Key.TAB)
type("a", KEY_CTRL)
type("localhost")
click( )
wait(5)
wait( )
I noticed someting. IF I named my class foo it works. I don't really understand.
Thanks in advance for your help.
OK I found something. I made something wrong with naming my files. Problem seems to have been fixed with made a save as and now I do not have this problem anymore. But I have another one. Now I did not get any error when I execute it but nothing is executed ...
New code:
main
# -*-coding:Latin-1 -*
# Path to def
myScriptPath = "C:\\NOT_SCANNED\\Stockage\\SikuliProject"
if not myScriptPath in sys.path: sys.path.append(myScriptPath)
# Import File.sikuli from sikuli.Sikuli import * from Logi import *
# Call Def
if __name__ == "__main__":
log = Logi()
log.login
Logi
from sikuli.Sikuli import *
class Logi:
def login(self):
openApp("MYAPP")
wait(5)
type("demo" + Key.TAB + "demo" + Key.TAB)
type("a", KEY_CTRL)
type("localhost")
click( )
wait(5)
wait( )
def logout(self):
click( )
wait( )
click( )
def openNewTab(self):
click( )
def createNewSingle(self):
click( )
click( )
rightClick( )
click( )
click( )
wait( )
click( )
type("test")
click( )
type("this is a test with Sikuli")
click( )
rightClick( )
click( )
click( )
wait( )
click( )
Thanks in advance for your help :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已添加脚本路径,但未添加脚本本身。在你的主要添加:
You have added the script path but not the script itself. In your main add: