Re: Newbie help understanding...

2007-05-26 Thread cmpython
The problem is that in your function t is a string (one of the cards
in the list called "cards") and strings don't have the ability to use
the append method.  But lists do.  Therefore t.append is wrong but
cards.append works fine.  (Append means "take the list you have and
add what is in the parenthesis to it...so cards.append("Ace") would
append the string Ace to the list of cards).

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


Re: calling the function of one class from another class

2007-09-24 Thread cmpython
On Sep 24, 2:27 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Furkan Kuru wrote:
>
> > On 9/22/07, *Mridula Ramesh* <[EMAIL PROTECTED]
> > > wrote:
>
> > hi.
>
> > i currently have code structured like this:
>
> > classA():
> > def __init__():
> >  ..
> >  ..
>
> > def fnc1():
> > 
> > 
>
> > classB():
> >def __init__():
> > 
> > 
> > classA.fnc1()#this is where i get an error
>
> > TypeError: unbound method fnc1() must be called with classA instance
> > as first argument (got nothing instead)
>
> > when i do  fnc1(classA) i get:
>
> > NameError: global name 'fnc1' is not defined
>
> > am i violating some programming rule by trying to call fnc1 in
> > classB? i am only now learning OO alongside python, so i'm not sure!
> > also, can someone please tell me where to go for more articles on
> > the classes and functions and calling them from other places?
>
> > thanks a lot!
>
> > mridula.
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list
> > 
>
> > you should create an instance of ClassA:
>
> > a = ClassA()
> > a.fnc1()
>
> Unfortunately this won't work either, as calling the method on an
> instance will automatically provide the instance as the first argument
> to the method call, but the method is defined to take no arguments.
>
> > or if you want a static function you should declare the method as static
>
> > classA():
> > def __init__():
> >  ..
> >  ..
> > @staticmethod
> > def fnc1():
> > 
> > 
>
> Although most often if you want a static function you should just define
> ... a function!
>
> The OP should read through the tutorial, or at least those sections
> dealing with function and class definitions. It appears (s)he may be
> trying to write Java in Python. That's never a satisfactory experience.

If the OP is not familiar with programming in general the official
Python
tutorial is probably hard to "get".  It's written for other
programmers
from C++ or other languages so they know what is different about
Python.

One way the OP could go is to (and yes this actually is mentioned in
that
section of the tutorial) add "self" to the fnc1 so that when you call
it from within classB the number of arguments--1--match, like:

classA():
def __init__():
def fnc1(self):

classB():
def __init__():
 a = ClassA()
 a.fnc1()

Is there another way without having to add self to fnc1?

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


Re: Can you please give me some advice?

2007-09-30 Thread cmpython

> Hello World in Ruby (and a few other 
> languages):http://www.oreillynet.com/ruby/blog/2005/12/hello_world.html

> Hello World in 
> Python:http://python.about.com/od/gettingstarted/ss/helloworld.htm

I know nothing of Ruby, but just the fact that in Ruby the Hello World
program is

puts 'Hello, World!'

whereas the Python Hello World program is

print 'Hello, World!'

suggests to me that Python is more intuitive because the word "print"
has a meaning in English that makes sense given what you want to do,
but "puts" just doesn't.  And, as someone who has been learning Python
from almost no knowledge of programming, I've found it is not too bad
in trying to keep as reasonably close to a natural language like
English
as possible.

I also think the mandatory indenting of Python is helpful in forcing
new programmers to be neat and see code blocks quickly.  Plus I doubt
the Ruby community has such a large group of helpful people and
libraries
and such (but I could be wrong about that, just assuming it based on
the
fact that Python has been around longer).

On the other hand, perhaps because Ruby is newer it has been able to
freshly start with advantages learned from the difficulties of other
languages.  Byung-Hee Hwang ought to go the Ruby group and see what
they are saying.

As far as English goes, Byung-Hee, you have to admit English grammar
is easy (though spelling is not so easy).  That anyone can speak and
write Chinese is impressive to me, as the language looks completely
impossible!  Good luck!


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


Re: Diferent files: GUI (wxpython) Program

2007-10-11 Thread cmpython
On Oct 11, 5:44 pm, marc <[EMAIL PROTECTED]> wrote:
> Hi why I can call an .py GUI (wxpython) from a program and control it?
> I'm newbie in python.

Sorry, could you restate that?  Explain again what you want to do.

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


Re: Diferent files: GUI (wxpython) Program

2007-10-11 Thread cmpython

On Oct 11, 7:47 pm, marc <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] escribió:> On Oct 11, 5:44 pm, marc <[EMAIL PROTECTED]> 
> wrote:
> >> Hi why I can call an .py GUI (wxpython) from a program and control it?
> >> I'm newbie in python.
>
> > Sorry, could you restate that?  Explain again what you want to do.
>
> I would to call a python file that contains a GUI (with wx) from a file
> program.
> The programs that I've do, contains a GUI and the code to run it in the
> same file, but I when need to modify a GUI file (I use wxglade) I need
> to delete all code lines (except the GUI code lines) and it difficult
> the program.

Marc,

I haven't used wxGlade, but I would be surprised
if you would have to delete all the code lines in
order to modify the GUI part of the program,
but maybe I am misunderstanding something.  You
should ask on some wxGlade list or help file or
such.

I use Boa Constructor to help build GUIs and it
allows you to make a file which will run the main
frame (the GUI itself).  Maybe this is what you are
looking for?  If so, this is one way to do it:

Say you have a main frame which is your GUI.  Here
is the code for that (this is simply a frame with
a panel on it, super simple):

#--MAIN FRAME---
import wx

def create(parent):
   return Frame1(parent)

class Frame1(wx.Frame):

def __init__(self, parent):
wx.Frame.__init__(self, id=-1, parent=parent)

self.panel1 = wx.Panel(id=-1, parent=self)
#-

You can save this as testFrame1.py

Now you have the program which calls this frame, which we can
save as testApp1.py.  The code for that is as follows:

#The app that calls the GUI---
import wx
import testFrame1

class MyApp(wx.App):
def OnInit(self):
self.main = testFrame1.create(None)
self.main.Show()
self.SetTopWindow(self.main)
return True

def main():
application = MyApp(0)
application.MainLoop()

if __name__ == '__main__':
main()
#

Now you can change anything in the file called
testFrame1 and still launch it from the file
called testApp1.  I think that's basically what
you wanted to do if I understood it.

I'd recommend checking out Boa Constructor.  I've
trimmed the auto-generated code from it to make
it simplified for this message, but it is good
once you're used to it, and it is very easy to make
quick changes to the GUI, both by coding or by using
its Designer, which allows you to arrange the GUI
elements visually.

Lastly, it is probably better to ask questions about
wxPython on the wxPython list.

cm


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

Re: Getting wxPython to work on a Mac

2007-12-05 Thread cmpython
On Dec 4, 9:35 pm, Timothy Smith <[EMAIL PROTECTED]> wrote:
> Not sure exactly what I need to do to get wxPython to work on either of
> my Macs. (One's a notebook running Tiger (OS X 10.4.11), the other a Mac
> Pro running Leopard (10.5.1.))
>
> I downloaded what should be the latest binary, and it installed without
> error. So Python comes up as
>
> $ python -V
> Python 2.5.1
> $ ls -l /usr/bin/python
> lrwxr-xr-x  1 root  wheel  72 Oct 26 17:59 /usr/bin/python@ ->
> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python
> $
>
> I set PYTHONPATH to
> System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5
>
> The Python interpreter works OK, far as I can tell. wx sort of works,
> but all the functionality is not there. For example, working through the
> exercises in "WxPython in Action" by Noel Rappin, I find that while I
> can create and display a frame, and create an app, stuff like
> wx.MessageBox() just doesn't work.
>
> The same exercises work just fine on a Python 2.5.1 installation on my
> wife's Windows XP machine.
>
> Any help appreciated. (I am obviously both a Python and a Wx beginner.
> And not much of a Unix expert either. :-)

If you don't get an answer here, you should try the wxPython mailing
list:
http://www.wxpython.org/maillist.php
I'm sure they'll be able to help you out (I don't have a Mac, so I
don't know).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie in python

2008-02-23 Thread cmpython
On Feb 21, 5:52 am, [EMAIL PROTECTED] wrote:
> Hi anyone
>
> I'm very interesed to learn python and really willing to do so,but
> unfortunately dont know where to start, or what programs need to
> install to start.
>
> Can someone help me to get in the right track, and get a good move?
>
> Thanks for all help
>
> pls reply on
> [EMAIL PROTECTED]
> or
> [EMAIL PROTECTED]

I'd first want to know if you are just new to Python or are new to
programming generally. Second, for what reason do you want to learn
Python?  What is it that you want to do with it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boa Constructor Mac crash when adding menubar

2008-02-23 Thread cmpython
On Feb 21, 2:08 am, Jacob Davis <[EMAIL PROTECTED]> wrote:
> hi.  Every time I go through the Boa Constructor tutorial and I get to
> the "Add a Menu Bar" section, Boa Constructor crashes after I select a
> wx.menubar and then left click either in the Data or design frames.
>
> I saw a post on the internet from the usenet about this very question,
> but was from 2005, and there was a reply that there would be a fix,
> but I can't figure out if this issue was supposed to be resolved.
>
> thanks for any help
>
> jake

Could it be you have an old version of Boa?  In any case,
I'd post this under the Help forum at the Boa site:
http://sourceforge.net/projects/boa-constructor/

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