[PyQt] Button Color

Josh Stratton strattonbrazil at gmail.com
Tue Aug 16 23:35:00 BST 2011


I would assume it should print true if it's focused.  Where are you
calling print?  It might receive focus after you check if it has
focus.  It might receive focus after the window is displayed.  Not
sure, but that's a guess.

On Tue, Aug 16, 2011 at 3:32 PM, uahmed <gleam.uahmed at gmail.com> wrote:
> Hi
>
> Thanks for the reply yes it is like that  When i press tab it moves to next
> button but When i use this command
>
> print close.hasFocus()
>
> It prints False , Does it indicate that it dont have Focus ?
>
> Thank You
>
> On Wed, Aug 17, 2011 at 3:26 AM, Josh Stratton <strattonbrazil at gmail.com>
> wrote:
>>
>> That looks like the default button that has focus if you were to hit
>> "Enter" sending an event to that button.  Like if you were to hit tab,
>> the second button would receive the focus.  You can check if the
>> button has focus by calling hasFocus() or clearing it by calling
>> clearFocus().  That should remove the focus (and coloring) if you
>> don't want it there.
>>
>> On Tue, Aug 16, 2011 at 3:03 PM, uahmed <gleam.uahmed at gmail.com> wrote:
>> > Hi ,
>> >
>> > I am new in Pyqt , i am confuse on one thing whenever i make buttons the
>> > first button color always have reddish layer . I am also attaching the
>> > code
>> > and Screen Shot .
>> >
>> > import sys
>> > from PyQt4 import QtGui, QtCore
>> >
>> > app = QtGui.QApplication(sys.argv)
>> > widget = QtGui.QWidget()
>> >
>> > widget.setGeometry(200, 100, 400, 300)
>> > widget.setWindowTitle('PyQt Application')
>> >
>> > close = QtGui.QPushButton(QtGui.QIcon('default.gif'), 'Close', widget)
>> > close.setGeometry(10, 10, 100, 30)
>> > close1 = QtGui.QPushButton(QtGui.QIcon('default.gif'), 'Close', widget)
>> > close1.setGeometry(10, 50, 100, 30)
>> >
>> > def hello():
>> >     print 'hello everybody'
>> >
>> > widget.connect(close, QtCore.SIGNAL('clicked()'), hello)
>> > widget.connect(close1, QtCore.SIGNAL('clicked()'), hello)
>> >
>> > widget.show()
>> > sys.exit(app.exec_())
>> >
>> > _______________________________________________
>> > PyQt mailing list    PyQt at riverbankcomputing.com
>> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>> >
>
>


More information about the PyQt mailing list