예제 #1
0
    def __init__(self, parent=None):
        super(FormExtractor, self).__init__(parent)

        self.ui = Ui_Form()
        self.ui.setupUi(self)

        webView = self.ui.webView
        webView.setUrl(QUrl('qrc:/form.html'))
        webView.page().mainFrame().javaScriptWindowObjectCleared.connect(
                self.populateJavaScriptWindowObject)

        self.resize(300, 300)
예제 #2
0
class FormExtractor(QWidget):
    def __init__(self, parent=None):
        super(FormExtractor, self).__init__(parent)

        self.ui = Ui_Form()
        self.ui.setupUi(self)

        webView = self.ui.webView
        webView.setUrl(QUrl('qrc:/form.html'))
        webView.page().mainFrame().javaScriptWindowObjectCleared.connect(
            self.populateJavaScriptWindowObject)

        self.resize(300, 300)

    @pyqtSlot()
    def submit(self):
        frame = self.ui.webView.page().mainFrame()
        firstName = frame.findFirstElement('#firstname')
        lastName = frame.findFirstElement('#lastname')
        maleGender = frame.findFirstElement('#genderMale')
        femaleGender = frame.findFirstElement('#genderFemale')
        updates = frame.findFirstElement('#updates')

        self.ui.firstNameEdit.setText(
            firstName.evaluateJavaScript('this.value'))
        self.ui.lastNameEdit.setText(lastName.evaluateJavaScript('this.value'))

        if maleGender.evaluateJavaScript('this.checked'):
            self.ui.genderEdit.setText(
                maleGender.evaluateJavaScript('this.value'))
        elif femaleGender.evaluateJavaScript('this.checked'):
            self.ui.genderEdit.setText(
                femaleGender.evaluateJavaScript('this.value'))

        if updates.evaluateJavaScript('this.checked'):
            self.ui.updatesEdit.setText("Yes")
        else:
            self.ui.updatesEdit.setText("No")

    def populateJavaScriptWindowObject(self):
        self.ui.webView.page().mainFrame().addToJavaScriptWindowObject(
            'formExtractor', self)
예제 #3
0
class FormExtractor(QWidget):
    def __init__(self, parent=None):
        super(FormExtractor, self).__init__(parent)

        self.ui = Ui_Form()
        self.ui.setupUi(self)

        webView = self.ui.webView
        webView.setUrl(QUrl('qrc:/form.html'))
        webView.page().mainFrame().javaScriptWindowObjectCleared.connect(
                self.populateJavaScriptWindowObject)

        self.resize(300, 300)
 
    @pyqtSlot()
    def submit(self):
        frame = self.ui.webView.page().mainFrame()
        firstName = frame.findFirstElement('#firstname')
        lastName = frame.findFirstElement('#lastname')
        maleGender = frame.findFirstElement('#genderMale')
        femaleGender = frame.findFirstElement('#genderFemale')
        updates = frame.findFirstElement('#updates')

        self.ui.firstNameEdit.setText(firstName.evaluateJavaScript('this.value'))
        self.ui.lastNameEdit.setText(lastName.evaluateJavaScript('this.value'))

        if maleGender.evaluateJavaScript('this.checked'):
            self.ui.genderEdit.setText(
                    maleGender.evaluateJavaScript('this.value'))
        elif femaleGender.evaluateJavaScript('this.checked'):
            self.ui.genderEdit.setText(
                    femaleGender.evaluateJavaScript('this.value'))

        if updates.evaluateJavaScript('this.checked'):
            self.ui.updatesEdit.setText("Yes")
        else:
            self.ui.updatesEdit.setText("No")

    def populateJavaScriptWindowObject(self):
        self.ui.webView.page().mainFrame().addToJavaScriptWindowObject(
                'formExtractor', self)