Re: [PyQt] QDirmodel - Removing a directory and it's descendents..

2010-01-17 Thread detlev
Hi,

how about using a QSortFilterProxy model to filter the excluded ones?

Detlev

On Samstag, 16. Januar 2010, Jebagnana Das wrote:
> Hello all,
> Greetings.. After a spending a long time for googling i found the
> way to list the contents of a particular directory. Thanks to QDirModel.
> 
>My aim here is to allow the user to exclude specific directories
> within the chosen directory.. After adding a particular directory to the
> exclusion list(on the right side)the selected directory and it's
>  descendents should be removed(or hidden)from the tree view so that the
>  user is not allowed to select the same folder again..
> 
>   Given here the minimal example needed for my app.. In this example
> when the user presses add to exclude list push button the folder is added
>  to the exclude folders listwidget..
> 
> from PyQt4 import QtCore, QtGui
> 
> class Ui_Dialog(QtGui.QDialog):
> 
> def __init__(self,parent=None):
> QtGui.QDialog.__init__(self,parent)
> self.resize(600, 500)
> 
> self.model = QtGui.QDirModel()
> self.tree = QtGui.QTreeView(self)
> self.tree.setModel(self.model)
> self.model.setFilter(QtCore.QDir.Dirs|QtCore.QDir.NoDotAndDotDot)
> self.tree.setSortingEnabled(True)
> 
> self.tree.setRootIndex(self.model.index("/home/jebagnanadasa/Python-3.1.1")
> )
> 
> self.tree.hideColumn(1)
> self.tree.setWindowTitle("Dir View")
> self.tree.resize(400, 480)
> self.tree.setColumnWidth(0,150)
> self.tree.show()
> 
> self.pushButton = QtGui.QPushButton(self)
> self.pushButton.setGeometry(QtCore.QRect(420, 30, 151, 28))
> self.listWidget = QtGui.QListWidget(self)
> self.listWidget.setGeometry(QtCore.QRect(410, 80, 171, 231))
> 
> QtCore.QObject.connect(self.tree,
> QtCore.SIGNAL("clicked(QModelIndex)"), self.test)
> 
> QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL('clicked()'),self.addT
> oList) QtCore.QMetaObject.connectSlotsByName(self)
> 
> self.setWindowTitle(QtGui.QApplication.translate("Dialog",
>  "Dialog", None, QtGui.QApplication.UnicodeUTF8))
> self.pushButton.setText(QtGui.QApplication.translate("Dialog", "Add
> to Exclude List", None, QtGui.QApplication.UnicodeUTF8))
> 
> def test(self,index):
> 
> if self.model.data(index.parent())=="jebagnanadasa":
> self.selectedDirectoryPath=self.model.data(index)
> print(self.selectedDirectoryPath)
> else:
> dirHierarchy=[]
> dirHierarchy.insert(0,self.model.data(index))
> while (self.model.data(index.parent())!="jebagnanadasa"):
> index=index.parent()
> dirHierarchy.insert(0,self.model.data(index))
> self.selectedDirectoryPath="/".join(dirHierarchy)
> print(self.selectedDirectoryPath)
> 
> #self.model.removeRow(0,index)
> 
> def addToList(self):
> self.listWidget.addItem(self.selectedDirectoryPath)
> 
> 
> if __name__ == "__main__":
> import sys
> app = QtGui.QApplication(sys.argv)
> ui = Ui_Dialog()
> ui.show()
> sys.exit(app.exec_())
> 
> See the screenshot also..
> 
> [image:
> ?ui=2&view=att&th=12637fd44b798078&attid=0.1&disp=attd&realattid=ii_12637fd
> 44b798078&zw]
> 
> Is there a way that i can make the excluded directories to be ignored when
> displaying the contents of the directory on consecutive startup(since it
>  was already on the exclusion list)?
> 
> Any help would be much appreciated.. Thanks..
> 
> P.S: remove() and rmdir() is not recommended since it deletes the
> directories entirely from the file System!
> 


-- 
Detlev Offenbach
det...@die-offenbachs.de
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Segmentation fault

2010-01-17 Thread hao yin
Hello,

I've wrote a program in pyqt4, that should redirect the output of another
program to a QTextEdit. Sometime the program crashes as soon as I start a
thread executing the second program with subprocess.Popen().
I used gdb:
(gdb) run TestThread.py
Starting program: /usr/bin/python TestThread.py
[Thread debugging using libthread_db enabled]
[New Thread 0xb7f036c0 (LWP 5001)]
[New Thread 0xb5a69b90 (LWP 5003)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7f036c0 (LWP 5001)]
0xb6be8802 in ?? () from /usr/lib/libQtGui.so.4

(gdb) bt
#0  0xb6be8802 in ?? () from /usr/lib/libQtGui.so.4
#1  0xb6be12a5 in ?? () from /usr/lib/libQtGui.so.4
#2  0xb6be1b32 in QTextEngine::itemize () from /usr/lib/libQtGui.so.4
#3  0xb6be93c8 in QTextLayout::beginLayout () from /usr/lib/libQtGui.so.4
#4  0xb6c296eb in ?? () from /usr/lib/libQtGui.so.4
#5  0xb6c3039f in ?? () from /usr/lib/libQtGui.so.4
#6  0xb6c2ec7a in ?? () from /usr/lib/libQtGui.so.4
#7  0xb6c2f186 in ?? () from /usr/lib/libQtGui.so.4
#8  0xb6c3166c in ?? () from /usr/lib/libQtGui.so.4
#9  0xb6c31710 in ?? () from /usr/lib/libQtGui.so.4
#10 0xb6c31902 in ?? () from /usr/lib/libQtGui.so.4
#11 0xb6c31d41 in ?? () from /usr/lib/libQtGui.so.4
#12 0xb6bfede5 in QTextDocument::setPageSize () from /usr/lib/libQtGui.so.4
#13 0xb6e39523 in ?? () from /usr/lib/libQtGui.so.4
#14 0xb6e39d92 in QTextEdit::resizeEvent () from /usr/lib/libQtGui.so.4
#15 0xb73dfe3b in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#16 0xb69d8956 in QWidget::event () from /usr/lib/libQtGui.so.4
#17 0xb6db2993 in QFrame::event () from /usr/lib/libQtGui.so.4
#18 0xb6e5294f in QAbstractScrollArea::viewportEvent ()
   from /usr/lib/libQtGui.so.4
#19 0xb73dd2fc in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#20 0xb6e54f55 in ?? () from /usr/lib/libQtGui.so.4
#21 0xb7bcdc5a in QCoreApplicationPrivate::sendThroughObjectEventFilters ()
---Type  to continue, or q  to quit---
   from /usr/lib/libQtCore.so.4
#22 0xb6981e7a in QApplicationPrivate::notify_helper ()
   from /usr/lib/libQtGui.so.4
#23 0xb698a282 in QApplication::notify () from /usr/lib/libQtGui.so.4
#24 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#25 0xb7bcea3b in QCoreApplication::notifyInternal ()
   from /usr/lib/libQtCore.so.4
#26 0xb6a181b6 in QWidgetPrivate::setGeometry_sys ()
   from /usr/lib/libQtGui.so.4
#27 0xb69d7788 in QWidget::setGeometry () from /usr/lib/libQtGui.so.4
#28 0xb6e52f08 in QAbstractScrollAreaPrivate::layoutChildren ()
   from /usr/lib/libQtGui.so.4
#29 0xb6e5363e in QAbstractScrollArea::event () from /usr/lib/libQtGui.so.4
#30 0xb6e3cd0e in QTextEdit::event () from /usr/lib/libQtGui.so.4
#31 0xb73def2d in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#32 0xb6981e9c in QApplicationPrivate::notify_helper ()
   from /usr/lib/libQtGui.so.4
#33 0xb698a282 in QApplication::notify () from /usr/lib/libQtGui.so.4
#34 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#35 0xb7bcea3b in QCoreApplication::notifyInternal ()
   from /usr/lib/libQtCore.so.4
#36 0xb69d7540 in QWidget::setContentsMargins () from /usr/lib/libQtGui.so.4
#37 0xb6db268c in QFrame::setFrameRect () from /usr/lib/libQtGui.so.4
---Type  to continue, or q  to quit---
#38 0xb6e532ee in QAbstractScrollAreaPrivate::layoutChildren ()
   from /usr/lib/libQtGui.so.4
#39 0xb6e533bd in QAbstractScrollAreaPrivate::_q_showOrHideScrollBars ()
   from /usr/lib/libQtGui.so.4
#40 0xb6e399d5 in ?? () from /usr/lib/libQtGui.so.4
#41 0xb6e3b61f in QTextEdit::qt_metacall () from /usr/lib/libQtGui.so.4
#42 0xb73e0020 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#43 0xb7be4ca8 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#44 0xb7be5932 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#45 0xb6bce7a3 in QTextControl::documentSizeChanged ()
   from /usr/lib/libQtGui.so.4
#46 0xb6bd5547 in QTextControl::qt_metacall () from /usr/lib/libQtGui.so.4
#47 0xb7bdd8fb in QMetaCallEvent::placeMetaCall () from
/usr/lib/libQtCore.so.4
#48 0xb7bdf3a0 in QObject::event () from /usr/lib/libQtCore.so.4
#49 0xb6bce514 in QTextControl::event () from /usr/lib/libQtGui.so.4
#50 0xb6981e9c in QApplicationPrivate::notify_helper ()
   from /usr/lib/libQtGui.so.4
#51 0xb698a19e in QApplication::notify () from /usr/lib/libQtGui.so.4
#52 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#53 0xb7bcea3b in QCoreApplication::notifyInternal ()
   from /usr/lib/libQtCore.so.4
#54 0xb7bcf695 in QCoreApplicationPrivate::sendPostedEvents ()
   from /usr/lib/libQtCore.so.4
---Type  to continue, or q  to quit---
#55 0xb7bcf88d in QCoreApplication::sendPostedEvents ()
   from /usr/lib/libQtCore.so.4
#56 0xb7bfa7ef in ?? () from /usr/lib/libQtCore.so.4
#57 0xb78f8b88 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#58 0xb78fc0eb in ?? () from /usr/lib/libglib-2.0.so.0
#59 0xb78fc268 in g_main_context_iteration () from /usr/

Re: [PyQt] Segmentation fault

2010-01-17 Thread hao yin
Hello,

I've wrote a program in pyqt4, that should redirect the output of another
program to a QTextEdit. Sometime the program crashes as soon as I start a
thread executing the second program with subprocess.Popen().
I used gdb:
(gdb) run TestThread.py
Starting program: /usr/bin/python TestThread.py
[Thread debugging using libthread_db enabled]
[New Thread 0xb7f036c0 (LWP 5001)]
[New Thread 0xb5a69b90 (LWP 5003)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7f036c0 (LWP 5001)]
0xb6be8802 in ?? () from /usr/lib/libQtGui.so.4

(gdb) bt
#0  0xb6be8802 in ?? () from /usr/lib/libQtGui.so.4
#1  0xb6be12a5 in ?? () from /usr/lib/libQtGui.so.4
#2  0xb6be1b32 in QTextEngine::itemize () from /usr/lib/libQtGui.so.4
#3  0xb6be93c8 in QTextLayout::beginLayout () from /usr/lib/libQtGui.so.4
#4  0xb6c296eb in ?? () from /usr/lib/libQtGui.so.4
#5  0xb6c3039f in ?? () from /usr/lib/libQtGui.so.4
#6  0xb6c2ec7a in ?? () from /usr/lib/libQtGui.so.4
#7  0xb6c2f186 in ?? () from /usr/lib/libQtGui.so.4
#8  0xb6c3166c in ?? () from /usr/lib/libQtGui.so.4
#9  0xb6c31710 in ?? () from /usr/lib/libQtGui.so.4
#10 0xb6c31902 in ?? () from /usr/lib/libQtGui.so.4
#11 0xb6c31d41 in ?? () from /usr/lib/libQtGui.so.4
#12 0xb6bfede5 in QTextDocument::setPageSize () from /usr/lib/libQtGui.so.4
#13 0xb6e39523 in ?? () from /usr/lib/libQtGui.so.4
#14 0xb6e39d92 in QTextEdit::resizeEvent () from /usr/lib/libQtGui.so.4
#15 0xb73dfe3b in ?? () from /usr/lib/python2.6/dist-
packages/PyQt4/QtGui.so
#16 0xb69d8956 in QWidget::event () from /usr/lib/libQtGui.so.4
#17 0xb6db2993 in QFrame::event () from /usr/lib/libQtGui.so.4
#18 0xb6e5294f in QAbstractScrollArea::viewportEvent ()
   from /usr/lib/libQtGui.so.4
#19 0xb73dd2fc in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#20 0xb6e54f55 in ?? () from /usr/lib/libQtGui.so.4
#21 0xb7bcdc5a in QCoreApplicationPrivate::sendThroughObjectEventFilters ()
---Type  to continue, or q  to quit---
   from /usr/lib/libQtCore.so.4
#22 0xb6981e7a in QApplicationPrivate::notify_helper ()
   from /usr/lib/libQtGui.so.4
#23 0xb698a282 in QApplication::notify () from /usr/lib/libQtGui.so.4
#24 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#25 0xb7bcea3b in QCoreApplication::notifyInternal ()
   from /usr/lib/libQtCore.so.4
#26 0xb6a181b6 in QWidgetPrivate::setGeometry_sys ()
   from /usr/lib/libQtGui.so.4
#27 0xb69d7788 in QWidget::setGeometry () from /usr/lib/libQtGui.so.4
#28 0xb6e52f08 in QAbstractScrollAreaPrivate::layoutChildren ()
   from /usr/lib/libQtGui.so.4
#29 0xb6e5363e in QAbstractScrollArea::event () from /usr/lib/libQtGui.so.4
#30 0xb6e3cd0e in QTextEdit::event () from /usr/lib/libQtGui.so.4
#31 0xb73def2d in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#32 0xb6981e9c in QApplicationPrivate::notify_helper ()
   from /usr/lib/libQtGui.so.4
#33 0xb698a282 in QApplication::notify () from /usr/lib/libQtGui.so.4
#34 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#35 0xb7bcea3b in QCoreApplication::notifyInternal ()
   from /usr/lib/libQtCore.so.4
#36 0xb69d7540 in QWidget::setContentsMargins () from /usr/lib/libQtGui.so.4
#37 0xb6db268c in QFrame::setFrameRect () from /usr/lib/libQtGui.so.4
---Type  to continue, or q  to quit---
#38 0xb6e532ee in QAbstractScrollAreaPrivate::layoutChildren ()
   from /usr/lib/libQtGui.so.4
#39 0xb6e533bd in QAbstractScrollAreaPrivate::_q_showOrHideScrollBars ()
   from /usr/lib/libQtGui.so.4
#40 0xb6e399d5 in ?? () from /usr/lib/libQtGui.so.4
#41 0xb6e3b61f in QTextEdit::qt_metacall () from /usr/lib/libQtGui.so.4
#42 0xb73e0020 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#43 0xb7be4ca8 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#44 0xb7be5932 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#45 0xb6bce7a3 in QTextControl::documentSizeChanged ()
   from /usr/lib/libQtGui.so.4
#46 0xb6bd5547 in QTextControl::qt_metacall () from /usr/lib/libQtGui.so.4
#47 0xb7bdd8fb in QMetaCallEvent::placeMetaCall () from
/usr/lib/libQtCore.so.4
#48 0xb7bdf3a0 in QObject::event () from /usr/lib/libQtCore.so.4
#49 0xb6bce514 in QTextControl::event () from /usr/lib/libQtGui.so.4
#50 0xb6981e9c in QApplicationPrivate::notify_helper ()
   from /usr/lib/libQtGui.so.4
#51 0xb698a19e in QApplication::notify () from /usr/lib/libQtGui.so.4
#52 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#53 0xb7bcea3b in QCoreApplication::notifyInternal ()
   from /usr/lib/libQtCore.so.4
#54 0xb7bcf695 in QCoreApplicationPrivate::sendPostedEvents ()
   from /usr/lib/libQtCore.so.4
---Type  to continue, or q  to quit---
#55 0xb7bcf88d in QCoreApplication::sendPostedEvents ()
   from /usr/lib/libQtCore.so.4
#56 0xb7bfa7ef in ?? () from /usr/lib/libQtCore.so.4
#57 0xb78f8b88 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#58 0xb78fc0eb in ?? () from /usr/lib/libglib-2.0.so.0
#59 0xb78fc268 in g_main_context_iteration () from /usr

Re: [PyQt] QDirmodel - Removing a directory and it's descendents..

2010-01-17 Thread Jebagnana Das
Thanks detlev for your suggestion.. Could you please give me any example
code snippet?. Bcoz. i'm totally new to model/view programming and pyqt.

On Sun, Jan 17, 2010 at 5:03 PM, detlev  wrote:

> Hi,
>
> how about using a QSortFilterProxy model to filter the excluded ones?
>
> Detlev
>
> On Samstag, 16. Januar 2010, Jebagnana Das wrote:
> > Hello all,
> > Greetings.. After a spending a long time for googling i found the
> > way to list the contents of a particular directory. Thanks to QDirModel.
> >
> >My aim here is to allow the user to exclude specific directories
> > within the chosen directory.. After adding a particular directory to the
> > exclusion list(on the right side)the selected directory and it's
> >  descendents should be removed(or hidden)from the tree view so that the
> >  user is not allowed to select the same folder again..
> >
> >   Given here the minimal example needed for my app.. In this example
> > when the user presses add to exclude list push button the folder is added
> >  to the exclude folders listwidget..
> >
> > from PyQt4 import QtCore, QtGui
> >
> > class Ui_Dialog(QtGui.QDialog):
> >
> > def __init__(self,parent=None):
> > QtGui.QDialog.__init__(self,parent)
> > self.resize(600, 500)
> >
> > self.model = QtGui.QDirModel()
> > self.tree = QtGui.QTreeView(self)
> > self.tree.setModel(self.model)
> > self.model.setFilter(QtCore.QDir.Dirs|QtCore.QDir.NoDotAndDotDot)
> > self.tree.setSortingEnabled(True)
> >
> >
> self.tree.setRootIndex(self.model.index("/home/jebagnanadasa/Python-3.1.1")
> > )
> >
> > self.tree.hideColumn(1)
> > self.tree.setWindowTitle("Dir View")
> > self.tree.resize(400, 480)
> > self.tree.setColumnWidth(0,150)
> > self.tree.show()
> >
> > self.pushButton = QtGui.QPushButton(self)
> > self.pushButton.setGeometry(QtCore.QRect(420, 30, 151, 28))
> > self.listWidget = QtGui.QListWidget(self)
> > self.listWidget.setGeometry(QtCore.QRect(410, 80, 171, 231))
> >
> > QtCore.QObject.connect(self.tree,
> > QtCore.SIGNAL("clicked(QModelIndex)"), self.test)
> >
> >
> QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL('clicked()'),self.addT
> > oList) QtCore.QMetaObject.connectSlotsByName(self)
> >
> > self.setWindowTitle(QtGui.QApplication.translate("Dialog",
> >  "Dialog", None, QtGui.QApplication.UnicodeUTF8))
> > self.pushButton.setText(QtGui.QApplication.translate("Dialog",
> "Add
> > to Exclude List", None, QtGui.QApplication.UnicodeUTF8))
> >
> > def test(self,index):
> >
> > if self.model.data(index.parent())=="jebagnanadasa":
> > self.selectedDirectoryPath=self.model.data(index)
> > print(self.selectedDirectoryPath)
> > else:
> > dirHierarchy=[]
> > dirHierarchy.insert(0,self.model.data(index))
> > while (self.model.data(index.parent())!="jebagnanadasa"):
> > index=index.parent()
> > dirHierarchy.insert(0,self.model.data(index))
> > self.selectedDirectoryPath="/".join(dirHierarchy)
> > print(self.selectedDirectoryPath)
> >
> > #self.model.removeRow(0,index)
> >
> > def addToList(self):
> > self.listWidget.addItem(self.selectedDirectoryPath)
> >
> >
> > if __name__ == "__main__":
> > import sys
> > app = QtGui.QApplication(sys.argv)
> > ui = Ui_Dialog()
> > ui.show()
> > sys.exit(app.exec_())
> >
> > See the screenshot also..
> >
> > [image:
> >
> ?ui=2&view=att&th=12637fd44b798078&attid=0.1&disp=attd&realattid=ii_12637fd
> > 44b798078&zw]
> >
> > Is there a way that i can make the excluded directories to be ignored
> when
> > displaying the contents of the directory on consecutive startup(since it
> >  was already on the exclusion list)?
> >
> > Any help would be much appreciated.. Thanks..
> >
> > P.S: remove() and rmdir() is not recommended since it deletes the
> > directories entirely from the file System!
> >
>
>
> --
> Detlev Offenbach
> det...@die-offenbachs.de
>
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Segmentation fault

2010-01-17 Thread Matt Smith
Hao

I don't get a segmentation fault, I get a different error:
QObject::connect: Cannot queue arguments of type 'QTextCursor'
(Make sure 'QTextCursor' is registered using qRegisterMetaType().)

  But I would suggest using a QThread instead of a Threading.thread, and
then you can connect them with signals.  I would guess that you are
getting your error from the:

self.box.append(line)

Try to do all of your gui work on the main thread. So try to emit a
signal, connect that signal to a slot on your main class and update the
text box there.  I have changed the example you sent to do that and I
don't get any errors.



import time, sys, os, subprocess, select, threading
from PyQt4 import QtCore, QtGui

class TestGUI(QtGui.QWidget):
  def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.Widgets()
self.Connections()

  def Widgets(self):
self.txtBox = QtGui.QTextEdit()
self.btnStart = QtGui.QPushButton("Start Thread")
self.txtBox.setReadOnly(True)

hb = QtGui.QHBoxLayout()
hb.addWidget(self.txtBox)
hb.addWidget(self.btnStart)

self.setLayout(hb)

  def Connections(self):
self.connect(self.btnStart, QtCore.SIGNAL("clicked()"),
self.startThread)

  def startThread(self):
self.thread = TestThread(self, cmd = ["ls", "/home/hao"], box =
self.txtBox)
self.thread.progress.connect(self.showID)
self.thread.start()
self.btnStart.setDisabled(True)
  @QtCore.pyqtSlot("QString")
  def showID(self, s):
self.txtBox.append(s);


class TestThread(QtCore.QThread):
  progress = QtCore.pyqtSignal("QString")
  def __init__(self, parent, cmd = None,  box = None):
QtCore.QThread.__init__(self)
self.cmd = cmd
self.box = box

  def run(self):
self.prog = subprocess.Popen(self.cmd, bufsize = 1, stdout =
subprocess.PIPE, stderr = subprocess.STDOUT)
self.rFile = select.select([self.prog.stdout], [], [], 3600)
line = ""

for line in self.rFile[0][0]:
  self.progress.emit(line)

if __name__ == "__main__":
  app = QtGui.QApplication(sys.argv)
  t = TestGUI()
  t.show()
  sys.exit(app.exec_()) 

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QDirmodel - Removing a directory and it's descendents..

2010-01-17 Thread detlev
On Sonntag, 17. Januar 2010, Jebagnana Das wrote:
> Thanks detlev for your suggestion.. Could you please give me any example
> code snippet?. Bcoz. i'm totally new to model/view programming and pyqt.
> 
> On Sun, Jan 17, 2010 at 5:03 PM, detlev  wrote:
> > Hi,
> >
> > how about using a QSortFilterProxy model to filter the excluded ones?
> >
> > Detlev
> >
> > On Samstag, 16. Januar 2010, Jebagnana Das wrote:
> > > Hello all,
> > > Greetings.. After a spending a long time for googling i found
> > > the way to list the contents of a particular directory. Thanks to
> > > QDirModel.
> > >
> > >My aim here is to allow the user to exclude specific directories
> > > within the chosen directory.. After adding a particular directory to
> > > the exclusion list(on the right side)the selected directory and it's
> > > descendents should be removed(or hidden)from the tree view so that the
> > > user is not allowed to select the same folder again..
> > >
> > >   Given here the minimal example needed for my app.. In this
> > > example when the user presses add to exclude list push button the
> > > folder is added to the exclude folders listwidget..
> > >
> > > from PyQt4 import QtCore, QtGui
> > >
> > > class Ui_Dialog(QtGui.QDialog):
> > >
> > > def __init__(self,parent=None):
> > > QtGui.QDialog.__init__(self,parent)
> > > self.resize(600, 500)
> > >
> > > self.model = QtGui.QDirModel()
> > > self.tree = QtGui.QTreeView(self)
> > > self.tree.setModel(self.model)
> > >
> > > self.model.setFilter(QtCore.QDir.Dirs|QtCore.QDir.NoDotAndDotDot)
> > > self.tree.setSortingEnabled(True)
> >
> > self.tree.setRootIndex(self.model.index("/home/jebagnanadasa/Python-3.1.1
> >")
> >
> > > )
> > >
> > > self.tree.hideColumn(1)
> > > self.tree.setWindowTitle("Dir View")
> > > self.tree.resize(400, 480)
> > > self.tree.setColumnWidth(0,150)
> > > self.tree.show()
> > >
> > > self.pushButton = QtGui.QPushButton(self)
> > > self.pushButton.setGeometry(QtCore.QRect(420, 30, 151, 28))
> > > self.listWidget = QtGui.QListWidget(self)
> > > self.listWidget.setGeometry(QtCore.QRect(410, 80, 171, 231))
> > >
> > > QtCore.QObject.connect(self.tree,
> > > QtCore.SIGNAL("clicked(QModelIndex)"), self.test)
> >
> > QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL('clicked()'),self.ad
> >dT
> >
> > > oList) QtCore.QMetaObject.connectSlotsByName(self)
> > >
> > > self.setWindowTitle(QtGui.QApplication.translate("Dialog",
> > >  "Dialog", None, QtGui.QApplication.UnicodeUTF8))
> > > self.pushButton.setText(QtGui.QApplication.translate("Dialog",
> >
> > "Add
> >
> > > to Exclude List", None, QtGui.QApplication.UnicodeUTF8))
> > >
> > > def test(self,index):
> > >
> > > if self.model.data(index.parent())=="jebagnanadasa":
> > > self.selectedDirectoryPath=self.model.data(index)
> > > print(self.selectedDirectoryPath)
> > > else:
> > > dirHierarchy=[]
> > > dirHierarchy.insert(0,self.model.data(index))
> > > while (self.model.data(index.parent())!="jebagnanadasa"):
> > > index=index.parent()
> > > dirHierarchy.insert(0,self.model.data(index))
> > > self.selectedDirectoryPath="/".join(dirHierarchy)
> > > print(self.selectedDirectoryPath)
> > >
> > > #self.model.removeRow(0,index)
> > >
> > > def addToList(self):
> > > self.listWidget.addItem(self.selectedDirectoryPath)
> > >
> > >
> > > if __name__ == "__main__":
> > > import sys
> > > app = QtGui.QApplication(sys.argv)
> > > ui = Ui_Dialog()
> > > ui.show()
> > > sys.exit(app.exec_())
> > >
> > > See the screenshot also..
> > >
> > > [image:
> >
> > ?ui=2&view=att&th=12637fd44b798078&attid=0.1&disp=attd&realattid=ii_12637
> >fd
> >
> > > 44b798078&zw]
> > >
> > > Is there a way that i can make the excluded directories to be ignored
> >
> > when
> >
> > > displaying the contents of the directory on consecutive startup(since
> > > it was already on the exclusion list)?
> > >
> > > Any help would be much appreciated.. Thanks..
> > >
> > > P.S: remove() and rmdir() is not recommended since it deletes the
> > > directories entirely from the file System!
> >
> > --
> > Detlev Offenbach
> > det...@die-offenbachs.de
> 

Haven't used one with QDirModel yet but eric4/5 contain quite a bunch of 
QSortFilterModel usage examples. The Qt docu isn't too bad either.

Regards,
Detlev
-- 
Detlev Offenbach
det...@die-offenbachs.de
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] [ANN] Spyder v1.0.3 released

2010-01-17 Thread Pierre Raybaut

Hi all,

I'm pleased to announce here that Spyder version 1.0.3 has been released:
http://packages.python.org/spyder

__Important__
Spyder v1.0.3 is a *critical* bugfix release (bonus: new "Apply" button 
in matplotlib's figure options editor).



Previously known as Pydee, Spyder (Scientific PYthon Development
EnviRonment) is a free open-source Python development environment
providing MATLAB-like features in a simple and light-weighted
software, available for Windows XP/Vista/7, GNU/Linux and MacOS X:
   * advanced code editing features (code analysis, ...)
   * interactive console with MATLAB-like workpace (with GUI-based
list, dictionary, tuple, text and array editors -- screenshots:
http://packages.python.org/spyder/console.html#the-workspace) and
integrated matplotlib figures
   * external console to open an interpreter or run a script in a
separate process (with a global variable explorer providing the same
features as the interactive console's workspace)
   * code analysis with pyflakes and pylint
   * search in files features
   * documentation viewer: automatically retrieves docstrings or
source code of the function/class called in the interactive/external
console
   * integrated file/directories explorer
   * MATLAB-like path management
   ...and more!

Spyder is part of spyderlib, a Python module based on PyQt4 and
QScintilla2 which provides powerful console-related PyQt4 widgets.

- Pierre
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] qlistview and setSelectionRectVisible

2010-01-17 Thread Mads
Hi,

when I use a qlistview I can toggle the 'selection rectangle' on/off
with setSelectionRectVisible(..). But how do I change the look
(outline, color, etc) of the selection rectangle?

Thanks,
Mads
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] exposedRect option passed to paint in subclass of QGraphicsItem

2010-01-17 Thread buddy+pyqt
I just updated my windows machine to the latest Qt and PyQt versions and I've 
been
having a problem with my custom subclasses of QGraphicsItems.  When I 
reimplement
the paint method it gets passed several option as a QStyleOptionGraphicsItem 
object.
 The exposedRect member of that is suppose to contain the area the needs to be
repainted, however I always get a null rectangle.  Attached is a simple example 
I
put together to illustrate the problem.  The attached example attached is 
suppose to
draw a 3x3 rectangle under the mouse cursor when the mouse button is pressed 
down,
but
since the exposedRect is always null it does nothing.  It also prints out the
rectangle and I always get lines of all zeroes when I run it.  I think this may 
be a
bug, but please tell me if I'm just doing something wrong or if something is 
messed
up with my PyQt install.

Thanks,
Buddy
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] exposedRect option passed to paint in subclass of QGraphicsItem

2010-01-17 Thread buddy+pyqt
I just updated my windows machine to the latest Qt and PyQt versions and I've 
been
having a problem with my custom subclasses of QGraphicsItems.  When I 
reimplement
the paint method it gets passed several option as a QStyleOptionGraphicsItem 
object.
 The exposedRect member of that is suppose to contain the area the needs to be
repainted, however I always get a null rectangle.  Attached is a simple example 
I
put together to illustrate the problem.  The example attached is suppose to 
draw a
3x3 rectangle under the mouse cursor when the mouse button is pressed down, but
since the exposedRect is always null it does nothing.  It also prints out the
rectangle and I always get lines of all zeroes.  I think this may be a bug, but
please tell me if I'm just doing something wrong or if something is messed up 
with
my PyQt install.

Thanks,
Buddyimport sys
import PyQt4.QtGui as qtgui
import PyQt4.QtCore as qtcore

class CustomPixmapItem(qtgui.QGraphicsItem):
def __init__(self,parent=None,scene=None):
qtgui.QGraphicsPixmapItem.__init__(self,parent,scene)

self.image=qtgui.QImage(200,200,qtgui.QImage.Format_ARGB32_Premultiplied)
self.image.fill(0x)

def drawPoint(self,x,y):
painter=qtgui.QPainter()
painter.begin(self.image)
rect=qtcore.QRect(x,y,3,3)
painter.fillRect(rect,qtgui.QColor(0,0,0))
self.update(qtcore.QRectF(rect))

def paint(self,painter,options,widget=None):
rect=options.exposedRect
print "Exposed Rect:", rect.x(), rect.y(), rect.width(), 
rect.height()
# this I think should work, but doesn't since the rectangle 
never has anything in it

painter.drawImage(options.exposedRect,self.image,options.exposedRect)

# this alternate line works fine
#painter.drawImage(qtcore.QPoint(0,0),self.image)

class CustomScene(qtgui.QGraphicsScene):
def __init__(self,rect,parent=None):
qtgui.QGraphicsScene.__init__(self,rect,parent)

def mousePressEvent(self,event):
for item in self.items():

item.drawPoint(event.scenePos().x(),event.scenePos().y())
self.update()

app=qtgui.QApplication(sys.argv)

window=qtgui.QMainWindow()
window.show()
window.resize(240,240)

scene=CustomScene(qtcore.QRectF(0,0,200,200))
scene.setBackgroundBrush(qtgui.QBrush(qtgui.QColor(255,255,255)))
scene.update()
view=qtgui.QGraphicsView(scene,window)

view.show()

window.setCentralWidget(view)

item=CustomPixmapItem(None,None)
scene.addItem(item)

app.exec_()___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] exposedRect option passed to paint in subclass of QGraphicsItem

2010-01-17 Thread Antonio Valentino
Hi Buddy,


Il giorno Sun, 17 Jan 2010 11:14:29 -0700 (MST)
buddy+p...@nmt.edu ha scritto:

> I just updated my windows machine to the latest Qt and PyQt versions
> and I've been having a problem with my custom subclasses of
> QGraphicsItems.  When I reimplement the paint method it gets passed
> several option as a QStyleOptionGraphicsItem object. The exposedRect
> member of that is suppose to contain the area the needs to be
> repainted, however I always get a null rectangle.  Attached is a

starting from Qt 4.6 exposedRect should contain the bounding box of
the item unless you set the QGraphicsItem::ItemUsesExtendedStyleOptions:

see
http://qt.gitorious.org/qt/qt/blobs/d16ba0a93d611689bce9a2732a1cc8c9a317f5bf/dist/changes-4.6.0#line1075
and
http://www.riverbankcomputing.com/pipermail/pyqt/2010-January/025521.html


> simple example I put together to illustrate the problem.  The example
> attached is suppose to draw a 3x3 rectangle under the mouse cursor
> when the mouse button is pressed down, but since the exposedRect is
> always null it does nothing.  It also prints out the rectangle and I
> always get lines of all zeroes.  I think this may be a bug, but
> please tell me if I'm just doing something wrong or if something is
> messed up with my PyQt install.

In your specific case I think you forgot to implement the boundingRect
method in yout custom QGraphicsItem.


Best regards

-- 
Antonio Valentino
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Poppler Configuration

2010-01-17 Thread Zabin Farishta
Hey!

I am a newbie to PyQt programming and I am trying to install the poppler
module. Unfortunately I am unsure of how to install it- right from the
basics- like I am unsure of what location to place the files from the site
below:

http://svn.pardus.org.tr/uludag/trunk/playground/pypoppler-qt4/

and what changes I need to make to the configuration fileany help would
be much appreciated!

Zabin
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt