PyQT, Sharp Zaurus and color in the QTextBrowser

Discussion in 'Python' started by Sybren Stuvel, Jul 14, 2003.

  1. Hi there!

    I'm a beginning Python programmer, and I like it a lot already. Since my
    Sharp Zaurus has a fairly complete Python environment including PyQT, I
    thought it would be the perfect language for programming some nice
    things on my Zaurus. The thing I really missed on the Z was a good
    Jabber client. That's why I'm building my own. Things are going good,
    and in a few nights I've been able to get a fairly decent though
    under-featured client.

    There is a small thing annoying me, though I'm trying to show the name
    of the person saying something in color: red = someone else, blue = me.
    This is an example of the text I'm adding to the QTextBrowser:

    <font color='#0000ff'>&lt;me&gt;</font>: hello world

    It works like a charm on my PC, but on the Zaurus the text is all black.
    Does anyone know how I can fix this?

    ~~~ brainwave flash ~~~

    I just thought of something: what if the Z doesn't allow single quotes
    around the "color" attribute? I gave it a try, and replaced the text
    with:

    <font color="#0000ff">&lt;me&gt;</font>: hello world

    And it works!

    Anyways, perhaps this will be picked up by others having the same
    problem. I'll stick around in this group and try to soak up as many good
    knowledge from people as I can ;-)

    A bit about myself: I'm a 24 year old, studying Computer Sciences at the
    University of Amsterdam, I'm Dutch (like Guido ;-)) and I currently live
    in Amsterdam too. I've been a programmer for half my life now :)

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
     
    Sybren Stuvel, Jul 14, 2003
    #1
    1. Advertising

  2. Sybren Stuvel

    Tim Gerla Guest


    > I just thought of something: what if the Z doesn't allow single quotes
    > around the "color" attribute? I gave it a try, and replaced the text
    > with:
    >
    > <font color="#0000ff">&lt;me&gt;</font>: hello world
    >
    > And it works!
    >


    Very fun stuff. Someday I hope to have a Zaurus or similar device to
    toy with. Anyway, to actually be on topic, "proper" HTML (XHTML 1.0,
    and maybe HTML 4.0? I don't recall...) requires double-quotes to be
    used. Single quotes are illegal. So, the Qt version your Zaurus is
    using must be a little more strict.

    -Tim
     
    Tim Gerla, Jul 14, 2003
    #2
    1. Advertising

  3. Tim Gerla wrote:
    > Anyway, to actually be on topic, "proper" HTML (XHTML 1.0, and
    > maybe HTML 4.0? I don't recall...) requires double-quotes to be
    > used. Single quotes are illegal.


    XHTML 1.0 is XML, which allows both single quotes and double
    quotes:

    http://www.w3.org/TR/REC-xml#NT-AttValue

    HTML 4 is derived from SGML, which also supports both single
    and double quotes, and also allows unquoted values, in some
    cases:

    http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2

    </F>
     
    Fredrik Lundh, Jul 14, 2003
    #3
  4. Sybren Stuvel

    Peter Hansen Guest

    Tim Gerla wrote:
    >
    > Very fun stuff. Someday I hope to have a Zaurus or similar device to
    > toy with. Anyway, to actually be on topic, "proper" HTML (XHTML 1.0,
    > and maybe HTML 4.0? I don't recall...) requires double-quotes to be
    > used. Single quotes are illegal.


    Are you certain about that? It seems very unlikely that it would
    outlaw use of single quotes when it is supposed to be XML-compatible,
    and XML explicitly allows either single or double quotes around attributes.

    I checked a page or two at W3C and couldn't find an obvious way to
    prove that you are wrong, but I think the onus is on you to prove
    that you are right here.

    -Peter
     
    Peter Hansen, Jul 14, 2003
    #4
  5. Peter Hansen enlightened us with:
    > Are you certain about that? It seems very unlikely that it would
    > outlaw use of single quotes when it is supposed to be XML-compatible,
    > and XML explicitly allows either single or double quotes around
    > attributes.


    I can't find it right now, but I've had the same discussion with a few
    collegues of mine, and according to W3C, both single and double quotes
    are accepted for both HTML and XML, and thus XHTML too.

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
     
    Sybren Stuvel, Jul 14, 2003
    #5
  6. Sybren Stuvel

    Tim Gerla Guest

    On Mon, 2003-07-14 at 14:30, Peter Hansen wrote:
    > Tim Gerla wrote:
    > >
    > > Very fun stuff. Someday I hope to have a Zaurus or similar device to
    > > toy with. Anyway, to actually be on topic, "proper" HTML (XHTML 1.0,
    > > and maybe HTML 4.0? I don't recall...) requires double-quotes to be
    > > used. Single quotes are illegal.

    >
    > Are you certain about that? It seems very unlikely that it would
    > outlaw use of single quotes when it is supposed to be XML-compatible,
    > and XML explicitly allows either single or double quotes around attributes.


    You're right--I was under the wrong impression about single & double quotes.
    For some reason I recall reading somewhere (can't trust everything you read online)
    that XML only allowed double quotes, and I never bothered to verify it.

    Anyway, does that mean that the Qt parser has a bug?

    -Tim
     
    Tim Gerla, Jul 14, 2003
    #6
  7. Tim Gerla enlightened us with:
    > Anyway, does that mean that the Qt parser has a bug?


    If it wants to be HTML-compliant: yes.
    If it wants to use HTML-like codes for markup: no

    Al least, that's the way I see it. I dont't know Trolltech's
    intentions. I'll check out the docs.

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
     
    Sybren Stuvel, Jul 15, 2003
    #7
  8. Jeremy Bowers enlightened us with:
    > The confusion probably stems from the fact that as of the latest XHTML
    > specification at the time I read it, every single example XHTML
    > fragment used double quotes. At no point is it ever specified either
    > way in the XHTML specification, except by reference to the XML
    > specification.


    Got a point there. I use single quotes all the time thouhg, in HTML generated
    in PHP:

    <?php
    echo "<span class='$class'>$msg</span>"
    ?>

    It's a lot better than something I otHften see in other people's code:

    echo "<span class=\"$class\">$msg</span>"

    Doing it the other way around doesn't work, since PHP doesn't do
    variable substitution between single quotes.

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
     
    Sybren Stuvel, Jul 15, 2003
    #8
  9. Jeremy Bowers wrote:

    > At no point is it ever specified either way in the XHTML specification,
    > except by reference to the XML specification.


    which is the whole point, of course.

    (we've been through this in the XML-RPC and RSS universes
    lately; for some reason, some people have a really hard time
    understanding that when you base a format on XML, you get
    more than just tags in angle brackets ;-)

    </F>
     
    Fredrik Lundh, Jul 15, 2003
    #9
  10. [OT] Re: Single or Double quotes [was Re: PyQT, Sharp Zaurus and color in the QTextBrowser]

    Jeremy Bowers enlightened us with:
    > At no point is it ever specified either way in the XHTML
    > specification, except by reference to the XML specification.


    I'm sorry to tell you, but you're wrong in that. It is clearly stated in
    the HTML 4.01 specification at
    http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2

    I found that by going to the index, looking up the item "attibutes" and
    then clicking the link at "quotation marks around value". Not that hard
    to find.

    The XML specification of attributes can be found at
    http://www.w3.org/TR/REC-xml#sec-common-syn and is a little harder to
    find, but not impossible.

    Since XHTML 1.0 is defined as "A Reformulation of HTML 4 in XML 1.0",
    this should be enough to also allow single and double quoted attribute
    values in XHTML.

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
     
    Sybren Stuvel, Jul 15, 2003
    #10
  11. Tim Gerla enlightened us with:
    > Very fun stuff. Someday I hope to have a Zaurus or similar device to
    > toy with.


    For those interested: I've put up some screenshots of my jabber client,
    Discuss Jabber, at http://zaurus.thirdtower.com/

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
     
    Sybren Stuvel, Jul 15, 2003
    #11
  12. Sybren Stuvel

    Greg Fortune Guest

    Are you intended on releasing the source for this? If so, dump something up
    there so we can play ;o)

    Greg Fortune

    Sybren Stuvel wrote:

    > Tim Gerla enlightened us with:
    >> Very fun stuff. Someday I hope to have a Zaurus or similar device to
    >> toy with.

    >
    > For those interested: I've put up some screenshots of my jabber client,
    > Discuss Jabber, at http://zaurus.thirdtower.com/
    >
    > Sybren
     
    Greg Fortune, Jul 16, 2003
    #12
  13. Greg Fortune enlightened us with:
    > Are you intended on releasing the source for this? If so, dump
    > something up there so we can play ;o)


    Yes, I am going to release the source for this ;-) I'll post it on
    http://zaurus.thirdtower.com/ when I'm a bit further in the building
    process. I'll let the group know when I do that!

    Sybren
    --
    The problem with the world is stupidity. Not saying there should be a
    capital punishment for stupidity, but why don't we just take the
    safety labels off of everything and let the problem solve itself?
     
    Sybren Stuvel, Jul 16, 2003
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. anton
    Replies:
    13
    Views:
    2,498
    Karl von Laudermann
    Feb 26, 2004
  2. Sybren Stuvel

    Python Jabber client for the Zaurus

    Sybren Stuvel, Jul 30, 2003, in forum: Python
    Replies:
    1
    Views:
    360
    Sybren Stuvel
    Jul 30, 2003
  3. Grant Edwards
    Replies:
    5
    Views:
    360
    Dave Reed
    Sep 17, 2003
  4. ThomasC
    Replies:
    0
    Views:
    267
    ThomasC
    Jan 23, 2007
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    464
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page