【问题标题】:Python easygui modulePython easygui 模块
【发布时间】:2019-07-21 03:06:55
【问题描述】:

在这段代码中:

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

【问题讨论】:

  • 我认为你需要传递msgbox() 列表中的字符串,例如easygui.msgbox([name, hNumber, street, city, country])

标签: python easygui


【解决方案1】:

这可能适用于"\n"

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

【讨论】:

    【解决方案2】:

    我试过了,你可以试试我的固定版本。

    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)
    

    【讨论】:

      【解决方案3】:
      easygui.msgbox(name + "\n" + hNumber + "\n" + street + "\n" +
                     city + "\n" + country)
      

      有点长,但也可以。

      【讨论】:

        【解决方案4】:

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

        所以你的代码是:

        #! 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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-03-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多