[wxPython] RE: wxPython-users digest, Vol 1 #90 - 15 msgs

Ne plus transmettre de message à cette adresse.
Merci

-----Message d'origine-----

···

De : wxpython-users-admin@wxwindows.org
[mailto:wxpython-users-admin@wxwindows.org]
Envoyé : mercredi 5 juillet 2000 19:35
À : wxpython-users@wxwindows.org
Objet : wxPython-users digest, Vol 1 #90 - 15 msgs

Send wxPython-users mailing list submissions to
  wxpython-users@wxwindows.org

To subscribe or unsubscribe via the web, visit
  http://wxwindows.org/mailman/listinfo/wxpython-users
or, via email, send a message with subject or body 'help' to
  wxpython-users-request@wxwindows.org
You can reach the person managing the list at
  wxpython-users-admin@wxwindows.org

When replying, please edit your Subject line so it is more specific than
"Re: Contents of wxPython-users digest..."

Today's Topics:

  1. Wxpython.wx (Montagne, Michael)
  2. Re: Wxpython.wx (Robin Dunn)
  3. RE: Wxpython.wx (Echeverria Rabi, Cristian Rodrigo, TRANSELEC S.A.)
  4. RE: Wxpython.wx (Yves GROLET)
  5. YASQFAN: Yet Another Stupid Question From A Newbie
(shawn.garbett@cti-pet.com)
  6. Overriding wxApp.MainLoop? wxTimer? (Stephen Hansen)
  7. Re: YASQFAN: Yet Another Stupid Question From A Newbie
(shawn.garbett@cti-pet.com)
  8. Re: Problems with wxPySimpleApp() to open modal dialogs (Chris Barker)
  9. Re: Properties (Chris Barker)
  10. Re: Properties (Joshua Rosen)
  11. glcanvas flickers on linux (Ryan Martin)
  12. RE: glcanvas flickers on linux (Mike Fletcher)
  13. Re: glcanvas flickers on linux (Ryan Martin)
  14. Re: Overriding wxApp.MainLoop? wxTimer? (Robin Dunn)
  15. RE: glcanvas flickers on linux (Mike Fletcher)

--__--__--

Message: 1
From: "Montagne, Michael" <montagne@BOORA.com>
To: "'wxpython-users@wxwindows.org'" <wxpython-users@wxwindows.org>
Date: Wed, 5 Jul 2000 10:21:23 -0700
charset="iso-8859-1"
Subject: [wxPython] Wxpython.wx
Reply-To: wxpython-users@wxwindows.org

Trying to run the demo I get an error trying to import from wxpython.wx. So
I looked for this file on my system and it is not anywhere to be found. I'm
using NT4.0.
What have I done wrong? Everything seemed so straightforward.

-mjm

--__--__--

Message: 2
From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@wxwindows.org>
Subject: Re: [wxPython] Wxpython.wx
Date: Wed, 5 Jul 2000 10:36:15 -0700
charset="iso-8859-1"
Reply-To: wxpython-users@wxwindows.org

Trying to run the demo I get an error trying to import from wxpython.wx.

So

I looked for this file on my system and it is not anywhere to be found.

I'm

using NT4.0.
What have I done wrong? Everything seemed so straightforward.

The package and module names are cases sensitive. Are you using
wxPython.wx? If so, look where you installed at. There should be a
directory named wxPython containing a file named wx.py (and many others.)
The directory containing the wxPython directory should be on the PYTHONPATH,
either in the environment or in the registry.

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!

--__--__--

Message: 3
From: "Echeverria Rabi, Cristian Rodrigo, TRANSELEC S.A."
<cer@transelec.cl>
To: wxpython-users@wxwindows.org
Subject: RE: [wxPython] Wxpython.wx
Date: Wed, 5 Jul 2000 13:38:16 -0400
charset="iso-8859-1"
Reply-To: wxpython-users@wxwindows.org

I suppose you were writing this: from wxPython.wx import *

Maybe you must send the traceback (error) you got. But to find
the file you need to search for wx.py inside a directory called =
"wxPython".

- C r i s t i a n E c h e v e r r i a -

-----Mensaje original-----
De: Montagne, Michael [SMTP:montagne@BOORA.com]
Enviado el: Mi=E9rcoles 5 de Julio de 2000 13:21
Para: 'wxpython-users@wxwindows.org'
Asunto: [wxPython] Wxpython.wx
=20
Trying to run the demo I get an error trying to import from =

wxpython.wx.

So
I looked for this file on my system and it is not anywhere to be =

found.

I'm
using NT4.0.
What have I done wrong? Everything seemed so straightforward.
=20
-mjm
=20
=20
_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

--__--__--

Message: 4
From: "Yves GROLET" <yves@grolet.com>
To: <wxpython-users@wxwindows.org>
Subject: RE: [wxPython] Wxpython.wx
Date: Wed, 5 Jul 2000 19:33:58 +0200
charset="iso-8859-1"
Reply-To: wxpython-users@wxwindows.org

I had this problem when I tried to use wxPython with Python1.6
I have uninstalled Python1.6 and wxPython and then reinstalled everything
with Python 1.5.2 and all goes well.

PS: Excuse my bad English :slight_smile:
__________________________________________
Yves GROLET - Game designer - Game developer
yves@grolet.com

-----Original Message-----
From: wxpython-users-admin@wxwindows.org
[mailto:wxpython-users-admin@wxwindows.org]On Behalf Of Montagne, Michael
Sent: mercredi 5 juillet 2000 19:21
To: 'wxpython-users@wxwindows.org'
Subject: [wxPython] Wxpython.wx

Trying to run the demo I get an error trying to import from wxpython.wx. So
I looked for this file on my system and it is not anywhere to be found. I'm
using NT4.0.
What have I done wrong? Everything seemed so straightforward.

-mjm

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

--__--__--

Message: 5
To: wxpython-users@wxwindows.org
From: Shawn.Garbett@cti-pet.com
Date: Wed, 5 Jul 2000 10:27:06 -0800
Subject: [wxPython] YASQFAN: Yet Another Stupid Question From A Newbie
Reply-To: wxpython-users@wxwindows.org

I'm trying the simple CGI examples from _Python_Essential_Reference_ by
Beazley. I can't get it to find the CGI script. I've tried all kinds of
directories, putting the script everywhere the default directories are,
resetting the CGIHTTPRequestHandler.cgi_directories to point to any given
instance of the script, tried modifying the http string to have a path,
etc, to no avail. Ran apache and ran into similar problems, was able to
edit the http string to get it to find the cgi script, but then it just
said I didn't have permissions to run it. Ugh!!!!

I'm missing something.

Shawn

--__--__--

Message: 6
From: "Stephen Hansen" <stephen@cerebralmaelstrom.com>
To: <wxpython-users@wxwindows.org>
Date: Wed, 5 Jul 2000 11:46:39 -0700
boundary="----=_NextPart_000_008F_01BFE676.AE5E2C80"
Subject: [wxPython] Overriding wxApp.MainLoop? wxTimer?
Reply-To: wxpython-users@wxwindows.org

This is a multi-part message in MIME format.

------=_NextPart_000_008F_01BFE676.AE5E2C80
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

    I'm using the Medusa async I/O core in an application of mine to =
handle some server opperations, and I want to use wxPython for its =
limited GUI. Normally when using asyncore, one would call =
asyncore.loop() when they wan to get everything started and running, but =
when using a GUI app that won't work since I already have a loop going =
-- MainLoop. So instead I need to place calls to asyncore.poll() into =
some sort of loop.

    The wxPython documentation mentions that you can override MainLoop =
to provide your own environment dependant loops. Is that best? Or shold =
I set up a wxTimer? My concern with the latter is that the docs say it's =
a "limited resource", and mention it could fire as infrequently as =
1second, which seems awfully bad :stuck_out_tongue:

    What's the best way to do this?

Thanks,

--Stephen

------=_NextPart_000_008F_01BFE676.AE5E2C80
Content-Type: text/html;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4030.2400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; I'm using the Medusa =
async I/O=20
core in an application of mine to handle some server opperations, and I =
want to=20
use wxPython for its limited GUI. Normally when using asyncore, one =
would call=20
asyncore.loop() when they wan to get everything started and running, but =
when=20
using a GUI app that won't work since I already have a loop going -- =
MainLoop.=20
So instead I need to place calls to asyncore.poll() into some sort of=20
loop.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; The wxPython =
documentation=20
mentions that you can override MainLoop to provide your own environment=20
dependant loops. Is that best? Or shold I set up a wxTimer? My concern =
with the=20
latter is that the docs say it's a "limited resource", and mention it =
could fire=20
as infrequently as 1second, which seems awfully bad :P</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; What's the best way =
to do=20
this?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>--Stephen</FONT></DIV></BODY></HTML>

------=_NextPart_000_008F_01BFE676.AE5E2C80--

--__--__--

Message: 7
Subject: Re: [wxPython] YASQFAN: Yet Another Stupid Question From A Newbie
To: wxpython-users@wxwindows.org
From: Shawn.Garbett@cti-pet.com
Date: Wed, 5 Jul 2000 11:04:30 -0800
Reply-To: wxpython-users@wxwindows.org

I located a cgi expert and pestered him.

I left the ":" out of "Content-type: text/html"

It drove everything daffy.

Do-min-ne-us-Re-qui-em

Wack ! <<<

Do-min-ne-us-Re-qui-em

Wack ! <<<

I'll learn python yet.

                    Shawn.Garbett@cti-pet.co
                    m To:
wxpython-users@wxwindows.org
                    Sent by: cc:
                    wxpython-users-admin@wxw Subject: [wxPython]
YASQFAN: Yet Another Stupid Question From A
                    indows.org Newbie

                    07/05/00 10:27 AM
                    Please respond to
                    wxpython-users

I'm trying the simple CGI examples from _Python_Essential_Reference_ by
Beazley. I can't get it to find the CGI script. I've tried all kinds of
directories, putting the script everywhere the default directories are,
resetting the CGIHTTPRequestHandler.cgi_directories to point to any given
instance of the script, tried modifying the http string to have a path,
etc, to no avail. Ran apache and ran into similar problems, was able to
edit the http string to get it to find the cgi script, but then it just
said I didn't have permissions to run it. Ugh!!!!

I'm missing something.

Shawn

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

--__--__--

Message: 8
Date: Wed, 05 Jul 2000 12:32:37 -0700
From: Chris Barker <cbarker@jps.net>
To: Dirk Hameier <dhameier@dspace.de>
CC: wxpython-users@wxwindows.org, Robin Dunn <robin@alldunn.com>
Subject: Re: [wxPython] Problems with wxPySimpleApp() to open modal dialogs
Reply-To: wxpython-users@wxwindows.org

This is a follow up question to a thread from quite a while back. I kept
it because I thought I would have a use for it, an indeed I do, but now
I have a question about it.

Robin Dunn wrote:

Common dialogs are very thing wrappers around the system dialogs, they

don't

actually create a wxWindow. To solve your problem you need to save a
reference to the app object and jump into MainLoop after your dialog

closes.

This gives the cleanup code in wxApp a chance to 1. process any pending
events, and 2. delete windows that have been closed.

     from wxPython.wx import *

     app = wxPySimpleApp()
     dlg = wxDialog(None, -1, "Test")
     dlg.ShowModal()
     dlg.Destroy()
     app.MainLoop()

This is a little too simple an example to be usefull. Most of the time,
you are going to want to call more than one dilaog box in a session, so
I tried this:

# Begin code###############################################
#!/usr/bin/env python
# a test of wxPySimpleApp

from wxPython.wx import *

app = wxPySimpleApp()

dlg = wxDialog(None, -1, "Test1",wxDefaultPosition,(100,100))
dlg.ShowModal()
dlg.Destroy()

dlg = wxDialog(None, -1, "Test2",wxDefaultPosition,(200,200))
dlg.ShowModal()
dlg.Destroy()

dlg = wxDialog(None, -1, "Test3",wxDefaultPosition,(300,300))
dlg.ShowModal()
dlg.Destroy()

dlg = wxDialog(None, -1, "This is the last",wxDefaultPosition,(400,400))
dlg.ShowModal()
dlg.Destroy()

app.MainLoop()

# END CODE ####################################################

This crashes with a "Segmentation fault (core dumped) "

Oddly enough, it seems to work fine if I only bring up three dialog
boxes, rather than four.

# BEGIN CODE ####################################################

#!/usr/bin/env python
# a test of wxPySimpleApp

from wxPython.wx import *

app = wxPySimpleApp()

dlg = wxDialog(None, -1, "Test1",wxDefaultPosition,(100,100))
dlg.ShowModal()
dlg.Destroy()

app.MainLoop()
app = wxPySimpleApp()

dlg = wxDialog(None, -1, "Test2",wxDefaultPosition,(200,200))
dlg.ShowModal()
dlg.Destroy()

app.MainLoop()
app = wxPySimpleApp()

dlg = wxDialog(None, -1, "Test3",wxDefaultPosition,(300,300))
dlg.ShowModal()
dlg.Destroy()

app.MainLoop()
app = wxPySimpleApp()

dlg = wxDialog(None, -1, "This is the last",wxDefaultPosition,(400,400))
dlg.ShowModal()
dlg.Destroy()

dlg = wxDialog(None, -1, "Just Kidding",wxDefaultPosition,(400,400))
dlg.ShowModal()
dlg.Destroy()

app.MainLoop()

# END CODE ####################################################

In this case, I get a lot of errors like:

GLib-CRITICAL **: file gmain.c: line 500 (g_source_remove): assertion
`tag > 0'
failed.

It does seem to work, in spite of the errors. I also tried putting a
"del(app)" in there before re-creating it, with no difference.

So, here ios what I want to do:

Have a procedural app, that isn't event driven, and doesn't have a main
window. I want it to start, do some stuff, occasionally ask the user a
question via a dialog box, and then end, with no limit on how many
questions can be asked before ending.

How do I do that?

-Chris

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

--__--__--

Message: 9
Date: Wed, 05 Jul 2000 13:12:59 -0700
From: Chris Barker <cbarker@jps.net>
To: wxpython-users@wxwindows.org
Subject: Re: [wxPython] Properties
Reply-To: wxpython-users@wxwindows.org

Might it be a good idea to go halfway on the properties thing?

I can see why people would object to a line of code a simple as:

thing.size = (100, 200)

having all sorts of side effects, but, by the same token, why do I have
to call a method like:

size = thing.GetSize()

when

size = thing.size

Would do just as well, and not have any side effects? Personally I
always find it odd (and annoying) when I have to call a method to just
get a value from an object. It requires the user to know whether or not
something has to be done to get that value, rather than it just being
stored. Why should we have to know that much about the internals?

Unfortunately, Python is full of such things that drive me crazy, such
as:

dict.keys()

to get the list of keys in a dictionary. I'm not altering anything, why
should it be a method?

Someone earlier in this thread said that in OOP, a method DOES
something, while an attribute holds a value. looking at a value isn't
exactly DOING something it my book, so it shouldn't be a method.

Just some more of my humble opinion.

-Chris

--
Christopher Barker,
Ph.D.
cbarker@jps.net --- --- ---
http://www.jps.net/cbarker -----@@ -----@@ -----@@
                                   ------@@@ ------@@@ ------@@@
Water Resources Engineering ------ @ ------ @ ------ @
Coastal and Fluvial Hydrodynamics ------- --------- --------
------------------------------------------------------------------------
------------------------------------------------------------------------

--__--__--

Message: 10
<4.2.2.20000701082315.00b69100@mailserver.sfu.ca> <20000703204627.A14116@yyz.electricrain.com>
From: "Joshua Rosen" <rozzin@jello.geekspace.com>
To: wxpython-users@wxwindows.org
Subject: Re: [wxPython] Properties
Date: Wed, 05 Jul 2000 20:36:23 GMT
Reply-To: wxpython-users@wxwindows.org

Gregory P. Smith writes:

This is the evil of operator overloading.
Unless the semantics are -exactly- the same as the original just don't
do it. (ie: for = there should be no side effects....

Assignment is, by definition, a side effect. Now, if `=' isn't supposed to
be assignment (and it's obviously not an equivalence-check), what is it
supposed to be?

--__--__--

Message: 11
Date: Wed, 5 Jul 2000 15:47:13 -0700
From: Ryan Martin <ryanm@wag.caltech.edu>
To: wxpython-users@wxwindows.org
Subject: [wxPython] glcanvas flickers on linux
Reply-To: wxpython-users@wxwindows.org

I have a program that loads and saves molecular description files and
gives the option to display them using opengl. When the user double
clicks on a molecule, I render that molecule in a second frame
containing a glcanvas object. It works fine but the moment I start
to rotate, translate or zoom on the molecule(meaning OnPaint is
being called a lot) the canvas flickers. I'm using the standard
SwapBuffers command that comes with glcanvas. Has anyone else run into
this problem using wxGTK on linux? Hopefully I can find a fix for this
so I don't have to go back to tkinter and try to get togl to work.

I'm using wxPython 2.1.16, wxWindows 2.1.16, GTK+ 1.2.8, and Mesa 3.2.

I'm not subscribe to the list, so can you please cc me on any replies.

Thanks.

-Ryan

--__--__--

Message: 12
From: Mike Fletcher <mfletch@tpresence.com>
To: "'wxpython-users@wxwindows.org'" <wxpython-users@wxwindows.org>
Cc: "'ryanm@wag.caltech.edu'" <ryanm@wag.caltech.edu>
Subject: RE: [wxPython] glcanvas flickers on linux
Date: Wed, 5 Jul 2000 19:53:32 -0400
charset="iso-8859-1"
Reply-To: wxpython-users@wxwindows.org

From a little internal project...

class GLCanvas(glcanvas.wxGLCanvas):
  def __init__(self, parent):
    glcanvas.wxGLCanvas.__init__(self, parent, -1)
    self.init = false
    EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
    EVT_CHAR(self, self.OnChar)
    EVT_LEFT_DOWN( self, self.OnMouseClickLeft )
    EVT_MOTION( self, self.OnMouseMove )
    EVT_LEFT_UP( self, self.OnMouseReleaseLeft )
    self.platform = viewplatform.ViewPlatform(
fieldOfView=self.fieldOfView )
  def OnEraseBackground(self, event):
    pass # Do nothing, to avoid flashing.

HTH,
Mike

-----Original Message-----
From: Ryan Martin [mailto:ryanm@wag.caltech.edu]
Sent: Wednesday, July 05, 2000 6:47 PM
To: wxpython-users@wxwindows.org
Subject: [wxPython] glcanvas flickers on linux

I have a program that loads and saves molecular description files and
gives the option to display them using opengl. When the user double
clicks on a molecule, I render that molecule in a second frame
containing a glcanvas object. It works fine but the moment I start
to rotate, translate or zoom on the molecule(meaning OnPaint is
being called a lot) the canvas flickers. I'm using the standard
SwapBuffers command that comes with glcanvas. Has anyone else run into
this problem using wxGTK on linux? Hopefully I can find a fix for this
so I don't have to go back to tkinter and try to get togl to work.

I'm using wxPython 2.1.16, wxWindows 2.1.16, GTK+ 1.2.8, and Mesa 3.2.

I'm not subscribe to the list, so can you please cc me on any replies.

Thanks.

-Ryan

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

--__--__--

Message: 13
Date: Wed, 5 Jul 2000 17:00:36 -0700
From: Ryan Martin <ryanm@wag.caltech.edu>
To: Mike Fletcher <mfletch@tpresence.com>
Cc: wxpython-users@wxwindows.org
Subject: Re: [wxPython] glcanvas flickers on linux
Reply-To: wxpython-users@wxwindows.org

Sorry, forgot to mention I already have an empty OnEraseBackground
handler. The problem is something else.

-Ryan

Mike Fletcher (mfletch@tpresence.com) [000705 16:54]

>From a little internal project...

class GLCanvas(glcanvas.wxGLCanvas):
  def __init__(self, parent):
    glcanvas.wxGLCanvas.__init__(self, parent, -1)
    self.init = false
    EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
    EVT_CHAR(self, self.OnChar)
    EVT_LEFT_DOWN( self, self.OnMouseClickLeft )
    EVT_MOTION( self, self.OnMouseMove )
    EVT_LEFT_UP( self, self.OnMouseReleaseLeft )
    self.platform = viewplatform.ViewPlatform(
fieldOfView=self.fieldOfView )
  def OnEraseBackground(self, event):
    pass # Do nothing, to avoid flashing.

HTH,
Mike

-----Original Message-----
From: Ryan Martin [mailto:ryanm@wag.caltech.edu]
Sent: Wednesday, July 05, 2000 6:47 PM
To: wxpython-users@wxwindows.org
Subject: [wxPython] glcanvas flickers on linux

I have a program that loads and saves molecular description files and
gives the option to display them using opengl. When the user double
clicks on a molecule, I render that molecule in a second frame
containing a glcanvas object. It works fine but the moment I start
to rotate, translate or zoom on the molecule(meaning OnPaint is
being called a lot) the canvas flickers. I'm using the standard
SwapBuffers command that comes with glcanvas. Has anyone else run into
this problem using wxGTK on linux? Hopefully I can find a fix for this
so I don't have to go back to tkinter and try to get togl to work.

I'm using wxPython 2.1.16, wxWindows 2.1.16, GTK+ 1.2.8, and Mesa 3.2.

I'm not subscribe to the list, so can you please cc me on any replies.

Thanks.

-Ryan

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

--__--__--

Message: 14
From: "Robin Dunn" <robin@alldunn.com>
To: "wxPython-users" <wxpython-users@wxwindows.org>
Subject: Re: [wxPython] Overriding wxApp.MainLoop? wxTimer?
Date: Wed, 5 Jul 2000 17:29:33 -0700
boundary="----=_NextPart_000_0008_01BFE6A6.95650B10"
Reply-To: wxpython-users@wxwindows.org

This is a multi-part message in MIME format.

------=_NextPart_000_0008_01BFE6A6.95650B10
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

      The wxPython documentation mentions that you can override MainLoop =
to provide your own environment dependant loops. Is that best? Or shold =
I set up a wxTimer? My concern with the latter is that the docs say it's =
a "limited resource", and mention it could fire as infrequently as =
1second, which seems awfully bad :stuck_out_tongue:
  =20
      What's the best way to do this?
  =20
If you havn't seen it already, there is an example of overriding the =
MainLoop in demo/demoMainLoop.py.

A couple other alternatives to think about:

1. Use an idle event handler. When the GUI's event queue becomes empty =
an idle event is sent to all top level windows. If the event handler =
calls event.RequestMore(true) then idle events will be sent again and =
again until there are GUI events waiting or you don't call RequestMore.

2. Run the GUI in the main thread and run your asyncore server in =
another thread. This will let each run "normally" without having to =
worry about sharing the main loop. The downside is that updating the =
GUI from the server will become a bit more complicated as most GUI =
functions can only be called from the GUI thread. See the Threads demo =
for an example of using custom events sent from a non-GUI thread to =
update a GUI.

It's hard to say which approach would work best for you. All four would =
probably work, but the MainLoop surgery and idle handler approaches will =
probably have an impact on CPU as there won't be any time that the =
application is just sitting (truly) idle waiting for an event to happen. =
The thread approach will be best for the CPU but could be more complex.

Let us know what you end up with.

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!

------=_NextPart_000_0008_01BFE6A6.95650B10
Content-Type: text/html;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3017.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; The wxPython =
documentation=20
  mentions that you can override MainLoop to provide your own =
environment=20
  dependant loops. Is that best? Or shold I set up a wxTimer? My concern =
with=20
  the latter is that the docs say it's a "limited resource", and mention =
it=20
  could fire as infrequently as 1second, which seems awfully bad =
:P</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; What's the best =
way to do=20
  this?</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BLOCKQUOTE>
<DIV><FONT size=3D2>
<DIV><FONT size=3D2>If you havn't seen it already, there is an example =
of=20
overriding the MainLoop in demo/demoMainLoop.py.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>A couple other alternatives to think =
about:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>1. Use an idle event handler.&nbsp; When the GUI's=20
event&nbsp;queue becomes empty an idle event is sent to all top level=20
windows.&nbsp; If the event handler calls event.RequestMore(true) then =
idle=20
events will be sent&nbsp;again and again until there are GUI events =
waiting or=20
you don't call RequestMore.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>2. Run the GUI in the main thread and run your =
asyncore server=20
in another thread.&nbsp; This will let each run "normally" without =
having to=20
worry about sharing the main loop.&nbsp; The downside is that updating =
the GUI=20
from the server will become a bit more complicated as most GUI functions =
can=20
only be called from the GUI thread.&nbsp; See the Threads demo for an =
example of=20
using custom events sent from a non-GUI thread to update a =
GUI.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>It's hard to say which approach would work best for =
you.&nbsp;=20
All four would probably work, but the MainLoop surgery and idle handler=20
approaches will probably have an impact on CPU as there won't be any =
time that=20
the&nbsp;application is just sitting (truly) idle waiting for an event =
to=20
happen.&nbsp; The thread approach will be best for the CPU but could be =
more=20
complex.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>Let us know what you end up with.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>--<BR>Robin Dunn<BR>Software Craftsman<BR><A=20
href=3D"mailto:robin@AllDunn.com">robin@AllDunn.com</A><BR><A=20
href=3D"http://wxpython.org">http://wxpython.org</A>&nbsp;&nbsp;&nbsp;&nb=
sp; Java=20
give you jitters?<BR><A=20
href=3D"http://wxpros.com">http://wxpros.com</A>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;=20
Relax with wxPython!<BR></FONT></DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_0008_01BFE6A6.95650B10--

--__--__--

Message: 15
From: Mike Fletcher <mfletch@tpresence.com>
To: "'wxpython-users@wxwindows.org'" <wxpython-users@wxwindows.org>
Cc: "'ryanm@wag.caltech.edu'" <ryanm@wag.caltech.edu>
Subject: RE: [wxPython] glcanvas flickers on linux
Date: Wed, 5 Jul 2000 20:34:58 -0400
charset="iso-8859-1"
Reply-To: wxpython-users@wxwindows.org

Okay, here's the whole demo. Unfortunately, it relies on all sorts of stuff
that I can't release, but it doesn't flicker. Things to note:

    self.Refresh(eraseBackground=FALSE)
  Uses double buffered OpenGL (swapbuffers)

Other than that, I'm at a loss. I used to fool with the Frame's styles to
attempt to get it to no draw in the client areas, but it didn't seem to make
a difference (so I removed it).

Good luck,
Mike

from math import pi
dependencies = '''This demo requires:
  wxPython (with wxGLCanvas compiled)
  PyOpenGL
  Numeric Python
  PyOpenGL extensions to support array drawing.
'''
try:
  from wxPython.wx import *
  from OpenGL.GL import *
  from OpenGL.GLU import *
  from wxPython import glcanvas
  import Numeric # just to make sure it's there before we start
working...
except ImportError, value:
  print dependencies
  raise

from glscenegraph import viewplatform
from glscenegraph.constants import *

class GLCanvas(glcanvas.wxGLCanvas):
  deltaTurn = pi/64
  step = 0.1
  multiplier = 4
  fieldOfView = pi/2
  lookAroundRotations = {
    WXK_UP:(1,0,0,-deltaTurn),
    WXK_DOWN: (1,0,0,deltaTurn),
    WXK_RIGHT: (0,1,0,-deltaTurn),
    WXK_LEFT: (0,1,0,deltaTurn),
  }
  def __init__(self, parent):
    glcanvas.wxGLCanvas.__init__(self, parent, -1)
    self.init = false
    EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
    EVT_CHAR(self, self.OnChar)
    EVT_LEFT_DOWN( self, self.OnMouseClickLeft )
    EVT_MOTION( self, self.OnMouseMove )
    EVT_LEFT_UP( self, self.OnMouseReleaseLeft )
    self.platform = viewplatform.ViewPlatform(
fieldOfView=self.fieldOfView )
  def OnPaint(self, event):
    dc = wxPaintDC(self)

    ctx = self.GetContext()
    if not ctx: return

    self.SetCurrent()

    if not self.init:
      self.InitGL()
      self.init = true
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    self.platform.render()
    self.DrawGeometry ()
    self.SwapBuffers()
  def DrawGeometry (self, mode=RENDER_MODE_OPAQUE ):
    ''' Override this to draw your own geometry '''
  def InitGL(self):
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glMatrixMode(GL_PROJECTION);
    self.platform.setup()
    glMatrixMode(GL_MODELVIEW);

    glDisable( GL_FOG )
    glDisable( GL_TEXTURE_2D );

    glEnable( GL_CULL_FACE );
    glFrontFace( GL_CCW );
    glCullFace( GL_BACK );

    glDisable( GL_COLOR_MATERIAL );
    glDisable(GL_BLEND);
    glShadeModel( GL_SMOOTH );
  def OnMouseMove ( self, event ):
    # see if we're over a sensitive child
    result = glSelectWithCallback( event.GetX(), event.GetY(),
self.renderPick)
    if result: # is over a sensitive object:
      print "over", result
  def OnMouseClickLeft( self, event ):
## print "OnMouseClickLeft", event.GetX(), event.GetY()
    result = glSelectWithCallback( event.GetX(), event.GetY(),
self.renderPick)
    if result: # is over a sensitive object:
      print "click", result
  def OnMouseReleaseLeft( self, event ):
    result = glSelectWithCallback( event.GetX(), event.GetY(),
self.renderPick)
    if result: # is over a sensitive object:
      print "release over", result

  def renderPick( self ):
    self.DrawGeometry( mode = RENDER_MODE_SELECT_FORCED )
    # do interpretation here...

  def OnChar(self, event):
    code = event.KeyCode()
    # general commands
    if code == ord('-'): #
      self.platform.straighten()
    # control modes...
    elif event.ControlDown():
      # This is the "look around" mode
      rotation = self.lookAroundRotations.get( code)
      if rotation:
        self.platform.turn ( rotation )
      else:
        event.Skip ()
        return
    else:
      # default is "walk/fly" mode
      if event.ShiftDown():
        multiplier = self.multiplier
      else:
        multiplier = 1
      if code == WXK_UP:
        # forward
        self.platform.forward(self.step*multiplier)
      elif code ==WXK_DOWN:
        # backward
        self.platform.forward
(-self.step*multiplier)
      else:
        # either a turn or nothing
        rotation = self.lookAroundRotations.get(
code)
        if rotation:
          self.platform.turn ( rotation )
        else:
          event.Skip ()
          return
    # force a repaint
    self.Refresh(eraseBackground=FALSE)
  def OnEraseBackground(self, event):
    pass # Do nothing, to avoid flashing.

  def OnSize(self, event):
    size = self.GetClientSize()
    if self.GetContext() != 'NULL':
      self.SetCurrent()
      # aspect ratio calculation
      # fov represents the vertical field of view
      # aspect represents ratio of width to height for
field of view
      # we want the field of view to the constant for the
smallest dimension
      # and all visible ratios to be 1.0:1.0
      if size.height > 0 and size.width >0:
        ratio = size.width/float(size.height )
        if size.height < size.width:
          # width specifies field of view
          fieldOfView = self.fieldOfView/ratio
        else:
          fieldOfView = self.fieldOfView
        self.platform.set_frustrum( fieldOfView,
ratio)
        self.platform.setup()
        self.Refresh (eraseBackground=FALSE)
      glViewport(0, 0, size.width, size.height)

if __name__ == '__main__':
  class TestGLCanvas( GLCanvas ):
    def DrawGeometry (self):
      ''' Override this to draw your own geometry '''
      glMatrixMode(GL_MODELVIEW)
      glPushMatrix()
      glRotate(1,0,0,-90)
      glDisable(GL_LIGHTING)
      glColor3f( 0,0,.3)
      fullsize = 40
      tilesize = 4

      glBegin(GL_QUADS)
      for x in range(-(fullsize/2),(fullsize/2),tilesize):
        for y in
range(-(fullsize/2),(fullsize/2),tilesize):
          if (((x+y)/tilesize)%2):
            glNormal3f( 0.0, 1.0, 0.0)
            glVertex3f( x, 0, y)
            glVertex3f( x, 0,
y+tilesize)
            glVertex3f( x+tilesize, 0,
y+tilesize)
            glVertex3f( x+tilesize, 0,
y)
      glEnd( )
      glColor3f( 1,1,0)
      glBegin(GL_QUADS)
      for x in range(-(fullsize/2),(fullsize/2),tilesize):
        for y in
range(-(fullsize/2),(fullsize/2),tilesize):
          if not (((x+y)/tilesize)%2):
            glNormal3f( 0.0, 1.0, 0.0)
            glVertex3f( x, 0, y)
            glVertex3f( x, 0,
y+tilesize)
            glVertex3f( x+tilesize, 0,
y+tilesize)
            glVertex3f( x+tilesize, 0,
y)
      glEnd( )
      glPopMatrix()
      # clear color and depth buffers
      glEnable(GL_LIGHTING)

      glPushMatrix()
      glColor3f( .8,.8,0)
      glTranslate( 0,.5,0)
      glRotatef(30.0, 1.0, 0.0, 0.0);
      glRotatef(30.0, 0.0, 1.0, 0.0);
      # draw six faces of a cube
      glBegin(GL_QUADS)
      glNormal3f( 0.0, 0.0, 1.0)
      glVertex3f( 0.5, 0.5, 0.5)
      glVertex3f(-0.5, 0.5, 0.5)
      glVertex3f(-0.5,-0.5, 0.5)
      glVertex3f( 0.5,-0.5, 0.5)

      glNormal3f( 0.0, 0.0,-1.0)
      glVertex3f(-0.5,-0.5,-0.5)
      glVertex3f(-0.5, 0.5,-0.5)
      glVertex3f( 0.5, 0.5,-0.5)
      glVertex3f( 0.5,-0.5,-0.5)

      glNormal3f( 0.0, 1.0, 0.0)
      glVertex3f( 0.5, 0.5, 0.5)
      glVertex3f( 0.5, 0.5,-0.5)
      glVertex3f(-0.5, 0.5,-0.5)
      glVertex3f(-0.5, 0.5, 0.5)

      glNormal3f( 0.0,-1.0, 0.0)
      glVertex3f(-0.5,-0.5,-0.5)
      glVertex3f( 0.5,-0.5,-0.5)
      glVertex3f( 0.5,-0.5, 0.5)
      glVertex3f(-0.5,-0.5, 0.5)

      glNormal3f( 1.0, 0.0, 0.0)
      glVertex3f( 0.5, 0.5, 0.5)
      glVertex3f( 0.5,-0.5, 0.5)
      glVertex3f( 0.5,-0.5,-0.5)
      glVertex3f( 0.5, 0.5,-0.5)

      glNormal3f(-1.0, 0.0, 0.0)
      glVertex3f(-0.5,-0.5,-0.5)
      glVertex3f(-0.5,-0.5, 0.5)
      glVertex3f(-0.5, 0.5, 0.5)
      glVertex3f(-0.5, 0.5,-0.5)
      glEnd()

      glPopMatrix()
  class MyApp(wxApp):
    def OnInit(self):
      frame = wxFrame(NULL, -1, "GL Cube",
wxDefaultPosition, wxSize(400,300))
      win = TestGLCanvas(frame)
      frame.Show(TRUE)
      self.SetTopWindow(frame)
      return TRUE

  app = MyApp(0)
  app.MainLoop()

-----Original Message-----
From: Ryan Martin [mailto:ryanm@wag.caltech.edu]
Sent: Wednesday, July 05, 2000 8:01 PM
To: Mike Fletcher
Cc: wxpython-users@wxwindows.org
Subject: Re: [wxPython] glcanvas flickers on linux

Sorry, forgot to mention I already have an empty OnEraseBackground
handler. The problem is something else.

-Ryan

Mike Fletcher (mfletch@tpresence.com) [000705 16:54]

>From a little internal project...

class GLCanvas(glcanvas.wxGLCanvas):
  def __init__(self, parent):
    glcanvas.wxGLCanvas.__init__(self, parent, -1)
    self.init = false
    EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
    EVT_CHAR(self, self.OnChar)
    EVT_LEFT_DOWN( self, self.OnMouseClickLeft )
    EVT_MOTION( self, self.OnMouseMove )
    EVT_LEFT_UP( self, self.OnMouseReleaseLeft )
    self.platform = viewplatform.ViewPlatform(
fieldOfView=self.fieldOfView )
  def OnEraseBackground(self, event):
    pass # Do nothing, to avoid flashing.

HTH,
Mike

-----Original Message-----
From: Ryan Martin [mailto:ryanm@wag.caltech.edu]
Sent: Wednesday, July 05, 2000 6:47 PM
To: wxpython-users@wxwindows.org
Subject: [wxPython] glcanvas flickers on linux

I have a program that loads and saves molecular description files and
gives the option to display them using opengl. When the user double
clicks on a molecule, I render that molecule in a second frame
containing a glcanvas object. It works fine but the moment I start
to rotate, translate or zoom on the molecule(meaning OnPaint is
being called a lot) the canvas flickers. I'm using the standard
SwapBuffers command that comes with glcanvas. Has anyone else run into
this problem using wxGTK on linux? Hopefully I can find a fix for this
so I don't have to go back to tkinter and try to get togl to work.

I'm using wxPython 2.1.16, wxWindows 2.1.16, GTK+ 1.2.8, and Mesa 3.2.

I'm not subscribe to the list, so can you please cc me on any replies.

Thanks.

-Ryan

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

--__--__--

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

End of wxPython-users Digest