Advertisement
stevennathaniel

PyQt6 : Memprint Pesan Yes / No Dialog Box

Jan 30th, 2021
1,040
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 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.  
  8. def tampilkanKotakPesan():
  9.  
  10.     kotakPesan = QMessageBox()
  11.  
  12.     kotakPesan.setWindowTitle("Kotak Pesan Kedua")
  13.  
  14.     kotakPesan.setText("Kotak Pesan Berhasil Ditampilkan")
  15.  
  16.     kotakPesan.setStandardButtons(kotakPesan.StandardButtons.Yes | kotakPesan.StandardButtons.No)
  17.  
  18.     x = kotakPesan.exec()
  19.  
  20.     if x == 16384:print("Tombol Yes telah di klik")
  21.  
  22.     if x == 65536:print("Tombol No telah di klik")
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. aplikasi = QApplication(sys.argv)
  31.  
  32. jendela = QWidget()
  33.  
  34. jendela.resize(300,300)
  35.  
  36. jendela.setWindowTitle("Tampilkan Dialog Box")
  37.  
  38.  
  39. # Membuat tombol
  40.  
  41. tombol1 = QPushButton(jendela)
  42.  
  43. tombol1.setText("Tampilkan Window Dialog")
  44.  
  45. tombol1.move(50,50)
  46.  
  47.  
  48. # tekan tombol
  49.  
  50. tombol1.clicked.connect(tampilkanKotakPesan)
  51.  
  52. jendela.show()
  53.  
  54. aplikasi.exec()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement