Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Chris Withers

Phil Thompson wrote:

On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
wrote:

A bit nasty, since I see (and follow) lots of examples that say:
from PyQt4.QtCore import *

This redefines the builtin hex.


Check the Roadmap.


Appending a _ just to make an unpleasant style of programming work seems 
like a pretty silly idea.


I, along with everyone else who's tryng to learn a new python package, 
absolutely *hate* from x import * as it makes it much more difficult 
figure out where something is coming from.


I did raise this with David when this very issue tripped me and a number 
of other people up at the PyConUK tutorial last year.


If this were done sanely, you'd likely have:

from PyQt4.QtCore import hex

...somewhere, which, if it's causing problems, can easilly be changed to:

from PyQt4.QtCore import hex as qt_hex

Or, if you don't want do have a load of import statements, you can use 
the style that xlrd seems to prefer:


from PyQt4 import QtCore
...
QtCore.hex(...)

Either way, you end up knowing where stuff if coming from...

cheers,

Chris (who's still putting off using PyQt as he's dreading fighting his 
way through a load of *'s)


--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Giovanni Bajo
On mer, 2009-01-07 at 09:26 +, Chris Withers wrote:
 Phil Thompson wrote:
  On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
  wrote:
  A bit nasty, since I see (and follow) lots of examples that say:
  from PyQt4.QtCore import *
 
  This redefines the builtin hex.
  
  Check the Roadmap.
 
 Appending a _ just to make an unpleasant style of programming work seems 
 like a pretty silly idea.
 
 I, along with everyone else who's tryng to learn a new python package, 
 absolutely *hate* from x import * as it makes it much more difficult 
 figure out where something is coming from.

So don't use it.

This has been discussed thousands of times and it starts getting
annoying. There are many people (including myself and all our customers)
that simply love using star-imports with PyQt, since the leading Q* on
most symbols is already a clear enough indication of where the symbol is
coming from.

Appending the underscore to those symbols is a perfect fix IMO. I don't
see why people that don't use star-imports in the first place should
care about it at all.
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


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


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Chris Withers

Phil Thompson wrote:

This has been discussed thousands of times and it starts getting
annoying. 
Yes, it is annoying that all the example code continues to be in a form 
that confuses users trying to learn PyQt.


*None* of the PyQt4 examples uses star imports.


Hmmm, apologies then, must have been exclusively a problem with Mark 
Summerfield's tutorial stuff.


(and in my previous mail when I said David I actually meant Mark, 
happy new year ;-) )


FWIW, I still think sticking a _ on the end of the name is silly...

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Giovanni Bajo
On mer, 2009-01-07 at 10:33 +, Chris Withers wrote:
 However, like most people, I learn by example, and when the examples 
 contain exclusively start imports, they are much less helpful than
 they could be.

I don't understand you. Are you really saying that it's harder to
understand that QListBox or QVariant is part of PyQt4 because it's not
prefixed by QtGui. or QtCore.?
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com


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


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Adeodato Simó
* Giovanni Bajo [Wed, 07 Jan 2009 11:06:09 +0100]:

 Appending the underscore to those symbols is a perfect fix IMO.

I realize this is a matter of preference, but I'd suggest using qbin()
and qhex() rather than the underscore: I think it makes more sense for
stuff that can be imported into the global namespace (as opposed to
stuff as exec_() that can only be attached to an object).

If you see in the middle of a program hex_(foo), you may wonder where
that came from, whereas qhex(foo) is going to be rather obvious.

Of course, do what you think it's best. :-)

-- 
Adeodato Simó dato at net.com.org.es
Debian Developer  adeodato at debian.org
 
- I love you, Shirley, I'm not ashamed to say.
- If you love me, then you'll want me to be happy. Even if I'm not with you.
- I don't love you that much.
-- Denny Crane and Shirley Schmidt

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


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Phil Thompson
On Wed, 07 Jan 2009 10:33:00 +, Chris Withers ch...@simplistix.co.uk
wrote:
 Giovanni Bajo wrote:
 On mer, 2009-01-07 at 09:26 +, Chris Withers wrote:
 Phil Thompson wrote:
 On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
 wrote:
 A bit nasty, since I see (and follow) lots of examples that say:
 from PyQt4.QtCore import *

 This redefines the builtin hex.
 Check the Roadmap.
 Appending a _ just to make an unpleasant style of programming work
seems

 like a pretty silly idea.

 I, along with everyone else who's tryng to learn a new python package, 
 absolutely *hate* from x import * as it makes it much more difficult 
 figure out where something is coming from.
 
 So don't use it.
 
 You rather miss my point.
 
 I don't ever use star imports anyway.
 
 However, like most people, I learn by example, and when the examples 
 contain exclusively start imports, they are much less helpful than they 
 could be.
 
 It's a shame PEP8 doesn't make a pronouncement on this. PEP 328 is 
 pretty clear though...
 
 This has been discussed thousands of times and it starts getting
 annoying. 
 
 Yes, it is annoying that all the example code continues to be in a form 
 that confuses users trying to learn PyQt.

*None* of the PyQt4 examples uses star imports.

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


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Chris Withers

Giovanni Bajo wrote:

On mer, 2009-01-07 at 09:26 +, Chris Withers wrote:

Phil Thompson wrote:

On Tue, 06 Jan 2009 14:19:50 -0500, Neal Becker ndbeck...@gmail.com
wrote:

A bit nasty, since I see (and follow) lots of examples that say:
from PyQt4.QtCore import *

This redefines the builtin hex.

Check the Roadmap.
Appending a _ just to make an unpleasant style of programming work seems 
like a pretty silly idea.


I, along with everyone else who's tryng to learn a new python package, 
absolutely *hate* from x import * as it makes it much more difficult 
figure out where something is coming from.


So don't use it.


You rather miss my point.

I don't ever use star imports anyway.

However, like most people, I learn by example, and when the examples 
contain exclusively start imports, they are much less helpful than they 
could be.


It's a shame PEP8 doesn't make a pronouncement on this. PEP 328 is 
pretty clear though...



This has been discussed thousands of times and it starts getting
annoying. 


Yes, it is annoying that all the example code continues to be in a form 
that confuses users trying to learn PyQt.



There are many people (including myself and all our customers)
that simply love using star-imports with PyQt, since the leading Q* on
most symbols is already a clear enough indication of where the symbol is
coming from.


What you and/or your customers do in the privacy of your own homes and 
offices is none of my concern ;-)



Appending the underscore to those symbols is a perfect fix IMO. I don't
see why people that don't use star-imports in the first place should
care about it at all.


Because it looks butt ugly for no reason.

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Chris Withers

Neal Becker wrote:
If the pyqt examples did not use *, and if you could import a useful enough 
subset without doing that, I'd agree.  If the suggestion is to explicitly 
qualify everything, I don't think that's reasonable.


Yes, python, well know for believing that implicit is better than 
explicit ;-)


Chris . o O ( import this )

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Mark Summerfield
On 2009-01-07, Chris Withers wrote:
 Phil Thompson wrote:
  This has been discussed thousands of times and it starts getting
  annoying.
 
  Yes, it is annoying that all the example code continues to be in a form
  that confuses users trying to learn PyQt.
 
  *None* of the PyQt4 examples uses star imports.

 Hmmm, apologies then, must have been exclusively a problem with Mark
 Summerfield's tutorial stuff.

I have now switched to a new style for imports, for example:

from PyQt4.QtCore import (PYQT_VERSION_STR, QFile, QFileInfo, QSettings,
QString, QT_VERSION_STR, QTimer, QVariant, Qt, SIGNAL)
from PyQt4.QtGui import (QAction, QActionGroup, QApplication,
QDockWidget, QFileDialog, QFrame, QIcon, QImage, QImageReader,
QImageWriter, QInputDialog, QKeySequence, QLabel, QListWidget,
QMainWindow, QMessageBox, QPainter, QPixmap, QPrintDialog,
QPrinter, QSpinBox)

This avoids importing confusing junk while still allowing you to write
nice things like:

action = QAction(Action)

The disadvantage is that you keep having to extend the lists of imports
as you develop and maintain your code.

I don't want to change this for the book's examples because I want them
to exactly match the text---although actually, the only change is to the
imports, the use of the classes is unchanged. However I've done a
separate set of Python 2.6 versions of the examples and these use the new
import style.

 FWIW, I still think sticking a _ on the end of the name is silly...

Yes, but it has precedents in PyQt already, e.g. QApplication.exec_().


 (and in my previous mail when I said David I actually meant Mark,
 happy new year ;-) )

Understandable since David is a much more regular poster than I am:-)

-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
Programming in Python 3 - ISBN 0137129297

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


[PyQt] ANN: eric4 4.2.5 available

2009-01-07 Thread Detlev Offenbach
Hi,

a bug fix release of the stable eric4 line is available on 
http://eric-ide.python-projects.org/index.html.

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


Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Sundance
Adeodato Simó wrote:

If you see in the middle of a program hex_(foo), you may wonder where
that came from, whereas qhex(foo) is going to be rather obvious.

Greetings all,

Might I humbly second this motion? I do understand the usual 
reservations about star-imports (being the kind of guy that often gets 
to debug other people's work...), but I also do appreciate the relative 
ease of getting away with it in PyQt's case, thanks to the prevalence of 
the Q prefix in its class names and its relative absence of module-level 
functions.

With this in mind, using the same prefix for the three problematic 
functions makes good sense to me. Are there reservations about this 
approach that I may not be aware of?

Ta,

-- S.

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


Re: [PyQt] Making application look more sexy

2009-01-07 Thread Marc Nations
That is an awesome looking app!

In the past I've been able to overcome a lot shortcomings with gui toolkits
with a healthy use of images. Even when I was using TkInter and the look was
extremely outdated I was able to mask it by basically replacing as much as
possible with foreground and background images. There are tons of free
icon/image websites to choose from so that you don't have to spend a bunch
of time building them.

If you are interested in building them you can use apps like PowerPoint to
create glossy looking buttons and backdrops. Gimp does some of this also,
but takes a little bit longer. I'm not much of an artist, so I just like to
go grab stuff I think looks nice.

I don't know why some are so resistant to creating an app with a better
look/feel. While I agree that it's difficult sometimes to balance useability
with a new look, the first thing people are going to see is the nice coat
of pain, not the engine. And first appearances go a long way when people are
trying out software. Assuming it's also easy to use, then it can give you an
edge when compared with other apps.

Btw, I still haven't figured out how to use an image as a background in
PyQt4 without it automatically texturing. I'd like to use an image in a 1:1
ratio with the size of the widget you apply it to, but used in the
background so that text and widgets can be placed over it. If I try and
scale it, you get the texturing. If I don't scale it, it just shows up in
it's natural size which you'd have to manually set and then lock the app
down with no resizing, obviously that's not a good solution. Anyone know how
to do this?



2009/1/6 Gustavo A. Díaz gustavo.d...@gmail.com

 Hi,

 I use purely Stylesheets+images in my App:

 http://opencoffee.lnxteam.org/trac/opencoffee/wiki/ScreenShots

 Cheers.



 2009/1/5 Reinaldo de Carvalho reinal...@gmail.com

  On Sun, Jan 4, 2009 at 7:08 PM, Filip Gruszczyński grusz...@gmail.com
 wrote:
  I guess many of us know the term 'programmers art'. I am well aware of
  it, so I am avoiding as much as it's possible touch stylesheets and
  trying to work on them myself. I would like, however, to make my
  application look better. Maybe you know some simple tricks or know
  some good style plugins, that I could use?
 

 If do you use a pure-gnome-system (wo/ kdelibs) its can to be usefull:

 http://tombuntu.com/index.php/2008/02/11/theme-qt3-applications-in-gnome

  --
  Filip Gruszczyński
 

 --
 Reinaldo de Carvalho
 http://korreio.sf.net (Now available in English)
 http://python-cyrus.sf.net

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




 --
 Gustavo A. Díaz
 GDNet Projects
 www.gdnet.com.ar

 ___
 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] QtSql issue

2009-01-07 Thread Brian Makin
I've just installed pyqt on an ubuntu box and many of the examples  
work fine.

When I try to run the sql examples I get the following error.

python -c from PyQt4 import QtSql
Traceback (most recent call last):
  File string, line 1, in module
ImportError: cannot import name QtSql

using QtCore or QtGui works just fine.
I've also attached some debugging output.

Anyone have a suggestion?



python.error
Description: Binary data



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

Re: [PyQt] PyQt4.Qtcore defines 'hex'

2009-01-07 Thread Jim Bublitz
On Wednesday 07 January 2009 05:27:06 am Sundance wrote:
 Adeodato Simó wrote:
 If you see in the middle of a program hex_(foo), you may wonder
  where that came from, whereas qhex(foo) is going to be rather
  obvious.

 Greetings all,

 Might I humbly second this motion? I do understand the usual
 reservations about star-imports (being the kind of guy that often
 gets to debug other people's work...), but I also do appreciate the
 relative ease of getting away with it in PyQt's case, thanks to the
 prevalence of the Q prefix in its class names and its relative
 absence of module-level functions.

 With this in mind, using the same prefix for the three problematic
 functions makes good sense to me. Are there reservations about this
 approach that I may not be aware of?

One problem I'd see is that 'qhex' doesn't sort alphabetically the same 
as 'hex' or 'hex_' does. Also, other bindings - like PyKDE - have the 
same problem. In the case of PyKDE, it's in a lot more than three 
places. That makes it a lot harder for people to find it in the docs, 
especially if they're coming from or reconciling with Qt or KDE docs 
and method names. 

The 'q*' convention doesn't make a lot of sense for other bindings 
packages, and the underscore seems less likely to clash with other 
people's naming schemes, although in the case of PyQt a clash seems to 
have a fairly low probability either way. 

As to the ugliness factor, I somewhat agree, but then we're talking 
about a language that uses things like __init__  or __main__ all over 
the place. 

As to '*' imports - having done a lot of C/C++ where you have to declare 
every variable, declaring objects in an import statement isn't that 
difficult. And IIRC, PyKDE4 inherits name clashes between modules from 
KDE itself in a couple of places.

Jim

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


Re: [PyQt] Making application look more sexy

2009-01-07 Thread Gustavo A. Díaz
Hi,

Agree that many would like to maintain OS look and feel, is why in my
application i give the user the option to set a own skin/qss style or to
select the styles available in the OS.

2009/1/7 Marc Nations mnations.li...@gmail.com

 That is an awesome looking app!

 In the past I've been able to overcome a lot shortcomings with gui toolkits
 with a healthy use of images. Even when I was using TkInter and the look was
 extremely outdated I was able to mask it by basically replacing as much as
 possible with foreground and background images. There are tons of free
 icon/image websites to choose from so that you don't have to spend a bunch
 of time building them.

 If you are interested in building them you can use apps like PowerPoint to
 create glossy looking buttons and backdrops. Gimp does some of this also,
 but takes a little bit longer. I'm not much of an artist, so I just like to
 go grab stuff I think looks nice.

 I don't know why some are so resistant to creating an app with a better
 look/feel. While I agree that it's difficult sometimes to balance useability
 with a new look, the first thing people are going to see is the nice coat
 of pain, not the engine. And first appearances go a long way when people are
 trying out software. Assuming it's also easy to use, then it can give you an
 edge when compared with other apps.

 Btw, I still haven't figured out how to use an image as a background in
 PyQt4 without it automatically texturing. I'd like to use an image in a 1:1
 ratio with the size of the widget you apply it to, but used in the
 background so that text and widgets can be placed over it. If I try and
 scale it, you get the texturing. If I don't scale it, it just shows up in
 it's natural size which you'd have to manually set and then lock the app
 down with no resizing, obviously that's not a good solution. Anyone know how
 to do this?



 2009/1/6 Gustavo A. Díaz gustavo.d...@gmail.com

 Hi,


 I use purely Stylesheets+images in my App:

 http://opencoffee.lnxteam.org/trac/opencoffee/wiki/ScreenShots

 Cheers.



 2009/1/5 Reinaldo de Carvalho reinal...@gmail.com

  On Sun, Jan 4, 2009 at 7:08 PM, Filip Gruszczyński grusz...@gmail.com
 wrote:
  I guess many of us know the term 'programmers art'. I am well aware of
  it, so I am avoiding as much as it's possible touch stylesheets and
  trying to work on them myself. I would like, however, to make my
  application look better. Maybe you know some simple tricks or know
  some good style plugins, that I could use?
 

 If do you use a pure-gnome-system (wo/ kdelibs) its can to be usefull:

 http://tombuntu.com/index.php/2008/02/11/theme-qt3-applications-in-gnome

  --
  Filip Gruszczyński
 

 --
 Reinaldo de Carvalho
 http://korreio.sf.net (Now available in English)
 http://python-cyrus.sf.net

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




 --
 Gustavo A. Díaz
 GDNet Projects
 www.gdnet.com.ar

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





-- 
Gustavo A. Díaz
GDNet Projects
www.gdnet.com.ar
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt