Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pyqt5 message box

# in pyqt5 it needs to be PyQt5.QtWidgets
msg=QMessageBox() # create an instance of it
msg.setIcon(QMessageBox.Information) # set icon
msg.setText("This is a message box") # set text
msg.setInformativeText("This is additional information") # set information under the main text
msg.setWindowTitle("MessageBox demo") # set title
msg.setDetailedText("The details are as follows:") # a button for more details will add in
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) # type of buttons associated
msg.buttonClicked.connect(myfunc) # connect clicked signal
return_value =msg.exec_() # get the return value
print("value of pressed message box button:", str(return_value)) # print result
Comment

python - How to display a message box on PyQT4?

from PyQt4.QtCore import *
from PyQt4.QtGui import *


class AppForm(QMainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.create_main_frame()       

    def create_main_frame(self):        
        page = QWidget()        

        self.button = QPushButton('joy', page)
        self.edit1 = QLineEdit()
        self.edit2 = QLineEdit()

        vbox1 = QVBoxLayout()
        vbox1.addWidget(self.edit1)
        vbox1.addWidget(self.edit2)
        vbox1.addWidget(self.button)
        page.setLayout(vbox1)
        self.setCentralWidget(page)

        self.connect(self.button, SIGNAL("clicked()"), self.clicked)

    def clicked(self):
        QMessageBox.about(self, "My message box", "Text1 = %s, Text2 = %s" % (
            self.edit1.text(), self.edit2.text()))



if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    form = AppForm()
    form.show()
    app.exec_()
Comment

pyqt5 message box

msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText("This is a message box")
msg.setInformativeText("This is additional information")
msg.setWindowTitle("MessageBox demo")
msg.setDetailedText("The details are as follows:")
Comment

pyqt5 message box

msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
Comment

pyqt5 message box

msg.buttonClicked.connect(msgbtn)
Comment

PREVIOUS NEXT
Code Example
Python :: python requests force ipv4 
Python :: django rest framework delete file 
Python :: rotate x labels in plots, matplotlib 
Python :: replace column values pandas 
Python :: python tkinter text widget 
Python :: python date + days 
Python :: python how to obfuscate code 
Python :: convert categorical variable to numeric python 
Python :: python make button do more than one command 
Python :: python check if string starting with substring from list ltrim python 
Python :: how to import PyMem python 
Python :: python spearman correlation 
Python :: remove 0 values from dataframe 
Python :: factors addition in pyhone 
Python :: pandas replace empty string with nan 
Python :: how to plotting points on matplotlib 
Python :: pyqt text in widget frame 
Python :: splittext py 
Python :: python encrypt password 
Python :: how to factorise an expression in python 
Python :: python number of elements in multidimensional array 
Python :: bulk file name changer in python 
Python :: how to remove data from mongo db python 
Python :: python multiply all elements in array by constant 
Python :: python write to text file with new line 
Python :: frequency of occurrence of that element in the list and the positions 
Python :: revesing case python 
Python :: all permutations python 
Python :: python subtract 2 strings 
Python :: how to clear a text file in python 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =