Python easygui模块

问题描述 投票:2回答:3

在这段代码中:

#! street.py
# A simple program which tests GUI

import easygui

easygui.msgbox("This programe asks for your info and stores them")
name = easygui.enterbox("What is your name?")
hNumber = easygui.enterbox("What is your house number")
street = easygui.enterbox("What is your post number?")
city = easygui.enterbox("What is your city?")
country = easygui.enterbox("What is your country?")

easygui.msgbox(name +  
               hNumber +
               street +
               city +
               country)

我有最后一个窗口的问题(easygui.msgbox(....),我想在不同行的单个窗口中显示所有信息,但我只能让它显示在一行上。 \n和类似的东西不起作用。

python easygui
3个回答
1
投票

这可能适用于"\n"

easygui.msgbox('\n'.join([
               name,
               hNumber,
               street,
               city,
               country]))

1
投票

我试过这个,你可以尝试我的固定版本。

import easygui
easygui.msgbox("This programe asks for your info and stores them")
name = easygui.enterbox("What is your name?")
hNumber = easygui.enterbox("What is your house number")
street = easygui.enterbox("What is your post number?")
city = easygui.enterbox("What is your city?")
country = easygui.enterbox("What is your country?")
easygui.msgbox(name + '\n' + hNumber + '\n' + street + '\n' + city + '\n' + country)

0
投票
easygui.msgbox(name + "\n" + hNumber + "\n" + street + "\n" +
               city + "\n" + country)

稍微长一点,但也可以。

© www.soinside.com 2019 - 2024. All rights reserved.