小编Ari*_*ric的帖子

为什么我的Haskell代码说'变量不在范围内:main'?

当我在repl.it网站上的Haskell的交互式shell中键入以下内容时,它完美地运行.

let squareMe x = x * x
let myFruit = ["banana", "apple", "kiwi", "orange"]
Run Code Online (Sandbox Code Playgroud)

但是,当我将其键入源文件并单击"运行"时,我收到错误:

<interactive>:3:1: error:
    • Variable not in scope: main
    • Perhaps you meant ‘min’ (imported from Prelude)
Run Code Online (Sandbox Code Playgroud)

我一直在努力理解这个错误,并提出了几个小时的解决方案,并且不再寻找解决方案或理解错误意味着什么.

haskell compiler-errors

10
推荐指数
2
解决办法
1万
查看次数

pywinauto:迭代窗口中的所有控件

我正在尝试编写一个通用测试脚本来查找新软件版本中的错误。我的想法是迭代窗口中的控件并与每个控件进行交互,记录引起的任何错误,并在软件崩溃时重新启动软件。

我正在寻找一种动态查找控件标识符的方法,有点像print_control_identifiers()但输出是一个列表或类似的结构,我可以对其进行迭代。

在关于控件标识符的GitHub 问题上提到了这一点:

可以通过使用.children()(仅直接子级)和.descendants() (整个子树作为普通列表)来遍历层次结构

我假设我可以迭代Application对象的descendants()列表并为每个对象调用相关的交互方法,但是我不知道如何获取此列表。我以为我可以做这样的事情,但我没有取得任何成功:

def test(application):
    for child in application.descendants():
        #interact with child control

software = Application(backend='uia').start(cmd_line=FILE_PATH)
test(software)
Run Code Online (Sandbox Code Playgroud)

AttributeError:既没有找到 GUI 元素(包装器)也没有找到包装器方法“后代”(拼写错误?)


编辑


我通过查看代码找到了print_control_identifiers方法:

class Application(object):

    def print_control_identifiers(self, depth=None, filename=None):
        """
        Prints the 'identifiers'
        Prints identifiers for the control and for its descendants to
        a depth of **depth** (the whole subtree if **None**).
        .. note:: The identifiers printed by this method have been …
Run Code Online (Sandbox Code Playgroud)

python pywinauto

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

圆形物体记录碰撞,但它们没有碰到

我刚刚在这里检查以确保这个问题是允许的,而且似乎就是这样,我走了:

我目前正在将2D物理引擎作为一个小项目.我有一个叫做circle半径,旋转,位置和速度等属性的类:

class circle():
    def __init__(self, radius = 10, r = 0.0, x = 0, y = 0, Vr = 0, Vx = 0, Vy = 0):

        self.radius = radius

        self.r = r
        self.x = x
        self.y = y

        self.Vr = Vr
        self.Vx = Vx
        self.Vy = Vy
Run Code Online (Sandbox Code Playgroud)

该类有一个名为的方法CheckCollisions(),用于检查其中心与另一个圆的中心之间的距离是否小于其半径的总和:

def CheckCollisions(self):
    for c in circles:
        distance = math.sqrt((c.x - self.x)*(c.x - self.x) + (c.y - self.y)*(c.y - self.y))
        if distance < self.radius + c.radius: …
Run Code Online (Sandbox Code Playgroud)

python pygame game-physics

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