Re: [Tutor] What’s the differences between these two pieces of code ?

2012-07-13 Thread Chris Hare
On Jul 6, 2012, at 11:59 PM, redstone-cold wrote: > What’s the differences between these two pieces of code ? > (1) > for i in range(1, 7): > print(2 * i, end=' ') > > > (2) > for i in range(1, 7): > print(2 * i, end=' ') > print() > I think they are exactly the same, except the se

Re: [Tutor] advice on global variables

2012-07-11 Thread Chris Hare
On Jul 11, 2012, at 8:05 AM, Walter Prins wrote: > [snip] > Your original example modified as demonstration: > > a.py: > > import shared > import b > > def func1(): >print "global var in func1 = %s" % shared.global_var > > class intclass: >def func2(self): >

Re: [Tutor] advice on global variables

2012-07-10 Thread Chris Hare
On Jul 10, 2012, at 6:24 PM, Alan Gauld wrote: > On 11/07/12 00:16, Alan Gauld wrote: > >>> One thought was a RAM based SQLite database, but that seems >> > like a lot of work. I dunno, maybe that is the option. >> >> is definitely the best option where the "global" needs to be shared >> acros

[Tutor] advice on global variables

2012-07-10 Thread Chris Hare
I know they are bad. That is why I would prefer not to use it, but I am not sure how else to handle this problem. In this app, the user must log in. Once authenticated, they have a userid stored in the SQLite database. Before splitting my app into multiple files, I used a global variable.

Re: [Tutor] str object is not callable

2012-07-10 Thread Chris Hare
piece of code - it was standalone, and didn't work in the class where it has been moved to. No excuse, but there it is nonetheless. Chris On Jul 10, 2012, at 10:33 AM, Devin Jeanpierre wrote: > On Tue, Jul 10, 2012 at 10:56 AM, Chris Hare wrote: >> The input to the function

[Tutor] str object is not callable

2012-07-10 Thread Chris Hare
This piece of code works: Big-Mac:Classes chare$ more tmp.py import re def special_match(string, search=re.compile(r'[^a-zA-Z0-9\.\ \-\#\$\*\@\!\%\^\&]').search): #string = string.rstrip() return not bool(search(string)) print special_match("admin") print special_match("&!*") p

Re: [Tutor] confusion about imports

2012-07-09 Thread Chris Hare
Good advice - thanks for that. And I think you're right - I think what is happening is in fact a bunch of circular references. As I resolve issues, I will be looking for those! Appreciate all the advice! On Jul 9, 2012, at 5:16 PM, Dave Angel wrote: > On 07/09/2012 11:56 AM, Ch

Re: [Tutor] confusion about imports

2012-07-09 Thread Chris Hare
On Jul 9, 2012, at 12:42 PM, Walter Prins wrote: > Hi Chris > >> So, I have to admit, imports have me really confused. I am trying to break >> apart a 10,000+ line single file into various files, one for each class, and >> one containing a whole bunch of functions which are used by a lot of

[Tutor] confusion about imports

2012-07-09 Thread Chris Hare
So, I have to admit, imports have me really confused. I am trying to break apart a 10,000+ line single file into various files, one for each class, and one containing a whole bunch of functions which are used by a lot of classes. Some of those functions use calls to methods in a Class. Even

Re: [Tutor] using dynamic import statements

2012-07-09 Thread Chris Hare
Thanks all for the ideas. I wanted to have my own error messages printed for the user - something a little more meaningful than the standard error. Thanks for the advice - very helpful! On Jul 9, 2012, at 6:12 AM, Alan Gauld wrote: > On 09/07/12 10:19, Kwpolska wrote: >> Why does this bloody

[Tutor] using dynamic import statements

2012-07-08 Thread Chris Hare
Here is what I want to do: I have a bunch of modules to import. instead of duplicating a lot of code for each import, I want to do something like this: importList = [ "sys", "os", "imp", "stat", "re", "webbrowser", "Image", "StringIO", "shutil", "datetime" ] for object in importList:

Re: [Tutor] looking for some advice

2012-05-07 Thread Chris Hare
Thanks Peter - I will give it a look On May 7, 2012, at 1:02 PM, Peter Otten wrote: > Chris Hare wrote: > >> Hello Everyone: >> >> Here is what I am trying to do: >> >> I have a window which has a row of buttons on it. Below the buttons is a >> labe

[Tutor] looking for some advice

2012-05-07 Thread Chris Hare
Hello Everyone: Here is what I am trying to do: I have a window which has a row of buttons on it. Below the buttons is a label frame. Depending upon which button they push, I want to change the widgets in the label frame. I can add widgets now with no problem. Basically, I am trying to

Re: [Tutor] events and popup menus

2012-05-05 Thread Chris Hare
, 2012, at 5:30 AM, Peter Otten wrote: > Chris Hare wrote: > >> I have four images in a frame. I want to pop up a menu when the user >> right clicks on an image, and when they choose an option from the menu, >> execute the action. >> >> I can create the popup menu

Re: [Tutor] events and popup menus

2012-05-02 Thread Chris Hare
ked a button? this is the first time I am doing this so I am not even sure what I need to search for online. Thanks On May 1, 2012, at 7:31 PM, Alan Gauld wrote: > On 01/05/12 21:59, Chris Hare wrote: >> ... what I can't figure out is how to detect in the popup menu code > &

[Tutor] events and popup menus

2012-05-01 Thread Chris Hare
I have four images in a frame. I want to pop up a menu when the user right clicks on an image, and when they choose an option from the menu, execute the action. I can create the popup menu, and bind it to the image. However, what I can't figure out is how to detect in the popup menu code w

[Tutor] putting an image into a canvas object

2012-04-28 Thread Chris Hare
What I am trying to do is put an image on a canvas object, which I think is allowed. self.picture1 = Canvas(self.pictureFrame,width=150,height=150) self.imageBuffer = StringIO.StringIO() image = Image.open(filename) image = image.resize((150,150),Image.ANTIALIAS) image.save(self.imageBuffer, f

Re: [Tutor] PIL and converting an image to and from a string value

2012-04-28 Thread Chris Hare
, 2012, at 1:22 PM, Russell Smith wrote: > What did you do? > > On Friday, April 27, 2012, Chris Hare wrote: > > I got it figured out. > > On Apr 27, 2012, at 12:21 AM, Chris Hare wrote: > > > > > Here is what I am trying to: > > > > the applicat

Re: [Tutor] PIL and converting an image to and from a string value

2012-04-27 Thread Chris Hare
I got it figured out. On Apr 27, 2012, at 12:21 AM, Chris Hare wrote: > > Here is what I am trying to: > > the application user chooses an image file. I want to store the image data > in a field in a sqlite database. My understanding from the reading I have > done

[Tutor] PIL and converting an image to and from a string value

2012-04-26 Thread Chris Hare
Here is what I am trying to: the application user chooses an image file. I want to store the image data in a field in a sqlite database. My understanding from the reading I have done is that I have to convert the image data into a string , which I can then store in the database. Additionall

Re: [Tutor] executing dynamic code with exec?

2011-12-02 Thread Chris Hare
Thanks Steve for your help (and the humor). I can see that it was a bad idea with your explanation. (I just didn't want to type all that extra code :-)) I am going to re-write it using your dict approach - that looks a lot cleaner Thanks! Chris Hare ch...@labr.net http://www.labr.net O

[Tutor] executing dynamic code with exec?

2011-12-01 Thread Chris Hare
I have this code chunk: tables = ["Farm", "Animals", "AnimalTypes","Users","Roles","Capabilities","Pedigrees","ChipMaker","Owner","Providers","RegistryL"] for x in tables: cmd = "self.cb" + x + "Read = IntVar()" exec cmd in locals(), globals() When the code is executed, I get th

[Tutor] advice

2011-11-28 Thread Chris Hare
I have been searching around a bit, but not really finding anything which is meaningful. I want to embed a set of help files in my application, and display them from within the application. I could use plain text files, which would be easy to suck into a Text field, but it would be nice to in

[Tutor] Tkinter grid manager question

2011-11-26 Thread Chris Hare
Hi everyone. I am attempting to create a form for the user to complete. I have the basic layout and supporting code working, but I am having a problem with getting things to display in the grid the way I want them. self.label1 = Label(self.frame, text = "Double click o

Re: [Tutor] binding problem

2011-11-03 Thread Chris Hare
That helps Wayne - and was what I was referring to when I posted that I thought I had figured it out. Thanks for your help. Chris Hare ch...@labr.net http://www.labr.net On Nov 3, 2011, at 10:08 AM, Wayne Werner wrote: > On Thu, Nov 3, 2011 at 9:41 AM, Chris Hare wrote: > Thanks

Re: [Tutor] binding problem

2011-11-03 Thread Chris Hare
fused about why it is complaining about 2 arguments, when I am not passing any. Although, I think I know what the problem is now. Thanks for your help anyway. Chris Hare ch...@labr.net http://www.labr.net On Nov 3, 2011, at 9:08 AM, Peter Otten wrote: > Chris Hare wrote: > >> Than

Re: [Tutor] binding problem

2011-11-03 Thread Chris Hare
focus_set() takes exactly 1 argument (2 given) In situations like this where the function isn't one you wrote, how to you debug these? Chris Hare ch...@labr.net http://www.labr.net On Nov 3, 2011, at 3:23 AM, Alan Gauld wrote: > On 03/11/11 04:46, Chris Hare wrote: >> >

Re: [Tutor] frame destroy problem

2011-11-03 Thread Chris Hare
Dang it - sure is a typo! Thanks! Chris Hare ch...@labr.net http://www.labr.net On Nov 3, 2011, at 12:58 AM, Dipo Elegbede wrote: > There is nothing called franeButton it should be frameButton. I guess its a > typo. > > On 3 Nov 2011 05:52, "Chris Hare" wro

[Tutor] frame destroy problem

2011-11-02 Thread Chris Hare
rong? the objective is to use the bottom part opt the window over and over again. Chris Hare ch...@labr.net http://www.labr.net ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] binding problem

2011-11-02 Thread Chris Hare
.list.bind("", self.login_userid.focus_set()) self.list.bind("", self.login_userid.focus_set()) self.list.bind("", self.login_userid.focus_set()) If I can get this working, I should be able to get the other bindings to work. Chris

Re: [Tutor] login window using Tk

2011-11-02 Thread Chris Hare
Just thought I would drop y'all a note and say thank you for your help on this. I have the login code working. I learned a bunch from you guys. Thanks! Chris Hare ch...@labr.net http://www.labr.net On Nov 2, 2011, at 5:02 AM, Alan Gauld wrote: > On 02/11/11 05:05, Chris Ha

Re: [Tutor] using separate py files for classes

2011-11-02 Thread Chris Hare
A…. thanks Hugo!! Chris Hare ch...@labr.net http://www.labr.net On Nov 2, 2011, at 2:14 AM, Hugo Arts wrote: > On Wed, Nov 2, 2011 at 7:29 AM, Chris Hare wrote: >> >> I would like to put each of my classes in separate files to make it easier >> to edit them and keep

[Tutor] using separate py files for classes

2011-11-02 Thread Chris Hare
uot;import file" 2. I have to include all of the import statements for things not found in the class file Is this normal or am I doing something wrong? Thanks! Chris Hare ch...@labr.net http://www.labr.net ___ Tutor maillist - Tutor@python.o

Re: [Tutor] login window using Tk

2011-11-01 Thread Chris Hare
229, in verifyLogin farmid = list.get(ACTIVE) AttributeError: type object 'list' has no attribute 'get' When the frame controls were added, list is defined as list = Listbox(frame) What have I got messed up? I have poked around the net but I can't find anything meaningfu

Re: [Tutor] login window using Tk

2011-11-01 Thread Chris Hare
Good feedback Alan, thanks. I wasn't using the root window to hold the login form, although I suppose I could. I guess where I am stuck is the login to control displaying the login window, and hiding it to display the actual application window once the user has authenticated. Chris

Re: [Tutor] login window using Tk

2011-11-01 Thread Chris Hare
Okay - that makes sense. The login window uses the show="*" for the password field and is authenticated against a database where the passwords are encrypted. I have this working in a text only environment, just struggling to get it right for the GUI Thanks Chris Hare ch...@lab

Re: [Tutor] login window using Tk

2011-11-01 Thread Chris Hare
Here is a code snippet I have pulled out of the project. It is as bare bones as I can make it to get the point across. the problems I am having: 1. I would really like the window to be centered in the user's screen, but setting the geometry doesn't place it there. (that isn't included here)

[Tutor] login window using Tk

2011-11-01 Thread Chris Hare
the user has authenticated? Thanks Chris Hare ch...@labr.net http://www.labr.net Chris Hare ch...@labr.net http://www.labr.net ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman