[Tutor] Interactive plots...

Michael Langford mlangford.cs03 at gtalumni.org
Tue Apr 1 19:30:46 CEST 2008

If you're just talking about something like this (ascii art) drawing:

1:*          * * * * * * * *                    *

0:  * * * *                    * * * * * * * *   * * * * * * *

Then I think you have a relatively simple alternative for a UI:

Create a scrollable UI in the toolkit of your choice. It scrolls left to
right. Make a series of radiobutton selections with all of the UI components
matching the background color. That way you only get the actual clickable
dots. Then your users can click on the dot to move it to the opposite
position (by overriding the on-click handler).

A rough tkinter solution without scrolling, the selection buttons removed,
or the switching logic follows this reply. You can make the following nicer
by rewriting the click command, and you can probably find a way to make
tkinter hide the empty circles or use a different toolkit to implement the
same idea. You should be able to put an X axis in to show time or whatever
dimension your data is over.


from Tkinter import *

def createDataPoint(master,var):


class Application(Frame):
    def __init__(self, master=None,data=[1]):
        Frame.__init__(self, master)
        self.data = data

    def show(self):
        l = []
        for each in self.ivlist:

    def createWidgets(self):
        self.showButton = Button ( self, text="Show",
            command=self.show )
        self.ivlist = []
        for i in range(len(self.data)):
            iv = IntVar(value=self.data[i])
            f = Frame(self)

if "__main__"==__name__:
  data = [1,0,1,0,1,1,1,1,0,1]
  app = Application(data=data)
  app.master.title("Flippin DOTS")

On Thu, Mar 27, 2008 at 6:54 PM, David Perlman <dperlman at wisc.edu> wrote:

> I am thinking about writing a program which will involve, among other
> things, displaying a plot of a series of numbers.  The idea is that
> you could click on the points and move them to change the numbers.
> Reverse-plotting, I suppose.  It need not be complex; the numbers
> will all be zero or one, and it's only necessary to flip the bits, so
> click-and-drag is seriously overkill.  Really it would be better to
> just double-click on a point to switch it from one value to the other.
> Can anyone point me in the right direction?  I have written some
> programs in python before, including TKinter, but this new project is
> beyond the point that I know where to even start looking.  :)
> In case you care, the application is in functional brain imaging; the
> brain scans generate a certain number of time points (say 500) and
> then the motion of the subject is also calculated.  Standard practice
> is to generate a "censor" file composed of zeros and ones, where zero
> indicates that that time point had excessive motion and must be
> disregarded.  I want to display a graph of the motion over time, and
> allow quick and easy interactive editing of the censor time series in
> visual parallel to the motion graph.  This would save a lot of time;
> at present everyone does this in Excel, which being a horrible
> Windows program can't be integrated into the predominantly UNIX-based
> processing pipeline.  And in any case, it requires manually typing
> all the zeros, looking back and forth between the graph of motion and
> the list of numbers.
> I have already written a program to algorithmically generate the
> censor time series from the motion data, but it is absolutely
> essential to be able to manually double-check and if necessary make
> minor edits.  I'd like to be able to keep that functionality in
> Python rather than sending everyone back to Excel...  if possible!
> Thanks very much for any help.
> --
> -dave----------------------------------------------------------------
> "Pseudo-colored pictures of a person's brain lighting up are
> undoubtedly more persuasive than a pattern of squiggles produced by a
> polygraph.  That could be a big problem if the goal is to get to the
> truth."  -Dr. Steven Hyman, Harvard
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Michael Langford
Phone: 404-386-0495
Consulting: http://www.RowdyLabs.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080401/3890a831/attachment.htm 

More information about the Tutor mailing list