Skip to content

Using PyQt to Output JSON #171

Discussion options

You must be logged in to vote

Not quite sure what you have in mind, and don't use PyQt, but with PySide a minimal example might look something like this:

from PySide2 import QtWidgets
import json

class MyWidget(QtWidgets.QWidget):
    def __init__(self):
        self.layout = QtWidgets.QVBoxLayout()
        self.setLayout(self.layout)

        self.input = QtWidgets.QLineEdit()
        self.save_button = QtWidgets.QPushButton()
        self.save_button.clicked.connect(self.save)

        self.layout.addWidget(self.input)
        self.layout.addWidget(self.save_button)

    def save(self):
        my_text = self.input.text()
        with open('output_file.json', 'w') as jfile:
            json.dump(my_test, jfile)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jmdelahanty
Comment options

@sneakers-the-rat
Comment options

@jmdelahanty
Comment options

Answer selected by jmdelahanty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants