www.pudn.com > main4.rar > main4.py, change:2017-05-06,size:10347b


# -*- coding: utf-8 -*- 
 
# Form implementation generated from reading ui file 'u.ui' 
# 
# Created by: PyQt4 UI code generator 4.11.4 
# 
# WARNING! All changes made in this file will be lost! 
 
import sys 
import serial  
import time   
import threading   
import glob   
import thread 
import socket 
import os 
from time import sleep  
 
 
from PyQt4 import QtCore, QtGui 
 
x1='' 
x2='' 
x3='' 
x4='' 
x5='' 
x6='' 
x7='' 
x8='' 
x9='' 
n='' 
try: 
    _fromUtf8 = QtCore.QString.fromUtf8 
except AttributeError: 
    def _fromUtf8(s): 
        return s 
 
try: 
    _encoding = QtGui.QApplication.UnicodeUTF8 
    def _translate(context, text, disambig): 
        return QtGui.QApplication.translate(context, text, disambig, _encoding) 
except AttributeError: 
    def _translate(context, text, disambig): 
        return QtGui.QApplication.translate(context, text, disambig) 
 
class Ui_Dialog(object): 
    def setupUi(self, Dialog): 
        Dialog.setObjectName(_fromUtf8("Dialog")) 
        Dialog.resize(502, 342) 
        self.label = QtGui.QLabel(Dialog) 
        self.label.setGeometry(QtCore.QRect(140, 10, 211, 61)) 
        font = QtGui.QFont() 
        font.setFamily(_fromUtf8("AcadEref")) 
        font.setPointSize(16) 
        self.label.setFont(font) 
        self.label.setObjectName(_fromUtf8("label")) 
        self.xingming = QtGui.QLineEdit(Dialog) 
        self.xingming.setGeometry(QtCore.QRect(90, 100, 133, 20)) 
        self.xingming.setObjectName(_fromUtf8("xingming")) 
        self.xingbie = QtGui.QLineEdit(Dialog) 
        self.xingbie.setGeometry(QtCore.QRect(90, 140, 133, 20)) 
        self.xingbie.setStyleSheet(_fromUtf8("")) 
        self.xingbie.setObjectName(_fromUtf8("xingbie")) 
        self.nianling = QtGui.QLineEdit(Dialog) 
        self.nianling.setGeometry(QtCore.QRect(90, 180, 133, 20)) 
        self.nianling.setObjectName(_fromUtf8("nianling")) 
        self.zhengzhuang = QtGui.QLineEdit(Dialog) 
        self.zhengzhuang.setGeometry(QtCore.QRect(90, 220, 133, 20)) 
        self.zhengzhuang.setObjectName(_fromUtf8("zhengzhuang")) 
        self.label_2 = QtGui.QLabel(Dialog) 
        self.label_2.setGeometry(QtCore.QRect(20, 100, 60, 18)) 
        self.label_2.setLayoutDirection(QtCore.Qt.LeftToRight) 
        self.label_2.setWordWrap(False) 
        self.label_2.setObjectName(_fromUtf8("label_2")) 
        self.label_3 = QtGui.QLabel(Dialog) 
        self.label_3.setGeometry(QtCore.QRect(20, 140, 60, 18)) 
        self.label_3.setObjectName(_fromUtf8("label_3")) 
        self.label_4 = QtGui.QLabel(Dialog) 
        self.label_4.setGeometry(QtCore.QRect(20, 180, 60, 18)) 
        self.label_4.setObjectName(_fromUtf8("label_4")) 
        self.label_6 = QtGui.QLabel(Dialog) 
        self.label_6.setGeometry(QtCore.QRect(0, 260, 85, 18)) 
        self.label_6.setObjectName(_fromUtf8("label_6")) 
        self.ok = QtGui.QPushButton(Dialog) 
        self.ok.setGeometry(QtCore.QRect(210, 300, 75, 23)) 
        self.ok.setStyleSheet(_fromUtf8("")) 
        self.ok.setObjectName(_fromUtf8("ok")) 
        self.yizhu = QtGui.QTextEdit(Dialog) 
        self.yizhu.setGeometry(QtCore.QRect(270, 110, 191, 71)) 
        self.yizhu.setObjectName(_fromUtf8("yizhu")) 
        self.yishi = QtGui.QLineEdit(Dialog) 
        self.yishi.setGeometry(QtCore.QRect(90, 260, 133, 20)) 
        self.yishi.setObjectName(_fromUtf8("yishi")) 
        self.label_7 = QtGui.QLabel(Dialog) 
        self.label_7.setGeometry(QtCore.QRect(20, 220, 60, 18)) 
        self.label_7.setObjectName(_fromUtf8("label_7")) 
        self.label_5 = QtGui.QLabel(Dialog) 
        self.label_5.setGeometry(QtCore.QRect(270, 80, 81, 31)) 
        self.label_5.setObjectName(_fromUtf8("label_5")) 
        self.label_8 = QtGui.QLabel(Dialog) 
        self.label_8.setGeometry(QtCore.QRect(0, 0, 511, 351)) 
        self.label_8.setStyleSheet(_fromUtf8("background: lightblue")) 
        self.label_8.setText(_fromUtf8("")) 
        self.label_8.setObjectName(_fromUtf8("label_8")) 
        self.label_9 = QtGui.QLabel(Dialog) 
        self.label_9.setGeometry(QtCore.QRect(270, 190, 81, 31)) 
        self.label_9.setObjectName(_fromUtf8("label_9")) 
        self.textEdit = QtGui.QTextEdit(Dialog) 
        self.textEdit.setGeometry(QtCore.QRect(270, 230, 191, 51)) 
        self.textEdit.setObjectName(_fromUtf8("textEdit")) 
        self.label_8.raise_() 
        self.label.raise_() 
        self.xingming.raise_() 
        self.xingbie.raise_() 
        self.nianling.raise_() 
        self.zhengzhuang.raise_() 
        self.label_2.raise_() 
        self.label_3.raise_() 
        self.label_4.raise_() 
        self.label_6.raise_() 
        self.ok.raise_() 
        self.yizhu.raise_() 
        self.yishi.raise_() 
        self.label_7.raise_() 
        self.label_5.raise_() 
        self.label_9.raise_() 
        self.textEdit.raise_() 
 
        self.retranslateUi(Dialog) 
        QtCore.QObject.connect(self.ok, QtCore.SIGNAL(_fromUtf8("clicked()")), self.umall) 
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
        Dialog.setTabOrder(self.ok, self.xingming) 
 
    def umall(self): 
        global x1 
        global x2 
        global x3 
        global x4 
        global x5 
        global x6 
        global x7 
        global x8 
        global x9 
        m='                            ' 
        x1= _fromUtf8("电子病房备忘录") 
        x2= _fromUtf8("姓名:") 
        x3=_fromUtf8("年龄:") 
        x4=_fromUtf8("性别:") 
        x5=_fromUtf8("症状:") 
        x6=_fromUtf8("医生:") 
        x7=_fromUtf8("医嘱:") 
        xingming = self.xingming.text() 
        xingbie= self.xingbie.text() 
        zhengzhuang= self.zhengzhuang.text() 
        yishi= self.yishi.text() 
        nianling= self.nianling.text() 
        yizhu= self.yizhu.toPlainText();  
        x2+=unicode(xingming) 
        x3+=unicode(nianling) 
        x4+=unicode(xingbie) 
        x5+=unicode(zhengzhuang) 
        x6+=unicode(yishi) 
        x7+=unicode(yizhu) 
        print unicode(x1) 
        print unicode(x2) 
        print unicode(x3) 
        print unicode(x4) 
        print unicode(x5) 
        print unicode(x6) 
        print unicode(x7) 
        t=serial.Serial('com7',9600) 
        x1=unicode(x1.toUtf8(), 'utf-8', 'ignore').encode('gbk') 
        x2=unicode(x2.toUtf8(), 'utf-8', 'ignore').encode('gbk') 
        x3=unicode(x3.toUtf8(), 'utf-8', 'ignore').encode('gbk') 
        x4=unicode(x4.toUtf8(), 'utf-8', 'ignore').encode('gbk') 
        x5=unicode(x5.toUtf8(), 'utf-8', 'ignore').encode('gbk') 
        x6=unicode(x6.toUtf8(), 'utf-8', 'ignore').encode('gbk') 
        x7=unicode(x7.toUtf8(), 'utf-8', 'ignore').encode('gbk') 
        t.write(x1) 
        time.sleep(0.5) 
        n2=len(x2) 
        if n2>=14: 
            t.write(x2) 
            time.sleep(0.5) 
        else: 
            n1=14-n2 
            x2+=m[0:n1] 
            t.write(x2) 
            time.sleep(0.5) 
        n2=len(x3) 
        if n2>=14: 
            t.write(x3) 
            time.sleep(0.5) 
        else: 
            n1=14-n2 
            x3+=m[0:n1] 
            t.write(x3) 
            time.sleep(0.5) 
        n2=len(x4) 
        if n2>=14: 
            t.write(x4) 
            time.sleep(0.5) 
        else: 
            n1=14-n2 
            x4+=m[0:n1] 
            t.write(x4) 
            time.sleep(0.5) 
        n2=len(x5) 
        if n2>=14: 
            t.write(x5) 
            time.sleep(0.5) 
        else: 
            n1=14-n2 
            x5+=m[0:n1] 
            t.write(x5) 
            time.sleep(0.5) 
        n2=len(x6) 
        if n2>=14: 
            t.write(x6) 
            time.sleep(0.5) 
        else: 
            n1=14-n2 
            x6+=m[0:n1] 
            t.write(x6) 
            time.sleep(0.5) 
        n2=len(x7) 
        if n2>=14: 
            x8=x7[0:14] 
            t.write(x8) 
            time.sleep(0.5) 
            x9=x7[14:] 
            n3=len(x9) 
            if n3<14: 
                n1=14-n3 
                x9+=m[0:n1] 
                t.write(x9) 
                time.sleep(0.5) 
        else: 
            n1=14-n2 
            x7+=m[0:n1] 
            t.write(x7) 
            time.sleep(0.5) 
 
        n=t.readline() 
        if(n!=''): 
            n=unicode(n,'gbk', 'ignore').encode('utf-8') 
            n= _fromUtf8(n) 
            self.textEdit.setPlainText(n) 
 
 
    def retranslateUi(self, Dialog): 
        Dialog.setWindowTitle(_translate("Dialog", "电子病房备忘录", None)) 
        self.label.setText(_translate("Dialog", "<html><head/><body><p align=\"center\"><span style=\" font-size:22pt; font-weight:600; font-style:italic;\">电子病房备忘录</span></p></body></html>", None)) 
        self.label_2.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:12pt; font-weight:600; font-style:italic;\">姓 名:</span></p></body></html>", None)) 
        self.label_3.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:12pt; font-weight:600; font-style:italic;\"> 性 别:</span></p></body></html>", None)) 
        self.label_4.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:12pt; font-weight:600; font-style:italic;\"> 年 龄:</span></p></body></html>", None)) 
        self.label_6.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:12pt; font-weight:600; font-style:italic;\">主治医师:</span></p></body></html>", None)) 
        self.ok.setText(_translate("Dialog", "确  定", None)) 
        self.label_7.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:12pt; font-weight:600; font-style:italic;\"> 症 状:</span></p></body></html>", None)) 
        self.label_5.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:16pt; font-weight:600; font-style:italic;\">医 嘱:</span></p></body></html>", None)) 
        self.label_9.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:16pt; font-weight:600; font-style:italic;\">提 醒:</span></p></body></html>", None)) 
 
 
if __name__ == '__main__': 
    app = QtGui.QApplication(sys.argv) 
    Form = QtGui.QWidget() 
    ui = Ui_Dialog() 
    ui.setupUi(Form) 
    Form.show() 
    sys.exit(app.exec_())