Using PyQt to Output JSON #171
Answered
by
sneakers-the-rat
jmdelahanty
asked this question in
Q&A
-
Hello Autopilots! I was curious about how to best output json files from a GUI. Is there a good spot in the repo here or resources out there you like for making a GUI that outputs json in PyQt5/6? I can't seem to get the callbacks to work right yet... |
Beta Was this translation helpful? Give feedback.
Answered by
sneakers-the-rat
Mar 30, 2022
Replies: 1 comment 3 replies
-
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) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
jmdelahanty
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not quite sure what you have in mind, and don't use PyQt, but with PySide a minimal example might look something like this: