Python 3.2 Tkinter and TTK

2011-04-28 Thread steven.oldner
Just downloaded Python3.2 from python's site and attempted to run some
of the examples in the 24.2.10Tk Styling.  The button worked, but the
menu didn't.  I also tried a couple from the TKDocs web site.  Only
errors from there.

So, what do I need to do to get it to run?
-- 
http://mail.python.org/mailman/listinfo/python-list


Newby Question for reading a file

2009-02-19 Thread steven.oldner
Simple question but I haven't found an answer.  I program in ABAP, and
in ABAP you define the data structure of the file and move the file
line into the structure, and then do something to the fields.  That's
my mental reference.

How do I separate or address each field in the file line with PYTHON?
What's the correct way of thinking?

Thanks!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newby Question for reading a file

2009-02-19 Thread steven.oldner
On Feb 19, 12:40 pm, Mike Driscoll  wrote:
> On Feb 19, 12:32 pm, "steven.oldner"  wrote:
>
> > Simple question but I haven't found an answer.  I program in ABAP, and
> > in ABAP you define the data structure of the file and move the file
> > line into the structure, and then do something to the fields.  That's
> > my mental reference.
>
> > How do I separate or address each field in the file line with PYTHON?
> > What's the correct way of thinking?
>
> > Thanks!
>
> I don't really follow what you mean since I've never used ABAP, but
> here's how I typically read a file in Python:
>
> f = open("someFile.txt")
> for line in f:
>     # do something with the line
>     print line
> f.close()
>
> Of course, you can read just portions of the file too, using something
> like this:
>
> f.read(64)
>
> Which will read 64 bytes. For more info, check the following out:
>
> http://www.diveintopython.org/file_handling/file_objects.html
>
>  - Mike

Hi Mike,

ABAP is loosely based on COBOL.

Here is what I was trying to do, but ended up just coding in ABAP.

Read a 4 column text file of about 1,000 lines and compare the 2
middle field of each line.  If there is a difference, output the line.

The line's definition in ABAP is PERNR(8) type c, ENDDA(10) type c,
BEGDA(10) type c, and LGART(4) type c.
In ABAP the code is:
LOOP AT in_file.
  IF in_file-endda <> in_file-begda.
WRITE:\ in_file. " that's same as python's print
  ENDIF.
ENDLOOP.

I can read the file, but didn't know how to look st the fields in the
line.  From what you wrote, I need to read each segment/field of the
line?

Thanks,

Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newby Question for reading a file

2009-02-19 Thread steven.oldner
On Feb 19, 1:44 pm, Curt Hash  wrote:
> On Thu, Feb 19, 2009 at 12:07 PM, steven.oldner  
> wrote:
>
> > On Feb 19, 12:40 pm, Mike Driscoll  wrote:
> > > On Feb 19, 12:32 pm, "steven.oldner"  wrote:
>
> > > > Simple question but I haven't found an answer.  I program in ABAP, and
> > > > in ABAP you define the data structure of the file and move the file
> > > > line into the structure, and then do something to the fields.  That's
> > > > my mental reference.
>
> > > > How do I separate or address each field in the file line with PYTHON?
> > > > What's the correct way of thinking?
>
> > > > Thanks!
>
> > > I don't really follow what you mean since I've never used ABAP, but
> > > here's how I typically read a file in Python:
>
> > > f = open("someFile.txt")
> > > for line in f:
> > >     # do something with the line
> > >     print line
> > > f.close()
>
> > > Of course, you can read just portions of the file too, using something
> > > like this:
>
> > > f.read(64)
>
> > > Which will read 64 bytes. For more info, check the following out:
>
> > >http://www.diveintopython.org/file_handling/file_objects.html
>
> > >  - Mike
>
> > Hi Mike,
>
> > ABAP is loosely based on COBOL.
>
> > Here is what I was trying to do, but ended up just coding in ABAP.
>
> > Read a 4 column text file of about 1,000 lines and compare the 2
> > middle field of each line.  If there is a difference, output the line.
>
> > The line's definition in ABAP is PERNR(8) type c, ENDDA(10) type c,
> > BEGDA(10) type c, and LGART(4) type c.
> > In ABAP the code is:
> > LOOP AT in_file.
> >  IF in_file-endda <> in_file-begda.
> >    WRITE:\ in_file. " that's same as python's print
> >  ENDIF.
> > ENDLOOP.
>
> > I can read the file, but didn't know how to look st the fields in the
> > line.  From what you wrote, I need to read each segment/field of the
> > line?
>
> > Thanks,
>
> > Steve
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> You could do something like this:
>
> f = open('file.txt', 'r')
> for line in f:
>     a,b = line.split()[1:-1]   # tokenize the string into sequence of
> length 4 and store two middle values in a and b
>     if a != b:
>         print line
> f.close()- Hide quoted text -
>
> - Show quoted text -

Peter, you are correct, just fields glued together.  I did not know
there was a struc module and that code looks real good.  This is
something I will use in the future. Thanks!

Curt, that looks good also.  I just need to test the 2 middle values.
I didn't know how to store line.split values into variables and this
is simple. Thanks!

Again, thanks Mike, Peter and Curt.  Now if you ever need to know
ABAP... ;)




--
http://mail.python.org/mailman/listinfo/python-list


Data Coding suggestions

2009-02-27 Thread steven.oldner
Just learning Python and have a project to create a weekly menu and a
shopping list from the menu.  This is something I do manually now, so
I'm automating it.

What I'd like is a list of menu choices, such as:
CODE-  Description - Est Cost

'B01 - Pancakes, Sausage,and Eggs - $5.80,
'L01 - Tuna Fish sandwices and chips -$ 4.25 ,
'D01 - Dirty Rice and Garlic Bread' - $5.70.

>From the choices, I'll create a weekly menu, print the menu, and then
print list of ingredients ( and sum the commom items)

CODE- Item - Qty. - Unit
B01 - pancake mix - 1 - box
B01 - milk - .3 -gal
B01 - eggs- 10 - each
D01 - dirty rice mix - 1 - box
D01 - milk - .3 - gal.

I would like to expand the ingredient list to include other fields
like 'last purchase date' and 'reorder point'.

I've used an example program and started to code it but just realized
I've been coding ABAP in Python, that is set up a data structure and
use that.  What I want is to learn code Python in Python.

Question:  How should I set up the data?  I'm looking at maybe 70 menu
items and maybe 1000 items for the shopping list.  I need to be able
to maintain each item also.

I am using python 2.6 but would like to use 3.0.

Thanks for any suggestions!

--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: updates to Python-by-example

2009-02-27 Thread steven.oldner
On Feb 27, 8:40 am, [email protected] wrote:
> Rainy,
>
> Great stuff! Thanks for your examples with the community!!
>
> Regards,
> Malcolm

Let me add my thanks!  I using it now...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Data Coding suggestions

2009-02-28 Thread steven.oldner
On Feb 27, 2:04 pm, Rick Dooling  wrote:
> On Feb 27, 6:42 am, "steven.oldner"  wrote:
>
> > Just learning Python and have a project to create a weekly menu and a
> > shopping list from the menu.  
> > Question:  How should I set up the data?  I'm looking at maybe 70 menu
> > items and maybe 1000 items for the shopping list.  I need to be able
> > to maintain each item also.
>
> I agree with Mr. Holden. It's a perfect exercise for using Python with
> sqlite3.
>
> And the nice thing about this documentation is it has plenty of good
> examples:
>
> http://docs.python.org/library/sqlite3.html
>
> Good luck,
>
> RD

Thanks guys.  While shopping today I've thought of a few more columns
for my data so my first item will be building the 3 DB tables and a
way to populate them.  Since this was intended to automate what I do
on a weekly basis, I didn't think about adding recipes since I know
what I need for the family, but that's a good touch.

Item 1. Build 3 db tables
Item 2. Build app to populate tables.
Item 3. Build app to read tables and print lists.

Anything else?

--
http://mail.python.org/mailman/listinfo/python-list


Re: Invalid syntax with print "Hello World"

2009-03-12 Thread steven.oldner
On Mar 12, 2:25 am, John Machin  wrote:
> On Mar 12, 5:57 pm, Henrik Bechmann  wrote:
>
> > obviously total mewbiew:
>
> > My first program in Python Windows
>
> What is that you are callind "Python Windows"? What version of Python
> are you running?
>
> 2.X: print "Hello World"
> should work.
>
> 3.X: print is now a function,
> print("Hello World")
> should work.
>
> If that gets you going: read the tutorial that belongs to the version
> of Python that you are using.
> If it doesn't, come back here with a bit more detail.
>
> BTW, don't indent your first line. Make sure it starts in column 1.
>
> HTH,
> John
>
>
>
>
>
> > print "Hello World"
>
> > I select Run/Run Module and get an error:
>
> > Syntax error, with the closing quote highlighted.
>
> > Tried with single quotes as well. Same problem.
>
> > Can someone explain my mistake?
>
> > Thanks,
>
> > - Henrik- Hide quoted text -
>
> - Show quoted text -

Henrik,

Welcome to the list.  As a newbie myself, I ran into the Python3 vrs
2.6 issue.  May I suggest starting with 2.6?  There is many more books
and internet stuff you can learn with in 2.6 - and the examples will
work. As Garry wrote, once you understand 2.6, 3.0 will not be a
challenge.

Steve Oldner
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Python: Rag October issue available

2009-10-02 Thread steven.oldner
On Oct 2, 11:14 am, Bernie  wrote:
> The Python: Rag October issue available
>
> The October issue of The Python: Rag is available at:
>
> http://www.pythonrag.org
>
> A monthly, free, community run, Python magazine - issues are in pdf
> format, intended for anyone interested in Python, without being
> particularly serious.  If you have anything you would like to say about
> Python, please contribute.

Thanks!  Any way to subscribe to it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-17 Thread steven.oldner
Along the COBOl line is ABAP, the 4gl language from SAP.

If today = 'Mon'.
  message 'oh boy'.
elseif today = 'Wed'.
  message 'Hump day'.
elseif today = 'Fri'.
  message 'TGIF'.
else.
  message 'get to work'.
endif.

The period is the statement teminator. Indentation and separte lines
are just to make it readable.

-- 
http://mail.python.org/mailman/listinfo/python-list


Blogger Widget web app

2009-06-11 Thread steven.oldner
Please give me directions on where to start researching for answers.
I probably can do the javascript, but I don't know where to start on
the Python.

1. Wife has a blogger blog and wants a widget to embed in the posts.
2. Widget will have a form that readers can enter their name and url.
3. Widget also lists in numeric order the name and url of all the
readers who signed up in that post.
4. Son has an old PC he turned into a server, and installed Windows
IIS on it.

What I need to do is to write the cgi scripts to send a list of names
and urls for each post on load, validate the input from the form and
store the results per blog post.

If you have seen Mr. Linky, that's what I'm tring to mimic.  This will
only be for her blog, so she can have a faster load time and less down
time.  I have NO intention to build this for more than her.  So very
simple and easy is the key.

I've read the mailing list, I just got the books,  Programming Python
by Mark Lutz and and Python Web Programming by Steve Holden.  There is
so much great info I don't know where to start or what I need to start
with.

Thanks for any pointers.

Steve Oldner


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: zip codes

2009-08-17 Thread steven.oldner
On Aug 17, 5:21 am, MRAB  wrote:
> Sjoerd Mullender wrote:
> > Martin P. Hellwig wrote:
> >> Shailen wrote:
> >>> Is there any Python module that helps with US and foreign zip-code
> >>> lookups? I'm thinking of something that provides basic mappings of zip
> >>> to cities, city to zips, etc. Since this kind of information is so
> >>> often used for basic user-registration, I'm assuming functionality of
> >>> this sort must be available for Python. Any suggestions will be much
> >>> appreciated.
>
> >> There might be an associated can of worms here, for example in the
> >> Netherlands zip codes are actually copyrighted and require a license if
> >> you want to do something with them, on the other hand you get a nice SQL
> >> formatted db to use it. I don't know how this works in other countries
> >> but I imagine that it is likely to be generally the same.
>
> > Also in The Netherlands, ZIP codes are much more fine-grained than in
> > some other countries: ZIP code plus house number together are sufficient
> > to uniquely identify an address.  I.e. you don't need the street name.
> > E.g., my work address has ZIP code 1098 XG and house number 123, so
> > together they indicate that I work at Science Park 123, Amsterdam.
>
> > In other words, a simple city <-> ZIP mapping is not sufficient.
>
> The same comment applies to UK postcodes, which are also alphanumeric.
> My home postcode, for example, is shared with only 3 other houses, IIRC.- 
> Hide quoted text -
>
> - Show quoted text -

Google for Zip codes.  There are some free databases of codes, but
they are dated.  USPS and 3 party vendors sell zip code databases and
lists.  The USPS APIs are a joke.  They were going to charge me for
using them.

I ended up using a 2 year old database of ZIP codes for my needs.

Hope this helps!

-- 
http://mail.python.org/mailman/listinfo/python-list