Re: What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-18 Thread Marcus Gnaß
See also
http://docs.python.org/dev/3.0/whatsnew/2.6.html#pep-3110-exception-handling-changes
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A beginner question about GUI use and development

2009-11-13 Thread Marcus Gnaß
uap12 wrote:

> When i givet the program away i like to pack it, so the enduser
> just run it, i don't like to tell the user to install Python, and/or
> som GUI package. is this possible.

So Tkinter would be your choice, cause its shipped with Python ...

> In the beginning it is okej to code the gui "by hand" to learn
> but after that i like som kind of GUI-designtool, and god
> to recommade ??

http://wiki.python.org/moin/GuiProgramming
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tax Calculator--Tkinter

2009-11-09 Thread Marcus Gnaß
Someone Something wrote:
> > from Tkinter import *;

Try to avoid this. Better import Tkinter. And don't forget to import
Tkconstants too!

> > rate=Frame(root)
> > income=Frame(root)
> > result=Frame(root)

Why do you use three frames? You only need one. And you can make your
class TaxCalc inherit from Tkinter.Frame ...

> > The thing is, that even if I put "12" in the result text field, get
> > returns an empty string. How can I fix this?

I haven't found the reason for that, but this should work. I also added
MRABs version of printResult().

import Tkinter, Tkconstants

class TaxCalc(Tkinter.Frame):

def __init__(self, root):

Tkinter.Frame.__init__(self, root)

Tkinter.Button(self,
text='Enter tax rate',
command=self.getRate).pack()

self.rate=Tkinter.Entry(self)
self.rate.pack()

Tkinter.Button(self,
text='Enter income',
command=self.getIncome).pack()  

self.income=Tkinter.Entry(self)
self.income.pack()

Tkinter.Button(self,
text='Get result',
command=self.printResult).pack()

self.result=Tkinter.Entry(self)
self.result.pack()

self.pack()

def getRate(self):
print "srate: ", self.rate.get()

def getIncome(self):
print "sincome: ", self.income.get()

def printResult(self):
try:
rate = float(self.rate.get())
income = float(self.income.get())
result = ((100.0 - rate) / 100.0) * income
self.result.insert(Tkconstants.END, str(result))
except ValueError:
print "Clear everything and start again."
print "Don't fool around with me."

root=Tkinter.Tk()
MyCalc=TaxCalc(root)
root.mainloop()

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