Advertisement
stevennathaniel

PyQT6 : membuat messagebox yes no

Jan 30th, 2021
1,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import sys
  2.  
  3. from PyQt6.QtCore import Qt
  4.  
  5. from PyQt6.QtWidgets import QApplication, QWidget, QMessageBox, QPushButton
  6.  
  7. def tampilkanKotakPesan(self):
  8.  
  9.     kotakPesan = QMessageBox()
  10.  
  11.     kotakPesan.setWindowTitle("Kotak Pesan Pertama")
  12.  
  13.     kotakPesan.setText("Kotak Pesan Berhasil Ditampilkan")
  14.  
  15.     kotakPesan.setStandardButtons(kotakPesan.StandardButtons.Yes | kotakPesan.StandardButtons.No)
  16.  
  17.     kotakPesan.exec()
  18.  
  19.  
  20.  
  21. aplikasi = QApplication(sys.argv)
  22.  
  23. jendela = QWidget()
  24.  
  25. jendela.resize(300,300)
  26.  
  27. jendela.setWindowTitle("Tampilkan Dialog Box")
  28.  
  29.  
  30. # Membuat tombol
  31.  
  32. tombol1 = QPushButton(jendela)
  33.  
  34. tombol1.setText("Tampilkan Window Dialog")
  35.  
  36. tombol1.move(50,50)
  37.  
  38.  
  39. # tekan tombol
  40.  
  41. tombol1.clicked.connect(tampilkanKotakPesan)
  42.  
  43.  
  44. jendela.show()
  45.  
  46. aplikasi.exec()
  47.  
  48. # Menampilkan Dialog Box Yes dan No, berhasil dengan source code ini
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement