Louis Pecora wrote:
Chris Barker wrote:

If you are interested in using FloatCanvas, you should send me a note, and I'll send you the latest version, and I can add you to a low-traffic mailing list for announcements and technical discussion.

Thanks for the offer.  I'll take you up on it.

I've added you to the list, and I'll send you the latest in a separate email.

I'm curious why you don't think matplotlib will help you here, though perhaps you mean it can't do the job by itself, which makes sense, it's a plotting library, not a GUI toolkit. Matplotlib + wxPython is a potent combination, however.

Because matplotlib presents the plot at the end of the program.

No it doesn't. At least it doesn't have to. That is the one fault I have with matplotlib, the docs are so focused on how you can use it like Matlab, that new users don't realize what a rich interface it provides for real OO programming.

> My
programs are written to be interactive and continue running, i.e. calculate something or massage data, plot the result, close the plot window, do more stuff, check another plot, or other options not in any particular order.

matplotlib is fully capable of doing all that. Look in the docs and mailing list for "embedded in wx" and "OO interface" and things like that. The core issue is that you want your program to manage the plotting window, not pylab. That's what embedded in wx means.

What kind of data are you trying to display, and how do you want it to look? I(we) can help steer you in the right direction.

I just need simple plotting. Example, feed a function a table of values over a common x-axis, plot them all in a window maybe each a different color and/or line thickness. Nothting fancy.

There is also wx.lib.plot, which can do this. However, we all know how these things work out: you start with simple needs, then suddenly you need a log plot or something. I'd take the time to figure out matplotlib. Much as I'd like to have you as a FloatCanvas user/bug reporter/ contributer, I think matplotlib is probably what you need.

>  But gotta keep
that program going when the window is closed. Possible problem: I use standard I/O to "talk" to the program (e.g. print and readline) in a terminal window. I don't have time for a fancier GUI and I really don't
need one.

This is a bit of a problem. In general, with wxPython, when you start the mainloop, the python interpreter halts and waits for it to finish before continuing, so it's hard to mingle wxPython and the command line. A few options to address this:

1) ipython
2) PyCrust
3) GUI_thread (or something, with scipy. I think that may be a sleeping project, however)

Also, in the pile of demos I sent is one called "ProceduralTest.py" which shows how you can pop up a bunch of wxPython dialogs in a procedural program (as opposed to an event-driven one). Perhaps you could pop up matplotlib windows the same way.

I've enclosed that demo, with a raw_input() call, to test it. It seems to work OK, except that focus doesn't return to the terminal window properly.

Incomplete means I can't find a list of classes, colors, event defintions, etc. It's just random hunting.

Well, it's not all that well indexed, but it's there. Have you found the "Alphabetical Class Index"

Chris, Thanks for your help and encouragement. Back to the drawing board.

You're welcome. I've found myself to be very productive in wxPython, so I like to spread the word.

-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

[EMAIL PROTECTED]
#!/usr/bin/env pythonw

"""

This is a little script that tried to demonstrate a simple "procedural"
program using wxPython. tHe goal is to have a script that runs through a
few questions for the user, poppin up dialogs as it goes, but wittout a
main frame, and all the baggage that usually comes with writing a full,
event drive app.

"""

import wx

from sys import exit

## Here's an example of a custom dialog with no parent
class MyCheckDialog(wx.Dialog):
    def __init__(self, Choices):
        wx.Dialog.__init__(self, None, -1, 'wxDialog')
        self.Choices = Choices 

        self.clb = wx.CheckListBox(self, -1, wx.DefaultPosition, 
wx.DefaultSize, self.Choices)

        ok = wx.Button(self, wx.ID_OK, 'Ok')
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.clb, 1, wx.EXPAND|wx.ALL, 5)
        sizer.Add(ok, 0, wx.ALIGN_RIGHT|wx.ALL^wx.TOP, 5)
        self.SetSizer(sizer)
        #self.Fit()
        
        self.Center() # make it come up on the center of the screen

    def GetChecked(self):
        Checked = []
        for (index, item) in enumerate(self.Choices):
            if self.clb.IsChecked(index):
                Checked.append(item)
        return Checked

# You could put some code here, to run before initializing wx.

# you need to start by initializing a wxApp
app = wx.PySimpleApp()


## now you can run your script, bringing  up various dialogs.

fd = wx.FileDialog(None,"Pick a File")
if fd.ShowModal() != wx.ID_OK:
    exit(1)
else:
    print "You choose the file: ", fd.GetFilename()

md = wx.MessageDialog(None, 'Continue?')
if md.ShowModal() != wx.ID_OK:
    exit(1)
else:
    print "You chose to continue"

scd = wx.SingleChoiceDialog(None, 'Pick One',
                            'A Single Choice Dialog',
                            ['single', 'choice', 
'dialog','with','some','choices'])
if scd.ShowModal() != wx.ID_OK:
    exit(1)
else:
    print "You chose:", scd.GetStringSelection()

# now lets get some input on the command line:
I = raw_input("type something here >>")
print "You typed:", I


myd = MyCheckDialog(['check', 'list', 'box', 'another'])
if myd.ShowModal() != wx.ID_OK:
    exit(1)
else:
    print "You checked:", myd.GetChecked()

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to