Guest User

Untitled

a guest
Oct 21st, 2019
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PyQt5.QtWidgets import QApplication, QWidget, QPlainTextEdit, QInputDialog,QLineEdit, QFileDialog, QGridLayout, QGroupBox, QLabel,QMessageBox, QPushButton
  2. from PyQt5.QtGui import QIcon, QPixmap
  3.  
  4. def on_open_button_clicked():
  5. options = QFileDialog.Options()
  6. options |= QFileDialog.DontUseNativeDialog
  7. openFilePath, _ = QFileDialog.getOpenFileName(widget,"Wybierz plik obrazu", "","Text Files (*.txt)", options=options)
  8. if openFilePath:
  9. s = open(openFilePath, 'r').read()
  10. editArea.setPlainText(s)
  11.  
  12.  
  13. def on_save_button_clicked():
  14. text = editArea.toPlainText()
  15. saveFilePath, _ = QFileDialog.getSaveFileName(None, "tytul", "name", None, None)
  16. if saveFilePath:
  17. print(saveFilePath)
  18. file = open(saveFilePath, "w")
  19. file.write(text)
  20. file.close()
  21.  
  22.  
  23.  
  24. app = QApplication([])
  25. horizontalGroupBox = QGroupBox("Nazwa grupy")
  26. layout = QGridLayout()
  27. widget = QWidget()
  28. widget.setWindowTitle("Title!!")
  29. openButton = QPushButton('Otworz plik')
  30. openButton.clicked.connect(on_open_button_clicked)
  31. saveButton = QPushButton('Zapisz plik')
  32. saveButton.clicked.connect(on_save_button_clicked)
  33. layout.addWidget(openButton)
  34. layout.addWidget(saveButton)
  35. editArea = QPlainTextEdit(widget)
  36. layout.addWidget(editArea)
  37.  
  38.  
  39. horizontalGroupBox.setLayout(layout)
  40. horizontalGroupBox.show()
  41. app.exec_()
RAW Paste Data