• python QMainWindow QWidget


    from PyQt5 import QtWidgets
    from untitled import Ui_MainWindow
    from PyQt5.QtWidgets import QFileDialog


    class MyWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
    super(MyWindow, self).__init__()
    self.setupUi(self)

    def openMsg(self):
    file, ok = QFileDialog.getOpenFileName(self, "打开", "C:/", "All Files (*);;Text Files (*.txt)")
    self.statusbar.showMessage(file) # 在状态栏显示文件地址


    if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    myshow = MyWindow()
    myshow.show()
    sys.exit(app.exec_())
     
     
     
    ======================
     
     
     
    import sys

    from PyQt5.QtWidgets import QApplication, QMainWindow, QTextEdit, QDockWidget, QListWidget
    from PyQt5.QtCore import Qt


    class MainWindow(QMainWindow):
    def __init__(self):
    super().__init__()
    # self.items = ['呵呵', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff','g', 'h', 'i', 'j', 'k', 'l', 'm'
    # ,'m','n','o','p','q','r','s','t']
    # self.init()
    # self.addDock()


    def init(self):
    self.text = QTextEdit('主窗口')
    self.text.setAlignment(Qt.AlignCenter)
    self.setCentralWidget(self.text)

    self.setGeometry(200, 200, 800, 400)
    self.setWindowTitle('QDockWidget示例')
    self.show()
    pass

    def onDockListIndexChanged(self, index):
    item = self.items[index]
    self.text.setText(item)
    pass

    def addDock(self):
    dock1 = QDockWidget('DockWidget')
    dock1.setFeatures(QDockWidget.DockWidgetFloatable)
    dock1.setAllowedAreas(Qt.LeftDockWidgetArea)
    listwidget = QListWidget()

    listwidget.addItems(self.items)
    listwidget.currentRowChanged.connect(self.onDockListIndexChanged)
    dock1.setWidget(listwidget)
    self.addDockWidget(Qt.LeftDockWidgetArea, dock1)


    def main():
    app = QApplication(sys.argv)
    window = MainWindow()
    sys.exit(app.exec_())


    # 入口
    if __name__ == '__main__':
    main()
     
    =============================
     
     
    # -*- coding: utf-8 -*-
    import json
    import logging
    import sys

    import requests
    from PyQt5 import QtWidgets
    from ReqSend import *

    '''===== [logg] .xu =============================================='''
    # -*- coding: utf-8 -*-
    import logging
    import sys
    import os
    # 获取logger实例,如果参数为空则返回root logger
    log = logging.getLogger("AppName")

    # 指定logger输出格式
    formatter = logging.Formatter('%(asctime)s %(levelname)-8s: %(message)s')

    # 文件日志
    file_handler = logging.FileHandler(os.path.basename(__file__)+".log")
    file_handler.setFormatter(formatter) # 可以通过setFormatter指定输出格式

    # 控制台日志
    console_handler = logging.StreamHandler(sys.stdout)
    console_handler.formatter = formatter # 也可以直接给formatter赋值

    # 为logger添加的日志处理器
    log.addHandler(file_handler)
    log.addHandler(console_handler)

    # 指定日志的最低输出级别,默认为WARN级别
    log.setLevel(logging.DEBUG)

    '''===== [logg] End of Section comment block .xu ==============='''


    class MyClass:
    # 初始化
    def __init__(self):
    print("=====>def: " , "def")


    myClass = MyClass()

    from Test1_Form import Ui_Form # 导入生成form.py里生成的类
    class mywindow(QtWidgets.QWidget, Ui_Form):
    # def inputRequest(self):
    # myClassnew.SBK = self.lineEdit_4.text()
    #
    # def outResponse(self):
    # self.textEdit_2.setText(r1Text)


    def __init__(self):
    super(mywindow,self).__init__()
    self.setupUi(self)

    def tes2(self):
    print("=====>self: " , "self")
    def tes1(self):
    print("=====>self: " , "self")
    try:
    url ="http://localhost:8080/AzuSpringMvc/test/xxrrr"
    myClassnew = MyClass()
    myClassnew.medicareNo ="A01534082"

    vvv=self.textEdit.toPlainText()
    log.warn(vvv)
    # myClassDict = vvv.__dict__
    # myClassJson = json.dumps(myClassDict, sort_keys=True, indent=2, ensure_ascii=False)
    # self.textEdit_2.setText(r1Text)
    myClassnew = MyClass()
    myClassnew = vvv
    # myClassnew.SBK = self.lineEdit_4.text()
    # r1Text = reqSend(myClassnew, url, log)
    myClassDict = myClassnew.__dict__
    log.warn(myClassDict)
    myClassJson = json.dumps(myClassDict, sort_keys=True, indent=2, ensure_ascii=False)
    log.warn(myClassJson)
    # self.textEdit_2.setText(r1Text)

    # myClassnew.SBK = self.lineEdit_4.text()
    r1Text = reqSend(myClassJson, url,log)
    # myClassDict = myClassnew.__dict__
    # myClassJson = json.dumps(myClassDict, sort_keys=True, indent=2, ensure_ascii=False)
    # self.textEdit_2.setText(r1Text)
    except:
    log.warn("except")
    pass


    app = QtWidgets.QApplication(sys.argv)
    window = mywindow()
    window.show()
    sys.exit(app.exec_())
    昨日已逝正在输入···
    赞赏支持!!!
    分享到: 更多
  • 相关阅读:
    x8086汇编在显存中显示字符串
    x8086汇编实现dos清屏(clear screen)
    原创:根据题目要求,通过素数的方式判断一个小的字符串是否属于另一个大的字符串的子集
    python signal信号
    转:python signal信号
    python signal(信号)
    python问题记录
    Python语言and-or的用法
    perl6中的q/qq/qx/qqx
    upupw注入by pass
  • 原文地址:https://www.cnblogs.com/rhxuza1993/p/9239296.html
Copyright © 2020-2023  润新知