Python easygui模块

时间:2017-07-23 18:53:39

标签: python easygui

在此代码中:

#! 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和类似情况不起作用。

4 个答案:

答案 0 :(得分:1)

这可能适用于"\n"

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

答案 1 :(得分: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)

答案 2 :(得分:0)

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

稍微长一点,但也可以。

答案 3 :(得分:0)

使用最新的easygui版本0.98.1,它是multenterbox选项。

因此您的代码应为:

#! street.pyw
# A simple program which tests GUI
import easygui
easygui.msgbox("This programe asks for your info and stores them")
info = easygui.multenterbox('Fill fields below','Info',['Name','Number','Street','City','Country'])
first = info[0]
second = info[1]
third = info[2]
fourth = info[3]
fiveth = info[4]
easygui.msgbox(first+'\n'+second+'\n'+third+'\n'+fourth+'\n'+fiveth)

最好将其另存为scriptname.pyw而不是scriptname.py