wx.HtmlDCRenderer

Does anyone have any experience using this? It sounded simple, but I
get nil when I try to use it.

For example, I would expect the following to work:

class Foo(wx.PyControl):
    def __init__(self, parent, id, text,
                 pos = wx.DefaultPosition, size = wx.DefaultSize,
                 style = 0,
                 name = "htmlfoo"):
        wx.PyControl.__init__(self, parent, id,
                              pos, size,
                              style | wx.NO_BORDER,
                              wx.DefaultValidator, name)

        self.html = html.HtmlDCRenderer()
        self.html.SetHtmlText(text)
        self.Bind(wx.EVT_PAINT, self.OnPaint)

    def OnPaint(self, event):
        dc = wx.PaintDC(self)
        self.PrepareDC(dc)
        self.Draw(dc)

    def Draw(self, dc):
        width, height = self.GetClientSize()
        if not width or not height:
            return
    
        dc.SetBackground(wx.Brush(wx.WHITE))
        dc.Clear()

        self.html.SetDC(dc, width)
        self.html.Render(0, 0)

But all I get is the white background. Any pointers?

Python 2.3.3
wxPythonGTK2-py2.3-2.5.2.6-FC2

Regards,
Cliff

···

--
Cliff Wells <clifford.wells@comcast.net>

Cliff Wells wrote:

Does anyone have any experience using this? It sounded simple, but I
get nil when I try to use it.

I do. I recently made an GridCellRenderer that uses HTML with the
rendering and sizing done using HtmlDCRenderer

But all I get is the white background. Any pointers?

The renderer uses the current DC parameters for some defaults
(eg background mode).

You also missed the red caution note in the online help. Look

···

at the doc for the Render method. At the bottom it says:

Caution!

  The Following three methods must always be called before any call to Render (preferably in this order):

    SetDC SetSize SetHtmlText

  Render() changes the DC's user scale and does NOT restore it.

I actually make a new renderer each time I need one, rather
than trying to use only one.

Roger

Cliff Wells wrote:
> Does anyone have any experience using this? It sounded simple, but I
> get nil when I try to use it.

I do. I recently made an GridCellRenderer that uses HTML with the
rendering and sizing done using HtmlDCRenderer

> But all I get is the white background. Any pointers?

The renderer uses the current DC parameters for some defaults
(eg background mode).

You also missed the red caution note in the online help. Look

Caution!

Actually, what I'm missing is the big red pointer to the docs for this
item =) Looked and looked but *still* don't see any documentation for
it. I only got as far as I did by reading the source for the html
module. What section is it in?

  The Following three methods must always be called before
  any call to Render (preferably in this order):

    SetDC
    SetSize
    SetHtmlText

  Render() changes the DC's user scale and does NOT restore it.

I actually make a new renderer each time I need one, rather
than trying to use only one.

Excellent. Thanks for the help. I'll give this a try.

Regards,
Cliff

···

On Thu, 2004-08-19 at 15:32, Roger Binns wrote:

at the doc for the Render method. At the bottom it says:

--
Cliff Wells <clifford.wells@comcast.net>

Cliff Wells wrote:

Actually, what I'm missing is the big red pointer to the docs for this
item =) Looked and looked but *still* don't see any documentation for
it. I only got as far as I did by reading the source for the html
module. What section is it in?

I use the CHM file that comes with wxPython on Windows (wx.chm). It also views fine with xchm on Linux. And then there are always the online
versions of the same file:

  http://www.wxpython.org/onlinedocs.php
  http://wxwidgets.org/manuals/2.4.2/wx.htm
  http://wxwidgets.org/downld2.htm (scroll down)

You are absolutely spoilt for choice, providing you knew it existed in
the first place :slight_smile:

Roger

I downloaded the current docs and I found it there. I still don't see
it in the online docs (http://www.wxpython.org/onlinedocs.php) which is
why I missed it in the first place :stuck_out_tongue:

Thanks for the info!

···

On Thu, 2004-08-19 at 19:37, Roger Binns wrote:

Cliff Wells wrote:
> Actually, what I'm missing is the big red pointer to the docs for this
> item =) Looked and looked but *still* don't see any documentation for
> it. I only got as far as I did by reading the source for the html
> module. What section is it in?

I use the CHM file that comes with wxPython on Windows (wx.chm). It
also views fine with xchm on Linux. And then there are always the online
versions of the same file:

  http://www.wxpython.org/onlinedocs.php
  http://wxwidgets.org/manuals/2.4.2/wx.htm
  http://wxwidgets.org/downld2.htm (scroll down)

--
Cliff Wells <clifford.wells@comcast.net>

Cliff Wells wrote:

I downloaded the current docs and I found it there. I still don't see
it in the online docs (http://www.wxpython.org/onlinedocs.php) which
is why I missed it in the first place :stuck_out_tongue:

Click on Alphabetical class reference and navigate from there.
It is exactly the same content and layout as the other docs.

Roger

Okay, now I feel really dumb :stuck_out_tongue: I must be getting old.

Thanks again.

Cliff

···

On Thu, 2004-08-19 at 22:14, Roger Binns wrote:

Cliff Wells wrote:
> I downloaded the current docs and I found it there. I still don't see
> it in the online docs (http://www.wxpython.org/onlinedocs.php) which
> is why I missed it in the first place :stuck_out_tongue:

Click on Alphabetical class reference and navigate from there.
It is exactly the same content and layout as the other docs.

--
Cliff Wells <clifford.wells@comcast.net>

Hi all

I have just upgraded from 2.5.1.5 to 2.5.2.7, on both MSW and GTK on RH9,
both running Python 2.3.3.

On GTK, there is a change in behaviour when entering data into a grid.
Anything that you type is invisible until you move to another cell. Then
everything that you have typed becomes visible. As I use the grid
extensively for data entry, this is quite serious for me.

You can see this easily from the demo. It happens whether you use a cell
editor or not. I have noticed that it does not happen if you use a text
editor with a style of TE_MULTILINE. However, if you use this style, GTK
ignores any MaxLength setting, which I also use extensively, so this is not
an option.

Any assistance will be much appreciated.

Thanks

Frank Millman

Frank Millman wrote:

Hi all

I have just upgraded from 2.5.1.5 to 2.5.2.7, on both MSW and GTK on RH9,
both running Python 2.3.3.

On GTK, there is a change in behaviour when entering data into a grid.
Anything that you type is invisible until you move to another cell. Then
everything that you have typed becomes visible. As I use the grid
extensively for data entry, this is quite serious for me.

You can see this easily from the demo.

I don't. Are you using the GTK or GTK2 version?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Frank Millman wrote:
> Hi all
>
> I have just upgraded from 2.5.1.5 to 2.5.2.7, on both MSW and GTK on

RH9,

> both running Python 2.3.3.
>
> On GTK, there is a change in behaviour when entering data into a grid.
> Anything that you type is invisible until you move to another cell. Then
> everything that you have typed becomes visible. As I use the grid
> extensively for data entry, this is quite serious for me.
>
> You can see this easily from the demo.

Robin Dunn wrote:

I don't. Are you using the GTK or GTK2 version?

Thanks for the reply, Robin. I am using GTK. I downloaded the binary rpm for
RedHat 9, and it seemed to install ok.

I reduced the problem to the smallest example I could manage, and it still
does it -

    import wx, wx.grid as grd
    app = wx.PySimpleApp()
    frame = wx.Frame(None,-1,"Test")
    grid = grd.Grid(Frame,-1)
    grid.CreateGrid(8,3)
    grid.SetFocus()
    frame.Show(True)
    app.MainLoop()

It seems to have something to do with the GridCellEditor. If I tab into a
cell that contains some text, the text is visible, but the moment I hit F2
to edit the text, it disappears. I can type anything I like, but nothing
appears until I press <tab> to move to another cell. Then all my typing
appears.

Hope this information helps.

Frank

Frank Millman wrote:

Frank Millman wrote:

Hi all

I have just upgraded from 2.5.1.5 to 2.5.2.7, on both MSW and GTK on

RH9,

both running Python 2.3.3.

On GTK, there is a change in behaviour when entering data into a grid.
Anything that you type is invisible until you move to another cell. Then
everything that you have typed becomes visible. As I use the grid
extensively for data entry, this is quite serious for me.

You can see this easily from the demo.

Robin Dunn wrote:

I don't. Are you using the GTK or GTK2 version?

Thanks for the reply, Robin. I am using GTK. I downloaded the binary rpm for
RedHat 9, and it seemed to install ok.

I reduced the problem to the smallest example I could manage, and it still
does it -

    import wx, wx.grid as grd
    app = wx.PySimpleApp()
    frame = wx.Frame(None,-1,"Test")
    grid = grd.Grid(Frame,-1)
    grid.CreateGrid(8,3)
    grid.SetFocus()
    frame.Show(True)
    app.MainLoop()

It seems to have something to do with the GridCellEditor. If I tab into a
cell that contains some text, the text is visible, but the moment I hit F2
to edit the text, it disappears. I can type anything I like, but nothing
appears until I press <tab> to move to another cell. Then all my typing
appears.

Try changing or disabling your gtk theme. I just tried with a GTK (1.2) build here and it works fine (comparativly ugly, but functional.) You might also want to try the GTK2 build to see how it compares.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

>>Frank Millman wrote:
>>
>>>Hi all
>>>
>>>I have just upgraded from 2.5.1.5 to 2.5.2.7, on both MSW and GTK on
>
> RH9,
>
>>>both running Python 2.3.3.
>>>
>>>On GTK, there is a change in behaviour when entering data into a grid.
>>>Anything that you type is invisible until you move to another cell.

Then

>>>everything that you have typed becomes visible. As I use the grid
>>>extensively for data entry, this is quite serious for me.
>>>
>>>You can see this easily from the demo.
>
>
> Robin Dunn wrote:
>
>>I don't. Are you using the GTK or GTK2 version?
>
>
> Thanks for the reply, Robin. I am using GTK. I downloaded the binary rpm

for

> RedHat 9, and it seemed to install ok.
>
> I reduced the problem to the smallest example I could manage, and it

still

> does it -
>
> import wx, wx.grid as grd
> app = wx.PySimpleApp()
> frame = wx.Frame(None,-1,"Test")
> grid = grd.Grid(Frame,-1)
> grid.CreateGrid(8,3)
> grid.SetFocus()
> frame.Show(True)
> app.MainLoop()
>
> It seems to have something to do with the GridCellEditor. If I tab into

a

> cell that contains some text, the text is visible, but the moment I hit

F2

> to edit the text, it disappears. I can type anything I like, but nothing
> appears until I press <tab> to move to another cell. Then all my typing
> appears.

Try changing or disabling your gtk theme. I just tried with a GTK (1.2)
build here and it works fine (comparativly ugly, but functional.) You
might also want to try the GTK2 build to see how it compares.

I don't know how to disable themes, but from the Preferences menu I tried
all the themes available, and it made no difference.

I suggest the following approach. If anyone else is reading this thread, and
experiences the same problem as me, please reply with any details - maybe
that will help us get to the bottom of it. If nobody replies, I must have
done something wrong in my installation, and I will reinstall.

Don't reply to say that you don't have the problem - that will just add
noise.

Thanks for the assistance so far.

Frank

Frank Millman wrote:

I don't know how to disable themes,

Try making your ~/.gtkrc file be empty, although depending on your distro if there is a system default then that may still override your default settings.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

> >Frank Millman wrote:
> >
> >Hi all
> >
> >I have just upgraded from 2.5.1.5 to 2.5.2.7, on both MSW and GTK on

RH9,

> >both running Python 2.3.3.
> >
> >On GTK, there is a change in behaviour when entering data into a grid.
> >Anything that you type is invisible until you move to another cell.

Then

> >everything that you have typed becomes visible. As I use the grid
> >extensively for data entry, this is quite serious for me.
> >
> >You can see this easily from the demo.
> >
> > Robin Dunn wrote:
> >
> >>I don't. Are you using the GTK or GTK2 version?
> >
> >
> > Thanks for the reply, Robin. I am using GTK. I downloaded the binary

rpm

> > for RedHat 9, and it seemed to install ok.
> >
I suggest the following approach. If anyone else is reading this thread,

and

experiences the same problem as me, please reply with any details - maybe
that will help us get to the bottom of it. If nobody replies, I must have
done something wrong in my installation, and I will reinstall.

I am not having any luck, I am afraid. I took a clean hard drive, installed
Red Hat 9, Python 2.3.3, and wxPython 2.5.2.7, and I still have the same
problem. As nobody else has reported the problem, I must be doing something
wrong, so I will explain my installation procedure, and see if someone can
spot the error.

Red Hat pre-installs Python 2.2.2 in /usr/bin and /usr/lib. By default,
Python 2.3.3 installs in /usr/local/bin and /usr/local/lib, which does not
cause any conflicts, so I just install it with all the defaults. Then I
create a symbolic link in /usr/bin called python, pointing to
/usr/local/bin/python2.3, and it all seems to work ok.

The wxPython rpm installs a directory called wxPython-2.5.2.7 in /usr/lib,
and directories called wx and wxPython in /usr/lib/python2.3/site-packages.
I install wxPython with defaults, which creates the directory
/usr/lib/python2.3/site-packages. Then I move wx and wxPython to
/usr/local/lib/python2.3/site-packages, renaming them to wx_2.5.2.7 and
wxPython_2.5.2.7. Then I create symbolic links called wx and wxPython. That
is all I do. As far as I can recall, that is all I did with 2.5.1.5, and I
had no problems with that.

While on the subject, I tried to 'downgrade' to 2.5.1.5 on my original hard
drive, to double-check that the problem does not occur there. I still have
wxPython-2.5.1.5 in /usr/lib, and wx_2.5.1.5 and wxPython_2.5.1.5 in
/usr/local/lib/python2.3/site-packages. I changed the symbolic links of wx
and wxPython to point to the 2.5.1.5 directories. If I then try to 'import
wx', I get the following error -

File "/usr/local/lib/python2.3/site-packages/wx/__init__.py", line 43, in ?
  del wx
NameError: name 'wx' is not defined

I did at one point erase the 2.5.1.5 rpm, and then reinstall it, so maybe
something has gone missing.

I hope this has given enough information for someone to tell me what I am
doing wrong.

Thanks

Frank

Frank Millman wrote:

Frank Millman wrote:

Red Hat pre-installs Python 2.2.2 in /usr/bin and /usr/lib. By default,
Python 2.3.3 installs in /usr/local/bin and /usr/local/lib, which does not
cause any conflicts, so I just install it with all the defaults. Then I
create a symbolic link in /usr/bin called python, pointing to
/usr/local/bin/python2.3, and it all seems to work ok.

Other than the binaries and links in /usr/bin there are no conflicts for installing both Python 2.2 and 2.3 with a prefix of /usr. In fact that is how my RH9 build machine is setup. After doing make install for Python 2.3 I just go and adjust the /usr/bin/python link to point back to /usr/bin/python2.2 for the redhat utilities and then I use "python2.3" when I want to run that version. If you do it this way then the py2.3 wxPython RPMs will put the packages into the right place for you with no need to move things around.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Python 2.3 I just go and adjust the /usr/bin/python link to point back to /usr/bin/python2.2 for the redhat utilities and then I use

So Redhat STILL hasn't had the brains to put:

#!/usr/bin/python2.2

in their scripts? AARRGG?

Of course, neither has GENTOO, but at least they keep Python pretty up to date.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Robin Dunn wrote:
> Python 2.3 I just go and adjust the /usr/bin/python link to point back
> to /usr/bin/python2.2 for the redhat utilities and then I use

Chris Barker wrote:

So Redhat STILL hasn't had the brains to put:

#!/usr/bin/python2.2

in their scripts? AARRGG?

Of course, neither has GENTOO, but at least they keep Python pretty up
to date.

-Chris

I think Redhat have got it right. I checked a couple of their scripts, and
they start with #!/usr/bin/env python2.2

I have a symbolic link in /usr/bin called 'python', which points to
python2.3, and I have not come across any problems.

Frank

Frank Millman wrote:
>>>>Frank Millman wrote:

> Red Hat pre-installs Python 2.2.2 in /usr/bin and /usr/lib. By default,
> Python 2.3.3 installs in /usr/local/bin and /usr/local/lib, which does

not

> cause any conflicts, so I just install it with all the defaults. Then I
> create a symbolic link in /usr/bin called python, pointing to
> /usr/local/bin/python2.3, and it all seems to work ok.

Robin Dunn wrote:

Other than the binaries and links in /usr/bin there are no conflicts for
installing both Python 2.2 and 2.3 with a prefix of /usr. In fact that
is how my RH9 build machine is setup. After doing make install for
Python 2.3 I just go and adjust the /usr/bin/python link to point back
to /usr/bin/python2.2 for the redhat utilities and then I use
"python2.3" when I want to run that version. If you do it this way then
the py2.3 wxPython RPMs will put the packages into the right place for
you with no need to move things around.

I understand what you are saying, Robin, but I assume (in the absence of any
comments to the contrary) that there is nothing obviously wrong with my way
of doing it. In that case, I am still stuck with my original problem :frowning:

I see that 2.5.2.8 has just been released (many thanks) so I will download
that and give it a try, and report back.

Thanks

Frank

Frank Millman wrote:

Frank Millman wrote:

Frank Millman wrote:

Red Hat pre-installs Python 2.2.2 in /usr/bin and /usr/lib. By default,
Python 2.3.3 installs in /usr/local/bin and /usr/local/lib, which does

not

cause any conflicts, so I just install it with all the defaults. Then I
create a symbolic link in /usr/bin called python, pointing to
/usr/local/bin/python2.3, and it all seems to work ok.

Robin Dunn wrote:

Other than the binaries and links in /usr/bin there are no conflicts for
installing both Python 2.2 and 2.3 with a prefix of /usr. In fact that
is how my RH9 build machine is setup. After doing make install for
Python 2.3 I just go and adjust the /usr/bin/python link to point back
to /usr/bin/python2.2 for the redhat utilities and then I use
"python2.3" when I want to run that version. If you do it this way then
the py2.3 wxPython RPMs will put the packages into the right place for
you with no need to move things around.

I understand what you are saying, Robin, but I assume (in the absence of any
comments to the contrary) that there is nothing obviously wrong with my way
of doing it.

Nothing other than possibly confusing RPM and making it so it can't reliably uninstall or upgrade.

In that case, I am still stuck with my original problem :frowning:

But you are right, it has nothing to do with the invisible text problem but everything with making your installs easier and more sane. :slight_smile:

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

> Robin Dunn wrote:
>
>>Other than the binaries and links in /usr/bin there are no conflicts for
>>installing both Python 2.2 and 2.3 with a prefix of /usr. In fact that
>>is how my RH9 build machine is setup. After doing make install for
>>Python 2.3 I just go and adjust the /usr/bin/python link to point back
>>to /usr/bin/python2.2 for the redhat utilities and then I use
>>"python2.3" when I want to run that version. If you do it this way then
>>the py2.3 wxPython RPMs will put the packages into the right place for
>>you with no need to move things around.
>>
>
> I understand what you are saying, Robin, but I assume (in the absence of

any

> comments to the contrary) that there is nothing obviously wrong with my

way

> of doing it.

Nothing other than possibly confusing RPM and making it so it can't
reliably uninstall or upgrade.

> In that case, I am still stuck with my original problem :frowning:

But you are right, it has nothing to do with the invisible text problem
but everything with making your installs easier and more sane. :slight_smile:

I am still stuck, I am afraid. Here is what I have done since my last post.

I reinstalled Red Hat and Python from scratch, and loaded GKT1-2.5.2.8. I
then ran my simplistic program with a frame and a grid, and I got exactly
the the same problem with my grid text not appearing.

Then I tried to install GTK2-2.5.2.8. It installed ok, but when I tried to
import wx I got an error. I assumed there was some clash, so I reintalled
Red Hat and Python from scratch again, using Robin's tip of moving Python
from usr/local to /usr. Then I reloaded GTK2, so it was the only version of
wxPython on the machine. When I import wx, I get the same error. Here is the
last part of the traceback -

ImportError: /usr/lib/python2.3/site-packages/wx/_core_.so: undefined
symbol: PyUnicodeUCS2_AsWideChar

As far as I can tell from the Python installation documentation, the default
is UCS2, but one can change it to UCS4. I did not pass any arguments to
./configure, so I assume it installed with all the defaults.

I am not planning to use GTK2 at this stage, due to the problems I
experienced with the printing framework. My only reason for installing it
was to narrow down my problem with grid text not appearing. So while it
would be good to get an answer to the above error, my main priority is to
get an answer to the grid text problem. I cannot think of anything else to
try.

Any further assistance will be much appreciated.

Frank