python - Draw error dialog icon myself in PyQt / PySide -


i trying implement dialog similar error message box additional functionality. draw same bitmap provided system when using qmessagebox.critical in qmessagebox.

in wxpython this:

self.error_bitmap = wx.artprovider.getbitmap(wx.art_error, wx.art_message_box) self.error_bitmap_ctrl = wx.staticbitmap(self) self.error_bitmap_ctrl.setbitmap(self.error_bitmap) 

i looking similar in qt. tried use qstyle.sp_messageboxcritical or qicon.fromtheme("dialog-error"), without success. seems not understand class structure widget able put on window next qlabel.

the various built-in icons used qt can retrieved via qstyle.standardicon method.

the qmessagebox class has method extract pixmap each qmessagebox.icon, it's not part of public api. here's pyqt/pyside port of it:

def messageboxicon(mbicon, widget=none):     if widget not none:         style = widget.style()     else:         style = qtgui.qapplication.style()     size = style.pixelmetric(         qtgui.qstyle.pm_messageboxiconsize, none, widget)     if mbicon == qtgui.qmessagebox.information:         icon = style.standardicon(             qtgui.qstyle.sp_messageboxinformation, none, widget)     elif mbicon == qtgui.qmessagebox.warning:         icon = style.standardicon(             qtgui.qstyle.sp_messageboxwarning, none, widget)     elif mbicon == qtgui.qmessagebox.critical:         icon = style.standardicon(             qtgui.qstyle.sp_messageboxcritical, none, widget)     elif mbicon == qtgui.qmessagebox.question:         icon = style.standardicon(             qtgui.qstyle.sp_messageboxquestion, none, widget)     else:         icon = qtgui.qicon()     if not icon.isnull():         return icon.pixmap(size, size)     return qtgui.qpixmap() 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -