Re: [PyQt] Is there a way to run the interp AND a gui?

2010-03-02 Thread Andreas Pakulat
On 02.03.10 15:04:37, Jason H wrote:
> I am working on the new Qt/Kinetic stuff and one thing I would really like to 
> have is an interactive GUI for it. Ideally, I'd have something like the 
> interactive interpreter, which when I type x=QGrahpicsTextItem(...) and add 
> it to the scene, it appears in the scene. Then I can do that with graphics 
> effects and test out animations. 
> 
> The problem though, is the event loop needs to be running for the painting to 
> happen. So I am confused if this is even possible? I'd even settle for some 
> IPC that would translate commands to a seperate process running the GUI, if 
> there was a way to do it (so that then I do x=QGrahicstextItem(...) x is 
> actually a handle to the actual object in another process. But this looks 
> waaay complicated. 

Well, you could simply create a textwidget along with the real GUI app
where you can type python commands and execute them via some shortcut by
passing the textedit content to eval(). Once you're done with
development of the app you can simply remove the couple of lines that
create the textwidget...

Andreas

-- 
Are you sure the back door is locked?
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Detecting clicks on Mac Dock

2010-03-02 Thread Yao Ko
Hi,

This is a Mac-specific question:

Is it possible to detect clicks on the dock icon of a QApplication?  I
tried adding debug messages on QApplication.event() and it only gets
triggered when the application is activated or deactivated.  But if
the user clicks on the dock when the app is already activated, it
doesn't trigger any more events.

Sample code:

"""
import sys
from PyQt4 import QtGui, QtCore

class MyApp(QtGui.QApplication):
  def __init__(self):
QtGui.QApplication.__init__(self, sys.argv)
QtGui.QApplication.setQuitOnLastWindowClosed(False)

  def event(self, e):
print 'Inside event(): %s' % e.type()
return QtGui.QApplication.event(self, e)

def main():
  app = MyApp()
  sys.exit(app.exec_())

if __name__ == '__main__':
  main()
"""

Running it:

$ python dock_example.py
Inside event(): 67
Inside event(): 70
Inside event(): 70
Inside event(): 70
Inside event(): 121  <- QEvent.ApplicationActivate

(and if I continue click on the dock icon, it doesn't trigger any more events).

The goal is to show() and raise() the QApplication whenever someone
clicks on the dock icon, even though if the main window is hidden.

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


Re: [PyQt] Limit the height of a Layout

2010-03-02 Thread dcassidy36
Are you using QtDesigner? You can set the min and max size for each widget, so 
I'd probably look at that.
--
Regards,
 -Demetrius Cassidy

 starglider develop  wrote: 

=
Hello,
I'm a newby and I have a question:
how can I limit the height of a QHBoxLayout?
e.g.:
There is a  central widget with a QHBoxLayout that as two QTableWidget and I
want to limit the size of the first QTableWidget to 300 points,
but let the second QTableWidget grow until the limit of the screen.

Thank you in advance for your help.

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


[PyQt] Limit the height of a Layout

2010-03-02 Thread starglider develop
Hello,
I'm a newby and I have a question:
how can I limit the height of a QHBoxLayout?
e.g.:
There is a  central widget with a QHBoxLayout that as two QTableWidget and I
want to limit the size of the first QTableWidget to 300 points,
but let the second QTableWidget grow until the limit of the screen.

Thank you in advance for your help.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Is there a way to run the interp AND a gui?

2010-03-02 Thread Jason H
I am working on the new Qt/Kinetic stuff and one thing I would really like to 
have is an interactive GUI for it. Ideally, I'd have something like the 
interactive interpreter, which when I type x=QGrahpicsTextItem(...) and add it 
to the scene, it appears in the scene. Then I can do that with graphics effects 
and test out animations. 

The problem though, is the event loop needs to be running for the painting to 
happen. So I am confused if this is even possible? I'd even settle for some IPC 
that would translate commands to a seperate process running the GUI, if there 
was a way to do it (so that then I do x=QGrahicstextItem(...) x is actually a 
handle to the actual object in another process. But this looks waaay 
complicated. 

Thoughts?


  

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


Re: [PyQt] how to open a gui module?

2010-03-02 Thread dcassidy36
I still don't quite understand what you are trying to do. Are you trying to 
open TestApp on event changes from the Calendar widget? Or are you just trying 
to open a dialog within another dialog? Because it's the same code that you 
have in your "__main__" section.

t = TestApp()
t.show()

And you shoulden't use the Qt C++ SIGNAL/SLOT implementation as it's not very 
Pythonic and can lead to some hard to find errors. 

Try something like this instead:
self.calenderWidget.selectionChanged.connect(self.Plans)


--
Regards,
 -Demetrius Cassidy

 p...@patx.me wrote: 

=
reply to addr: pat...@gmail.com

On Tue, Mar 2, 2010 at 4:44 PM,  wrote:

> Yea, http://patx.me/paste/28462914.html and
> http://patx.me/paste/2160335.html
>
> so i need to use paste # 28462914 to open paste # 2160335
>
> thanks :)
>
>
> On Tue, Mar 2, 2010 at 4:36 PM,  wrote:
>
>> Can you post some sample code of what you are trying to do?
>> --
>> Regards,
>>  -Demetrius Cassidy
>>
>>  p...@patx.me wrote:
>>
>> =
>> I have coded a GUI, in a .py... It is called foo.py. Then in another GUI,
>> bar.py, I need to be able to open/display/execute foo.py. So basically I
>> need to use the following:
>>
>>self.connect(self.pb1, QtCore.SIGNAL('clicked()'),
>>self.open_foo)
>>
>> So self.pb1 would be a PushButton and self.open_foo would be the function
>> that would open foo.py.
>>
>>
>> How would I do this?
>>
>> --
>> patx, patx.me
>>
>> ___
>> PyQt mailing listPyQt@riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>
>
>
> --
> patx, python gui and web, http://patx.me, amateur skier and football
> player
>



-- 
patx, python gui and web, http://patx.me, amateur skier and football player

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


Re: [PyQt] pyqt does not find phonon (from kde.org) at build time

2010-03-02 Thread Phil Thompson
On Tue, 02 Mar 2010 14:52:15 -0600, Matt Carlson 
wrote:
> Phil Thompson wrote:
>> On Sun, 28 Feb 2010 07:21:34 -0600, Matt Carlson 
>> wrote:
>>   
>>> Hi, I think I'm having the same problem described in the message below 
>>> (or at least a similar one). I tried using the latest stable source 
>>> package for PyQt 4.7 and also the latest development snapshot (as of 
>>> Feb. 28). With both installations, I get an import error when I try to 
>>> use phonon. It seems to be the same problem with configure.py. When 
>>> configure.py runs it does not list phonon when "creating the makefile" 
>>> and "generating the C++ source."
>>>
>>> I'm not sure if the patch that solsTiCe included would fix my problem. 
>>> Using it is beyond my skill level. So, I searched around a little bit 
>>> more and found another person describing a similar problem with version

>>> 4.6: http://trac.macports.org/ticket/22370. This led me to try 
>>> installing version 4.5, which got phonon working for me. I'm not sure 
>>> exactly what this means, but I'm guessing someone else might.
>>>
>>> Although version 4.5 should work fine for what I need to do, I spent a 
>>> while trying to figure out how to make 4.7 work. I checked (or tried to

>>> check) if I had phonon installed with Qt, reinstalled some Qt
libraries,
>>>
>>> and tried listing phonon in the plugin configure.py option. It's very 
>>> likely this is still just a problem for me, but it seems like there's a

>>> chance other people are still having this problem too. If anyone would 
>>> like to help me troubleshoot this, let me know what other information 
>>> you need. I'm using Ubuntu 8.10 and Python 2.5.2.
>>> 
>>
>> Running configure.py with the --verbose argument will tell you why it's
>> failing to detect phonon.
>>
>>   
> I ran configure.py with the --verbose argument. This is what I got:
> 
> Checking to see if the phonon module should be built...
> g++ -DQT_NO_DEBUG -DQT_PHONON_LIB -I. -I/usr/mkspecs/linux-g++ 
> -I/usr/include/qt4/phonon -I/usr/include/qt4 -I/usr/X11R6/include -pipe 
> -O2 -w -D_REENTRANT cfgtest_phonon.cpp -o cfgtest_phonon -L/usr/lib 
> -L/usr/X11R6/lib -Wl,--no-undefined -Wl,-rpath,/usr/lib -lphonon -lXext 
> -lX11 -lm -lpthread
> cfgtest_phonon.cpp:1:30: error: phonon/VideoWidget: No such file or 
> directory
> cfgtest_phonon.cpp: In function ‘int main(int, char**)’:
> cfgtest_phonon.cpp:5: error: expected type-specifier before ‘Phonon’
> cfgtest_phonon.cpp:5: error: expected `;' before ‘Phonon’
> 
> So, I patched line 367 as described in the original message about this 
> issue:
> 
> -check_module("phonon", "Phonon/VideoWidget",
> +check_module("phonon", "phonon/videowidget.h",
>  "new Phonon::VideoWidget()")
> 
> That seemed to fix that problem, but then I got this error:
> 
> Generating the C++ source for the phonon module...
> "/usr/bin/sip" -k -o -P -x VendorID -t WS_X11 -x PyQt_NoPrintRangeBug -t 
> Qt_4_4_1 -x Py_v3 -g -a phonon.api -c phonon -b phonon/phonon.sbf -I 
> /home/m/installation_files/PyQt-x11-gpl-snapshot-4.7.1-106919e3444b/sip 
>
/home/m/installation_files/PyQt-x11-gpl-snapshot-4.7.1-106919e3444b/sip/phonon/phononmod.sip
> sip: QVariantList is undefined
> Error: Unable to create the C++ code.
> 
> I searched around for things related to QVariantList, but am very lost 
> on this one. Any ideas?

Both problems should be fixed in tonight's snapshot.

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

Re: [PyQt] how to open a gui module?

2010-03-02 Thread dcassidy36
Can you post some sample code of what you are trying to do?
--
Regards,
 -Demetrius Cassidy

 p...@patx.me wrote: 

=
I have coded a GUI, in a .py... It is called foo.py. Then in another GUI,
bar.py, I need to be able to open/display/execute foo.py. So basically I
need to use the following:

self.connect(self.pb1, QtCore.SIGNAL('clicked()'),
self.open_foo)

So self.pb1 would be a PushButton and self.open_foo would be the function
that would open foo.py.


How would I do this?

-- 
patx, patx.me

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


Re: [PyQt] pyqt does not find phonon (from kde.org) at build time

2010-03-02 Thread Matt Carlson

Phil Thompson wrote:

On Sun, 28 Feb 2010 07:21:34 -0600, Matt Carlson 
wrote:
  
Hi, I think I'm having the same problem described in the message below 
(or at least a similar one). I tried using the latest stable source 
package for PyQt 4.7 and also the latest development snapshot (as of 
Feb. 28). With both installations, I get an import error when I try to 
use phonon. It seems to be the same problem with configure.py. When 
configure.py runs it does not list phonon when "creating the makefile" 
and "generating the C++ source."


I'm not sure if the patch that solsTiCe included would fix my problem. 
Using it is beyond my skill level. So, I searched around a little bit 
more and found another person describing a similar problem with version 
4.6: http://trac.macports.org/ticket/22370. This led me to try 
installing version 4.5, which got phonon working for me. I'm not sure 
exactly what this means, but I'm guessing someone else might.


Although version 4.5 should work fine for what I need to do, I spent a 
while trying to figure out how to make 4.7 work. I checked (or tried to 
check) if I had phonon installed with Qt, reinstalled some Qt libraries, 
and tried listing phonon in the plugin configure.py option. It's very 
likely this is still just a problem for me, but it seems like there's a 
chance other people are still having this problem too. If anyone would 
like to help me troubleshoot this, let me know what other information 
you need. I'm using Ubuntu 8.10 and Python 2.5.2.



Running configure.py with the --verbose argument will tell you why it's
failing to detect phonon.

  

I ran configure.py with the --verbose argument. This is what I got:

Checking to see if the phonon module should be built...
g++ -DQT_NO_DEBUG -DQT_PHONON_LIB -I. -I/usr/mkspecs/linux-g++ 
-I/usr/include/qt4/phonon -I/usr/include/qt4 -I/usr/X11R6/include -pipe 
-O2 -w -D_REENTRANT cfgtest_phonon.cpp -o cfgtest_phonon -L/usr/lib 
-L/usr/X11R6/lib -Wl,--no-undefined -Wl,-rpath,/usr/lib -lphonon -lXext 
-lX11 -lm -lpthread
cfgtest_phonon.cpp:1:30: error: phonon/VideoWidget: No such file or 
directory

cfgtest_phonon.cpp: In function ‘int main(int, char**)’:
cfgtest_phonon.cpp:5: error: expected type-specifier before ‘Phonon’
cfgtest_phonon.cpp:5: error: expected `;' before ‘Phonon’

So, I patched line 367 as described in the original message about this 
issue:


-check_module("phonon", "Phonon/VideoWidget",
+check_module("phonon", "phonon/videowidget.h",
"new Phonon::VideoWidget()")

That seemed to fix that problem, but then I got this error:

Generating the C++ source for the phonon module...
"/usr/bin/sip" -k -o -P -x VendorID -t WS_X11 -x PyQt_NoPrintRangeBug -t 
Qt_4_4_1 -x Py_v3 -g -a phonon.api -c phonon -b phonon/phonon.sbf -I 
/home/m/installation_files/PyQt-x11-gpl-snapshot-4.7.1-106919e3444b/sip 
/home/m/installation_files/PyQt-x11-gpl-snapshot-4.7.1-106919e3444b/sip/phonon/phononmod.sip

sip: QVariantList is undefined
Error: Unable to create the C++ code.

I searched around for things related to QVariantList, but am very lost 
on this one. Any ideas?


Thanks.

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

Re: [PyQt] signals and dialogs

2010-03-02 Thread Scott Frankel


On Mar 2, 2010, at 11:56 AM,  wrote:

Your code is not going to work. You are trying to connect to a  
signal that has already been emitted. For this to work, you need to  
manually call emitSignal AFTER you create your Foo() Dialog.


Of course.  Thanks!







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


[PyQt] how to open a gui module?

2010-03-02 Thread patx
I have coded a GUI, in a .py... It is called foo.py. Then in another GUI,
bar.py, I need to be able to open/display/execute foo.py. So basically I
need to use the following:

self.connect(self.pb1, QtCore.SIGNAL('clicked()'),
self.open_foo)

So self.pb1 would be a PushButton and self.open_foo would be the function
that would open foo.py.


How would I do this?

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

Re: [PyQt] signals and dialogs

2010-03-02 Thread dcassidy36
Your code is not going to work. You are trying to connect to a signal that has 
already been emitted. For this to work, you need to manually call emitSignal 
AFTER you create your Foo() Dialog.

if dialog.exec_():
print "dialog executed"
dialog.emitSignal()

emitSignal()...
dialog executed
emitSignal()...
theString:  signal: this is foo

--
Regards,
 -Demetrius Cassidy

 Scott Frankel  wrote: 

=

Hi all,

How does one connect dialogs to a parent object to receive any signals  
they may emit?

This doesn't work:
dialog = Foo()
self.connect(dialog, QtCore.SIGNAL("foo(string)"), 
self.printString)

The attached code sample creates a dialog that emits a signal on  
init().  The main window tries to connect the dialog, receive the  
signal, and call its assigned slot.  Seems like it should work, but of  
course it doesn't.

I'm sure I'm overlooking something simple.  Thanks in advance!
Scott




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


[PyQt] signals and dialogs

2010-03-02 Thread Scott Frankel


Hi all,

How does one connect dialogs to a parent object to receive any signals  
they may emit?


This doesn't work:
dialog = Foo()
self.connect(dialog, QtCore.SIGNAL("foo(string)"), 
self.printString)

The attached code sample creates a dialog that emits a signal on  
init().  The main window tries to connect the dialog, receive the  
signal, and call its assigned slot.  Seems like it should work, but of  
course it doesn't.


I'm sure I'm overlooking something simple.  Thanks in advance!
Scott



#!/usr/bin/env python

import sys
from PyQt4 import QtCore, QtGui

class Foo(QtGui.QDialog):
	def __init__(self, parent=None):
		QtGui.QDialog.__init__(self)
		self.okButton   = QtGui.QPushButton(self.tr("OK"))
		self.okButton.setDefault(True)
		self.closeButton= QtGui.QPushButton(self.tr("Close"))
		self.formLayout = QtGui.QVBoxLayout()
		self.formLayout.addWidget(self.okButton)
		self.formLayout.addWidget(self.closeButton)
		self.setLayout(self.formLayout)
		self.connect(self.okButton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("accept()"))
		self.connect(self.closeButton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("close()"))

		self.emitSignal()


	def emitSignal(self):
		print "emitSignal()..."
		self.emit(QtCore.SIGNAL("foo(string)"), "signal: this is foo")



class MainWindow(QtGui.QMainWindow):
	def __init__(self):
		QtGui.QMainWindow.__init__(self)

		self.displayDialog()

	def displayDialog(self):
		dialog = Foo()
		self.connect(dialog, QtCore.SIGNAL("foo(string)"), self.printString)

		if dialog.exec_():
			print "dialog executed"


	def printString(self, theString):
		print "theString: ", theString



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








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

Re: [PyQt] Slider sender().value()

2010-03-02 Thread Gib Bogle

Russell Valentine wrote:

I would suggest sending a small example version of the code that just 
has enough code to show the problem you are talking about. You also 
might find the problem when making this small example.


I tracked this down.  The code (which I didn't write) uses the Qt Undo/Redo 
capability, but it obviously wasn't working perfectly.  When I disabled this 
feature in the code the slider problem went away.  I think Undo/Redo is a bridge 
too far.

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


Re: [PyQt] How to cast QStyleOption objects in PyQt4?

2010-03-02 Thread Phil Thompson
On Tue, 2 Mar 2010 17:01:26 +, Jugdish  wrote:
> How do I convert a QStyleOptionViewItem into a QStyleOptionViewItemV4? Qt
> has the qstyleoption_cast() method, but no such method exists in PyQt4.
> 
> I have my own subclass of QStyledItemDelegate and have overridden the
> initStyleOption() method so that I can provide my own
foreground/background
> colors, fonts, etc. The problem I'm running into is with the background
> color -- I need to set the backgroundBrush attribute, which is only
> available on QStyleOptionViewItemV4. So I need to somehow cast the
> QStyleOptionViewItem object into a QStyleOptionViewItemV4 object...
> 
> from PyQt4 import *
> 
> class MyItemDelegate(QStyledItemDelegate):
> 
> def initStyleOption(self, option, index):
> QStyledItemDelegate.initStyleOption(self, option, index)
> 
> # set font family and color
> option.font.setFamily("Courier")
> option.palette.setBrush(QPalette.Text, QtCore.Qt.red)
> 
> # set background color
> # this doesn't work:
> option.backgroundBrush = QBrush(QtCore.Qt.black)
> # neither does this:
> option = QStyleOptionViewItemV4(option)
> option.backgroundBrush = QBrush(QtCore.Qt.black)

Implemented in tonight's snapshot - but untested.

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


Re: [PyQt] How to cast QStyleOption objects in PyQt4?

2010-03-02 Thread Phil Thompson
On Tue, 2 Mar 2010 17:01:26 +, Jugdish  wrote:
> How do I convert a QStyleOptionViewItem into a QStyleOptionViewItemV4? Qt
> has the qstyleoption_cast() method, but no such method exists in PyQt4.
> 
> I have my own subclass of QStyledItemDelegate and have overridden the
> initStyleOption() method so that I can provide my own
foreground/background
> colors, fonts, etc. The problem I'm running into is with the background
> color -- I need to set the backgroundBrush attribute, which is only
> available on QStyleOptionViewItemV4. So I need to somehow cast the
> QStyleOptionViewItem object into a QStyleOptionViewItemV4 object...
> 
> from PyQt4 import *
> 
> class MyItemDelegate(QStyledItemDelegate):
> 
> def initStyleOption(self, option, index):
> QStyledItemDelegate.initStyleOption(self, option, index)
> 
> # set font family and color
> option.font.setFamily("Courier")
> option.palette.setBrush(QPalette.Text, QtCore.Qt.red)
> 
> # set background color
> # this doesn't work:
> option.backgroundBrush = QBrush(QtCore.Qt.black)
> # neither does this:
> option = QStyleOptionViewItemV4(option)
> option.backgroundBrush = QBrush(QtCore.Qt.black)

You can't at the moment, but I don't see any reason why it couldn't be
supported.

Watch this space...

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


Re: [PyQt] Help: packaging PyQt app

2010-03-02 Thread Scott Ballard




You need to include sip:

http://www.py2exe.org/index.cgi/Py2exeAndPyQt

from distutils.core import setup
import py2exe
setup(windows=[{"script":"main.py"}], options={"py2exe":{"includes":["sip"]}})
-Scott

On 3/2/2010 8:51 AM, Anshul Jain wrote:
I have made a very simple browser using Qwebview in PyQt.
Now i want to package it as an installer to distribute it. I have tried
out py2exe. But after i do the command:
  
  
  python setup.py py2exe
  
  
  and then try and run the .exe file created, i get an error, "no
module named sip found". please help me where am i going wrong. My
setup.py code is as follows:
  
  
  
  from distutils.core import setup
  
  
  setup(name = "Aura Browser",
        version = "0.1",
        description = "A tiny Web Browser",
        author = "Anshul kumar Jain",
        author_email = "ans...@seeta.in",
        url = ""true"
 href="http://seeta.in/j/team.html">http://seeta.in/j/team.html",
        packages = [""],
        data_files = [("browser/images", ["images/back.png",
                                          "images/home.png",
                                          "images/reload.png",
                                          "images/next.png",
                                          "images/stop.png",])]
        )
  
  
  the code has 'browser.py' as main file and a Qt python class
file 'httpWidget.py'
  
  
  Please help me sort out the problem.
  
  
  Thanks
  
  

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


__ Information from ESET NOD32 Antivirus, version of virus signature database 4909 (20100302) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

  



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

[PyQt] How to cast QStyleOption objects in PyQt4?

2010-03-02 Thread Jugdish
How do I convert a QStyleOptionViewItem into a QStyleOptionViewItemV4? Qt
has the qstyleoption_cast() method, but no such method exists in PyQt4.

I have my own subclass of QStyledItemDelegate and have overridden the
initStyleOption() method so that I can provide my own foreground/background
colors, fonts, etc. The problem I'm running into is with the background
color -- I need to set the backgroundBrush attribute, which is only
available on QStyleOptionViewItemV4. So I need to somehow cast the
QStyleOptionViewItem object into a QStyleOptionViewItemV4 object...

from PyQt4 import *

class MyItemDelegate(QStyledItemDelegate):

def initStyleOption(self, option, index):
QStyledItemDelegate.initStyleOption(self, option, index)

# set font family and color
option.font.setFamily("Courier")
option.palette.setBrush(QPalette.Text, QtCore.Qt.red)

# set background color
# this doesn't work:
option.backgroundBrush = QBrush(QtCore.Qt.black)
# neither does this:
option = QStyleOptionViewItemV4(option)
option.backgroundBrush = QBrush(QtCore.Qt.black)
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Help: packaging PyQt app

2010-03-02 Thread Anshul Jain
I have made a very simple browser using Qwebview in PyQt. Now i want to
package it as an installer to distribute it. I have tried out py2exe. But
after i do the command:

python setup.py py2exe

and then try and run the .exe file created, i get an error, "no module named
sip found". please help me where am i going wrong. My setup.py code is as
follows:

from distutils.core import setup

setup(name = "Aura Browser",
  version = "0.1",
  description = "A tiny Web Browser",
  author = "Anshul kumar Jain",
  author_email = "ans...@seeta.in",
  url = "http://seeta.in/j/team.html";,
  packages = [""],
  data_files = [("browser/images", ["images/back.png",
"images/home.png",
"images/reload.png",
"images/next.png",
"images/stop.png",])]
  )

the code has 'browser.py' as main file and a Qt python class file
'httpWidget.py'

Please help me sort out the problem.

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

Re: [PyQt] QAbstractItemModel's "dataChanged" signal not working?

2010-03-02 Thread Mark Summerfield
On 2010-02-27, Claudio Felix wrote:
> Hi everyone,
> 
> I'm using a QSqlRelationalTableModel for a simple dialog where I can
> add/delete periods related to a particular customer, which is chosen
> by a QComboBox. The periods table is filtered by customer (whose ID is
> a foreign key) and shown through a QTableView. There's an "Add" button
> which basically inserts a new row in the Periods table and sets the
> view to edit mode, so the period data can be entered:
> 
> def addRecord(self):
> row = self.model.rowCount()
> customerid = self._getRecordID(self.customerComboBox,
> self.customersModel, "CUSTOMER_ID")
> self.enableControls(False)
> self.model.insertRow(row)
> index = self.model.index(row, CUSTOMER_ID)
> self.model.setData(index, QVariant(customerid))
> index = self.model.index(row, PERIOD_YEAR)
> self.periodsTableView.setCurrentIndex(index)
> self.periodsTableView.edit(index)
> 
> I noticed that, while the view is in edit mode (with the asterisk '*'
> appearing in the leftmost field), if the user clicks on the add button
> again, an empty row appears in the view and the asterisk appears in
> the next row, with this message on the console:
> 
> edit: index was invalid
> edit: editing failed
> 
> The same problem happens in the "assetmanager.pyw" example from the
> (great!) book "Rapid GUI Programming with Python and QT", which is my
> main guide. That way, in my limited experience with PyQT, I tried to
> work around the undesirable behavior creating the method
> "enableControls" for the dialog, which is called in the addRecord
> method so it makes it impossible for the user to click on "add" again
> while the view is in edit mode. The idea then was to re-enable the
> controls when the data was finally committed by the view. That's when
> the main problem comes up. I tried to use the model's "dataChanged"
> signal for calling my "enableControls" method, but it looks like it
> never gets emitted, although the record does get written to the
> database table. Does anybody can confirm that or help me avoiding the
> problem at all? I used the following signature for the signal, exactly
> the same shown on QAbstractItemModel's documentation:
> 
> self.connect(self.model, SIGNAL("dataChanged(const QModelIndex&,const
> QModelIndex&)"), self.enableControls)
> 
> That line is declared in my dialog's __init__, along with all the
> other (working) signals. self.model referes to the
> QSqlRelationalTableModel.
> 
> Thanks for any help!

Hi Claudio,

I must admit that I've grown very frustrated with Qt's database support,
particularly with SQLite. I've found that the book's database examples
(which all use SQLite since that is supplied with Qt) exhibit varying
differences in behavior depending on the Qt version.

Regarding your specific problem, I can't see anything obviously wrong
with your connection. Personally, I would have written it as

self.connect(self.model, SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
 self.enableControls)

but that should make no difference.

Is your model a QSqlRelationalTableModel or a subclass? If it is a
subclass and you have reimplemented setData() then you must emit the
dataChanged() signal in your reimplemented setData() method. But if
you're using QSqlRelationalTableModel directly then it isn't obvious to
me what you're doing wrong. However, dataChanged() might be the wrong
signal for reenabling the Add button since it is emitted for every
change to every field, whereas I'd have thought you wanted to enable the
Add button only when the record was inserted? So maybe you could try
connecting to the QAbstractItemModel::rowsInserted() signal?

I had a quick go at changing assetmanager.pyw to do this but without
success (using PyQt 4.6 and Qt 4.5.2); maybe things have improved with
Qt 4.6.

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"C++ GUI Programming with Qt 4" - ISBN 0132354160
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Problem with KDialogButtonBox.addButton

2010-03-02 Thread Wolfgang Rohdewald
Hi,

how can I pass my own python slot to addButton?
 
def slotInsert(self):
  pass

newItem = KGuiItem(QString("&New"), KIcon("document-new"))
self.newButton = self.buttonBox.addButton(newItem, KDialogButtonBox.ActionRole, 
self, self.slotInsert)

TypeError: KDialogButtonBox.addButton(): arguments did not match any overloaded 
call:
  overload 1: argument 1 has unexpected type 'KGuiItem'
  overload 2: argument 1 has unexpected type 'KGuiItem'
  overload 3: argument 4 has unexpected type 'instancemethod'
  overload 4: argument 3 has unexpected type 'PlayerList'

This is KDE 4.4 with pyqt4 4.7.0

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