[PyKDE] Re: Problem finding and showing a record in a QDataBrowser

2005-08-09 Thread Jorge Godoy
Jorge Godoy wrote:

> I have created an interface where I have a QDataBrowser and all of its
> editing and navigating controls and one of the displayed controls is in a
> QSpinBox.
> 
> I have the navigation from current to next and previous records working
> fine if I only use the data browser controls.  I also can recover the
> correct record if I type in a valid code at the spin box.

Just to make the answer available to other that might have the same problem,
I had to deactivate the framework code and handle the cursor from the
databrowser manually.

It also fixed a performance problem since I only have one record fetched and
not all of them.  This makes the answer time linear (database dependant, of
course) no matter how many records I have on the database.

-- 
Jorge Godoy  <[EMAIL PROTECTED]>


___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Problem finding and showing a record in a QDataBrowser

2005-08-07 Thread Jorge Godoy

Hi.


I have created an interface where I have a QDataBrowser and all of its
editing and navigating controls and one of the displayed controls is in a
QSpinBox.

I have the navigation from current to next and previous records working fine
if I only use the data browser controls.  I also can recover the correct
record if I type in a valid code at the spin box.

For the spin box to work, I'm doing this:


def codAmostra_valueChanged(self, amostra_id):
cursor = self.dbAmostras.sqlCursor()
cursor.select('amostra_id=%s' % amostra_id)
self.dbAmostras.first()
self.dbAmostras.refresh()


(codAmostra is my spinbox, dbAmostras is my QDataBrowser -- just as a
curiosity, "amostra" is the pt_BR for "sample")

I was willing to use "self.dbAmostras.seek()", but it requires that I know
the exact position of the record -- using it I wouldn't need to filter my
data and I think the problem would be solved... -- but I don't know it. 

There can be "holes" in my sequence (otherwise I'd use only the spinbox) and
I'll be having a few million entries (what makes it impossible to go
through each and every record every time I change the value at the spinbox
manually).

I was reading Qt3 docs trying to find out some other mean to recover the
record I need without messing with the filter because if I use the filter,
then I can't paginate through all records anymore.

Any hints on an alternative approach that would allow me to use both
controls?


* Python 2.4
* SIP 4.1.1 (4.1.1-255)
* >>> qt.qVersion()
  '3.3.4'
  >>>


Thanks in advance,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>


___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Problems with QWidgetStack.raiseWidget()

2005-07-21 Thread Jorge Godoy

Hi,

I'm trying to write functions to cycle through the widgets created on a
widgetstack.  I can get their ID correctly, guess what the next widget's ID
should be but when I can the raiseWidget(int id) method it doesn't work.  A
code snippet with its output is included below, as well as program versions.
I appreciate any hints on what I might be doing wrong.

CODE:

def nextWidgetStack(self):
print 'List:', self.widgetstacksList
id = self.widgetStack1.id(self.widgetStack1.visibleWidget())
pos = self.widgetstacksList.index(id)
print 'Actual:', self.widgetstacksList[pos]
try:
next = self.widgetstacksList[pos + 1]
except IndexError:
next = self.widgetstacksList[0]
print 'Next:', next
print 'Widget Found:', self.widgetStack1.widget(next)
self.widgetStack1.raiseWidget(next)



OUTPUT (activated twice to show that nothing changes):

List: [1, 2, 3]
Actual: 3
Next: 1
Widget Found: None
List: [1, 2, 3]
Actual: 3
Next: 1
Widget Found: None



Versions:
   pyuic -version --> Python User Interface Compiler 3.13 for Qt version 3.3.4
   sip -V --> 4.1.1 (4.1.1-255)

   >>> import qt
   >>> qt.qVersion()
   '3.3.4'
   >>>  


Expected behaviour:
   Having widget with ID 1 raised on the widgetstack.


Thanks in advance,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>


___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: PyQT on Win32

2005-07-05 Thread Jorge Godoy
Edson Tadeu <[EMAIL PROTECTED]> writes:

> I'm trying to use PyQT on Windows, compiling the QT 3.3, sip 4.1.1 and PyQT 
> sources through the MinGW compiler. The problem is that the MinGW linker is 
> *very* slow and swaps a lot too (it was using 420Mb of VM)... I couldn't get 
> to compile it in less than 10 hours, then I cancelled the linkage. I've 
> managed to get the pre-compiled QT binaries, but couldn't find the binaries 
> for sip or PyQT, so what I'm asking is:
> 
> * Is there a way to link it faster and using less memory with MinGW tools 
> and maybe some changes in makefiles or ./configure parameters?
> 
> * Could someone that already done that provide the binaries, please?

If so, could this person also provide ODBC or PostgreSQL drivers for Qt as
well?  It would be *really* helpful to be able to integrate to a free database
(as in free speech and in free beer) and ODBC would allow integrating with
several other databases. 

One of the strongest points of Qt over other toolkits, besides its cleaness is
the easiness to integrate it with database servers.

This could be a vast field for GPL application replacing what is normally done
with Microsoft Access. 


-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: PyQt as a statically compiled shared library...

2005-06-14 Thread Jorge Godoy
"Truls A. Tangstad" <[EMAIL PROTECTED]> writes:

> So it's possible to create a single RPM usable on
> Fedora/SuSE/Mandrake? What about non-rpm systems like
> gentoo/slackware?
> 
> (I have no experience in packaging for non-debian systems)

They can install RPM as well.  There's a package of it for Slackware, IIRC.
They'll have to worry with dependencies, though.  And this is one of the
reasons that LSB adopted one standard...

> > This is a bad approach, IMHO.  It wastes a lot of resources since
> > the system won't be able to share already loaded libraries.  Besides
> > that, the size of your programs will also get very big, making it
> > harder to download...
> 
> Yes, I know the tradeoffs, but the most important thing is having an
> easy install that works for all systems.

I'd avoid using something like that, unless there's no other way to accomplish
something that I really need to...  But you have your reasons, of course. 

> One problem we would have is testing and specifying versions. One
> distribution might be very up to date, and provide libraries of
> version which we require, others might be too old, or even too new. If
> we stuff everything required into one package, all we should end up
> depending on is the libc/glibc (hopefully), but then again, we'd have
> to package in everything except the kitchen sink...

This is true...  But then, again, how big are you willing to make it?  I still
think that a dynamic package is better than a stactic one.  But that is just
my opinion and I don't really know what you have there.  It might be worth...


-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: PyQt as a statically compiled shared library...

2005-06-14 Thread Jorge Godoy
"Truls A. Tangstad" <[EMAIL PROTECTED]> writes:

> What we're aiming for now though is making installation easier for
> users on different linux systems to install our software without
> having to satisfy all dependencies manually.

Why don't you adopt the LSB way and uses RPM, as you did with DEB packages?
It is the easiest way.  And with Apt for RPM you can have the same
installation procedure in different Linux systems.

There are Apt repositories for all major distributions and you won't have to
worry with another dependency on your site... 

> My though (which might be naïve) is to compile statically linked
> binaries of the libraries/programs we directly depend on and then
> provide them together with our software, modifying
> LD_LIBRARY_PATH/PYTHONPATH on startup. Is it possible to create a
> qt.so (with friends) that is statically linked against all its
> dependencies, or is it a nightmare of manual labour?

This is a bad approach, IMHO.  It wastes a lot of resources since the system
won't be able to share already loaded libraries.  Besides that, the size of
your programs will also get very big, making it harder to download...

> Is there another approach which might be better for getting a
> no-brainer installation usable across linux distros of a pyqt program?
> (for example not requiring user to install pyqt first)

I'd use Apt with RPM.  And write the dependencies as generic as possible,
aiming a larger base.  

-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Translating UI files

2005-05-20 Thread Jorge Godoy
"Hihn, Jason" <[EMAIL PROTECTED]> writes:

> How does one go about translating UI files when apps are completely
> written in python with PyQt?

Run something like 

pyuic -p 4 -o file.py file.ui

This will create 'modules'.  Run something like 

pyuic -x -p 4 -o main.py main.ui

to create the main executable.

You'll have to subclass the modules to make changes since the files get
overwritten everytime they are regenerated.

> In my app I use QWidgetFactory to create a dialog from a ui file. I need
> to translate that, preferably without making a ui file for each
> language.


There's a method for handling and dealing with I18N and L10N.  Here on my box
the docs are at /usr/share/doc/packages/qt3/html/i18n.html and you should be
able to find them online at http://doc.trolltech.com/3.3/i18n.html


Be seeing you,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] SOLVED --> Re: Failing to set the text of comboboxes

2005-05-16 Thread Jorge Godoy
Jorge Godoy <[EMAIL PROTECTED]> writes:

> It is all working perfectly, except that when I need to come back from the
> database to the GUI it isn't accepting the 'setCurrentText()' command.  In
> fact, it accepts it, gives no error, but doesn't change the text in the
> comboboxes. 

OK.  I found the bug.

And it only happens when I associate the combobox with some field in the
database.  If I handle everything manually without connecting the combobox to
the databrowser it works perfectly.

Four days lost on this but I hope nobody else looses more time with that :-)

I believe that if I create some PropertyMap (I believe that's the name...) and
use it instead of the default map it might work.  Sometime later I'll give it
a try.


I'd also like to thank all the people that tried helping me with this problem
here on the news or with private messages, thanks guys.


So, if you can't use your comboboxes the way it is expected, remove the
references to the database and handle everything by hand.


Be seeing you,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Failing to set the text of comboboxes

2005-05-16 Thread Jorge Godoy
Torsten Marek <[EMAIL PROTECTED]> writes:

> if I try to use setCurrentText in a simple example, I do not observe any
> problems, the text just gets set.

If I do that, it works here too...  With editable comboboxes and with
duplicatesEnabled set to false, as I need it to work.

I was trying some combinations to see when it failed, but it worked with
everything I tried until I got in the situation that I need in the application
:-( The only variable that is missing is the database connection, but both
data -- the one that populates the combobox and the one that is used to set
the combobox text -- comes from the database and should be identical...

> And if not, can you produce a minimal program that displays your problem and
> send it in along with the versions of Python, Qt, sip and PyQt?

It works in a simpler test...  I'll have to triple check the application
code...


Thanks for your help.

-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Failing to set the text of comboboxes

2005-05-16 Thread Jorge Godoy
Torsten Marek <[EMAIL PROTECTED]> writes:

> Hi Jorge,

Hi Torsten.

> if I try to use setCurrentText in a simple example, I do not observe any
> problems, the text just gets set.
> Have you been able to track down the problem?
> And if not, can you produce a minimal program that displays your problem and
> send it in along with the versions of Python, Qt, sip and PyQt?

I'll try something like that.  I should have done that this weekend, but I had
to leave for a while or I'd get crazy with so many things to do...  :-)  It
was a nice weekend.  Hot for mid-autumn. 

Anyway, if what you suggested below doesn't work, I'll do that.  But I haven't
done anything too complicated.  What I've done is:

- connect to the database
- retrieve the information I want to show
- populate the combobox, using a loop ('while query.next(): ...')
- trap the currentChanged signal from the dataBrowser and selecting
  trying to set the item on the combobox to the correct value

If I print debug messages they show the correct value, but the item doesn't
change on screen.

> Maybe you should first call insertItem(..) and then setCurrentItem(...)?

I haven't tried that because the items already exist there.  They were
retrieved from a database and populated the comboboxes when it was
instantiated.  I have disallowed inserting duplicate items, so it might
work...  I'll give it a try right now.  (time passes)  It didn't work.  I'll
try coming up with a simple example in one file only.  I'll be posting it in a
few minutes.


Thanks for your help!
-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Failing to set the text of comboboxes

2005-05-13 Thread Jorge Godoy
Jorge Godoy <[EMAIL PROTECTED]> writes:

(...)

> It is all working perfectly, except that when I need to come back from the
> database to the GUI it isn't accepting the 'setCurrentText()' command.  In
> fact, it accepts it, gives no error, but doesn't change the text in the
> comboboxes. 
> 
> My code is like this:
> 
> 
> def dbExams_currentChanged(self, record):
> code = record.value('code').toString()
(...)
> self.cbCode.setCurrentText(code)

I also tried this variation without success:

code = registro.value('code').toString()
for i in xrange(self.cbCode.count()):
if self.cbCode.text(i) == code:
self.cbCode.setCurrentItem(i)
break

> Is there any method to find the index position for some given text that I
> could use to try showing the desired item?

The attempt above was a way to achieve that...  I don't know if it is the best
or not, but it didn't work.

-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Failing to set the text of comboboxes

2005-05-13 Thread Jorge Godoy

Hi!


I have some comboboxes with some items in it, I allow them to be edited and I
disallowed having duplicate items on them, so that if the text the user inputs
already exists then it is used by the program instead of having a new item.

It is all working perfectly, except that when I need to come back from the
database to the GUI it isn't accepting the 'setCurrentText()' command.  In
fact, it accepts it, gives no error, but doesn't change the text in the
comboboxes. 

My code is like this:


def dbExams_currentChanged(self, record):
code = record.value('code').toString()
relatnum = record.value('unidaderelatnum').toString()
relatden = record.value('unidaderelatden').toString()
equipnum = record.value('unidadeequipnum').toString()
equipden = record.value('unidadeequipden').toString()
self.cbCode.setCurrentText(code)
self.cbRelatNum.setCurrentText(relatnum)
self.cbRelatDen.setCurrentText(relatden)
self.cbEquipNum.setCurrentText(equipnum)
self.cbEquipDen.setCurrentText(equipden)


This is activated by a handler created with KDevDesigner.  This piece of code
gets called, but doesn't change the text on the GUI and I get no errors at
all. 

cbCode, cbRelatNum, cbRelatDen, etc. are comboboxes.

As an example, the code generated by pyuic for cbCode is:


self.cbCode = QComboBox(0,self.dbExames,"cbCode")
self.cbCode.setGeometry(QRect(120,0,330,23))
self.cbCode.setEditable(1)
self.cbCode.setAutoCompletion(1)
self.cbCode.setDuplicatesEnabled(0)


Should I be doing something else?

Is there any method to find the index position for some given text that I
could use to try showing the desired item?



Be seeing you,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>


___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using comboboxes indexes for referencing data

2005-05-10 Thread Jorge Godoy
Jim Bublitz <[EMAIL PROTECTED]> writes:

> The easiest way would be to simply maintain a separate list:
> 
> X = ['a', '','', 'b', 'c','', 'd']
> 
> where the position in the list is your index (if the range of your index 
> values makes that reasonable to do; for example, fill a list with null 
> strings and then put the values in the positions where they belong).
> 
> Then just load/reload the combo box as needed (initially, when the list 
> changes, etc):
> 
> comboBox.clear ()
> for item in X:
> if item:
> comboBox.insertItem (item)
> 
> Then all you need to do with the user's selection is:
> 
> choiceIndex = X.index (comboBox.currentText ())
> 
> and you have its index value from the original list.

This would add blanks in the middle of the combobox items.  It isn't that
elegant, specially if something has index 0 and another thing has index 50 or
1000.  I could eliminate those blank spaces, when inserting, but it looks like
something that isn't all that clean. 

> That may not be an extremely efficient way to do it if the contents of the 
> list changes often, or the list is extremely long (in which case, a combo box 
>  
> probably isn't a good choice anyway).

It is acceptable in this case, but definitely it won't last forever. :-)
There are, on the other hand, other restrictions such as screen size and the
amount of information I need to display and this seemed to be the best option
to show everything.

> dicts add the problem of maintaining a sort order if that's important to your 
> application, but they'd probably be easier if the range of your index values 
> is large or they make some other part of the app easier to write.

I can ask Qt to sort items for me in some particular way and that will do it.
It doesn't matter to me the order of insertion, alphabetical order makes more
sense in 99% of the cases, so if I need something different I can do the work
by hand in that 1%...

> Subclassing would be similar, except the list or dict would be internal to 
> the 
> QComboBox subclass.

This is what I was thinking.  Then I'd have to handle some changes on
QSqlPropertyMap as well to get the right property in an automatic way...  

I'll have to take a look at this.

> Without knowing the details of the application, it's hard to be more specific.

Hey!  Leave some of the fun to me. :-)  I just want some hints, not that you
do the work for me :-)  I'm still learning and seeing how experienced people
do that is, IMHO, the best way.

Thank you very much for your help!  I'll see what I can get from here.

-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using comboboxes indexes for referencing data

2005-05-10 Thread Jorge Godoy
Jesper Anderson <[EMAIL PROTECTED]> writes:

> On Tue, May 10, 2005 at 06:44:07PM -0300, Jorge Godoy wrote:
> > Jim Bublitz <[EMAIL PROTECTED]> writes:
> > 
> > > In the case of QComboBox, "index" refers to an item's position in the 
> > > combo 
> > > box's list of items. The list of items is a list of strings.
> > 
> > Pity. :-(  I was happy thinking I could do that as with wxPython. 
> 
> Like this one?
> 
> http://www.opendocspublishing.com/pyqt/index.lxp?lxpwrap=x2976%2ehtm#AEN3160

If you mean something like example 10-10, it looks like that. :-)  Thanks for
the link!  I'll see what I can do with this and with Jim's comments.


Be seeing you,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using comboboxes indexes for referencing data

2005-05-10 Thread Jorge Godoy
Jim Bublitz <[EMAIL PROTECTED]> writes:

> In the case of QComboBox, "index" refers to an item's position in the combo 
> box's list of items. The list of items is a list of strings.

Pity. :-(  I was happy thinking I could do that as with wxPython. 

> There are a number of ways to do what you want, but they would be things like 
> maintaining a separate data structure which maps items and (your) index 
> values, or subclassing QComboBox to do that for you automatically. The 
> implementation would depend a lot on your application.

I'll have to take a look at this.  For now, all cases contained unique values,
so I could get the text and find the correct reference to it, but I would
really like having this possibility.

Do you think that using a dict would be enough?  The key would be the position
in the combobox and the value would be what I want (either another number or
some text).  I think it would be enough...

Subclassing QComboBox, on the other hand, might be interesting if I can make
this subclass behaves like a combobox with KDevDesigner.


Thanks for you help, Jim.


Be seeing you,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Using comboboxes indexes for referencing data

2005-05-10 Thread Jorge Godoy

Hi,


I'm using some comboboxes in an application and I'd like to know if there's
some way to use both information it contains simultaneously:

- text
- index

I'd like to show the text and to make the index contain a reference to other
stuff.  It works great if my data has no holes in it, but I get the following
message if I try to insert a record with index 0 and a second record with
index 3:

QComboBox::insertItem: (cbCodigo) Index 3 out of range

I used to work that way with wxPython and I'd really like to maintain some
logic with pyQt.

Is it possible or not?  Docs doesn't mention anything at all about that.



TIA,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>


___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: RPM packages for RHEL AS 3

2005-05-09 Thread Jorge Godoy
Ken Godee <[EMAIL PROTECTED]> writes:

> Check out the sourceforge project "KDE for Red Hat" at ...
> 
> http://kde-redhat.sourceforge.net/
> 
> They have a yum repository for Rhel 3.0 at
> 
> http://apt.kde-redhat.org/apt/kde-redhat/3.0/stable/RPMS/
> 
> It includes
> Qt,PyQt,PyKDE,eric,qscintilla and much more.
> 
> I have not used it yet, but will be in next week or two.

Sorry for the long delay...  I got a little busy here.

These worked, but I had to install a package manually from the CDs
(gdk-pixbuff) because it wasn't in the Apt repositories. :-)


Thanks for your help!

-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] RPM packages for RHEL AS 3

2005-04-29 Thread Jorge Godoy

Hi there!


Anyone using pyQt with RHEL AS 3?  It has KDE 3.1.3 and Python 2.2.3...  We
were going to do an in house application and we'd like to use pyQt for it, but
I found no package and I wasn't willing to install compilation tools on a
production server...


Thanks in advance,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>


___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Manipulating a QSqlRecord in a primeInsert handler

2005-04-28 Thread Jorge Godoy
Jorge Godoy <[EMAIL PROTECTED]> writes:

> Is there something else I should be doing?  Is it the correct way to handle
> this kind of thing to create a new button to get the correct ID and then use
> the 'Insert' button to make the insertion on the database?

OK, answering myself...


Contradicting one of the docs --
http://doc.trolltech.com/3.3/designer-manual-8.html -- but following the Qt
documentation (both should say the same thing, but...) I had to use the
'beforeInsert' handler instead of the 'primeInsert'.  At least with pyQt.  I
don't know if it works correctly with a C++ program, but I suspect it does.
(I suspect why pyQt doesn't work, but I'm not sure.  I think it isn't
expecting a return value and is discarding the changes.  I dunno how to make
it work in the same way -- and scope -- that the C++ version does...)

On the other hand, this brought me a new problem: (py?)Qt decides for itself
what SQL command to generate, no matter what button I click.  If I have some
data on the screen, change it and click 'Insert', it generates an UPDATE SQL
instruction.  If the cursor is positioned in an invalid position, though, the
INSERT SQL instruction is generated correctly.

This causes me a problem because there are redundant actions for both 'Insert'
and 'Update' buttons that are automatically generated by Qt Designer (actually
KDevDesigner)...  

I'm doing the insertion in two 'superposing' methods: first I position the
cursor in an invalid position with the 'New Record' button I had to add and
then I insert it into the database with the 'Insert' button KDevDesigner
created for me... 


Should I remove the 'Update' button and keep just the 'Insert' one?  Or is
this a bug somewhere?  Should I be doing the insertion in two handlers?  I'll
be "playing" more with this today...



Thanks in advance for any hints,
-- 
Jorge Godoy  <[EMAIL PROTECTED]>

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Manipulating a QSqlRecord in a primeInsert handler

2005-04-27 Thread Jorge Godoy

Hi, 


I'm trying to use a QDataBrowser to browse and manipulate some records.  The
problem is that I'm not being able to set a new ID before inserting the record
and it is overwriting the only record available all the time.

My table structure -- this is a PostgreSQL database -- is:

symbol -> varchar(9)
name   -> varchar(30)
id -> serial


My "primeInsert()" handler is:


def dbGetNewUnitsID(self, record):
query = QSqlQuery("SELECT NEXTVAL('units_id_seq')")
query.execQuery()
query.first()
record.setValue('id', query.value(0))


It gets invoked correctly, it even executes the query, but it doesn't insert
the record as part of the transaction after getting the new ID.

Is there something else I should be doing?  Is it the correct way to handle
this kind of thing to create a new button to get the correct ID and then use
the 'Insert' button to make the insertion on the database?


Thanks in advance,

-- 
Jorge Godoy  <[EMAIL PROTECTED]>


___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Painting one cell of a table

2005-03-05 Thread Jorge Godoy

Hi,


I'm trying to paint one cell in a table but the result is put on the wrong
place.  My code is:


row = 2
col = 2

cg = QColorGroup()
cg.setColor(QColorGroup.Base, Qt.red)

cr = self.table1.cellGeometry(row, col)
#cr = self.table1.cellRect(row, col)

print cr.x(), cr.y()

painter = QPainter(self.table1)

self.table1.paintCell(painter, row, col, cr, False, cg)


If I use cellGeometry the print statement shows "200 40".  If I use cellRect
it shows "0 0".  It doesn't matter with which one, the red cell appears at
position 0, 0 and the table is drawn over it.  How can I make the red cell
appears at the row and col given?

I have already tried with QTableItem and the result is the same:

currentItem = self.table1.item(row, col)
currentItem.paint(painter, cg, cr, False)


This message talks about the same problem, but had no answer:
http://lists.trolltech.com/qt-interest/2004-03/thread00108-0.html



Thanks for any hints,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Qstring problem

2005-03-01 Thread Jorge Godoy
FlÃvio CodeÃo Coelho <[EMAIL PROTECTED]> writes:

> My question is how do I get the string so that I can convert it to int?

FlÃvio,


Have you tried "str(QLineEdit.text())"? 


It works here, since QString has an __str__ method.


>>> QString('123')
<__main__.qt.QString object at 0x4039983c>
>>> int(QString('123'))
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: int() argument must be a string or a number
>>> int(str(QString('123')))
123
>>>


Atà mais,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: "Joining" two Databrowsers / Dataviews on Designer

2005-02-28 Thread Jorge Godoy
Jorge Godoy <[EMAIL PROTECTED]> writes:

> I have a database where the information that I need to present the user is
> spread in more than one table.  Is there some way to join this table with
> another in a mix of one databrowser and one dataview (or two databrowsers)? 

Answering myself with a link that was in my bookmarks and I forgot it existed: 

http://web.mit.edu/qt_v3.3.3/www/designer-manual-8.html


Be seeing you,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] "Joining" two Databrowsers / Dataviews on Designer

2005-02-27 Thread Jorge Godoy

Hi.


I have a database where the information that I need to present the user is
spread in more than one table.  Is there some way to join this table with
another in a mix of one databrowser and one dataview (or two databrowsers)? 

I need the information to be sync'ed and I have one field that joins then (the
PK of one table is the FK in another).

I'll need that for three and maybe four tables as well, so I was willing
something that could be handled with Qt Designer. 

Actually, I think I need one way to reference fields from one table into
another one that is used by QDataBrowser or QDataView.


I am trying to avoiding using a view + a rule...


Any hints would be appreciated.


Be seeing you,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using QSqlQuery + bindValue = TypeError ?

2005-02-27 Thread Jorge Godoy
Jorge Godoy <[EMAIL PROTECTED]> writes:

> I'll check my query again...  But one difference is that I used triple quotes
> for multiline commands and you didn't. 

It seems, indeed, that multiline is the problem.  I simply added quotes on
every line and it worked.  This is also something that is weird...


Thanks for all your help on this sunny and hot Sunday. :-)


Be seeing you,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using QSqlQuery + bindValue = TypeError ?

2005-02-27 Thread Jorge Godoy
Hans-Peter Jansen <[EMAIL PROTECTED]> writes:

> Just mangle one of the SQL examples, that comes with Qt...

I think it won't be necessary.  Your code works here, so it is not a Qt
issue. 

> You can't use the Python DB API syntax, since it's completely bypassed 
> with Qt SQL. I was talking about the usual Python string syntax, but 

That's what I thought: I can't use it because I'm using a Qt abstraction.

> you're right, you have to handle the quoting yourself in this case.

Yep.  I'm not going into this.  I'd use an alternative without the SQL layer
of Qt if I had to do that.  It would leave me worried on each and every error
or database problem.

It won't be worth it.

> BTW, I just checked your problem with the attached script, MySQL, and 
> a database as defined as in testdb_mysql.sql from PyQt/examples3/SQL 
> without such problems.

Weird.  It worked here too.

I'll check my query again...  But one difference is that I used triple quotes
for multiline commands and you didn't. 

Changing that on your code also made no difference and worked.

There must be, then, something on my code that is preventing that from
working.  I'll check it and I'll post here if I find out what it is.

> Python version: 2.3+

Python 2.3.4

> sip version: 4.2

sip 4.1.1.

> Qt version: 3.2.1

Qt 3.3.4

> PyQt version: 3.14

PyQt 3.13.

> MySQL version: 4.0.21

I'm using PostgreSQL here, both 7.4.6 and 8.0.1. 

> Cheers,
> Pete


Thanks for the help, Pete.


Be seeing you,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using QSqlQuery + bindValue = TypeError ?

2005-02-27 Thread Jorge Godoy
Hans-Peter Jansen <[EMAIL PROTECTED]> writes:

> You may try to reproduce this behaviour within a minimal Qt example, 
> since I would suspect this problem there.. PyQts cover is just to 
> thin to mangle the results in such a way ;-)

I'll try and see if I remember enough C++ for that (hey! it's been more than 5
years that I don't write C or C++ code, thanks to Perl and Python ;-))

> Anyway, I would go the pythonic way by using %s or in more complex 
> situations dictionary referencing: %(senha)s with python strings..

The problem here is loosing the "auto-quoting" facility.  I'd have to check
the string to see if there's no single quote inside it or anything else that
can be used to trick the DB and do something that is not allowed. 

Letting the driver quote everything I don't have to worry with that.  At
least, everything used to be correct with both pypgsql and psycopg when I used
to use wxPython for this application.


OR, did I misunderstand you and PyQt will auto-quote things correctly if I use
the DB API syntax?


Thanks again,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using QSqlQuery + bindValue = TypeError ?

2005-02-27 Thread Jorge Godoy
Phil Thompson <[EMAIL PROTECTED]> writes:

> It could be implemented, but I don't think the benefits outweigh the added 
> complexity.

If it's too complex, adding a note on the docs should be enough.  Today they
don't mention it is needed and they say that the implementation is fully
compliant with Qt's. 


Thanks,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using QSqlQuery + bindValue = TypeError ?

2005-02-27 Thread Jorge Godoy
Hans-Peter Jansen <[EMAIL PROTECTED]> writes:

> Try:
> query.bindValue(":senha", QVariant(senhaNova))

I found out that this also don't work.  The binding variable isn't removed
from the query when it is sent to the database and it also fails.  If I use
"?" as a positional placeholder, the query is completed sucessfully.

Is it a bug too?

There's no mention that this is an exclusive option on the docs, they say that
I can use either the position or the name to bind values.


Thanks,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using QSqlQuery + bindValue = TypeError ?

2005-02-27 Thread Jorge Godoy
Hans-Peter Jansen <[EMAIL PROTECTED]> writes:

> On Sunday 27 February 2005 14:37, Jorge Godoy wrote:
> >
> > But I keep always getting the following error message:
> >
> > query.bindValue(":senha", senhaNova)
> > TypeError: argument 2 of QSqlQuery.bindValue() has an invalid type
> 
> Try:
> query.bindValue(":senha", QVariant(senhaNova))
> 
> Phil, Qt is able to cast such stuff automatically, IIRC. Why can't 
> PyQt do this for us, too?
> 
> Pete

OK...

I'm back ;-)

Shouldn't the binding variables be removed?  My PostgreSQL is getting:

Feb 27 11:26:43 wintermute postgres[20529]: [5545-2] ^ISET Senha 
=:senhasistema'teste2'

And is aborting. 

Feb 27 11:26:43 wintermute postgres[20529]: [5545-6] LOCATION:  pg_parse_query, 
postgres.c:464
Feb 27 11:26:43 wintermute postgres[20529]: [5546-1] ERROR:  42601: syntax 
error at or near ":" at character 48
Feb 27 11:26:43 wintermute postgres[20529]: [5546-2] LOCATION:  yyerror, 
scan.l:573


Anything else seems to be wrong.

Any other hints? 


Thanks,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Re: Using QSqlQuery + bindValue = TypeError ?

2005-02-27 Thread Jorge Godoy
Hans-Peter Jansen <[EMAIL PROTECTED]> writes:

> On Sunday 27 February 2005 14:37, Jorge Godoy wrote:
> >
> > But I keep always getting the following error message:
> >
> > query.bindValue(":senha", senhaNova)
> > TypeError: argument 2 of QSqlQuery.bindValue() has an invalid type
> 
> Try:
> query.bindValue(":senha", QVariant(senhaNova))
> 
> Phil, Qt is able to cast such stuff automatically, IIRC. Why can't 
> PyQt do this for us, too?
> 
> Pete

Thanks, Pete.

It works now.  And yes, Qt does that automatically -- at least that's what in
all examples I've seen while googling for an answer and also on the docs
(even though they don't mention that explicitly).


Now I have to check the database logs and find out why the query wasn't
commited ;-)


Thanks for your help.
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] Using QSqlQuery + bindValue = TypeError ?

2005-02-27 Thread Jorge Godoy

Hi!


I'm trying to use a QSqlQuery and then supply the values with bindValue but it
isn't working.

I read my values from a QLineEdit with

senhaNova = self.txtNovaSenha.text()

and then I create the query

query = QSqlQuery ()
query.prepare("UPDATE usuarios SET senha=:senha")

after that I try binding the value

query.bindValue(":senha", senhaNova)

and, finally, executing the query

query.execQuery()


But I keep always getting the following error message:

query.bindValue(":senha", senhaNova)
TypeError: argument 2 of QSqlQuery.bindValue() has an invalid type


Doing a "print type(senhaNova)" I get  as the
result. 

What am I doing wrong?


Thanks in advance,
Godoy.

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde