Re: [PyQt] Plugin widget for designer
On Thu Mar 17 16:47:27 GMT 2011, Entity Reborn wrote: > I have successfully managed to get my widget to show up in the > designer. Unfortunately when I insert it into the form, there is no > content. All that Is seen is the bounding box. My widget inherits > qTreeView. Any ideas? Maybe you have already fixed this by now, but it sounds like some meta-data is missing and you only get a QWidget inserted into the form. You need to post some code - ideally a minimal running example - showing what you have done so that we can try to diagnose the problem. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] include text in FigureCanvas
On Thu Mar 24 03:35:58 GMT 2011, nimi pillai wrote: > Can someone please tell me how to include some texts in FigureCanvas > 3Dplot. Can you tell us what FigureCanvas is and how you are using it with PyQt? David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] distinguish / enable / disable multiple pointer devices
On Friday 25 March 2011 00:10:21 +0100, Gelonida wrote: > I have a PC (Windows) with a mouse, a touch screen and a graphics tablet. > > Is there any way to know with which device a widget was clicked? If the widget interprets a mouse click, screen touch or a press on the tablet as mouse events then there may not be a way to distinguish between them. In other words, if Windows converts events to mouse clicks and sends them to Qt then there wouldn't be a way to tell. > Is there any way to disable for example the touch screen events for one > widget and the mouse events for another? If you are receiving different kinds of events for the mouse, screen and tablet then you could install event filters to stop certain kinds of events from being delivered to each widget. Qt has classes to represent these kinds of events: QMouseEvent: http://doc.qt.nokia.com/4.7/qmouseevent.html QTabletEvent: http://doc.qt.nokia.com/4.7/qtabletevent.html QTouchEvent: http://doc.qt.nokia.com/4.7/qtouchevent.html So, in theory, it should be possible. David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Qwebview crashes almost always when entering Facebook apps
Hi Pete, Thanks for your quick reply and thanks for confirming my issue. On 3/25/2011 12:21 AM, Hans-Peter Jansen wrote: On Thursday 24 March 2011, 23:52:53 Gelonida wrote: Hi I have a rather small (mostly crashing) script with a QWebViewwidget. # beginning of script import sys import platform import PyQt4.QtGui as QtGui import PyQt4.QtCore as QtCore from PyQt4.QtWebKit import QWebView class MyMainWindow(QtGui.QMainWindow): def __init__(self, parent=None): super(MyMainWindow, self).__init__(parent) self.setWindowTitle("Simple Crasher") self.webview = QWebView() self.setCentralWidget(self.webview) # I tried with two face book apps so you can probably # reproduce with another facebook app urlstr ="http://apps.facebook.com/be-heroic"; self.webview.setUrl(QtCore.QUrl(urlstr)) print sys.platform, platform.release() print QtCore.PYQT_VERSION_STR,QtCore.PYQT_VERSION app = QtGui.QApplication(sys.argv) window = MyMainWindow() window.show() sys.exit(app.exec_()) # end of script The url points to a facebook application. I tried with the url in the sample script, but failed also with other facebook applications. What happens: After starting the script a login screen shows up (email address and password field in the top right corner of the dispay) after a few seconds the layout changes and the emailaddress and password field are in the middle of the screen I enter email address and password of my facebook account and click on connect. In 90 % of the cases the script crashes without any python back trace or error message. Example output: linux2 2.6.32-29-generic 4.7.2 263938 Segmentation fault (core dumped) The application crashes also under windows where the output would be win32 post2008Server 4,7 263936 Can anybody else reproduce this? Confirmed: python: 2.6 sip: 4.12.1 qt4: 4.6.3 pyqt4: snapshot-4.8.4-278054fd857c Given the simpleness of your script, and since this happens deep under the covers in the javascript core, a *Qt* bugreport would be in order. That requires a C++ version, though. If that version works, then Phil is to blame, but I doubt that. Well I must admit I never wrote C++ code with Qt I'll have to check what exactly is needed to write is as pure C++ application. Leaving a pointer to the report here would be nice. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] distinguish / enable / disable multiple pointer devices
On Friday 25 March 2011, 00:10:21 Gelonida wrote: > Hi I have a small question, > > > I have a PC (Windows) with a mouse, a touch screen and a graphics > tablet. > > > Is there any way to know with which device a widget was clicked? > > Is there any way to disable for example the touch screen events for > one widget > and the mouse events for another? Try ignoring these events in the respective event handlers of your widgets subclasses. Note that some devices just emulate mouse events, these aren't distinguishable from real mouse events AFAIK. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] distinguish / enable / disable multiple pointer devices
On Freitag 25 März 2011, Gelonida wrote: > I have a PC (Windows) with a mouse, a touch screen and a > graphics tablet. > > > Is there any way to know with which device a widget was > clicked? something like QKeyEvent, QMouseEvent, QTabletEvent, QTouchEvent and QWheelEvent? class MyWidget(QWidget): ... def mousePressEvent(self, event): if event.type() == QEvent.TabletPress: print '%s clicked with Tablet' % self.objectName() It would be more difficult to differentiate between two mice -- Wolfgang ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Qwebview crashes almost always when entering Facebook apps
On Thursday 24 March 2011, 23:52:53 Gelonida wrote: > Hi I have a rather small (mostly crashing) script with a > QWebViewwidget. > > # beginning of script > import sys > import platform > import PyQt4.QtGui as QtGui > import PyQt4.QtCore as QtCore > from PyQt4.QtWebKit import QWebView > > class MyMainWindow(QtGui.QMainWindow): > def __init__(self, parent=None): > super(MyMainWindow, self).__init__(parent) > self.setWindowTitle("Simple Crasher") > self.webview = QWebView() > self.setCentralWidget(self.webview) > # I tried with two face book apps so you can probably > # reproduce with another facebook app > urlstr ="http://apps.facebook.com/be-heroic"; > self.webview.setUrl(QtCore.QUrl(urlstr)) > > > print sys.platform, platform.release() > print QtCore.PYQT_VERSION_STR,QtCore.PYQT_VERSION > app = QtGui.QApplication(sys.argv) > window = MyMainWindow() > window.show() > sys.exit(app.exec_()) > # end of script > > > The url points to a facebook application. > I tried with the url in the sample script, but failed also with other > facebook applications. > > What happens: > > After starting the script a login screen shows up > (email address and password field in the top right corner of the > dispay) after a few seconds the layout changes and the emailaddress > and password field are in the middle of the screen > > I enter email address and password of my facebook account and click > on connect. > > In 90 % of the cases the script crashes without any python back trace > or error message. > > > Example output: > linux2 2.6.32-29-generic > 4.7.2 263938 > Segmentation fault (core dumped) > > The application crashes also under windows where the output would be > win32 post2008Server > 4,7 263936 > > Can anybody else reproduce this? Confirmed: python: 2.6 sip: 4.12.1 qt4: 4.6.3 pyqt4: snapshot-4.8.4-278054fd857c #0 0xb4e97c80 in JSC::Interpreter::prepareForRepeatCall(JSC::FunctionExecutable*, JSC::ExecState*, JSC::JSFunction*, int, JSC::ScopeChainNode*, JSC::JSValue*) () from /usr/lib/libQtWebKit.so.4 #1 0xb4f034a7 in JSC::JSArray::sort(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&) () from /usr/lib/libQtWebKit.so.4 #2 0xb4ecc19e in JSC::arrayProtoFuncSort(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, JSC::ArgList const&) () from /usr/lib/libQtWebKit.so.4 #3 0xb7b9d16e in ?? () #4 0xb4e98993 in JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::ScopeChainNode*, JSC::JSObject*, JSC::JSValue*) () from /usr/lib/libQtWebKit.so.4 #5 0xb4efcd13 in JSC::evaluate(JSC::ExecState*, JSC::ScopeChain&, JSC::SourceCode const&, JSC::JSValue) () from /usr/lib/libQtWebKit.so.4 #6 0xb4fed23e in WebCore::evaluateInWorld(JSC::ExecState*, JSC::ScopeChain&, JSC::SourceCode const&, JSC::JSValue, WebCore::DOMWrapperWorld*) () from /usr/lib/libQtWebKit.so.4 #7 0xb4ffba66 in WebCore::ScriptController::evaluateInWorld(WebCore::ScriptSourceCode const&, WebCore::DOMWrapperWorld*) () from /usr/lib/libQtWebKit.so.4 #8 0xb4ffbcd9 in WebCore::ScriptController::evaluate(WebCore::ScriptSourceCode const&) () from /usr/lib/libQtWebKit.so.4 #9 0xb5107f9f in WebCore::ScriptElementData::evaluateScript(WebCore::ScriptSourceCode const&) () from /usr/lib/libQtWebKit.so.4 #10 0xb51084de in WebCore::ScriptElementData::execute(WebCore::CachedScript*) () from /usr/lib/libQtWebKit.so.4 #11 0xb50c12a2 in WebCore::Document::executeScriptSoonTimerFired(WebCore::Timer*) () from /usr/lib/libQtWebKit.so.4 #12 0xb50af531 in WebCore::Timer::fired() () from /usr/lib/libQtWebKit.so.4 #13 0xb53905fd in WebCore::ThreadTimers::sharedTimerFiredInternal() () from /usr/lib/libQtWebKit.so.4 #14 0xb5390662 in WebCore::ThreadTimers::sharedTimerFired() () from /usr/lib/libQtWebKit.so.4 #15 0xb54b85d6 in WebCore::SharedTimerQt::timerEvent(QTimerEvent*) () from /usr/lib/libQtWebKit.so.4 #16 0xb6793a44 in QObject::event (this=0x832a3f8, e=0xbfffe34c) at kernel/qobject.cpp:1212 #17 0xb69d8d3c in QApplicationPrivate::notify_helper (this=0x82a5700, receiver=0x832a3f8, e=0xbfffe34c) at kernel/qapplication.cpp:4302 #18 0xb69e0516 in QApplication::notify (this=0x815bd68, receiver=0x832a3f8, e=0xbfffe34c) at kernel/qapplication.cpp:3706 #19 0xb78830de in sipQApplication::notify (this=0x815bd68, a0=0x832a3f8, a1=0xbfffe34c) at sipQtGuiQApplication.cpp:297 #20 0xb678292b in QCoreApplication::notifyInternal (this=0x815bd68, receiver=0x832a3f8, event=0xbfffe34c) at kernel/qcoreapplication.cpp:726 #21 0xb67b31d6 in QTimerInfoList::activateTimers (this=0x82ade84) at kernel/qcoreapplication.h:215 #22 0xb67af727 in idleTimerSourceDispatch (source=0x82adeb8) at kernel/qeventdispatcher_glib.cpp:184 #23 0xb630f845 in g_main_context_dispatch (context=0x82ad290) at gmain.c:2440 #24 0xb6313d9b in g_main_context_iterate (context=0x82ad290, block=1, dispatch=1, self=0x82aaea8) at gmain.c:3091 #25 0xb6314018 in g_main_c
[PyQt] distinguish / enable / disable multiple pointer devices
Hi I have a small question, I have a PC (Windows) with a mouse, a touch screen and a graphics tablet. Is there any way to know with which device a widget was clicked? Is there any way to disable for example the touch screen events for one widget and the mouse events for another? Thanks in advance for any info / ideas ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Qwebview crashes almost always when entering Facebook apps
Hi I have a rather small (mostly crashing) script with a QWebViewwidget. # beginning of script import sys import platform import PyQt4.QtGui as QtGui import PyQt4.QtCore as QtCore from PyQt4.QtWebKit import QWebView class MyMainWindow(QtGui.QMainWindow): def __init__(self, parent=None): super(MyMainWindow, self).__init__(parent) self.setWindowTitle("Simple Crasher") self.webview = QWebView() self.setCentralWidget(self.webview) # I tried with two face book apps so you can probably # reproduce with another facebook app urlstr ="http://apps.facebook.com/be-heroic"; self.webview.setUrl(QtCore.QUrl(urlstr)) print sys.platform, platform.release() print QtCore.PYQT_VERSION_STR,QtCore.PYQT_VERSION app = QtGui.QApplication(sys.argv) window = MyMainWindow() window.show() sys.exit(app.exec_()) # end of script The url points to a facebook application. I tried with the url in the sample script, but failed also with other facebook applications. What happens: After starting the script a login screen shows up (email address and password field in the top right corner of the dispay) after a few seconds the layout changes and the emailaddress and password field are in the middle of the screen I enter email address and password of my facebook account and click on connect. In 90 % of the cases the script crashes without any python back trace or error message. Example output: linux2 2.6.32-29-generic 4.7.2 263938 Segmentation fault (core dumped) The application crashes also under windows where the output would be win32 post2008Server 4,7 263936 Can anybody else reproduce this? looking at the backtrace with gdb python core and the command 'bt' gives: #0 JSC::Interpreter::prepareForRepeatCall (this=0x7f8bab407b00, FunctionExecutable=0x7f8ba05424d0, callFrame=0x7f8baa712768, function= 0x7f8ba2db05c0, argCount=, scopeChain=0x7f8ba80d1bd0, exception=0x7f8bab3c45c0) at ../JavaScriptCore/interpreter/Interpreter.cpp:715 #1 0x7f8bb796c7e7 in CachedCall (this=0x7f8ba2db2d40, exec=, compareFunction=..., callType=, callData=) at ../JavaScriptCore/interpreter/CachedCall.h:44 #2 JSC::JSArray::sort (this=0x7f8ba2db2d40, exec=, compareFunction=..., callType=, callData=) at ../JavaScriptCore/runtime/JSArray.cpp:830 #3 0x7f8bb7942d46 in arrayProtoFuncSort (exec=0x7f8baa712768, thisValue=..., args=...) at ../JavaScriptCore/runtime/ArrayPrototype.cpp:482 #4 0x7f8bb792e2d4 in JSC::Interpreter::privateExecute (this=, flag=, registerFile=, callFrame=0x7f8baa7126f0, exception=) at ../JavaScriptCore/interpreter/Interpreter.cpp:3200 #5 0x7f8bb7935ebf in JSC::Interpreter::execute (this=0x7f8bab407b00, program=0x7f8ba2f3da80, callFrame=0x19502c8, scopeChain=, thisObj=, exception=) at ../JavaScriptCore/interpreter/Interpreter.cpp:615 #6 0x7f8bb7966df4 in JSC::evaluate (exec=0x19502c8, scopeChain=..., source=, thisValue=...) at ../JavaScriptCore/runtime/Completion.cpp:60 #7 0x7f8bb7a24705 in WebCore::evaluateInWorld (exec=0x19502c8, scopeChain=..., sourceCode=..., thisValue=..., isolatedWorld=) at bindings/js/JSDOMBinding.cpp:834 #8 0x7f8bb7a325a0 in WebCore::ScriptController::evaluateInWorld (this=0x7f8bab3b5390, sourceCode=, world= 0x1792510) at bindings/js/ScriptController.cpp:121 #9 0x7f8bb7a327c2 in WebCore::ScriptController::evaluate (this=0x7f8bab3b5390, sourceCode=...) at bindings/js/ScriptController.cpp:142 #10 0x7f8bb7b24b1e in WebCore::ScriptElementData::evaluateScript (this=0x7f8ba2c8f2f8, sourceCode=...) at dom/ScriptElement.cpp:185 #11 0x7f8bb7b24cc1 in WebCore::ScriptElementData::execute (this=0x7f8ba2c8f2f8, cachedScript=0x1d80970) at dom/ScriptElement.cpp:204 #12 0x7f8bb7ae2314 in WebCore::Document::executeScriptSoonTimerFired (this=, timer=) at dom/Document.cpp:4341 #13 0x7f8bb7d4ea76 in WebCore::ThreadTimers::sharedTimerFiredInternal (this=0x7f8bab3b2900) at platform/ThreadTimers.cpp:112 #14 0x7f8bbc5f0a63 in QObject::event (this=0x15b75d0, e=0x7fff5441cce0) at kernel/qobject.cpp:1212 #15 0x7f8bbcab422c in QApplicationPrivate::notify_helper (this=0x15a6cc0, receiver=0x15b75d0, e=0x7fff5441cce0) at kernel/qapplication.cpp:4300 #16 0x7f8bbcaba6fb in QApplication::notify (this=0x15a66c0, receiver=0x15b75d0, e=0x7fff5441cce0) at kernel/qapplication.cpp:4183 #17 0x7f8bbda20443 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtGui.so #18 0x7f8bbc5e106c in QCoreApplication::notifyInternal (this=0x15a66c0, receiver=0x15b75d0, event=0x7fff5441cce0) at kernel/qcoreapplication.cpp:704 #19 0x7f8bbc60dd42 in QCoreApplication::sendEvent (this=0x15b7130) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215 #20 QTimerInfoList::activateTimers (this=0x15b7130) at kernel/qeventdispatcher_unix.cpp:603 #21 0x7f8bbc60a848 in timerSourceDispatch (source=) at kernel/qeventdispatcher_glib.cpp:184 #22 idleTimerSou
[PyQt] Method returning QList
Hi everyone, I'm using sip 4.10.5 and PyQt 4.7.4. If a method returns a QList of const pointers, it seems that the const keyword is discarded. Make gives me this error: -- /usr/share/sip/PyQt4/QtCore/qlist.sip: In function ‘int convertTo_QList_0111Item(PyObject*, void**, int*, PyObject*)’: /usr/share/sip/PyQt4/QtCore/qlist.sip:195: error: cannot convert ‘QList*’ to ‘QList*’ in assignment /usr/share/sip/PyQt4/QtCore/qlist.sip: In function ‘PyObject* convertFrom_QList_0111Item(void*, PyObject*)’: /usr/share/sip/PyQt4/QtCore/qlist.sip:138: error: invalid conversion from ‘const Item*’ to ‘Item*’ -- Here's the sip file generating the error (it's almost identical to the header file): --- %Module Proof %ModuleHeaderCode #include "proof.h" %End %Import QtCore/QtCoremod.sip class Item { %TypeHeaderCode #include "proof.h" %End public: Item(int i); }; class Proof { %TypeHeaderCode #include "proof.h" %End public: Proof(); ~Proof(); QList items() const; }; --- Cheers -- Lorenzo Masini Develer srl ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Stop main window from showing when closing dialog
How are you closing the dialog, .close()? Try .hide() and recycling the window for later. Some example code that exhibits this problem would be most excellent as well! On Mar 24, 2011, at 7:40 AM, Mikael Modin wrote: > Hi, > > I'm working on a background application that sometimes show a dialog in a > lower corner, most of the time it's meant to just sit queitly in the taskbar > or system tray. My problem is this; When the dialog in the corner is closed > the main window get the focus again and becomes the top window, stealing it > from whichever window had it before. > > The corner window doesn't take the focus when shown which is correct. Now I > just need to stop the main window from receiving the focus when the corner > dialog is closed, or failing that loose it directly after getting it. > > I tried setting parent to None when calling QDialog.__init__ for my corner > dialog but then it didn't show up at all. If anyone has any idea how to fix > this I'd greatly appreciate it. > > Regards, > Mikael > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Stop main window from showing when closing dialog
Hi, I'm working on a background application that sometimes show a dialog in a lower corner, most of the time it's meant to just sit queitly in the taskbar or system tray. My problem is this; When the dialog in the corner is closed the main window get the focus again and becomes the top window, stealing it from whichever window had it before. The corner window doesn't take the focus when shown which is correct. Now I just need to stop the main window from receiving the focus when the corner dialog is closed, or failing that loose it directly after getting it. I tried setting parent to None when calling QDialog.__init__ for my corner dialog but then it didn't show up at all. If anyone has any idea how to fix this I'd greatly appreciate it. Regards, Mikael ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Long running processes, threads, progress dialog
On Thursday 24 March 2011, 02:00:03 Catriona Johnson wrote: > >> Hello > >> > >> I have a GUI application that occasionally has a number of long > >> running processes - eg data deletions , html report generation. > >> > >> I have a custom progress widget that displays a spinning icon (my > >> client didn't like the Qt QProgressDialog) which I display during > >>long running processes - the user doesn't need to be able to > >> interact with the GUI while this is happening. > >> > >> I have started to implement a worker thread to perform these long > >> running processes. My question is do I initiate each process from > >> the Thread's run method as follows or does each operation have its > >> own thread ?? Do I need to use a secondary thread at all? Is there > >> a better way ?? > >> > >> def run(self): > >> if self.operation == A_DELETE: > >> self.completed = > >> AModel.model().removeRecord(self.identity) elif self.operation == > >> B_DELETE: > >> self.completed = > >> BModel.model().removeRecord(self.identity) elif self.operation == > >> REPORTS: > >> self.completed = > >> ReportWriter.generateReport() self.stop() > >> self.emit(SIGNAL("finished(bool)"), self.completed) > >> self.wait() > > > >You may want to read this article, which is mostly valid also for > > PyQt: > > > > http://www.linuxjournal.com/article/9602 > > > >From a PyQt POV and depending on where the action is, the presence > > of the GIL might want to be taken into account.. > > > >Pete > > Thanks for that Pete - it is a good article. > > My case is not that complicated though. I am reading and sometimes > updating binary files that contain the data for the application. > These processes are never concurrent and do not connect to a > database. My understanding is from the article that each process has > a thread and the process is run from the thread's run method? Hmm, every process _is_ a thread (in the sense of an execution unit). Since that cannot be stopped easily (apart from termination), there's no run method involved. That comes into play, if threads enter the picture. For every running thread (one, that got its start method called), your process grows another execution unit, but these need some preparation and following special rules, as the article shows. > Implementing threading does seem a little bit of overkill if all I > want is a modal progress dialog to display while the operation is > occurring. What is the best way to do it. > > I did try a QProgressDialog as follows but although it was displayed > there was no animation. I want an indeterminate progress bar > > progressDialog = QProgressDialog() > progressDialog.setMinimum(0) > progressDialog.setMaximum(0) > progressDialog.setValue(-1) # As set in Designer > progressDialog.show() Ahh, I didn't understand your issue. Try calling QtGui.QApplication.processEvents() periodically in the loops, but note, that calling this method has to be done from the UI thread, e.g. the one, that called QtGui.QApplication() before. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt