[PyQt] Text and Image Alignment

Nick Gaens mail at nickgaens.com
Wed Aug 17 11:02:45 BST 2011


Try this method:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtoolbutton.html#setToolButtonStyle
with one of these values:
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qt.html#ToolButtonStyle-enum
.

E.g.:

yourButton = QtGui.QToolButton()
yourButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
yourButton.setText("Some text")
yourButton.setIcon(QtGui.QIcon("./images/someImage.png"))
yourButton.setIconSize(QtCore.QSize(140, 140))
yourButton.clicked.connect(self.onButtonClicked)

On Wed, Aug 17, 2011 at 03:39, uahmed <gleam.uahmed at gmail.com> wrote:

> Hi
>
> Thank you for the reply i search for it
>
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtoolbutton.html
>
> but unfortunately i didnt get any of such method .
>
> On Wed, Aug 17, 2011 at 3:28 AM, Josh Stratton <strattonbrazil at gmail.com>wrote:
>
>> QToolbarButton has a value for putting text underneath, which may be
>> more what you want.
>>
>> On Tue, Aug 16, 2011 at 3:20 PM, uahmed <gleam.uahmed at gmail.com> wrote:
>> > HI
>> >
>> > I want to do alignment in  image and text , i want that image should be
>> on
>> > center top and text should be at the bottom of image . I search for it
>> but
>> > didnt get the  relevant search result . Can you please tell me how to do
>> > that ?
>> >
>> > Chunk of Code for Button Without Text:
>> >
>> >                 button = QtGui.QPushButton(widget)
>> >                 button.setIcon(QtGui.QIcon('default.gif'))
>> >                 button.setIconSize(QtCore.QSize(100,100))
>> >                 button.setGeometry(xval,yval, 130, 130)
>> >                 button.connect(button, QtCore.SIGNAL('clicked()'),
>> > partial(calluser, user_Handle))
>> >
>> > Chunk of Code for Button With Text:
>> >
>> >                 button = QtGui.QPushButton(widget)
>> >                 button.setIcon(QtGui.QIcon('default.gif'))
>> >                 button.setIconSize(QtCore.QSize(100,100))
>> >                 button[text].setText(QtCore.QString(user_Handle))
>> >                 button.setGeometry(xval,yval, 130, 130)
>> >                 button.connect(button, QtCore.SIGNAL('clicked()'),
>> > partial(calluser, user_Handle))
>> >
>> > Thank You
>> >
>> > Ahmed
>> >
>> > _______________________________________________
>> > PyQt mailing list    PyQt at riverbankcomputing.com
>> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>> >
>>
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



-- 
Nick Gaens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110817/4d72d655/attachment-0001.html>


More information about the PyQt mailing list