If you are using your own custom status bar in a widget, then you have to
connect focus or hover events to something that sets the message on the
status bar. You can set the setStatusTip("") on each widget and then just
read that.
When you use a QMainWindow, the status bar is already wired up for you so
that any time you hover a widget, the statusBar will automatically read the
widgets statusTip():
app = QtGui.QApplication([])
w = QtGui.QMainWindow()
button = QtGui.QPushButton("clicky", w)
button.setStatusTip("I am a clicky")
w.setCentralWidget(button)
status = w.statusBar()
w.show()
w.raise_()
status.showMessage("Welcome to the app!", 5000)
app.exec_()
For the file dialog, the way you are using it, there is a convenience
static method you can call:
http://qt-project.org/doc/qt-4.8/qfiledialog.html#getExistingDirectory
It will return an empty string if they cancel:
directory=os.path.expanduser('~')
selectedDir = QtGui.QFileDialog.getExistingDirectory(w,
"Select Render Directory", directory)
if selectedDir.isEmpty():
print "No directory selected"
else:
print selectedDir
On Fri, Dec 7, 2012 at 9:56 AM, Kurian O.S <[email protected]> wrote:
> For Directory you want to use exec so you need to change your code like
> this
>
> def showDirDialog(self):
> directory=os.path.expanduser('~')
> dirPath=QtGui.QFileDialog(self,"Select Render Directory",
> directory)
> dirPath.setFileMode(QtGui.QFileDialog.DirectoryOnly)
> if dirPath.exec_() == 1:
> fname_list = str(dirPath.selectedFiles()[0])
> print fname_list
>
> For changing the statusBar text you need to implement focusIn and out
> Event and Justin already mention about that in reimplement QPlainText’s
> focusInEvent in another source file ,how to ? thread.
>
>
> On Fri, Dec 7, 2012 at 6:25 AM, san <[email protected]> wrote:
>
>> as a part of my learning PyQt4 I started making a gui(see attachment)
>> where I implement all the examples I learn from video tuts or book I am
>> referring,
>>
>> however I count figure out how should I implement the method to show text
>> message on the status bar when user hover mouse over a widget[link to
>> pastebin
>> <http://pastebin.com/9gfYaWRV>]
>>
>> and secondly I dont understand how come this method to select Directory
>> is not working?
>>
>> def showDirDialog(self):
>> directory=os.path.expanduser('~')
>> dirPath=QtGui.QFileDialog(self,"Select Render Directory",
>> directory)
>> dirPath.setFileMode(QtGui.QFileDialog.DirectoryOnly)
>>
>> --
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings:
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>
>
>
> --
> --:: Kurian ::--
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe