• 2016-09-06 15:19:59 python352 + PyQt5 QTextEdit 追加写入(分行)/自动滚屏


    2016-09-06 15:19:59 PyQt5 QTextEdit 追加写入 / 分行写入
     
    1. #!/usr/bin/env python3
    2. # Author:1626478661
    3. # Date:2016-09-06 15:28:21
    4. # PyQt5 QTextEdit
    5. from PyQt5 import QtWidgets, QtCore, QtGui
    6. from PyQt5.QtWidgets import (QPushButton, QLineEdit, QTextEdit, QWidget, QHBoxLayout, QVBoxLayout, QApplication)
    7. from PyQt5.QtCore import Qt
    8. from PyQt5.QtGui import QTextCursor
    9. import sys
    10. import time
    11. class Windows(QWidget):
    12. def __init__(self):
    13. super(Windows, self).__init__()
    14. self.setWindowTitle('PyQt5 QTextEdit © QQ 1626478661')
    15. self.setFixedSize(300, 150)
    16. # IP address / Hostname
    17. self.IPHostnameEdit = QLineEdit()
    18. self.IPHostnameEdit.setPlaceholderText('IP address or Hostname')
    19. self.IPHostnameButton = QPushButton('追加')
    20. self.IPHostnameButton.clicked.connect(self.checkButton)
    21. self.IPHostnameButton02 = QPushButton('分行')
    22. self.IPHostnameButton02.clicked.connect(self.checkButton02)
    23. # Message / Log
    24. self.showLogText = QTextEdit()
    25. self.showLogText.setText("{0} initializing...".format(time.strftime("%F %T")))
    26. # layout for IPHostname
    27. self.IPHostnameLayout = QHBoxLayout()
    28. self.IPHostnameLayout.addWidget(self.IPHostnameEdit)
    29. self.IPHostnameLayout.addWidget(self.IPHostnameButton)
    30. self.IPHostnameLayout.addWidget(self.IPHostnameButton02)
    31. # layout
    32. self.mainLayout = QVBoxLayout()
    33. self.mainLayout.addLayout(self.IPHostnameLayout)
    34. self.mainLayout.addWidget(self.showLogText)
    35. self.setLayout(self.mainLayout)
    36. # Disable zoom- / zoom+
    37. self.setWindowFlags(Qt.WindowCloseButtonHint)
    38. # Function for check Button
    39. def checkButton(self):
    40. self.showLogText.moveCursor(QTextCursor.End)
    41. self.showLogText.insertPlainText(self.IPHostnameEdit.text())
    42. def checkButton02(self):
    43.        self.showLogText.moveCursor(QTextCursor.End)
    44. self.showLogText.append(self.IPHostnameEdit.text())
    45. app = QApplication(sys.argv)
    46. win = Windows()
    47. win.show()
    48. app.exec_()






  • 相关阅读:
    6_10 下落的树叶(UVa699)<二叉树的DFS>
    6_9 天平(UVa839)<二叉树的DFS>
    6_8 树(UVa548)<从中序和后序恢复二叉树>
    6_7 树的层次遍历(UVa122)<二叉树的动态创建与BFS>
    6_6 小球下落(UVa679)<完全二叉树编号>
    6_4 破损的键盘(UVa11988)<链表>
    6_3 矩阵链乘(UVa424)<用栈实现简单的表达式解析>
    6_2 铁轨(UVa514)<栈>
    第五周课程总结&试验报告(三)
    第四周课程总结和实验报告
  • 原文地址:https://www.cnblogs.com/topshooter/p/5576c4b13acc73812b0f0ac7902237b9.html
Copyright © 2020-2023  润新知