[wxPython] win - linux

Hello,

yesterday I tried to port my application to Linux and after some
problems I got it run up.
However, I still have some problems and hope you folks can help me.

I have several panels stacked over each over, showing just one, hiding
the overs. I use wxDC::Print to put information on it, since the
updating of several TextControls seems to be too slow. On several
points the user has to input information, in this case I create a
ListControl, which will destroy itself after it looses its focus. This works
great on windows.

On Linux the ListControl will not destroy itself, either it gets no
focus event, or the Destroy call doesn't work. Also the switching
between the panels seems to be very slow. I had set the panels to
black background colour and at every refresh they also seems to take the
original grey color for a moment, causing flicker.

My question are:, is it a correct way to put panels above each other?
Is wxPython slower on Linux? Can I catch Kill Focus events on Linux
and how do I destroy the ListControl? How can I prevent the flicker?

Keep up the good work. :slight_smile:
Lucian

···

--
Best regards,
Lucian mailto:gemes@gmx.at

I have several panels stacked over each over, showing just one, hiding
the overs. I use wxDC::Print

Huh?

to put information on it, since the
updating of several TextControls seems to be too slow. On several
points the user has to input information, in this case I create a
ListControl, which will destroy itself after it looses its focus. This

works

great on windows.

On Linux the ListControl will not destroy itself, either it gets no
focus event, or the Destroy call doesn't work.

The generic wxListCtrl used on wxGTK is actually composed of a couple
separate windows, so probably the window with the focus is not the actual
wxListCtrl window but one of its children. BUt how are you getting input
via a list control?

Also the switching
between the panels seems to be very slow.

You're just doing a Hide() and Show()?

I had set the panels to
black background colour and at every refresh they also seems to take the
original grey color for a moment, causing flicker.

It may be affected by any gtk theme you have active, otherwise I'll take a
look at a small sample if you have one.

My question are:, is it a correct way to put panels above each other?

I think the "Correct" way is to use a wxNotebook. Anything else and you're
on your own.

Is wxPython slower on Linux?

Yes and no. wxPythonGTK itself is probably about the same, but there are
different factors at the API level. MS Windows API goes direct to the video
driver and then to the hardware. GTK goes to X Windows which then goes to
the X Server via a network socket interface which then goes to the hardware.

···

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

Hello Robin,

I have several panels stacked over each over, showing just one, hiding
the overs. I use wxDC::Print

Huh?

Sorry I thought that was clear, I mean wxDC::DrawText. Since the
updating of textctrl did too long, by switching the panels.

The generic wxListCtrl used on wxGTK is actually composed of a couple
separate windows, so probably the window with the focus is not the actual
wxListCtrl window but one of its children.

How can I set the focus event on this windows?

BUt how are you getting input
via a list control?

The user has just to chose between several options, the listcontrol
pops up and he can pick what he wants.

Also the switching
between the panels seems to be very slow.

You're just doing a Hide() and Show()?

Yes. And afterwards painting with wxDC::DrawText. But that dosn't
explain the flicker. By the way, if I set the font size on windows
with:

fontn=dc.GetFont()
fontn.SetPointSize(3)
dc.SetFont(fontn)

I get a readable textsize. But on linux it will be pretty small. (As
it should be at 3 points.) However, if I set the font on windows with

fonts=wxFont(10,wxMODERN,wxNORMAL,wxLIGHT)

and change the pointsize afterwards to 3 points, it will be also very
small. Why is that?

I had set the panels to
black background colour and at every refresh they also seems to take the
original grey color for a moment, causing flicker.

It may be affected by any gtk theme you have active, otherwise I'll take a
look at a small sample if you have one.

It is the standard SUSE 8.0 theme, I think.

the code is:

class basepan(wxPanel):
    def __init__(self,parent):
        wxPanel.__init__(self,parent,-1,pos = wxPoint(750 , 100), size = wxSize(200, 300),style = wxDEFAULT_FRAME_STYLE)
        self.SetBackgroundColour(wxColour(0,0,0))

        .
        .
        .

class vplistgrid:

    def __init__(self,parent):

        self.Span = basepan(self.parent)
        self.Span.Show(false)
        self.Bpan = basepan(self.parent)
        self.Bpan.Show(false)

   def showBpan(self):

       self.Span.Show(false)
       self.Bpan.Show(true)

       self.Bpan.DrawContent() # -> just wxDC::DrawText

   def showSpan(self):

       self.Bpan.Show(false)
       self.Span.Show(true)

       self.Span.DrawContent() # -> just wxDC::DrawText

My question are:, is it a correct way to put panels above each other?

I think the "Correct" way is to use a wxNotebook. Anything else and you're
on your own.

Is it possible to hide the tabs, so that the switching between the
pages can be controlled completely by the program?

And a new question: I tried the code on win98 and had problem with the
wxGrid, it didn't show up correctly, cleared stuff stays on screen,
and it will not be updated correctly, using this code:

def __init__(self,parent):
        ##print 'init im vpgrid'
        wxGrid.__init__(self,parent, -1,pos = wxPoint(750 , 400), size = wxSize(250, 350))

        self.CreateGrid(20,3)
          .
          .
          .

        self.Clear()
        self.BeginBatch()
        
        for obj in muster:
            ##print obj
            x,y,name,col=obj
            if type(name)!='str':
                name=str(name)
            y=y-off
            self.SetCellValue(x,y,name)
            self.SetCellTextColour(x,y,col)
            self.SetCellFont(x,y,font)

        self.EndBatch()
        self.ForceRefresh()

I do not have a panel below it, draw it directly on the frame. It
works on WinXP and a different win98 computer with a better graphic
card. Something how I could improve in the code?

thanks for the answers and wxPython :slight_smile:

Lucian

> The generic wxListCtrl used on wxGTK is actually composed of a couple
> separate windows, so probably the window with the focus is not the

actual

> wxListCtrl window but one of its children.

How can I set the focus event on this windows?

I've added an accessor method for the next release. You might also be able
to use EVT_CHILD_FOCUS...

By the way, if I set the font size on windows
with:

fontn=dc.GetFont()
fontn.SetPointSize(3)
dc.SetFont(fontn)

I get a readable textsize. But on linux it will be pretty small. (As
it should be at 3 points.) However, if I set the font on windows with

fonts=wxFont(10,wxMODERN,wxNORMAL,wxLIGHT)

and change the pointsize afterwards to 3 points, it will be also very
small. Why is that?

I could be wrong but I think that if a font is already selected into the DC
then it won't be reselected. Just changing the pointsize probably confuses
the DC... Just create a new font with all the attributes of the old font
and then select it into the DC.

>> I had set the panels to
>> black background colour and at every refresh they also seems to take

the

>> original grey color for a moment, causing flicker.

> It may be affected by any gtk theme you have active, otherwise I'll

take a

> look at a small sample if you have one.

...

[next time please send a fully functional sample that I can run directly,
otherwise I just have to guess]

   def showBpan(self):

       self.Span.Show(false)
       self.Bpan.Show(true)

       self.Bpan.DrawContent() # -> just wxDC::DrawText

Does Bpan catch EVT_PAINT or are you just drawing with a wxClientDC? That
may be the source of your flicker: when shown the window is painted with
the default background and then later you draw your text. Using the new
wxBufferedDC and wxBufferedPaintDC will probably also help.

>> My question are:, is it a correct way to put panels above each other?

> I think the "Correct" way is to use a wxNotebook. Anything else and

you're

> on your own.

Is it possible to hide the tabs, so that the switching between the
pages can be controlled completely by the program?

No.

And a new question: I tried the code on win98 and had problem with the
wxGrid, it didn't show up correctly, cleared stuff stays on screen,
and it will not be updated correctly, using this code:

...

I do not have a panel below it, draw it directly on the frame. It
works on WinXP and a different win98 computer with a better graphic
card. Something how I could improve in the code?

Which wxPython version? There was something similar to this in 2.3.1.

···

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