AttributeError:__enter__ with Appjar subWindow GUI

时间:2018-05-01 02:44:41

标签: python user-interface

我使用appJar用python编写了一些GUI。我试图用登录Subwindow启动应用程序。但是,当我运行代码时,我收到错误" AttributeError:输入"希望有人能让我知道我做错了什么。这是我第一次使用GUI。

完整错误消息: 2018-05-01 15:24:38,521 appJar:ERROR [第40行 - > 1630 / 退出]:ContextManager失败:输入 Traceback(最近一次调用最后一次):   File" C:/ Users / Jason Smit / PycharmProjects / Project-X / main.py",第17行,in     使用app.startSubWindow(" Sub1"," LogWin",): AttributeError:输入

    def login(btn):
    if btn == "Unlock":
        app.infoBox("Success", "Access granted\n Welcome User")
        app.hideSubWindow("Sub1")
    return

###################
# GUI starts here # 
###################

with gui("Project-X") as app:
    app.setBg("white")
    app.setIcon("app_icon.ico")  # App icon
    with app.startSubWindow("Sub1", "LogWin",):
        # Empty left container (To help get login in center.)
        with app.frame("LEFT", row=0, column=0, sticky='NEW', stretch='COLUMN'):
            """"""
        # Login container/gui

        with app.frame("CenterTop", row=0, column=1, sticky='NEW', stretch='column'):
            app.setBg("white")
            with app.labelFrame("Login"):
                app.setBg("white")
                app.setSticky("ew")
                # Login widget setup
                app.addLabel("l1", "Name", 0, 0)
                app.addEntry("Name", 0, 1)
                app.addLabel("l2", "Password", 1, 0)
                app.addSecretEntry("Password", 1, 1)
                app.addNamedButton("Submit", "Unlock", login, 2, 0, 2)

        # Empty right container (To help get login in center.)

        with app.frame("RIGHT", row=0, column=2,  sticky='NEW', stretch='COLUMN'):
            """"""
        app.stopSubWindow()
    app.go(startWindow="Sub1")

1 个答案:

答案 0 :(得分:1)

The context manager is subWindow, not startSubWindow

with app.subWindow("Sub1", "LogWin"):