Re: [PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

1999-12-07 Thread Richard Jones

[Phil Thompson]
 Firstly, I'm wondering why you're using repr() to obtain a string instea
 d of
  str(). str() is used to create a user-viewable string whereas repr() is use
 d to
  generate a string representation of an object. From the Library Reference:
  
str(object): Return a string containing a nicely printable
  representation of an object. For strings, this returns the string
  itself. The difference with repr(object) is that str(object) does
  not always attempt to return a string that is acceptable to eval();
  its goal is to return a printable string.
 
 I'm implementing the char* cast operator - repr() seems "closer" in
 meaning to this than str().  It's coincidence that this operator, when
 applied to a QString, produces a user viewable string.  SIP is a general
 tool - it isn't just used for the Qt/KDE bindings.

   I would still feel more comfortable calling str(), even if it passes 
straight through to a __repr__ -- as with a lot of cases in Python.


 My view is that the bad design decision was the orginal one to map
 QStrings onto Python strings - I'm now correcting that mistake. 
 However, there is a choice...
 
 I can very easily revert the Qt v1.x behavior to what it was in earlier
 versions, but the Qt v2.x behavior will be done like this in order to
 support Unicode. The disadvantage of mixing the two approaches is that
 scripts won't be portable between the two.  What's the consensus?

   I'd be interested to know what the general Python approach to Unicode is. I 
guess it'd be nice to just seamlessly move from python 1.5  Qt 1.x to python 
1.6  Qt 2.x with no buggering around with repr() ;)

   I've just had a poke around, but couldn't find any concrete information on 
how Unicode in Python is going...


   Richard








Re: [PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

1999-12-07 Thread Boudewijn Rempt

On Mon, 6 Dec 1999, Phil Thompson wrote:

 
 Could be.  Do you want me to wait until Python 1.6 to find out :)
 

No! ;-).

Boudewijn Rempt  | http://denden.conlang.org







Re: [PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

1999-12-07 Thread Richard Jones

[Boudewijn Rempt]
 Of course, since Python strings are 8-bit clean you can just as easily
 store Unicode data in them (in fact, you can store any binary data in
 them - although I don't know whether you can embed null characters in
 Python strings)

Just so you know, yes you can:

 'Say hello to Mr Null: \0...'
'Say hello to Mr Null: \000...'


 Perhaps it would be neat to have QString.latin1(), QString.utf8(),
 QString.local8bit() and QString.unicode() return a Python string - with
 the bytes in the chosen encoding, as an equivalent of the array of QChars.
 Could be combined with a repr which returns the QString in the current
 encoding.

   I like this idea a lot. Mind you, I still have a problem with using repr 
here - I still think it's an abuse of the function when str() should be used. I 
would like to see a toPyString or asPyString method which returns the QString 
in the "current encoding".


   Richard








Re: [PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

1999-12-06 Thread Richard Jones


Please replace all confused occurrences of QObject with QString in my previous 
message.


 Richard








Re: [PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

1999-12-06 Thread Phil Thompson

Boudewijn Rempt wrote:
 
 On Thu, 2 Dec 1999, Phil Thompson wrote:
 
 
  While this change isn't strictly necessary at this stage, it will be
  needed for Qt v2's Unicode support - so it's best to get used to it now.
 
 
 It's painful all the same - I guess we have to use
 self.text=repr(myTextBox.text()), too! Lots of trouble to go wrong and
 make silly mistakes. Still, Unicode support should be worth it ;-).

I think the key is to delay the conversion to Python strings to the last
possible moment. Keep things as QStrings until something really needs a
Python string - the Python file open method for instance.

Phil







Re: [PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

1999-12-06 Thread Boudewijn Rempt

On Sat, 4 Dec 1999, Phil Thompson wrote:

 Boudewijn Rempt wrote:
  
  On Thu, 2 Dec 1999, Phil Thompson wrote:
  
  
   While this change isn't strictly necessary at this stage, it will be
   needed for Qt v2's Unicode support - so it's best to get used to it now.
  
  
  It's painful all the same - I guess we have to use
  self.text=repr(myTextBox.text()), too! Lots of trouble to go wrong and
  make silly mistakes. Still, Unicode support should be worth it ;-).
 
 I think the key is to delay the conversion to Python strings to the last
 possible moment. Keep things as QStrings until something really needs a
 Python string - the Python file open method for instance.
 

What I'm wondering about is, how will this combine with the
Unicode support promised for Python 1.6? If the standard Python
strings become Unicode strings, QString might be superfluous
again.

Boudewijn Rempt  | http://denden.conlang.org







Re: [PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

1999-12-04 Thread Boudewijn Rempt

On Fri, 3 Dec 1999, Boudewijn Rempt wrote:

 I got past the log-in problem to MySQLdb, but now I don't get
 any gui. Simple examples still work fine, but I am having a bit of
 trouble with Kura, which is a bit larger and more complex. The app gets
 started, I get an entry in the taskbar, but I don't get any interface
 showing... Still, I'm sure I can find out exactly where it goes wrong -
 it's probably my own fault. I'll be working on it this weekend, but 
 because it's Sinterklaas I don't have a lot of time (got to prepare
 the presents for the kids!)
 

Ha! I've solved my problem. It was unbelievably silly... I also
save the geometry of the main window, and because I moved to a
new machine, where there wasn't already a kurarc file, the geometry
was set to 0,0,0,0... Hence an invisible window! Ok, on with the
testing ;-).

Boudewijn Rempt  | http://denden.conlang.org







Re: [PyKDE] ANNOUNCE: PyQt/PyKDE v0.10pre5

1999-12-03 Thread Boudewijn Rempt

On Thu, 2 Dec 1999, Phil Thompson wrote:

 PyQt/PyKDE v0.10pre5 is in the usual place at
 http://www.river-bank.demon.co.uk/software/private/. I've fixed all the
 bugs I know about and, unless you find anything new, this will be
 released later as v0.10 - so this is your last chance.

I'm busy with it - I may have found a bug, but I can't put the finger to
it. It started with the problem that the string that came out of KConfig
were, of course, QStrings (but only the empty one? - I had four, three
filled, one empty). When I had put repr's around them, like:

 self.user=repr(self.config.readEntry("user", "boud"))
 self.db=repr(self.config.readEntry("db","lng"))
 self.password=repr(self.config.readEntry("password", ""))
 self.host=repr(self.config.readEntry("host","calcifer"))

I got past the log-in problem to MySQLdb, but now I don't get
any gui. Simple examples still work fine, but I am having a bit of
trouble with Kura, which is a bit larger and more complex. The app gets
started, I get an entry in the taskbar, but I don't get any interface
showing... Still, I'm sure I can find out exactly where it goes wrong -
it's probably my own fault. I'll be working on it this weekend, but 
because it's Sinterklaas I don't have a lot of time (got to prepare
the presents for the kids!)

 
 While this change isn't strictly necessary at this stage, it will be
 needed for Qt v2's Unicode support - so it's best to get used to it now.
 

It's painful all the same - I guess we have to use
self.text=repr(myTextBox.text()), too! Lots of trouble to go wrong and
make silly mistakes. Still, Unicode support should be worth it ;-).

Boudewijn Rempt  | http://denden.conlang.org