PyQt多行文本输入框

时间:2017-02-15 01:12:33

标签: python pyqt pyqt4 pyqt5

我正在使用PyQt,我正在尝试为用户构建一个多行文本输入框。但是,当我运行下面的代码时,我得到一个只允许输入单行文本的框。如何修复它以便用户可以根据需要输入多行?

   import sys
   from PyQt4.QtGui import *
   from PyQt4.QtCore import *

   def window():
       app = QApplication(sys.argv)
       w = QWidget()

       w.resize(640, 480)

       textBox = QLineEdit(w)
       textBox.move(250, 120)

       button = QPushButton("click me")
       button.move(20, 80)

       w.show()

       sys.exit(app.exec_())


   if __name__ == '__main__':
       window()

1 个答案:

答案 0 :(得分:8)

import sys from PyQt4.QtGui import * from PyQt4.QtCore import * def window(): app = QApplication(sys.argv) w = QWidget() w.resize(640, 480) textBox = QPlainTextEdit(w) textBox.move(250, 120) button = QPushButton("click me", w) button.move(20, 80) w.show() sys.exit(app.exec_()) if __name__ == '__main__': window() 是一个小部件,提供单行,而不是多行。您可以将<asp:Image ID="img" runat="server" ImageUrl='<%# !string.IsNullOrEmpty(Eval("fldImg").ToString()) ? "../img/profil/" + Eval("fldImg") : "../img/profil/default-billede/ingen-profil-billede.png" %>' /> 用于此目的。

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);
    }
}
相关问题