Example #1
0
 def createRadioButton(self, text='Button', tip=None, slot=None):
     btn = QRadioButton(text, self)
     btn.setFocusPolicy(Qt.NoFocus)
     if tip is not None:
         btn.setToolTip(tip)
     if slot is not None:
         btn.toggled.connect(slot)
     return btn
Example #2
0
class QtUserTypeSelectionDialog(QDialog):
    """A modal dialog presenting the user with options for what kind of
    user to sign in as.
    """

    def __init__(self, message, parent=None):
        super(QtUserTypeSelectionDialog, self).__init__(parent)

        lbl_message = QLabel(message, self)

        self.rb_tutor = QRadioButton('Tutor', self)
        self.rb_student = QRadioButton('Student', self)
        self.rb_tutor.setFocusPolicy(Qt.StrongFocus)
        self.rb_student.setFocusPolicy(Qt.StrongFocus)

        radio_vbox = QVBoxLayout()
        radio_vbox.addWidget(self.rb_tutor)
        radio_vbox.addWidget(self.rb_student)

        radios = QGroupBox(self)
        radios.setLayout(radio_vbox)

        btn_sign_in = QPushButton('Sign In', self)
        btn_sign_in.setDefault(True)
        btn_sign_in.setAutoDefault(True)
        btn_cancel = QPushButton('Cancel', self)
        btn_cancel.setAutoDefault(True)

        btn_sign_in.clicked.connect(self.update_user_type)
        btn_cancel.clicked.connect(self.reject)

        self.rb_tutor.setChecked(True)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(btn_sign_in)
        hbox.addWidget(btn_cancel)

        vbox = QVBoxLayout()
        vbox.addWidget(lbl_message)
        vbox.addWidget(radios)
        vbox.addStretch(1)
        vbox.addLayout(hbox)

        self.setLayout(vbox)
        self.setWindowTitle('User Type Selection')

    def update_user_type(self):
        """Return either 'tutor' or 'student' based on which radio
        button is selected.
        """
        if self.rb_tutor.isChecked():
            self.user_type = 'tutor'
        elif self.rb_student.isChecked():
            self.user_type = 'student'
        self.accept()
Example #3
0
class RadioButton(QtWidgets.QWidget):
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self)

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('Check')

        self.rb = QRadioButton('Show title', self)
        self.rb.setFocusPolicy(Qt.NoFocus)

        self.rb.move(10, 10)
        self.rb.toggle()
        self.rb.toggled.connect(self.changeTitle)

    def changeTitle(self, value):
        if self.rb.isChecked():
            self.setWindowTitle('Check')
        else:
            self.setWindowTitle('unchecked')
Example #4
0
class CloseActionsBox(QGroupBox):
    close_act_changed = pyqtSignal(int)
    def __init__(self, parent=None):
        super(CloseActionsBox, self).__init__(parent)
        self.setup_ui()
        self.create_connections()
    
    def create_connections(self):
        self.hideItButton.pressed.connect(self.hideit_button_clicked)
        self.exitItButton.pressed.connect(self.exitit_button_clicked)
    
    def setup_ui(self):
        self.setTitle('关闭主面板时')
        self.hideItButton = QRadioButton('最小化到托盘')
        self.hideItButton.setFocusPolicy(Qt.NoFocus)
        self.exitItButton = QRadioButton('退出程序')
        self.exitItButton.setFocusPolicy(Qt.NoFocus)    
        vbox = QVBoxLayout(self)
        vbox.addWidget(self.hideItButton)
        vbox.addWidget(self.exitItButton)
    
    def set_close_act(self, act):
        if act == Configures.SettingsHide:
            self.hideItButton.setChecked(True)
        elif act == Configures.SettingsExit:
            self.exitItButton.setChecked(True) 
        self.close_act_changed.emit(act)
    
    def hideit_button_clicked(self):
        self.close_act_changed.emit(Configures.SettingsHide)
    
    def exitit_button_clicked(self):
        self.close_act_changed.emit(Configures.SettingsExit)
    
    def restore_default_close_act(self):
        self.set_close_act(configOptions[globalSettings.optionsHub.CloseButtonAct])
Example #5
0
class PreviewWidgetStyle(QGroupBox):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setTitle(self.tr("Preview"))
        self.setMaximumHeight(220)
        self.setObjectName("groupBox")

        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.tabWidget = QTabWidget(self)
        self.tabWidget.setObjectName("tabWidgetPreview")

        self.tab = QWidget()
        self.tab.setObjectName("tab")

        self.horizontalLayout = QHBoxLayout(self.tab)
        self.horizontalLayout.setObjectName("horizontalLayout")

        self.groupBox = QGroupBox(self.tab)
        self.groupBox.setTitle(self.tr("Group Box"))
        self.groupBox.setObjectName("groupBox")

        self.verticalLayout_2 = QVBoxLayout(self.groupBox)
        self.verticalLayout_2.setObjectName("verticalLayout_2")

        self.radioButton = QRadioButton(self.groupBox)
        self.radioButton.setText(self.tr("Radio Button"))
        self.radioButton.setChecked(True)
        self.radioButton.setObjectName("radioButton")
        self.verticalLayout_2.addWidget(self.radioButton)

        self.radioButton_2 = QRadioButton(self.groupBox)
        self.radioButton_2.setText(self.tr("Radio Button"))
        self.radioButton_2.setObjectName("radioButton_2")
        self.verticalLayout_2.addWidget(self.radioButton_2)

        self.line = QFrame(self.groupBox)
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout_2.addWidget(self.line)

        self.checkBox = QCheckBox(self.groupBox)
        self.checkBox.setText(self.tr("Check Box"))
        self.checkBox.setChecked(True)
        self.checkBox.setObjectName("checkBox")
        self.verticalLayout_2.addWidget(self.checkBox)

        self.horizontalLayout.addWidget(self.groupBox)

        self.verticalLayout_3 = QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")

        self.progressBar = QProgressBar(self.tab)
        self.progressBar.setProperty("value", 75)
        self.progressBar.setObjectName("progressBar")
        self.verticalLayout_3.addWidget(self.progressBar)

        self.horizontalSlider = QSlider(self.tab)
        self.horizontalSlider.setProperty("value", 45)
        self.horizontalSlider.setSliderPosition(45)
        self.horizontalSlider.setOrientation(Qt.Horizontal)
        self.horizontalSlider.setObjectName("horizontalSlider")
        self.verticalLayout_3.addWidget(self.horizontalSlider)

        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")

        self.spinBox = QSpinBox(self.tab)
        self.spinBox.setObjectName("spinBox")
        self.horizontalLayout_2.addWidget(self.spinBox)

        self.pushButton = QPushButton(self.tab)
        self.pushButton.setText(self.tr("Button"))
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout_2.addWidget(self.pushButton)

        self.verticalLayout_3.addLayout(self.horizontalLayout_2)

        self.comboBox = QComboBox(self.tab)
        self.comboBox.setObjectName("comboBox")
        self.comboBox.addItem(self.tr("Combo Box"))
        self.verticalLayout_3.addWidget(self.comboBox)

        self.horizontalLayout.addLayout(self.verticalLayout_3)

        self.verticalScrollBar = QScrollBar(self.tab)
        self.verticalScrollBar.setPageStep(50)
        self.verticalScrollBar.setOrientation(Qt.Vertical)
        self.verticalScrollBar.setObjectName("verticalScrollBar")
        self.horizontalLayout.addWidget(self.verticalScrollBar)
        self.tabWidget.addTab(self.tab, self.tr("Tab 1"))

        self.tab_2 = QWidget()
        self.tab_2.setObjectName("tab_2")
        self.tabWidget.addTab(self.tab_2, self.tr("Tab 2"))

        self.verticalLayout.addWidget(self.tabWidget)

        self.pushButton.installEventFilter(self)
        self.pushButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton.installEventFilter(self)
        self.radioButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton_2.installEventFilter(self)
        self.radioButton_2.setFocusPolicy(Qt.NoFocus)
        self.checkBox.installEventFilter(self)
        self.checkBox.setFocusPolicy(Qt.NoFocus)
        self.comboBox.installEventFilter(self)
        self.comboBox.setFocusPolicy(Qt.NoFocus)
        self.spinBox.installEventFilter(self)
        self.spinBox.setFocusPolicy(Qt.NoFocus)
        self.horizontalSlider.installEventFilter(self)
        self.horizontalSlider.setFocusPolicy(Qt.NoFocus)
        self.verticalScrollBar.installEventFilter(self)
        self.verticalScrollBar.setFocusPolicy(Qt.NoFocus)
        self.tab.installEventFilter(self)
        self.tab.setFocusPolicy(Qt.NoFocus)
        self.tab_2.installEventFilter(self)
        self.tab_2.setFocusPolicy(Qt.NoFocus)
        self.tabWidget.installEventFilter(self)
        self.tabWidget.setFocusPolicy(Qt.NoFocus)

        self.tabWidget.currentChanged.connect(self.noClick)

    def noClick(self, x):
        self.tabWidget.setCurrentIndex(0)

    def eventFilter(self, obj, event):
        if self.pushButton:
            if event.type() == QEvent.MouseButtonRelease:
                return True
            elif event.type() == QEvent.MouseButtonPress:
                return True
            elif event.type() == QEvent.MouseButtonDblClick:
                return True
            else:
                return False
        else:
            super().eventFilter(obj, event)
Example #6
0
class PreviewWidgetStyle(QGroupBox):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setTitle(self.tr("Preview"))
        self.setMaximumHeight(220)
        self.setObjectName("groupBox")

        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")

        self.tabWidget = QTabWidget(self)
        self.tabWidget.setObjectName("tabWidgetPreview")

        self.tab = QWidget()
        self.tab.setObjectName("tab")

        self.horizontalLayout = QHBoxLayout(self.tab)
        self.horizontalLayout.setObjectName("horizontalLayout")

        self.groupBox = QGroupBox(self.tab)
        self.groupBox.setTitle(self.tr("Group Box"))
        self.groupBox.setObjectName("groupBox")


        self.verticalLayout_2 = QVBoxLayout(self.groupBox)
        self.verticalLayout_2.setObjectName("verticalLayout_2")

        self.radioButton = QRadioButton(self.groupBox)
        self.radioButton.setText(self.tr("Radio Button"))
        self.radioButton.setChecked(True)
        self.radioButton.setObjectName("radioButton")
        self.verticalLayout_2.addWidget(self.radioButton)

        self.radioButton_2 = QRadioButton(self.groupBox)
        self.radioButton_2.setText(self.tr("Radio Button"))
        self.radioButton_2.setObjectName("radioButton_2")
        self.verticalLayout_2.addWidget(self.radioButton_2)

        self.line = QFrame(self.groupBox)
        self.line.setFrameShape(QFrame.HLine)
        self.line.setFrameShadow(QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout_2.addWidget(self.line)

        self.checkBox = QCheckBox(self.groupBox)
        self.checkBox.setText(self.tr("Check Box"))
        self.checkBox.setChecked(True)
        self.checkBox.setObjectName("checkBox")
        self.verticalLayout_2.addWidget(self.checkBox)

        self.horizontalLayout.addWidget(self.groupBox)


        self.verticalLayout_3 = QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")

        self.progressBar = QProgressBar(self.tab)
        self.progressBar.setProperty("value", 75)
        self.progressBar.setObjectName("progressBar")
        self.verticalLayout_3.addWidget(self.progressBar)

        self.horizontalSlider = QSlider(self.tab)
        self.horizontalSlider.setProperty("value", 45)
        self.horizontalSlider.setSliderPosition(45)
        self.horizontalSlider.setOrientation(Qt.Horizontal)
        self.horizontalSlider.setObjectName("horizontalSlider")
        self.verticalLayout_3.addWidget(self.horizontalSlider)

        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")

        self.spinBox = QSpinBox(self.tab)
        self.spinBox.setObjectName("spinBox")
        self.horizontalLayout_2.addWidget(self.spinBox)

        self.pushButton = QPushButton(self.tab)
        self.pushButton.setText(self.tr("Button"))
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout_2.addWidget(self.pushButton)

        self.verticalLayout_3.addLayout(self.horizontalLayout_2)

        self.comboBox = QComboBox(self.tab)
        self.comboBox.setObjectName("comboBox")
        self.comboBox.addItem(self.tr("Combo Box"))
        self.verticalLayout_3.addWidget(self.comboBox)

        self.horizontalLayout.addLayout(self.verticalLayout_3)

        self.verticalScrollBar = QScrollBar(self.tab)
        self.verticalScrollBar.setPageStep(50)
        self.verticalScrollBar.setOrientation(Qt.Vertical)
        self.verticalScrollBar.setObjectName("verticalScrollBar")
        self.horizontalLayout.addWidget(self.verticalScrollBar)
        self.tabWidget.addTab(self.tab, self.tr("Tab 1"))


        self.tab_2 = QWidget()
        self.tab_2.setObjectName("tab_2")
        self.tabWidget.addTab(self.tab_2, self.tr("Tab 2"))

        self.verticalLayout.addWidget(self.tabWidget)

        self.pushButton.installEventFilter(self)
        self.pushButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton.installEventFilter(self)
        self.radioButton.setFocusPolicy(Qt.NoFocus)
        self.radioButton_2.installEventFilter(self)
        self.radioButton_2.setFocusPolicy(Qt.NoFocus)
        self.checkBox.installEventFilter(self)
        self.checkBox.setFocusPolicy(Qt.NoFocus)
        self.comboBox.installEventFilter(self)
        self.comboBox.setFocusPolicy(Qt.NoFocus)
        self.spinBox.installEventFilter(self)
        self.spinBox.setFocusPolicy(Qt.NoFocus)
        self.horizontalSlider.installEventFilter(self)
        self.horizontalSlider.setFocusPolicy(Qt.NoFocus)
        self.verticalScrollBar.installEventFilter(self)
        self.verticalScrollBar.setFocusPolicy(Qt.NoFocus)
        self.tab.installEventFilter(self)
        self.tab.setFocusPolicy(Qt.NoFocus)
        self.tab_2.installEventFilter(self)
        self.tab_2.setFocusPolicy(Qt.NoFocus)
        self.tabWidget.installEventFilter(self)
        self.tabWidget.setFocusPolicy(Qt.NoFocus)

        self.tabWidget.currentChanged.connect(self.noClick)

    def noClick(self, x):
        self.tabWidget.setCurrentIndex(0)

    def eventFilter(self, obj, event):
        if self.pushButton:
            if event.type() == QEvent.MouseButtonRelease:
                return True
            elif event.type() == QEvent.MouseButtonPress:
                return True
            elif event.type() == QEvent.MouseButtonDblClick:
                return True
            else:
                return False
        else:
            super().eventFilter(obj, event)
Example #7
0
class Example(QWidget):
    def __init__(self):

        super().__init__()

        self.sz = 8

        self.m_type = 'sat'

        self.s1 = "55.7507"

        self.s2 = "37.6256"

        self.matka = None

        self.perem = None

        self.radio = True

        self.initUI()

    def initUI(self):

        self.setGeometry(100, 100, W, H)

        self.setWindowTitle('Map')

        self.maps = "one.png"

        self.label = QLabel(self)

        self.label.setText("Size:")

        self.label.move(360, 10)

        self.btn = QPushButton('+', self)

        self.btn.setFocusPolicy(0)

        self.btn.resize(23, 23)

        self.btn.move(373, 29)

        self.btn.clicked.connect(self.cp)

        self.btn = QPushButton('-', self)

        self.btn.setFocusPolicy(0)

        self.btn.resize(23, 23)

        self.btn.move(347, 29)

        self.btn.clicked.connect(self.cm)

        self.label = QLabel(self)

        self.label.setText("Your coords:")

        self.label.move(10, 10)

        self.lat_input = QLineEdit(self)

        self.lat_input.setFocusPolicy(2)

        self.lat_input.setText("55.7507")

        self.lat_input.move(10, 30)

        self.lon_input = QLineEdit(self)

        self.lon_input.setFocusPolicy(2)

        self.lon_input.setText("37.6256")

        self.lon_input.move(W // 3 * 1, 30)

        self.btn = QPushButton('Show', self)

        self.btn.setFocusPolicy(0)

        self.btn.resize(self.btn.sizeHint())

        self.btn.move(W // 3 * 2, 29)

        self.btn.clicked.connect(self.show_map_file)

        self.pixmap = QPixmap(self.maps)

        self.lbl = QLabel(self)

        self.lbl.setFocusPolicy(0)

        self.lbl.setPixmap(self.pixmap)

        self.lbl.setGeometry(m, m + dMenu, map_w, map_h)

        self.lbl.move(10, 60)

        self.combo = QComboBox(self)

        self.combo.resize(90, 25)

        self.combo.addItems(["map", "sat", 'hyb'])

        self.combo.move(W // 2, 4)

        self.combo.activated[str].connect(self.onActivated)

        self.combo.setFocusPolicy(0)

        self.poisk = QLineEdit(self)

        self.poisk.setFocusPolicy(2)

        self.poisk.move(10, 450)

        self.poisk.resize(200, 21)

        self.btn = QPushButton('Search', self)

        self.btn.setFocusPolicy(0)

        self.btn.resize(self.btn.sizeHint())

        self.btn.move(W // 3 * 1.6, 449)

        self.btn.clicked.connect(self.find)

        self.btn = QPushButton('Clear', self)

        self.btn.setFocusPolicy(0)

        self.btn.resize(self.btn.sizeHint())

        self.btn.move(W // 3 * 2.3, 449)

        self.btn.clicked.connect(self.del_text)

        self.radiobutton = QRadioButton("index", self)
        self.radiobutton.setChecked(True)
        self.radiobutton.setFocusPolicy(0)
        self.radiobutton.move(20, 470)
        self.radiobutton.toggled.connect(self.radiot)

        self.radiobutton = QRadioButton("no index", self)
        self.radiobutton.setFocusPolicy(0)
        self.radiobutton.move(100, 470)
        self.radiobutton.toggled.connect(self.radiot)

        self.show_map_file()

    def radiot(self):
        if self.sender() and self.sender().text() == 'index':
            self.radio = True
        else:
            self.radio = False
        self.find()

    def del_text(self):
        self.poisk.setText('')
        self.perem = None
        self.matka = None
        self.show_map_file()

    def find(self):

        geocoder_request = "http://geocode-maps.yandex.ru/1.x/?geocode={}&format=json".format(
            self.poisk.text())

        response = None

        response = requests.get(geocoder_request)

        if response:

            json_response = response.json()

            try:
                toponym = json_response["response"]["GeoObjectCollection"][
                    "featureMember"][0]["GeoObject"]

                toponym1 = toponym['metaDataProperty']['GeocoderMetaData'][
                    'text']
            except Exception as e:
                print(e)

            try:
                if not self.radio:
                    raise IndexError
                index = toponym['metaDataProperty']['GeocoderMetaData'][
                    'AddressDetails']['Country']['AdministrativeArea'][
                        'Locality']['Thoroughfare']['Premise']['PostalCode'][
                            'PostalCodeNumber']
            except Exception as e:
                index = ' '
            text = str(toponym1) + ' ' + str(index)
            self.poisk.setText(text)

            toponym_coodrinates = toponym["Point"]["pos"]

            self.s1, self.s2 = toponym_coodrinates.split()

        self.matka = True

        self.perem = [self.s1, self.s2]
        self.lat_input.setText(self.s1)
        self.lon_input.setText(self.s2)

        self.show_map_file()

    def onActivated(self, text):

        d = {"sat": "sat", "map": "map", 'hyb': 'skl'}

        if text in d:

            self.m_type = d[text]

    def show_map_file(self):

        try:
            if self.sender() and self.sender().text() == 'Show':

                self.s1 = self.lat_input.text()

                self.s2 = self.lon_input.text()

            # Ïîêàçàòü êàðòó

            lon = self.s1

            lat = self.s2

            map_locations = "ll=" + ",".join([lon, lat])  # + "&spn=1.0,1.+-0"

            map_type = self.m_type

            if self.matka:

                map_param = "z={}&size=400,400&pt={},{}".format(
                    self.sz, self.perem[0], self.perem[1])

            else:

                map_param = "z={}&size=400,400".format(self.sz)

            f_name = get_file_map(map_locations, map_type, map_param)

            if f_name:

                self.maps = f_name

            self.pixmap.load(self.maps)

            self.lbl.setPixmap(self.pixmap)
        except Exception as e:
            print(e)

    def cm(self):  # óæàñíîå ðåøåíèå íó ëàäíî

        if 1 < self.sz:

            self.sz -= 1

            self.show_map_file()

    def cp(self):

        if self.sz < 17:

            self.sz += 1

            self.show_map_file()

    def keyPressEvent(self, event):

        try:
            if self.lat_input.hasFocus():

                self.lat_input.clearFocus()

            if self.lon_input.hasFocus():

                self.lon_input.clearFocus()

            if self.poisk.hasFocus():

                self.poisk.clearFocus()

            if event.key() == QtCore.Qt.Key_PageDown:

                self.cm()

            if event.key() == QtCore.Qt.Key_PageUp:

                self.cp()

            if event.key() == QtCore.Qt.Key_Up:

                self.s2 = str(float(self.s2) + 8 / self.sz)

                self.lon_input.setText(self.s2)

                self.show_map_file()

            if event.key() == QtCore.Qt.Key_Down:

                self.s2 = str(float(self.s2) - 8 / self.sz)

                self.lon_input.setText(self.s2)

                self.show_map_file()

            if event.key() == QtCore.Qt.Key_Right:

                self.s1 = str(float(self.s1) + 8 / self.sz)

                self.lat_input.setText(self.s1)

                self.show_map_file()

            if event.key() == QtCore.Qt.Key_Left:

                self.s1 = str(float(self.s1) - 8 / self.sz)

                self.lat_input.setText(self.s1)

                self.show_map_file()
        except Exception as e:
            print(e)
class ShowMedicalRecordWidget(QWidget):

    def __init__(self):
        super().__init__()
        self.record_id = None
        self.user_id = None
        self.initUI()

    def initUI(self):
        self.grid = QGridLayout()
        self.grid.setSpacing(1)
        # 外层网格

        self.gridinformation = QGridLayout()
        self.gridinformation.setSpacing(10)
        # 病人基本信息网格,行距1个字距

        self.title = QLabel('                                电子病历', self)
        self.title.setFont(QFont("Microsoft YaHei", 18, QFont.Bold))
        self.gridinformation.addWidget(self.title, 0, 0)

        string = '  姓名: '
        self.name = QLabel(string, self)
        self.name.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation.addWidget(self.name, 1, 0)

        string = '工作单位: '
        self.company = QLabel(string, self)
        self.company.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation.addWidget(self.company, 1, 1)

        string = '  性别: '
        self.gender = QLabel(string, self)
        self.gender.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation.addWidget(self.gender, 2, 0)

        string = '住       址: '
        self.address = QLabel(string, self)
        self.address.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation.addWidget(self.address, 2, 1)

        string = '  年龄: '
        self.age = QLabel(string, self)
        self.age.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation.addWidget(self.age, 3, 0)

        string = '科       室: '
        self.department = QLabel(string, self)
        self.department.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation.addWidget(self.department, 3, 1)

        string = '  民族: '
        self.nation = QLabel(string, self)
        self.nation.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation.addWidget(self.nation, 4, 0)

        string = '日       期: '
        self.date = QLabel(string, self)
        self.date.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation.addWidget(self.date, 4, 1)

        self.gridinformation2 = QGridLayout()
        self.gridinformation2.setSpacing(1)

        string = '症       状: '
        self.symptom = QLabel(string, self)
        self.symptom.setWordWrap(True)
        self.symptom.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation2.addWidget(self.symptom, 0, 0, 2, 2)

        string = '病情结论: '
        self.conclusion = QLabel(string, self)
        self.conclusion.setWordWrap(True)
        self.conclusion.setFont(QFont("Microsoft YaHei", 11))
        self.gridinformation2.addWidget(self.conclusion, 1, 0, 2, 2)

        self.editButton = QPushButton('编辑')
        self.editButton.setFixedSize(60, 30)
        self.gridinformation2.addWidget(self.editButton, 4, 0)

        self.setGeometry(0, 0, 570, 650)
        self.setFixedSize(610, 650)
        self.center()
        self.setWindowTitle('电子病历')
        self.gridsign = QGridLayout()
        self.gridsign.setSpacing(1)
        self.signframe = QFrame(self)
        self.signframe.setFrameShape(QFrame.StyledPanel)
        self.signframe.move(20, 420)
        self.signframe.resize(575, 190)

    def load_ui_not_signed(self):
        if not hasattr(self, 'signprompt'):
            string = '          是否电子签名,若进行电子签名,病历便不能修改'
            self.signprompt = QLabel(string, self)
            self.signprompt.setFont(QFont("Microsoft YaHei", 11))
            self.gridsign.addWidget(self.signprompt, 0, 0)

            self.yes = QRadioButton('是', self)
            self.yes.setFocusPolicy(Qt.NoFocus)
            self.yes.toggle()

            self.no = QRadioButton('否', self)
            self.no.setFocusPolicy(Qt.NoFocus)
            self.no.toggle()
            self.gridsign.addWidget(self.yes, 1, 1)
            self.gridsign.addWidget(self.no, 1, 2)

            self.gridbutton = QGridLayout()
            self.gridbutton.setSpacing(1)
            self.okButton = QPushButton('提交')
            self.okButton.setFixedSize(60, 30)
            self.gridbutton.addWidget(self.okButton, 0, 2)
            self.okButton.clicked.connect(self.on_sign_button_clicked)

            self.grid.addLayout(self.gridbutton, 3, 0)
            self.grid.addLayout(self.gridinformation, 0, 0)
            self.grid.addLayout(self.gridinformation2, 1, 0)
            self.grid.addLayout(self.gridsign, 2, 0)
            self.setLayout(self.grid)
        else:
            self.signprompt.show()
            self.yes.show()
            self.no.show()
            self.okButton.show()
        if hasattr(self, 'Sign'):
            self.Sign.hide()

    def load_ui_signed(self, name):

        if not hasattr(self, 'Sign'):
            self.Sign = QLabel('         电子签名:' + name, self)
            self.Sign.setFont(QFont("Microsoft YaHei", 14, QFont.Bold))
            self.gridsign.addWidget(self.Sign, 2, 0)

            self.gridblank = QGridLayout()
            self.gridblank.setSpacing(1)
            self.blank = QLabel('')
            self.blank.setFixedSize(60, 30)
            self.gridblank.addWidget(self.blank, 0, 2)

            self.grid.addLayout(self.gridblank, 3, 0)
            self.grid.addLayout(self.gridinformation, 0, 0)
            self.grid.addLayout(self.gridinformation2, 1, 0)
            self.grid.addLayout(self.gridsign, 2, 0)
            self.setLayout(self.grid)
        else:
            self.Sign.setText('         电子签名:' + name)
            self.Sign.show()

        if hasattr(self, 'signprompt'):
            self.signprompt.hide()
            self.yes.hide()
            self.no.hide()
            self.okButton.hide()

    def center(self):
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())

    def load_data(self, name):
        self.data = RecordService().get_record_data(name)

    def refresh_data(self, user_id):
        if self.data is None:
            return False
        self.record_id = self.data.get('id')
        self.user_id = user_id
        self.name.setText('  姓名: ' + self.data.get('name'))
        self.company.setText('工作单位: ' + self.data.get('company'))
        self.gender.setText('  性别: ' + self.data.get('gender'))
        self.age.setText('  年龄: ' + self.data.get('age'))
        self.address.setText('住       址: ' + self.data.get('address'))
        self.department.setText('科       室: ' + self.data.get('department'))
        self.nation.setText('  民族: ' + self.data.get('nation'))
        self.date.setText('日       期: ' + self.data.get('date'))
        self.symptom.setText('症       状: ' + self.data.get('symptom'))
        self.conclusion.setText('病情结论: ' + self.data.get('conclusion'))
        if self.data.get('sign') is None:
            self.load_ui_not_signed()
        else:
            self.load_ui_signed(self.data.get('sign'))
        return True

    def on_sign_button_clicked(self):
        if self.yes.isChecked():
            ret, message = SignService().sign(self.user_id, self.record_id)
            QMessageBox.information(self, "警告", message, QMessageBox.Yes)
            if ret:
                self.hide()
        else:
            QMessageBox.information(self, "警告", '提交了,然而并没有什么卵用', QMessageBox.Yes)