1

我只是试图运行最简单的程序以使其工作,但我不断得到一个黑色背景的窗口,其中没有任何内容。我试过改变背景颜色,但似乎没有任何效果?

from guizero import App, Text, TextBox, PushButton

app = App("Hello world", bg = "white")

welcome_message = Text(app, text="Welcome to my app", size=40, font="Times New Roman", color="white")
my_name = TextBox(app)
update_text = PushButton(app, command=say_my_name, text="Display my name")

app.display()

在此处输入图像描述

4

1 回答 1

-1

您正在尝试调用say_my_name而不先定义它。您还将welcome_message应用程序背景设置为相同的颜色。

from guizero import App, Text, TextBox, PushButton, info
app = App("Hello world", bg = "white")


def say_my_name():
    #Change to do what you want
    #my_name.value gives you the text value of myname after you use the pushbutton  
    app.info("User greeting", "welcome "+my_name.value)


welcome_message = Text(app, text="Welcome to my app", size=40, font="Times New Roman", color="Black")
my_name = TextBox(app)
update_text = PushButton(app, command=say_my_name, text="Display my name")


app.display()
于 2021-12-06T16:05:42.943 回答