Thank you wxPython mailing list!

I started the journey of writting a program because I couldn’t

find a program someone else had written that did what I wanted.

I was a neophyte at best. You guys helped me along, and

the first “version” of TopiView (my program) was born. It worked.

After showing some of you my finished product, you told me

of the “better way” time and time again, and now I wanted to

share with you some details of my journey.

First off, TopiView is meant to parse a log file in real time.

As new lines are added to the log, those lines are read, and

depending on the parameters the user sets those lines are

sorted to various frames with a text control widget in them.

The user can elect to set an audio trigger to alert the user

that a line of text has been matched.

As for the actual value to Joe Schmoe? That’s relative…

For me, it allows me to remove chat boxes from a game I

play and stick that dialog on my computer’s second monitor.

Thus, letting me “see” more of the game environment instead

of the games cluttered user interface.

TopiView ugly version:

  • 1386 lines of code

  • 45+ global variables

  • The user had to use all 6 containers / search strings.

  • No real time sample of back / fore ground color, or fonts.

  • 1 search string per container, 1 sound per container.

  • No refactors, or abstracting (lots of fluff code, not dynamic)

  • Exceptions handled poorly.

TopiView less ugly version:

  • 725 lines of code

  • 0 global variables

  • The user sets how many containers they want.

  • Real time visual of color combinations and fonts in configuration dialog.

  • 2 search strings per container, 1 sound per search string.

  • Everything is refactored and abstracted (less fluff, as dynamic as I knew how to make.)

  • User is “herded” away from ever encountering an exception.

Dictionaries and lists are a wonderfull thing!

Thank you all! I really couldn’t have done this without your help.

Steve

I’m glad we’ve been able to help you to make your program at the same time: smaller, better, more usable!

Regards,

–Tim

···

On Sat, Aug 16, 2008 at 8:47 AM, Steve Freedenburg stevefreedenburg@charter.net wrote:

I started the journey of writting a program because I couldn’t

find a program someone else had written that did what I wanted.

I was a neophyte at best. You guys helped me along, and

the first “version” of TopiView (my program) was born. It worked.

After showing some of you my finished product, you told me

of the “better way” time and time again, and now I wanted to

share with you some details of my journey.

Steve Freedenburg wrote:

I started the journey of writting a program because I couldn't
find a program someone else had written that did what I wanted.
I was a neophyte at best. You guys helped me along, and
the first "version" of TopiView (my program) was born. It worked.
After showing some of you my finished product, you told me
of the "better way" time and time again, and now I wanted to
share with you some details of my journey.
First off, TopiView is meant to parse a log file in real time.
As new lines are added to the log, those lines are read, and
depending on the parameters the user sets those lines are
sorted to various frames with a text control widget in them.
The user can elect to set an audio trigger to alert the user
that a line of text has been matched.
As for the actual value to Joe Schmoe? That's relative...
For me, it allows me to remove chat boxes from a game I
play and stick that dialog on my computer's second monitor.
Thus, letting me "see" more of the game environment instead
of the games cluttered user interface.
TopiView ugly version:
- 1386 lines of code
- 45+ global variables
- The user had to use all 6 containers / search strings.
- No real time sample of back / fore ground color, or fonts.
- 1 search string per container, 1 sound per container.
- No refactors, or abstracting (lots of fluff code, not dynamic)
- Exceptions handled poorly.
TopiView less ugly version:
- 725 lines of code
- 0 global variables
- The user sets how many containers they want.
- Real time visual of color combinations and fonts in configuration dialog.
- 2 search strings per container, 1 sound per search string.
- Everything is refactored and abstracted (less fluff, as dynamic as I knew how to make.)
- User is "herded" away from ever encountering an exception.
Dictionaries and lists are a wonderfull thing!
Thank you all! I really couldn't have done this without your help.
Steve

It's good to hear you got it done and improved it so much! I hope you'll continue to develop and come back here time and again to share your discoveries.

···

-------------------
Mike Driscoll

Blog: http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org

I'm just starting out on a program for a test pattern generator for projectors. There are alot out there, and
this one won't be anything special, but I want to learn how to interface with specific parts of a computer.
I'd like to see if Python and read (poll) and send data through USB , RS-232 and parallel ports of a computer
and start using Python as a front end for whatever projects I do with micro controllers

It's been great learning so much from you guys... I'm not going anywhere

Steve

···

----- Original Message ----- From: "Mike Driscoll" <mike@pythonlibrary.org>
To: <wxpython-users@lists.wxwidgets.org>
Sent: Sunday, 17 August, 2008 17:11
Subject: Re: [wxpython-users] Thank you wxPython mailing list!

Steve Freedenburg wrote:

I started the journey of writting a program because I couldn't
find a program someone else had written that did what I wanted.
I was a neophyte at best. You guys helped me along, and
the first "version" of TopiView (my program) was born. It worked.
After showing some of you my finished product, you told me
of the "better way" time and time again, and now I wanted to
share with you some details of my journey.
First off, TopiView is meant to parse a log file in real time.
As new lines are added to the log, those lines are read, and
depending on the parameters the user sets those lines are
sorted to various frames with a text control widget in them.
The user can elect to set an audio trigger to alert the user
that a line of text has been matched.
As for the actual value to Joe Schmoe? That's relative...
For me, it allows me to remove chat boxes from a game I
play and stick that dialog on my computer's second monitor.
Thus, letting me "see" more of the game environment instead
of the games cluttered user interface.
TopiView ugly version:
- 1386 lines of code
- 45+ global variables
- The user had to use all 6 containers / search strings.
- No real time sample of back / fore ground color, or fonts.
- 1 search string per container, 1 sound per container.
- No refactors, or abstracting (lots of fluff code, not dynamic)
- Exceptions handled poorly.
TopiView less ugly version:
- 725 lines of code
- 0 global variables
- The user sets how many containers they want.
- Real time visual of color combinations and fonts in configuration dialog.
- 2 search strings per container, 1 sound per search string.
- Everything is refactored and abstracted (less fluff, as dynamic as I knew how to make.)
- User is "herded" away from ever encountering an exception.
Dictionaries and lists are a wonderfull thing!
Thank you all! I really couldn't have done this without your help.
Steve

It's good to hear you got it done and improved it so much! I hope you'll continue to develop and come back here time and again to share your discoveries.

-------------------
Mike Driscoll

Blog: http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hello Steve,

I'm trying to parse a real time log file too (GPS data), do you mind
sharing how you did the following:

First off, TopiView is meant to parse a log file in real time.
As new lines are added to the log, those lines are read, and
depending on the parameters the user sets those lines are
sorted to various frames with a text control widget in them.
The user can elect to set an audio trigger to alert the user
that a line of text has been matched.

Thanks!
Alex

It would be my pleasure to share with you some of the things I have learned.

The more information you can give about what your trying to do, and what
you're having a problem with would be great, but I'll throw some generals
at you, and your reply can give some code.

This is how I did it with my program in general.

I establish a variable that reads the total lines of the log file.
Let's call it self.InitLineCount with an initial value of zero. And a variable
so this is less confusing for the path to your log file. You'll also need to
import linecache

import linecache
self.InitLineCount = 0
self.LogPath = C:\yourdirectory\yoursubdir\logfile.txt

The next thing we need to do is set up a way of polling that
log file at a regular interval. I haven't done much with threading,
but wx.Timer works just fine for me. The function below creates
the timer, sets the interval something happens, and then bind that
"something" to the timer so it happens over and over. Create a
button and bind it to the event below:

def StartPolling(self, event):
    self.Interval = wx.Timer(self, id=wx.NewId())
    self.Bind(wx.EVT_TIMER, self.ProcessLog)
    self.Interval.Start(1000) # 1000 = about 1 second
    event.Skip()

You'll need another button to stop the wx.Timer. Maybe
instead of 2 buttons you use a check box, or something, but this
example is generalized.

def StopPolling (self, event):
    try:
        self.Interval.Stop()
        del self.Interval
        event.Skip()
    except:
            return

The try statement is important, if the timer doesn't exist because
it hasn't been started you'll get an error. this way, it will try to do
the following, and if it can't Python just shrugs and carries on.

Now for the actual log processing:

def ProcessLog(self, event):
    self.CurrentLineCount = len(open(self.LogPath, 'rb').readlines())
    if self.CurrentLineCount == self.InitLineCount:
        pass
    elif self.CurrentLineCount > self.InitLineCount:
        self.DoSomething()

    self.InitLineCount = self.CurrentLineCount
    event.Skip()

def DoSomething(self):
    # Do whatever it is you want to do here.

EXPLAINED:

You set self.InitLineCount to zero in the beginning. And when you
created the wx.Timer with whatever interval you wanted (100 would be
10 times a second, 500 half a second etc.) the "ProcessLog" function
happens.

The variable self.CurrentLineCount will be quantity of lines in the log
file. So if the log is 10 lines long, self.CurrentLineCount will be 10.

So there we go. If Current is equal to Init line count then don't do anything OR
If Current is greater than Init Line count go to "DoSomething"

After "DoSomething" happens it goes back to "ProcessLog" and makes
self.InitLineCount = self.CurrentLinecount and repeats checking the length
over and over and over again until you stop it.

If you have specific questions ask away, that code should work as is if you create
the variables and do the imports. It's also as basic as I could make it, you may
want to save the self.CurrentLineCount so the next time you start the program you
don't get a false "TRUE" since the self.CurrentLineCount will always be greater on
the very first pass.

Another aside: wx.Timer doesn't "do something" then wait the amount of time
you set in the interval. It waits the amount of time you set in the interval then it
"does something" Ultimately it may not make any diference, but I thought you
may wnat to know.

Good luck, hope it helps.

Steve

···

----- Original Message ----- From: "Alex Garbino" <agarbino@gmail.com>
To: <wxpython-users@lists.wxwidgets.org>
Sent: Sunday, 17 August, 2008 20:08
Subject: Re: [wxpython-users] Thank you wxPython mailing list!

Hello Steve,

I'm trying to parse a real time log file too (GPS data), do you mind
sharing how you did the following:

First off, TopiView is meant to parse a log file in real time.
As new lines are added to the log, those lines are read, and
depending on the parameters the user sets those lines are
sorted to various frames with a text control widget in them.
The user can elect to set an audio trigger to alert the user
that a line of text has been matched.

Thanks!
Alex
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Alex,

Does the GPS allow you to poll it for data instead of writing data to
a file? It might be easier to simply poll it every 100ms or something
like that and use the data it gives back instead of trying to figure
out how far through a log file you need to read to get the next item.

···

On Sun, Aug 17, 2008 at 5:08 PM, Alex Garbino <agarbino@gmail.com> wrote:

Hello Steve,

I'm trying to parse a real time log file too (GPS data), do you mind
sharing how you did the following:

First off, TopiView is meant to parse a log file in real time.
As new lines are added to the log, those lines are read, and
depending on the parameters the user sets those lines are
sorted to various frames with a text control widget in them.
The user can elect to set an audio trigger to alert the user
that a line of text has been matched.

Thanks!
Alex

--
Stand Fast,
tjg. [Timothy Grant]

It depends on how the GPS drivers are implemented; but there are two problems:
1) I would like to make it generic so that it can be used in windows
or linux, with any GPS
2) I have no clue how to make python interact with the operating
system/drivers/etc. I use both linux and windows; the reason I began
with python is that it's cross-platform. The problem is I have no clue
how to even get data from the GPS in windows, and in linux I have the
standard gpsd daemon running, and then have gpspipe log the data in
NMEA format.

I figured I'd start by assuming I have an NMEA-formatted log file
being updated, and take care of the downstream part to begin with.

Alex

···

On Sun, Aug 17, 2008 at 8:34 PM, Timothy Grant <timothy.grant@gmail.com> wrote:

On Sun, Aug 17, 2008 at 5:08 PM, Alex Garbino <agarbino@gmail.com> wrote:

Hello Steve,

I'm trying to parse a real time log file too (GPS data), do you mind
sharing how you did the following:

First off, TopiView is meant to parse a log file in real time.
As new lines are added to the log, those lines are read, and
depending on the parameters the user sets those lines are
sorted to various frames with a text control widget in them.
The user can elect to set an audio trigger to alert the user
that a line of text has been matched.

Thanks!
Alex

Alex,

Does the GPS allow you to poll it for data instead of writing data to
a file? It might be easier to simply poll it every 100ms or something
like that and use the data it gives back instead of trying to figure
out how far through a log file you need to read to get the next item.

--
Stand Fast,
tjg. [Timothy Grant]
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users