Jul-07-2022, 07:00 AM
Hi All,
I am working on QWidget part where I wanted to browse a file and upload the file data on widget window (that should be editable too). It is a yaml file (consists of dictionary). Same widget should also have the 'submit' button. I have written a code where I able to browse the file and read the data, however am printing it on console, instead I wanted to display it on another widget/window, once it is displayed on the widget, it should allow to modify the data and have the submit button to click as well. when submit button clicked it should connect to remote system and execute the predefined script and result of that script should display it back on the same widget as an output as well.
This is my code, I know it is not complete yet
Regards,
maiya
I am working on QWidget part where I wanted to browse a file and upload the file data on widget window (that should be editable too). It is a yaml file (consists of dictionary). Same widget should also have the 'submit' button. I have written a code where I able to browse the file and read the data, however am printing it on console, instead I wanted to display it on another widget/window, once it is displayed on the widget, it should allow to modify the data and have the submit button to click as well. when submit button clicked it should connect to remote system and execute the predefined script and result of that script should display it back on the same widget as an output as well.
This is my code, I know it is not complete yet
from PyQt5 import QtGui, QtCore, QtWidgets import os, sys ''' class YMLWidget(QtWidgets.QWidget): def __init__(self) -> None: super().__init__() self.setWindowTitle('YML Display Widget') self.setFixedWidth(500) mainLayout = QtWidgets.QVBoxLayout() ''' class MyWidget(QtWidgets.QWidget): def __init__(self): super(MyWidget, self).__init__() self.initUI() def initUI(self): self.setGeometry(600, 300, 450, 300) self.setWindowTitle('YAML Uploader Button') button = QtWidgets.QPushButton('upload a yaml', self) button.resize(button.sizeHint()) button.clicked.connect(self.YamlUpload) button.move(150, 150) self.show() def YamlUpload(self): filePath, _ = QtWidgets.QFileDialog.getOpenFileName(self, 'Single File', r'C:\Users\maiya\Desktop\compare', '*.yml') with open(filePath, 'r', encoding='mbcs') as file_pointer: self.lines = file_pointer.readlines() def main(): app = QtWidgets.QApplication(sys.argv) widget = MyWidget() app.exec_() if __name__ == '__main__': main()Any help on this would really appreciated, thanks a lot
Regards,
maiya