GIDForums  

Go Back   GIDForums > Computer Programming Forums > Python Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Oct-2008, 06:07
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,627
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice
Thumbs up

wxPython GUI tutorial


I have created a new tutorial for those interested in learning GUI programming using wxPython and Python.

You can find the tutorial on my blog. I have only been using wxPython for a couple of months so I don't know everything, but I know enough to answer some basic questions so feel free to post questions either at my blog or here on GIDForums.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.
-------------
Common Sense v2.0-Striving to make the world a little bit smarter.
  #2  
Old 21-Nov-2008, 23:35
osamie osamie is offline
New Member
 
Join Date: Nov 2008
Posts: 3
osamie is on a distinguished road

Re: wxPython GUI tutorial


Please I need some help here.
I'm creating a money class, and i have no idea why whenever i call the object with specified parts, it gives me a type error. Please have a look. Try running the code below on an IDE, and then call this Money(6,182).

Python Code:
class Money:
    def _init_(self, franc, rappen):
        self.franc = franc
        self.rappen = rappen
        while self.rappen>99:
            rappen_1 = self.rappen - 100
            self.rappen = self.rappen_1
            self.franc += 1            
        
    def _str_(self):
        self.rappen = self.rappen/100
        amount = self.franc + self.rappen
        return 'Fr' + str(round(amount,2))
    
    def _add_(self,other):
        if isinstance(other,Money):
            rappen = self.rappen + other.rappen
            franc = self.franc + other.franc
            return Money(franc,rappen)
        elif isinstance(other,int):
            franc = self.franc + other
            return Money(franc,rappen)
        else:
            return NotImplemented
        
    def _eq_(self,other):
        return self.franc==other.franc and self.rappen==other.rappen
Last edited by admin : 22-Nov-2008 at 07:17. Reason: Please insert your example Python codes between [PY] and [/PY] tags
  #3  
Old 22-Nov-2008, 08:09
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,627
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: wxPython GUI tutorial


Sorry, I ran the program and I'm not getting any errors. Can you copy and paste the error message?
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.
-------------
Common Sense v2.0-Striving to make the world a little bit smarter.
  #4  
Old 22-Nov-2008, 15:39
osamie osamie is offline
New Member
 
Join Date: Nov 2008
Posts: 3
osamie is on a distinguished road

Re: wxPython GUI tutorial


>>>Money(6,182)
Traceback (most recent call last) :
File "<string>",line 1 , in <string>
TypeError: this constructor takes no arguments

ok if you read through the code, you'd understand that, when you call Money(6,182), i.e Money(self,frans,rappen), the shell should return Fr7.82.
100 rappens make a Franc.
  #5  
Old 23-Nov-2008, 06:28
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,627
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: wxPython GUI tutorial


How are you running this? I mean, is the code you posted all there is? Do you have a
Python Code:
if __name == "__main__"
or other, similar call to this class?

From your error message, it sounds like the class (more specifically, the constructor for the class) can't take the arguments you are passing to it. I know that your __init__ has the arguments in it but it doesn't sound like it's being "seen" by the intepreter.
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.
-------------
Common Sense v2.0-Striving to make the world a little bit smarter.
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a book or tutorial on OpenSSL with php Blake MySQL / PHP Forum 2 13-Feb-2008 10:19
Tutorial: How to Make a Web 2.0-Style Logo PhotoshopTrend Graphics Forum 0 20-Sep-2007 06:57
Re: Beginning Python Tutorial (Part 10) crystalattice Python Forum 5 11-Mar-2007 03:19
Photoshop Tutorial: Make An Inspirational/Mystical Picture ToddSAFM Graphics Forum 9 09-Aug-2005 21:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:24.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.