Re: [Tutor] Help with Python Program

2012-02-24 Thread Steven D'Aprano
Carolina Dianne LaCourse wrote: [...] I understand that I need to ask for raw input from the user and that I need to be able to use the if elif else to tell the user whether their number matches or id too high or to low but am just not sure what to do first. Any advice would be greatly appreciat

Re: [Tutor] Help with Python Program

2012-02-24 Thread bob gailer
On 2/24/2012 10:18 PM, Carolina Dianne LaCourse wrote: Hi, I have never programed before and am brand new to python also. I am trying to create a Hi-Lo game and am not really sure where to start. These are the instructions that I have. I know that I will need to import the random number generator

[Tutor] Help with Python Program

2012-02-24 Thread Carolina Dianne LaCourse
Hi, I have never programed before and am brand new to python also. I am trying to create a Hi-Lo game and am not really sure where to start. These are the instructions that I have. I know that I will need to import the random number generator and have looked up how to do that. I understand that I n

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Anthony Papillion
On Fri, Feb 24, 2012 at 8:08 PM, Steven D'Aprano wrote: > > Are you aware that the database connection gets made, but not stored > anywhere? Once the Manager instance is created, the database connection is > thrown away. > > My guess is that you mean to use self.conn instead of conn in the above.

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Steven D'Aprano
Anthony Papillion wrote: class Manager(object): def __init__(self): builder = gtk.Builder() builder.add_from_file("winMain.glade") builder.connect_signals(self) self.window = builder.get_object("winMain") self.window.show() conn = None

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Alan Gauld
On 25/02/12 00:17, Anthony Papillion wrote: The entire GUI is created using Glade. In Glade, I've clicked on the button widget and then the Signals tab. I'm associating the btnSearch's click event with the on_btnSearch.clicked method. As I said above, the method is being called, I'm just not abl

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Anthony Papillion
On Fri, Feb 24, 2012 at 5:55 PM, Prasad, Ramit wrote: > > How are you running this? I assume from an IDE because this should most > likely cause an error. I would recommend trying to run your python script > from the commandline which is much more likely to print an error. > > $python your_script.

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Anthony Papillion
On Fri, Feb 24, 2012 at 6:07 PM, Alan Gauld wrote: > > Add a trace to see if the method ever gets called The method is definitely getting called. If I remove the attempt to get the widgets text and replace it with print "btnSearch has been clicked" The method is called and the message is printe

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Prasad, Ramit
>def on_btnSearch_click(self, data=None): >if btnSearch.get_text() == "": >print "Nothing to search" >else: >print "I would do this search" >The code above does nothing. No error, no print, nothing. Any idea? How are you running this? I assume from an IDE because this shou

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Alan Gauld
On 24/02/12 23:49, Anthony Papillion wrote: Add a trace to see if the method ever gets called def on_btnSearch_click(self, data=None): print "I'm in on_btnSearch_click" if btnSearch.get_text() == "": print "Nothing to search" else: print "I would do this s

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Anthony Papillion
On Fri, Feb 24, 2012 at 5:10 PM, Prasad, Ramit wrote: > > Please post a more significant code sample as I have no idea from this, > but at least one of those should have given you an error. Always include > the full error (including stacktrace) you get from Python. Use copy/paste > and do not try

Re: [Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Prasad, Ramit
>if txtSearch.get_text() == "": >    print "The entry is empty" >This didn't work. So I thought, maybe I need to reference self and tried: >if self.txtSearch.get_text() == "": >    print "The entry is empty" >Neither worked. What am I doing wrong? Please post a more significant code sample as I

[Tutor] Checking if a GtkEntry is empty

2012-02-24 Thread Anthony Papillion
Hi Everyone, I'm learning pyGtk and am developing my first application. I'm trying to check if a GtkEntry is empty and I'm using the following code: if txtSearch.get_text() == "": print "The entry is empty" This didn't work. So I thought, maybe I need to reference self and tried: if self.tx

Re: [Tutor] Suggestions for a good intro OO & Python

2012-02-24 Thread Alan Gauld
On 24/02/12 15:43, Sivaram Neelakantan wrote: Can someone point me to a good intro on OO in Python? If it does OO basics too, even better, assuming no prior knowledge of Object Orientation. You can try the OOP topic in my tutorial. It also has some pointers to some more advanced tutors and b

Re: [Tutor] problem editing modules and defs

2012-02-24 Thread Walter Prins
Hi, On 24 February 2012 16:29, David Craig wrote: > Hi, > I am new to python and have made a couple of definitions. I imported them > and they worked ok except for one which gave me the error "NameError: global > name 'np' is not defined". I then edited my script for the def to include > "import

Re: [Tutor] problem editing modules and defs

2012-02-24 Thread Walter Prins
Hi Dave, On 24 February 2012 16:29, David Craig wrote: > Hi, > I am new to python and have made a couple of definitions. I imported them > and they worked ok except for one which gave me the error "NameError: global > name 'np' is not defined". I then edited my script for the def to include > "im

Re: [Tutor] problem editing modules and defs

2012-02-24 Thread Dave Angel
On 02/24/2012 11:11 AM, David Craig wrote: Hi, I am new to python and have made a couple of definitions. I imported them and they worked ok. I they worked except for one which gave me the error "NameError: global name 'np' is not defined". I then edited my script for the def to include "import

Re: [Tutor] problem editing modules and defs

2012-02-24 Thread David Craig
Hi again, sorry if that wasnt clear. I am using the ipython interpreter to debug scripts. I have a function:-) saved as part of a module called daves_modules.py. import numpy as np def find_nearest(array,value): idx=(np.abs(array-value)).argmin() return array[idx], idx

Re: [Tutor] Attribute error message received on Card Game program

2012-02-24 Thread Dave Angel
On 02/24/2012 11:34 AM, bob gailer wrote: On 2/24/2012 11:08 AM, SKHUMBUZO ZIKHALI wrote: Hi /*I am trying to run the following program from Guide to Programming with Python by Micheal Dawson:*/ /**/ class Card(object): RANK = ["A","2","3","4","5","6","7" "8","9","K","Q","J"]

Re: [Tutor] help writing functions

2012-02-24 Thread Wayne Werner
On Thu, 23 Feb 2012, Saad Javed wrote: I am learning python and need guidance for writing some code. I've written a simple program (with pointers from people) that parses an tv show xml feed and prints their values in plain text after performing some string operations. Unless you're really i

Re: [Tutor] Attribute error message received on Card Game program

2012-02-24 Thread bob gailer
On 2/24/2012 11:08 AM, SKHUMBUZO ZIKHALI wrote: Hi /*I am trying to run the following program from Guide to Programming with Python by Micheal Dawson:*/ /**/ class Card(object): RANK = ["A","2","3","4","5","6","7" "8","9","K","Q","J"] SUIT = ["s","d","h","c"] def __init

[Tutor] problem editing modules and defs

2012-02-24 Thread David Craig
Hi, I am new to python and have made a couple of definitions. I imported them and they worked ok except for one which gave me the error "NameError: global name 'np' is not defined". I then edited my script for the def to include "import numpy as np" saved it and imported the def again. However

Re: [Tutor] problem editing modules and defs

2012-02-24 Thread Evert Rol
Hi David, > Hi, > I am new to python and have made a couple of definitions. I imported them and > they worked ok. I they worked except for one which gave me the error > "NameError: global name 'np' is not defined". I then edited my script for the > def to include "import numpy as np" saved it

[Tutor] problem editing modules and defs

2012-02-24 Thread David Craig
Hi, I am new to python and have made a couple of definitions. I imported them and they worked ok. I they worked except for one which gave me the error "NameError: global name 'np' is not defined". I then edited my script for the def to include "import numpy as np" saved it and imported the def

[Tutor] Attribute error message received on Card Game program

2012-02-24 Thread SKHUMBUZO ZIKHALI
Hi I am trying to run the following program from Guide to Programming with Python by Micheal Dawson:   class Card(object):     RANK = ["A","2","3","4","5","6","7"     "8","9","K","Q","J"]     SUIT = ["s","d","h","c"]     def __init__(self,rank, suit):     self.rank = rank    

[Tutor] Suggestions for a good intro OO & Python

2012-02-24 Thread Sivaram Neelakantan
Can someone point me to a good intro on OO in Python? If it does OO basics too, even better, assuming no prior knowledge of Object Orientation. sivaram -- ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http:

Re: [Tutor] Solve wave equation

2012-02-24 Thread Jose Amoreira
On Thursday, February 23, 2012 12:57:39 PM David Craig wrote: > Hi, > I am trying to write some code that will solve the 2D wave equation by > the finite difference method, but it just returns an array full of zeros > and NaN's. Not sure where I am going wrong, the code is attached so if > could so