0

i have a code like the one below but when the message box pop ups , the buttons are English (Yes , No) . but the question is that , how can i change it into another language like (Ja , NEIN)

ask = QMessageBox.question(self , "ask" , "example text")

Sina
  • 19
  • 3
  • If you're asking this for localization purposes, then a standard Qt installation should cover about 20 languages (including german) for the basic dialog and buttons created with static functions (including QMessageBox), and will be used as long as the translations of the system locale language are found. If you're trying to set the button texts to *custom* values, that's not possible using the static functions, and you need to construct a QMessageBox instance, then use `addButton()` to add a custom button text, or `button()` to get the existing buttons and change their text. – musicamante Feb 10 '23 at 17:07
  • @musicamante I don't this this is the answer I'm looking for . I import QTWidget and make that through QTWdiget , I don't creat it myself – Sina Feb 11 '23 at 05:56
  • https://stackoverflow.com/q/35887523 – musicamante Feb 11 '23 at 05:58
  • @musicamante , module 'PyQt5.QtGui' has no attribute 'QMessageBox' – Sina Feb 11 '23 at 06:04
  • 1
    That answer was meant for PyQt4, PyQt5 splitted the QtGui module to QtGui and QtWidgets. All *direcly* related UI classes (including anything that inherits from QtWidget, like QMessageBox, which inherits QDialog) are supposed to be on the QtWidgets module. – musicamante Feb 11 '23 at 06:10

0 Answers0