Re: [Tutor] Paython as a career
You should not choose a specific programming language and start a career in it. If you want a career in programming you need to learn a great deal about computer science (the theory). One of the things you will learn in your studies is that programming languages are just the tools, and you leverage them to create great software. Therefore you shouldn't need to "know" how used a programming language is - if you understand how programming works, you can choose a language to specialize in (for example, I use Python for all my personal projects because I feel like the language design is better than most others), but I am grounded enough in the theory that I am not tied to Python. For example, I worked a 6-month internship where the main programming language was C#, and they used all Microsoft tools. I'd never used C# or the tools, but within a week or two, I was able to familiarize myself with their codebase and start working on it at a fairly competent level. Now it would take a while for me to become as productive in C# as I am in Python, just based on my ability to recall so much information about Python without having to look at reference material. If you're really asking us which language has the largest job market, Python is definitely not the answer to that question? Can you find jobs in Python? Sure, if you are determined and you look hard enough. But as far as widespread use, I'd say C/C++, Java, and C# are still the reigning programming languages. That's just my personal opinion and I didn't consult any statistical sources for that. What it all boils down to is this: Programming is difficult. If you like to spend your free time solving mathematical equations and doing logic problems, it might be for you. If you like to spend your free time fixing up your car, or something, you'd probably do better to choose a different career. I think you will not be very successful if you try to pick up a programming career on a whim, as a side income. If you are not committed enough to either study it in school or learn it really well at a job, you will not be successful. Especially if your boss is a programmer, it is very clear after only a short while at a job whether you are a competent programmer, and unless you find yourself in a very poorly run company, you won't be able to skirt by. You'll have to know what you're doing. That having been said, for people of a certain mindset, programming is extremely enjoyable and a rewarding field to be in. If you are interested in Python because you are interested in the things you can do with it, rather than being interested in it because it is a potential source of revenue, start playing around with it and learning it. Do some projects. Ask us lots of questions. And if you still like it after completing something substantial, then start thinking about it in terms of a career path. That's my 2 cents, of course you have no obligation to take my advice. I hope it helps you one way or the other. Good luck. -Luke On Tue, Mar 17, 2009 at 1:37 AM, Hussain Ali < hussainali.hussain...@gmail.com> wrote: > Dear all > > I want to start learning python but before going further I need answer to > my > questions so that my path can be clear to me. I shall be grateful for your > answers: > > 1) Where does python stand as compared to other programming languages? > 2) What is the future for python? > 3) Will it survive for long in this rapidly changing trends and new > languages? > 4) Should I start it to earn my bread and butter? I mean is that beneficial > for income. > > > Sincerely > > Hussain > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Paython as a career
"Hussain Ali" wrote 1) Where does python stand as compared to other programming languages? That depends on how you measure it. On functionality? On popularity? On number of active projects on Sourceforge? How do you measure "standing"? 2) What is the future for python? I don't have psychic powers but the short term future is version 3 growing and version 2 slowly diminishing. Beyond that I couldn't say. 3) Will it survive for long in this rapidly changing trends and new languages? Provided there is an active community of users it will survive. Very few languages die out completely. There are still plenty users of COBOL, Fortran, Lisp, Smalltalk, ADA, Pascal, etc. Python has been around for almost 20 years, if it survived that long I don't see it disappearing any time soon. 4) Should I start it to earn my bread and butter? I mean is that beneficial for income. There are plenty people earning a living using Python. There are probably even more who use Python as a second language for building tools, prototyping, etc. Any professional programmer should know several languages, not all of which are likely to be his main source of income but all will be useful tools. In my experience its very unusual to find any significant project that only uses one language (especially if we include shell scripting, SQL, etc) More to the point is the matter of what do YOU want to do? What kind of projects do you want to work on? What kind of company do you want to work for? The programming language should not be your primary concern. But if I was starting out as a programer today I'd want to know at least the basics of: 1) Java 2) C (plus a little bit of C++) 3) SQL 4) bash 5) VB.NET/VBA 6) Javascript 7) One of the scripting languages (Perl, Python, PHP, Ruby, Tcl) And more than the basics of at least two of them. And for a rounded out education I'd consider reading up on: 1) Lisp/Scheme 2) Prolog 3) Haskell 4) Smalltalk With that under my belt I'd feel reasonably competent. Other languages you can pick up as you need them. HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Paython as a career
Luke, i think you gave a more balanced answer :) On Tue, Mar 17, 2009 at 10:45 AM, Luke Paireepinart wrote: > You should not choose a specific programming language and start a career in > it. If you want a career in programming you need to learn a great deal > about computer science (the theory). One of the things you will learn in > your studies is that programming languages are just the tools, and you > leverage them to create great software. Therefore you shouldn't need to > "know" how used a programming language is - if you understand how > programming works, you can choose a language to specialize in (for example, > I use Python for all my personal projects because I feel like the language > design is better than most others), but I am grounded enough in the theory > that I am not tied to Python. For example, I worked a 6-month internship > where the main programming language was C#, and they used all Microsoft > tools. I'd never used C# or the tools, but within a week or two, I was able > to familiarize myself with their codebase and start working on it at a > fairly competent level. Now it would take a while for me to become as > productive in C# as I am in Python, just based on my ability to recall so > much information about Python without having to look at reference material. > If you're really asking us which language has the largest job market, Python > is definitely not the answer to that question? Can you find jobs in > Python? Sure, if you are determined and you look hard enough. But as far > as widespread use, I'd say C/C++, Java, and C# are still the reigning > programming languages. That's just my personal opinion and I didn't consult > any statistical sources for that. > > What it all boils down to is this: Programming is difficult. If you like > to spend your free time solving mathematical equations and doing logic > problems, it might be for you. If you like to spend your free time fixing > up your car, or something, you'd probably do better to choose a different > career. I think you will not be very successful if you try to pick up a > programming career on a whim, as a side income. If you are not committed > enough to either study it in school or learn it really well at a job, you > will not be successful. Especially if your boss is a programmer, it is very > clear after only a short while at a job whether you are a competent > programmer, and unless you find yourself in a very poorly run company, you > won't be able to skirt by. You'll have to know what you're doing. > > That having been said, for people of a certain mindset, programming is > extremely enjoyable and a rewarding field to be in. If you are interested > in Python because you are interested in the things you can do with it, > rather than being interested in it because it is a potential source of > revenue, start playing around with it and learning it. Do some projects. > Ask us lots of questions. And if you still like it after completing > something substantial, then start thinking about it in terms of a career > path. > > That's my 2 cents, of course you have no obligation to take my advice. I > hope it helps you one way or the other. > Good luck. > -Luke > > On Tue, Mar 17, 2009 at 1:37 AM, Hussain Ali < > hussainali.hussain...@gmail.com> wrote: > >> Dear all >> >> I want to start learning python but before going further I need answer to >> my >> questions so that my path can be clear to me. I shall be grateful for your >> answers: >> >> 1) Where does python stand as compared to other programming languages? >> 2) What is the future for python? >> 3) Will it survive for long in this rapidly changing trends and new >> languages? >> 4) Should I start it to earn my bread and butter? I mean is that >> beneficial for income. >> >> >> Sincerely >> >> Hussain >> >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> >> > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Lloyd Dube ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Paython as a career
Le Tue, 17 Mar 2009 03:45:36 -0500, Luke Paireepinart s'exprima ainsi: > If you're really asking us which language has the largest job market, Python > is definitely not the answer to that question? Can you find jobs in > Python? Sure, if you are determined and you look hard enough. But as far > as widespread use, I'd say C/C++, Java, and C# are still the reigning > programming languages. That's just my personal opinion and I didn't consult > any statistical sources for that. Python is much more prominent in the free software/open-source world -- than for commercial software. You may think the reason is that free developpers can choose ;-) Free software rarely pays back in terms of money. Denis -- la vita e estrany ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Making exe Python file - standalone executable file
Hi! Py2exe i standard way (up to my knowledge) of making standalone executable Python file in order to distribute your program to others who don't have Python installed (too bad that it is not part of standard Python distribution). I have no experience with wxPython and PyQT. Do they have their own compilers or we must do it again with Py2exe? Thanks, Neven ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] memory error files over 100MB
Kent Johnson wrote: On Mon, Mar 16, 2009 at 12:30 PM, A.T.Hofkamp wrote: I don't know what code is executed in an assignment exactly, but **possibly**, first the 'read()' is executed (thus loading a very big string into memory), before assigning the value to the variable (which releases the previous value of the variable). That means that just after reading but before assigning, you **may** have two very big strings in memory that cannot be garbage collected. No. Python variables are references to values, not containers for values. Python assignment is *always* reference assignment, not copying of a value. More here; http://personalpages.tds.net/~kent37/kk/00012.html Nice web-page! I am aware of how variables are treated in Python. Let me explain my reasoning in more detail. Consider the statement s = s + "def" under the assumption that s is now "abc" (or rather, s references the data value "abc"). For the assignment, I believe the following happens inside the python interpreter (but I am not 100% sure that it is exactly the sequence): 1. get a reference to the current value of s. 2. get a reference to the constant value "def". 3. compute the new value "abcdef", store it in memory, and make a reference to it. 4. drop the old reference of s (thus free-ing "abc") 5. give s a reference to the newly computed value. The point I was trying to make is that after step 3 and before step 4, the old value of s is still referenced by s, and the new value is referenced internally (so step 5 can be performed). In other words, both the old and the new value are in memory at the same time after step 3 and before step 4, and both are referenced (that is, they cannot be garbage-collected). Assuming that the above mechanism is used with all assignments, this will also be the case in the sequence of assignments s = read() # write s s = read() # write s where in the second assignment statement, the read() is done (creating the new value in memory) before dropping the value of s from the first assignment. You can do the above statements also iteratively of course for i in ... s = read() # write s but since the loop does nothing with either s or read(), this will not change how the assignment works. In the case that you are manipulating large values (as in taking a lot of computer memory for each value), the execution of the read() during step 3 may fail due to memory being used for the previously assigned value of s. Sincerely, Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Paython as a career
Luke, You have explained it beautifully ! Thanks & Regards Rajkumar. B On Tue, 17 Mar 2009 02:17:44 -0700 OkaMthembo wrote > Luke, i think you gave a more balanced answer :) > > On Tue, Mar 17, 2009 at 10:45 AM, Luke Paireepinart > wrote: > You should not choose a specific programming language and start a career in > it. If you want a career in programming you need to learn a great deal > about computer science (the theory). One of the things you will learn in > your studies is that programming languages are just the tools, and you > leverage them to create great software. Therefore you shouldn't need to > "know" how used a programming language is - if you understand how > programming works, you can choose a language to specialize in (for example, > I use Python for all my personal projects because I feel like the language > design is better than most others), but I am grounded enough in the theory > that I am not tied to Python. For example, I worked a 6-month internship > where the main programming language was C#, and they used all Microsoft > tools. I'd never used C# or the tools, but within a week or two, I was able > to familiarize myself with their codebase and start working on it at a > fairly competent level. Now it would take a while for me to become as > productive in C# as I am in Python, just based on my ability to recall so > much information about Python without having to look at reference material. > If you're really asking us which language has the largest job market, Python > is definitely not the answer to that question? Can you find jobs in Python? > Sure, if you are determined and you look hard enough. But as far as > widespread use, I'd say C/C++, Java, and C# are still the reigning > programming languages. That's just my personal opinion and I didn't consult > any statistical sources for that. > > What it all boils down to is this: Programming is difficult. If you like > to spend your free time solving mathematical equations and doing logic > problems, it might be for you. If you like to spend your free time fixing > up your car, or something, you'd probably do better to choose a different > career. I think you will not be very successful if you try to pick up a > programming career on a whim, as a side income. If you are not committed > enough to either study it in school or learn it really well at a job, you > will not be successful. Especially if your boss is a programmer, it is very > clear after only a short while at a job whether you are a competent > programmer, and unless you find yourself in a very poorly run company, you > won't be able to skirt by. You'll have to know what you're doing. > > That having been said, for people of a certain mindset, programming is > extremely enjoyable and a rewarding field to be in. If you are interested > in Python because you are interested in the things you can do with it, > rather than being interested in it because it is a potential source of > revenue, start playing around with it and learning it. Do some projects. > Ask us lots of questions. And if you still like it after completing > something substantial, then start thinking about it in terms of a career > path. > > That's my 2 cents, of course you have no obligation to take my advice. I > hope it helps you one way or the other. > Good luck. > -Luke > > > On Tue, Mar 17, 2009 at 1:37 AM, Hussain Ali > wrote: > > > > Dear all > > I want to start learning python but before going further I need answer to > my > questions so that my path can be clear to me. I shall be grateful for your > answers: > > 1) Where does python stand as compared to other programming languages? > 2) What is the future for python? > 3) Will it survive for long in this rapidly changing trends and new > languages? > 4) Should I start it to earn my bread and butter? I mean is that beneficial > for income. > > > Sincerely > > Hussain > > > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > > > > -- > Lloyd Dube > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] (no subject)
Would anyone know how to Write an application that displays the following patterns separately, one below the other. Use for or while loops to generate the patterns. All asterisks (*) should be printed by a single statement of print( '*' ); which causes the asterisks to print side by side. A statement of println(\n); can be used to move to the next line. * ** *** * ** *** * ** ** * *** ** * *** ** * dukelx2...@gmail.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] combining Python 2.x and Python 3
I have an open source project I have done some work on, which is programmed in Python 2.3-2.6. I would like to change it so that it can be run under both Python 3 and Python 2.x. Two questions for that: * is there a place where I can find an overview of what to do to make such a change? * is there a way to check, on one computer, the code under both versions (I am using Windows Vista, in case it matters)? -- André Engels, andreeng...@gmail.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] list.replace -- string.swap
Hello Denis, spir wrote: Is there a list.replace builtin I cannot find? Or a workaround? You didn't find it because it does not exist. You should do something like [f(x) for x in old_lst] where f(x) implements the replacement. Also: How would perform string.swap(s1, s2) in the following cases: * There is no secure 'temp' char, meaning that s.replace(s1,temp).replace(s2,s1).replace(temp,s2) will fail because any char can be part of s. split on s1, replace all pieces s2 -> s1, join with s2 ? pieces = txt.split(s1) pieces = [p.replace(s2, s1) for p in pieces] text = s2.join(pieces) which may not work if s1 and s2 overlap, but that case was not described above. Sincerely, Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
So the extent of your effort is "Would anyone know how to Ctrl+c". That deserves an award. 2009/3/17 Jared White > Would anyone know how to Write an application that displays the following > patterns separately, one below the other. Use for or while loops to generate > the patterns. All asterisks (*) should be printed by a single statement of > print( '*' ); which causes the asterisks to print side by side. A statement > of println(\n); can be used to move to the next line. > * > ** > *** > > * > ** > *** > > * > ** > > ** > * > > *** > ** > * > > *** > ** > * > dukelx2...@gmail.com > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Michael Connors ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
Michael Connors wrote: So the extent of your effort is "Would anyone know how to Ctrl+c". That deserves an award. I think you meant ctrl-v, but good point, nonetheless :) (Took me a moment, because I thought you were referring to a KeyboardInterrupt-type ctrl-c!) TJG ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] list.replace -- string.swap
Is there a list.replace builtin I cannot find? Or a workaround? Also: How would perform string.swap(s1, s2) in the following cases: * There is no secure 'temp' char, meaning that s.replace(s1,temp).replace(s2,s1).replace(temp,s2) will fail because any char can be part of s. * Either s1 or s2 can be more than a single char. Denis -- la vita e estrany ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] (no subject)
Would anyone know how to Write an application that displays the following patterns separately, one below the other. Use for or while loops to generate the patterns. All asterisks (*) should be printed by a single statement of print( '*' ); which causes the asterisks to print side by side. A statement of println(\n); can be used to move to the next line. * ** *** * ** *** * ** ** * *** ** * *** ** * dukelx2...@gmail.com Sent from my Verizon Wireless BlackBerry Please consider the environment before printing this email or attachments ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] list.replace -- string.swap
On Tue, Mar 17, 2009 at 7:01 AM, spir wrote: > Is there a list.replace builtin I cannot find? Or a workaround? Just assign directly to list elements. To replace s1 with s2 in l: for i, x in enumerate(l): if x == s1: l[i] = s2 > Also: How would perform string.swap(s1, s2) in the following cases: > > * There is no secure 'temp' char, meaning that > s.replace(s1,temp).replace(s2,s1).replace(temp,s2) > will fail because any char can be part of s. You could use re.sub() with a function for the replacement string. It takes a little setup but it's not really difficult: import re def string_swap(s, s1, s2): ''' Swap s1 and s2 in s''' # Given a match, return s2 for s1 and vice-versa def replace(m): return s2 if m.group()==s1 else s1 # re to match s1 or s2 matcher = re.compile('%s|%s' % (re.escape(s1), re.escape(s2))) return matcher.sub(replace, s) print string_swap('go to the park', 'o', 'a') Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
On Tue, Mar 17, 2009 at 6:56 AM, Jared White wrote: > Would anyone know how to Write an application that displays the following > patterns separately, one below the other. Yes. How about if you try? Presumably this is homework. What have you learned that might be helpful here? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] combining Python 2.x and Python 3
On Tue, Mar 17, 2009 at 7:33 AM, Andre Engels wrote: > I have an open source project I have done some work on, which is > programmed in Python 2.3-2.6. I would like to change it so that it can > be run under both Python 3 and Python 2.x. Two questions for that: > * is there a place where I can find an overview of what to do to make > such a change? A very brief overwiew here: http://docs.python.org/3.0/whatsnew/3.0.html#porting-to-python-3-0 There are quite a few porting anecdotes in blogs, etc. Some googling should turn them up. > * is there a way to check, on one computer, the code under both > versions (I am using Windows Vista, in case it matters)? You can install Python 2.x and 3.0 on the same computer, no problem. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] memory error files over 100MB
On Tue, Mar 17, 2009 at 6:34 AM, A.T.Hofkamp wrote: >> http://personalpages.tds.net/~kent37/kk/00012.html > > Nice web-page! Thanks! > You can do the above statements also iteratively of course > > for i in ... > s = read() > # write s > > but since the loop does nothing with either s or read(), this will not > change how the assignment works. > > > In the case that you are manipulating large values (as in taking a lot of > computer memory for each value), the execution of the read() during step 3 > may fail due to memory being used for the previously assigned value of s. Ah, thanks, I misunderstood the point you were making. You can allow the previous value of s to be garbage-collected by assigning s=None, for example: for i in ... s = read() # process s s = None Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] (no subject)
Honestly I'm doing tutorials, I'm not in school. I am trying to learn it for my own sake. I got the *'s to come up but they are not forming the way I would like it to. So that why I was asking for help. This isn't a homework assignment. I'm just going thu tutorials which are not helping me Sent from my Verizon Wireless BlackBerry Please consider the environment before printing this email or attachments ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
On Tue, Mar 17, 2009 at 9:03 AM, wrote: > Honestly I'm doing tutorials, I'm not in school. I am trying to learn it for > my own sake. > > I got the *'s to come up but they are not forming the way I would like it to. > So that why I was asking for help. OK, then show us the code you have and we'll help you fix it. Tell us what happens and what you want to happen. Don't just ask us to write a program for you. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] combining Python 2.x and Python 3
On Tue, Mar 17, 2009 at 8:59 AM, Kent Johnson wrote: > There are quite a few porting anecdotes in blogs, etc. Some googling > should turn them up. Google "python 3 porting" for lots of resources. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
As a policy we don't give answers to homework questions. However, if you have tried this and you are stuck, we'd be happy to help with any specific questions you have about your implementation. On Tue, Mar 17, 2009 at 6:00 AM, wrote: > Would anyone know how to Write an application that displays the following > patterns separately, one below the other. Use for or while loops to generate > the patterns. All asterisks (*) should be printed by a single statement of > print( '*' ); which causes the asterisks to print side by side. A statement > of println(\n); can be used to move to the next line. > * > ** > *** > > * > ** > *** > > * > ** > > ** > * > > *** > ** > * > > *** > ** > * > > dukelx2...@gmail.com > Sent from my Verizon Wireless BlackBerry > > Please consider the environment before printing this email or attachments > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Gtk time control and Glade
I am writing a Blood-Glucose Analysis application for Diabetics. I am using Python 2.5 under Ubuntu 8.10 and Glade 3.4.5. Manually recorded test results require a calendar control for the date of the test (no problem) and a timer control for the time of the test(big problem). While Glade certainly supports a calender control with a great deal of documentation, there is not an available time control for Glade. Nor was I able to find a general time control for Gtk. I did find one for wxwidgets but I am not using wxwidgets nor am I using PyQt. I am reasonably sure such a control exists. I know I'm not the only individual who needs date and time controls. But, using Google has provided all kinds of information, there has not been a specific statement about any specific controls. At this time I do not feel I have the level of expertise to build my own control and it is something I would rather not have to do. Have any of you heard of such an available time control specifically for Gtk and available or capable of being used by Glade. Thank you for any insights and suggestions. Robert Berman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Modifying Grayson's Example 5_14
> Martin Walsh wrote: >> Wayne Watson wrote: >> >> >> >>> it. It works pretty well, but puts up a a few probably top level >>> windows that are blank. How do I get around them, and is there anything >>> >> >> >> >> >>> root = Tk() >>> >> >> Try adding this, >> >> root.withdraw() >> >> >>> dialog = GetPassword(root) >>> >> >> HTH, >> Marty Wayne Watson wrote: > That worked. Why the "extra" blank window though? I'm no Tkinter expert -- far from it. But I would assume that GetPassword, as a subclass of Dialog, creates a new window, and thus you have no need for the root window. root.withdraw() hides the root window from view, and allows the application to continue running. I imagine there are other ways to accomplish the same thing. HTH, Marty ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
> From: dukelx2...@gmail.com > To: tu...@python.org > Honestly I'm doing tutorials, I'm not in school. I am trying to learn it for > my own sake. > I got the *'s to come up but they are not forming the way I would like it to. > So that why I was asking for help. I suppose the trick here is to add a comma at the end of the print statement, to let the next one continue printing on the same line. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
Doesn't backslash also escape the newline? Thought i saw something to that effect in the tutorial. Lloyd On Tue, Mar 17, 2009 at 4:33 PM, Daniele wrote: > > From: dukelx2...@gmail.com > > To: tutor@python.org > > Honestly I'm doing tutorials, I'm not in school. I am trying to learn it > for my own sake. > > I got the *'s to come up but they are not forming the way I would like it > to. So that why I was asking for help. > > I suppose the trick here is to add a comma at the end of the print > statement, to let the next one continue printing on the same line. > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Lloyd Dube ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python and Tkinter Programming by Grayson--New Version?
Title: Signature.html I've poked around at the pieces of the book in Subject, which are on the web--two chapters. It was published in 2000, first ed. It looks quite good, and certainly is big, 680 or so pages. He sells a digital version. It uses Pmw, which I barely no more than how to spell it. Is that even current any longer? I'd like to think the author is going to produce another version. Anyone know? Here's a clipped version of the contents. It got good review on Amazon. bout the cover xxii author online xxiii Part 1 Basic concepts 1 1 Python 3 1.1 Introduction to Python programming and a feature review 3 Why Python? 4, Where can Python be used? 5 1.2 Key data types: lists, tuples and dictionaries 5 Lists 5, Tuples 7, Dictionaries 8 1.3 Classes 9 How do classes describe objects? 9, Defining classes 9, Neat Python trick #10 9, Initializing an instance 10, Methods 10, Private and public variables and methods 11, Inheritance 11, Multiple inheritance 11, Mixin classes 11 2 Tkinter 12 2.1 The Tkinter module 12 What is Tkinter? 12, What about performance? 13, How do I use Tkinter? 13, Tkinter features 14 2.2 Mapping Tcl/Tk to Tkinter 14 2.3 Win32 and Unix GUIs 15 2.4 Tkinter class hierarchy 16 2.5 Tkinter widget appearance 17 3 Building an application 18 3.1 Calculator example: key features 21 3.2 Calculator example: source code 21 3.3 Examining the application structure 27 3.4 Extending the application 28 Part 2 Displays 29 4 Tkinter widgets 31 4.1 Tkinter widget tour 31 Toplevel 32, Frame 33, Label 35, Button 36, Entry 37, Radiobutton 37, Checkbutton 38, Menu 39, Message 42, Text 43, Canvas 44, Scrollbar 45, Listbox 45, Scale 46 4.2 Fonts and colors 47 Font descriptors 47, X Window System font descriptors 47, Colors 48, Setting application-wide default fonts and colors 49 4.3 Pmw Megawidget tour 49 AboutDialog 50, Balloon 50, ButtonBox 51, ComboBox 52, ComboBoxDialog 53, Counter 54, CounterDialog 55, Dialog 56, EntryField 56, Group 57, LabeledWidget 58, MenuBar 59, MessageBar 59, MessageDialog 61, NoteBookR 61, NoteBookS 62, NoteBook 63, OptionMenu 64, PanedWidget 65, PromptDialog 66, RadioSelect 66, ScrolledCanvas 67, ScrolledField 68, ScrolledFrame 69, ScrolledListbox 70, ScrolledText 70, SelectionDialog 71, TextDialog 72, TimeCounter 73 ... snip 8 Dialogs and forms 140 8.1 Dialogs 141 Standard dialogs 141, Data entry dialogs 142, Single-shot forms 146, Tkinter variables 152 8.2 A standard application framework 155 8.3 Data dictionaries 165 8.4 Notebooks 172 8.5 Browsers 175 8.6 Wizards 184 8.7 Image maps 191 8.8 Summary 198 9 Panels and machines 199 9.1 Building a front panel 199 9.2 Modularity 201 9.3 Implementing the front panel 201 9.4 GIF, BMP and overlays 215 9.5 And now for a more complete example 220 9.6 Virtual machines using POV-Ray 232 And now for something completely different... #10 The Example 233 9.7 Summary 236 10 Drawing blobs and rubber lines 237 10.1 Drawing on a canvas 238 Moving canvas objects 243 10.2 A more complete drawing program 244 10.3 Scrolled canvases 251 10.4 Ruler-class tools 254 10.5 Stretching canvas objects 258 10.6 Some finishing touches 262 10.7 Speed drawing 271 10.8 Summary 275 11 Graphs and charts 276 11.1 Simple graphs 276 11.2 A graph widget 279 Adding bargraphs 286, Pie charts 289 11.3 3-D graphs 292 11.4 Strip charts 296 11.5 Summary 298 12 Navigation 300 12.1 Introduction: navigation models 300 12.2 Mouse navigation 301 ... snip 18 Threads and asynchronous techniques 361 18.1 Threading 361 Non-GUI threads 362, GUI threads 365 18.2 ?after? processing 369 18.3 Summary 373 19 Distributing Tkinter applications 374 19.1 General issues in distributing applications 374 19.2 Distributing Unix applications 375 19.3 Distributing Win32 applications 376 19.4 Python distribution tools 379 Part 4 Appendices 381 appendix A Mapping Tk to Tkinter 383 appendix B Tkinter reference 425 appendix C Pmw reference: Python megawidgets 542 appendix D Building and installing Python, Tkinter 610 appendix E Events and keysyms 617 appendix F Cursors 621 appendix G References 625 index 629 -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] combining Python 2.x and Python 3
Apparently there's a tool to convert older Python code to Python 3 compatibility - is this what you want? Must be somewhere in the cheese shop - sorry i cannot recall the name, or where exactly i saw the discussion. Lloyd On Tue, Mar 17, 2009 at 1:33 PM, Andre Engels wrote: > I have an open source project I have done some work on, which is > programmed in Python 2.3-2.6. I would like to change it so that it can > be run under both Python 3 and Python 2.x. Two questions for that: > * is there a place where I can find an overview of what to do to make > such a change? > * is there a way to check, on one computer, the code under both > versions (I am using Windows Vista, in case it matters)? > > -- > André Engels, andreeng...@gmail.com > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Lloyd Dube ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] escaping newline (was: (no subject))
OkaMthembo wrote: Doesn't backslash also escape the newline? Thought i saw something to that effect in the tutorial. It does, but only inside the .py file. It has no effect when you run the program. Its purpose is to allow you to break long lines, for example if long_function_name(a) == long_function_name(b) \ and long_function_name(c) == long_function_name(d) \ and long_function_name(e) == long_function_name(f): # do something if all three equalities hold note that you can place the \ break anywhere. Some people like the following layout if long_function_name(a) == long_function_name(b) and \ long_function_name(c) == long_function_name(d) and \ long_function_name(e) == long_function_name(f): # do something if all three equalities hold The conditions now nicely line up, making it easier to read. The down side (in my opinion) is that the difference in indent is really small. Sincerely, Albert ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Checking Entry Values in Tkinter Widgets
Title: Signature.html The program I'm modifying uses something of a primitive way to check the validity of values entered into widgets on a larger dialog. It uses try-except after the user has pressed OK and departed from the dialog. Isn't this supposed to be done in the apply method for the dialog? A typical data widget inside the set operations dialog class is: class OperationalSettingsDialog(tkSimpleDialog.Dialog): def __init__(self, parent, sdict): self.sdict = sdict tkSimpleDialog.Dialog.__init__(self, parent) def body(self,master): self.title("Operational Settings") ... # data widget Label( master, text="Max Hourly Event Rate: ").grid(row=5, sticky=W) self.rateVar = StringVar() Entry(master, width=10, textvariable=self.rateVar).grid(row=5, column=1) self.rateVar.set( "%s" % self.sdict["hourly_rate"] ) ... def apply(self): self.sdict["ok"] = True #END of class Furthermore, doesn't the use of tkSimpleDialog.Dialog provide an OK and Cancel button, which upon use causes the the invocation of the apply method to depart? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Gtk time control and Glade
Make your own. You can have empty containers in glade that you fill in at runtime, or you could create the interface in glade, perhaps a couple of ComboBoxes. I would leave an empty container and create a reusable widget descended from gtk.HBox that implements validation or anything else that it would need to do. Maybe it could default to the current time, for instance. I know its possible to configure glade to use custom widgets, but I've never bothered to learn about since it's so easy (and free of caveats that I might become subject to) to leave empty space for runtime use. Here's a quick and dirty (and untested!) example: class TimeEntry(gtk.HBox): def __init__(self): gtk.HBox.__init__(self) self.hr = \ w = gtk.ComboBox() for i in range(24): w.append_text('%02d'%(i,)) self.pack_start(w, False, False, 0) w.show() w = gtk.Label(':') self.pack_start(w, False, False, 0) w.show() self.min = \ w = gtk.ComboBox() for i in range(60): w.append_text('%02d'%(i,)) self.pack_start(w, False, False, 0) w.show() def get(self): return '%02d:%02d' % (self.hr.get_active(),self.min.get_active()) Cheers On Tuesday 17 March 2009 09:25, Robert Berman wrote: > I am writing a Blood-Glucose Analysis application for Diabetics. I am > using Python 2.5 under Ubuntu 8.10 and Glade 3.4.5. > > Manually recorded test results require a calendar control for the date > of the test (no problem) and a timer control for the time of the > test(big problem). While Glade certainly supports a calender control > with a great deal of documentation, there is not an available time > control for Glade. Nor was I able to find a general time control for > Gtk. I did find one for wxwidgets but I am not using wxwidgets nor am I > using PyQt. > > I am reasonably sure such a control exists. I know I'm not the only > individual who needs date and time controls. But, using Google has > provided all kinds of information, there has not been a specific > statement about any specific controls. At this time I do not feel I have > the level of expertise to build my own control and it is something I > would rather not have to do. > > Have any of you heard of such an available time control specifically for > Gtk and available or capable of being used by Glade. > > Thank you for any insights and suggestions. > > > Robert Berman > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Gtk time control and Glade
Thank you Chris, that will certainly get me started. Robert Chris Fuller wrote: Make your own. You can have empty containers in glade that you fill in at runtime, or you could create the interface in glade, perhaps a couple of ComboBoxes. I would leave an empty container and create a reusable widget descended from gtk.HBox that implements validation or anything else that it would need to do. Maybe it could default to the current time, for instance. I know its possible to configure glade to use custom widgets, but I've never bothered to learn about since it's so easy (and free of caveats that I might become subject to) to leave empty space for runtime use. Here's a quick and dirty (and untested!) example: class TimeEntry(gtk.HBox): def __init__(self): gtk.HBox.__init__(self) self.hr = \ w = gtk.ComboBox() for i in range(24): w.append_text('%02d'%(i,)) self.pack_start(w, False, False, 0) w.show() w = gtk.Label(':') self.pack_start(w, False, False, 0) w.show() self.min = \ w = gtk.ComboBox() for i in range(60): w.append_text('%02d'%(i,)) self.pack_start(w, False, False, 0) w.show() def get(self): return '%02d:%02d' % (self.hr.get_active(),self.min.get_active()) Cheers On Tuesday 17 March 2009 09:25, Robert Berman wrote: I am writing a Blood-Glucose Analysis application for Diabetics. I am using Python 2.5 under Ubuntu 8.10 and Glade 3.4.5. Manually recorded test results require a calendar control for the date of the test (no problem) and a timer control for the time of the test(big problem). While Glade certainly supports a calender control with a great deal of documentation, there is not an available time control for Glade. Nor was I able to find a general time control for Gtk. I did find one for wxwidgets but I am not using wxwidgets nor am I using PyQt. I am reasonably sure such a control exists. I know I'm not the only individual who needs date and time controls. But, using Google has provided all kinds of information, there has not been a specific statement about any specific controls. At this time I do not feel I have the level of expertise to build my own control and it is something I would rather not have to do. Have any of you heard of such an available time control specifically for Gtk and available or capable of being used by Glade. Thank you for any insights and suggestions. Robert Berman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Paython as a career
On Tue, Mar 17, 2009 at 10:46:59AM +0100, spir wrote: [snip] > Python is much more prominent in the free software/open-source > world -- than for commercial software. You may think the reason > is that free developpers can choose ;-) Free software rarely pays > back in terms of money. I'd like to disagree to some extend. While you may be right that it's less than common to be able to get a job as a Python programmer. It's also true that programming skills in general and Python skills in particular can add value to your resume. I've been hired a number of times to teach classes in corporations that had a need for Python skills. So, there are definitely companies out there that would view Python programming skills as valuable. I suspect that there are others on this list who also teach Python in a corporate setting. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Paython as a career
Lukes answer is an excellent one! I would add that you can find language popularity here: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html I am moving to Python from Visual FoxPro. I have been programming all of my adult career. I have used Cobol, RPG, Basic, FoxPro and Python all in production to make my living. I have been using FoxPro for 16 years and really love it, but find Python the most complete language. You don't need active X or third party libraries because they are all there and written Python. My success as a programmer has little to do with the language or even how well I program. It has more to do with my ability to understand the problem and communicate with customers or my employer. Good luck Hussain Ali wrote: Dear all I want to start learning python but before going further I need answer to my questions so that my path can be clear to me. I shall be grateful for your answers: 1) Where does python stand as compared to other programming languages? 2) What is the future for python? 3) Will it survive for long in this rapidly changing trends and new languages? 4) Should I start it to earn my bread and butter? I mean is that beneficial for income. Sincerely Hussain -- Jeff Jeff Johnson j...@dcsoftware.com Phoenix Python User Group - sunpigg...@googlegroups.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] (no subject)
This is what i have so far an this is not what i want it to do "NO this isnt homework" i am trying to learn this myself #!/usr/bin/env python # #Author: J White #Python 2.5.2 # howmany = int(raw_input('How many lines ')) rhowmany = howmany strout = '*' while howmany > 0: print strout strout += '*' howmany -= 1 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Fun with Label and Entry--Why NoneType?
Title: Signature.html The program below is derived from an example in Grayson for showing how one might a dialog for entering passwords. The structure seems just like the original, down to the use of self, Label and Entry plus . Yet the print "here" statement produces: here None I'm missing something. The NoneType causes the print of the self.lat to fail with get(). The original returns something from the corresponding body function, but taking it out does nothing in either program. The original program is posted above under "Modifying Grayson's Example 5_14". # Derived from Grayson 5_14.py from Tkinter import * from tkSimpleDialog import Dialog import tkSimpleDialog import tkMessageBox #import Pmw class DialogPrototype(Dialog): def body(self, master): self.title("Enter Site Data") Label(master, text='Latitude:').grid(row=0, sticky=W) self.lat=Entry(master, width=12).grid(row=0, column=1) Label(master, text='Longitude:').grid(row=0, column=2) self.long=Entry(master, width=12).grid(row=0, column=3) print "here", self.long,type(self.long) return def apply(self): print "apply" print self.lat.get() print self.long.get() print "setting" lat=1.0 long=0.0 root = Tk() root.withdraw() dialog = DialogPrototype(root) -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
On Tue, Mar 17, 2009 at 2:16 PM, Jared White wrote: > This is what i have so far an this is not what i want it to do > "NO this isnt homework" i am trying to learn this myself > > #!/usr/bin/env python > # > #Author: J White > #Python 2.5.2 > # > howmany = int(raw_input('How many lines ')) > rhowmany = howmany > strout = '*' > while howmany > 0: > print strout > strout += '*' > howmany -= 1 > try this: mystr = "h" print mystr*10 that should help. -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
Wayne Watson wrote: > The program below is derived from an example in Grayson for showing how > one might a dialog for entering passwords. The structure seems just like > the original, down to the use of self, Label and Entry plus . Yet the > print "here" statement produces: > here None > I'm missing something. The NoneType causes the print of the self.lat to > fail with get(). > > The original returns something from the corresponding body function, but > taking it out does nothing in either program. The original program is > posted above under "Modifying Grayson's Example 5_14". > > # Derived from Grayson 5_14.py > from Tkinter import * > from tkSimpleDialog import Dialog > import tkSimpleDialog > import tkMessageBox > #import Pmw > > class DialogPrototype(Dialog): > > def body(self, master): > self.title("Enter Site Data") > Label(master, text='Latitude:').grid(row=0, sticky=W) > self.lat=Entry(master, width=12).grid(row=0, column=1) This is where you diverge from the Grayson example. What you're saying is that self.lat should be set to the result of Entry(...).grid(...) which is always None, presumably. What I think you want is self.lat to be a reference to the Entry widget itself. Try this, self.lat = Entry(master, width=12) self.lat.grid(row=0, column=1) > > Label(master, text='Longitude:').grid(row=0, column=2) > self.long=Entry(master, width=12).grid(row=0, column=3) ... and, self.long = Entry(master, width=12) self.long.grid(row=0, column=3) > print "here", self.long,type(self.long) > return > > def apply(self): > print "apply" > print self.lat.get() > print self.long.get() > > print "setting" > lat=1.0 > long=0.0 Is that the way you indented the above, really? I suppose it could be intentional, but probably not. > > root = Tk() > root.withdraw() > dialog = DialogPrototype(root) HTH, Marty ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] combining Python 2.x and Python 3
> I would like to change it so that it can be run under both Python 3 and > Python 2.x. everyone who has responded so far are telling about converting your piece of code from Python 2 to Python 3, for example, using the "2to3" tool that comes with Python 2.6+: http://docs.python.org/library/2to3.html however, that means that you have to maintain 2 different files, one for Python 3 and one for Python 2. no one has addressed your original request directly, so i'll do it here: it is nearly impossible to have a sufficiently complex single .py source file that will run under both Python 3 and Python 2 -- one single print statement would ruin it, if you know what i mean. however, Python 2.6 (and the rest of the 2.x series) have some of 3.0's features backported to it so that you can start writing against 3.x interpreters, and i would recommend that you start there. finally, 2.6 has a -3 switch that you can turn on to warn you about Python 3 incompatibilities. hope this helps! -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 "Python Fundamentals", Prentice Hall, (c)2009 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
On Tue, Mar 17, 2009 at 3:16 PM, Jared White wrote: > howmany = int(raw_input('How many lines ')) > rhowmany = howmany > strout = '*' > while howmany > 0: > print strout > strout += '*' > howmany -= 1 Another hint: learn how to use the range() function and for loops: In [1]: for i in range(4) ...: print i 0 1 2 3 Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Making exe Python file - standalone executable file
"Neven Gorsic" wrote Py2exe i standard way (up to my knowledge) of making standalone executable Python file in order to distribute your program to others who don't have Python installed It is one of several ways to do that for those who believe that it is more advantageousd that simply packaging python with the application. But it is not "the standard way", it is a way. (too bad that it is not part of standard Python distribution). I actually like that since it helps people get out of thinking that way. I have no experience with wxPython and PyQT. Do they have their own compilers or we must do it again with Py2exe? Neither is a compiled environment (and py2exe is not a compiler either). But if you want to package Qt or wxPython apps as a single file then yes you need to use a bundling tool like py2exe. HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] escaping newline (was: (no subject))
"A.T.Hofkamp" wrote Some people like the following layout if long_function_name(a) == long_function_name(b) and \ long_function_name(c) == long_function_name(d) and \ long_function_name(e) == long_function_name(f): # do something if all three equalities hold I prefer to use parens for that: if ( long_function_name(a) == long_function_name(b) and long_function_name(c) == long_function_name(d) and long_function_name(e) == long_function_name(f) ): # do something if all three equalities hold That increases the indent and avoids the pesky \ chars. But it adds a hard-to-spot closing paren at the end :-( -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/l2p/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
Title: Signature.html Ah, very subtle. Thanks. That worked, but I got shelled by: Program output (22, 33 are what I entered): apply 22 33 Traceback (most recent call last): File "C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-Utilities/sentuser/NewSentDlg.py", line 35, in dialog = DialogPrototype(root) File "C:\Python25\lib\lib-tk\tkSimpleDialog.py", line 69, in __init__ self.wait_visibility() # window needs to be visible for the grab File "C:\Python25\lib\lib-tk\Tkinter.py", line 415, in wait_visibility self.tk.call('tkwait', 'visibility', window._w) TclError: window ".60529560" was deleted before its visibility changed Martin Walsh wrote: Wayne Watson wrote: The program below is derived from an example in Grayson for showing how one might a dialog for entering passwords. The structure seems just like the original, down to the use of self, Label and Entry plus . Yet the print "here" statement produces: here None I'm missing something. The NoneType causes the print of the self.lat to fail with get(). The original returns something from the corresponding body function, but taking it out does nothing in either program. The original program is posted above under "Modifying Grayson's Example 5_14". # Derived from Grayson 5_14.py from Tkinter import * from tkSimpleDialog import Dialog import tkSimpleDialog import tkMessageBox #import Pmw class DialogPrototype(Dialog): def body(self, master): self.title("Enter Site Data") Label(master, text='Latitude:').grid(row=0, sticky=W) self.lat=Entry(master, width=12).grid(row=0, column=1) This is where you diverge from the Grayson example. What you're saying is that self.lat should be set to the result of Entry(...).grid(...) which is always None, presumably. What I think you want is self.lat to be a reference to the Entry widget itself. Try this, self.lat = Entry(master, width=12) self.lat.grid(row=0, column=1) Label(master, text='Longitude:').grid(row=0, column=2) self.long=Entry(master, width=12).grid(row=0, column=3) and, self.long = Entry(master, width=12) self.long.grid(row=0, column=3) print "here", self.long,type(self.long) return def apply(self): print "apply" print self.lat.get() print self.long.get() print "setting" lat=1.0 long=0.0 Is that the way you indented the above, really? I suppose it could be intentional, but probably not. root = Tk() root.withdraw() dialog = DialogPrototype(root) HTH, Marty ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Personal: Fwd: Re: Paython as a career
Malcolm: I have four sticky XML / flat files downloaded from a web site that is converted into four text files and then synchronized into one file. Due to the web interface I moved it from VFP to Python. It was easier, cleaner and very fast. I run it from the VFP RUN command. I have been using VFP / Foxpro since 1992. I have an app that is running fine for a long time and then something seems to go wrong. Maybe it's an upgrade of the OS or a Microsoft update or who knows what. I have to deal with it and rehash old code that was working fine. I have noticed that Python "just works". I have seen it already with this first project. Oh, I download all of my bank accounts and credit cards as .csv files. I then use Python to convert them to Quickbooks IIF files and import them into Quickbooks. No data entry because of Python! I am now developing a dabo app that has a UI. I should have it done soon and will let you know more about it on the dabo list. For me, Python is a lot like VFP only you don't need to bring in active X or third party libraries. I also have two Ubuntu machines that I can run it all on. As far as Dabo goes, check it out. The video of the report designer will get you hooked. I just wish I had more time. Malcolm Greene wrote: Hi Jeff, My success as a programmer has little to do with the language or even how well I program. It has more to do with my ability to understand the problem and communicate with customers or my employer. Great response! I'm really enjoying my move to Python. Not only the language, but the optimism that surrounds the language (vs. the gray cloud of depression that has haunted FoxPro for so many years). I've focused all my Python efforts on back room data processing (ETL) vs. GUI type applications. In fact, I haven't moved any of our GUI based products to Python (or Dabo). What are you doing with Python? Have you built any GUI apps yet and if so, using wxPython (and Dabo?), pyQt, Tkinter, etc? Do you have any Dabo based apps in production yet? Curious to hear about your FoxPro migration journey when you have a moment. Regards, Malcolm (from the Profox list) -- Jeff Jeff Johnson j...@dcsoftware.com Phoenix Python User Group - sunpigg...@googlegroups.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
"Jared White" wrote howmany = int(raw_input('How many lines ')) rhowmany = howmany what does rhowmany do? strout = '*' while howmany > 0: print strout strout += '*' howmany -= 1 Combine the two hints so far to improve it, then look even more closely at range() to see how to do the decreasing lengths. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] list.replace -- string.swap
"spir" wrote Is there a list.replace builtin I cannot find? Or a workaround? myList[x] = newValue Or is that too obvious? Also: How would perform string.swap(s1, s2) in the following cases: * There is no secure 'temp' char, meaning that s.replace(s1,temp).replace(s2,s1).replace(temp,s2) will fail because any char can be part of s. * Either s1 or s2 can be more than a single char. Sorry you lost me there. No idea what you mean. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] combining Python 2.x and Python 3
On Tue, Mar 17, 2009 at 3:54 PM, wesley chun wrote: >> I would like to change it so that it can be run under both Python 3 and >> Python 2.x. > > everyone who has responded so far are telling about converting your > piece of code from Python 2 to Python 3, for example, using the "2to3" > tool that comes with Python 2.6+: > http://docs.python.org/library/2to3.html > > however, that means that you have to maintain 2 different files, one > for Python 3 and one for Python 2. Not necessarily. I think the intent of 2to3 is that you maintain the Python 2.6 version and automatically create the Python 3 version from it. So there is only one source file. At least one person found this practical, for a large codebase (well, he says it "mostly works"): http://wiki.python.org/moin/PortingDjangoTo3k > no one has addressed your original > request directly, so i'll do it here: it is nearly impossible to have > a sufficiently complex single .py source file that will run under both > Python 3 and Python 2 -- one single print statement would ruin it, if > you know what i mean. Here are three success stories of creating a single version of a sizable project that runs in both 2.x and 3.0: http://pythonology.blogspot.com/2009/02/making-code-run-on-python-20-through-30.html http://mail.mems-exchange.org/durusmail/qp/441/ and followup The postings have a fair amount of detail. Durus, QP, QPy and evoque are all open source so you can see how they did it. http://www.mems-exchange.org/software/ - the latest releases include the Py 3.0 code though the README files don't mention it. http://evoque.gizmojo.org/ Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] combining Python 2.x and Python 3
"Andre Engels" wrote I have an open source project I have done some work on, which is programmed in Python 2.3-2.6. I would like to change it so that it can be run under both Python 3 and Python 2.x. That will be tricky. I think you can pretty much make Python 3 code that can run under v2.6. But I doubt you can make it run under anything older. There are too many new syntax features - just think about the difference in input() and print()... That's all your user I/O operations affected for starters! Maybe a Tkinter GUI could be made to work though? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?
"Wayne Watson" wrote I've poked around at the pieces of the book in Subject, which are on the web It was published in 2000, first ed. It looks quite good, and certainly is big, About a third of it is reference material. Not a bad thing, I use it a lot, but other sources have the same stuff. A lot is PMW which although still active I think, is no longer the only add on toolkit. Indeed Tix is now partof the standard library and adds a lot of the same sort of things. (Tabbed notebooks etc) The other oddity is a fair portion of the book is taken up with building photo-realistic UIs. This is not something I've ever found a need for! It is quite impressive but of distinctly limitedvalue for most programmers IMHO. I'd like to think the author is going to produce another version. I've seen no signs of that. And although some of the newer widgets are not included very little of the book is out of date. OTOH if you just need a reference the "Tcl/Tk in a Nutshell" by O'Reilly might suit just as well and is available very cheaply second hand on Amazon... It is my second most used Tk source. (after Lundh's online reference, Grayson is my third!) It also covers Tix. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Checking Entry Values in Tkinter Widgets
"Wayne Watson" wrote The program I'm modifying uses something of a primitive way to check the validity of values entered into widgets on a larger dialog. You can bind events to the individual entry widgets to check values when you navigate away from the widget. Or even on each keypress... ...Isn't this supposed to be done in the apply method for the dialog? I believe so. That is where you would check the data consisterncy/integrity across all the widgets in the dialog. From your question it seems you don't think the apply() is getting called? A typical data widget inside the set operations dialog class is: class OperationalSettingsDialog(tkSimpleDialog.Dialog): def __init__(self, parent, sdict): self.sdict = sdict tkSimpleDialog.Dialog.__init__(self, parent) def body(self,master): self.title("Operational Settings") ... # data widget Label( master, text="Max Hourly Event Rate: ").grid(row=5, sticky=W) self.rateVar = StringVar() Entry(master, width=10, textvariable=self.rateVar).grid(row=5, column=1) self.rateVar.set( "%s" % self.sdict["hourly_rate"] ) ... def apply(self): self.sdict["ok"] = True #END of class Furthermore, doesn't the use of tkSimpleDialog.Dialog provide an OK and Cancel button, which upon use causes the the invocation of the apply method to depart? Again I believe so but I'm no expert on SimpleDialog. I usually just write my own dialogs based on Toplevel... Just habit. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?
This is a super book for beginners who are new to GUI programming. Tkinter is easy to use, and comes included with Python. Serious programmers will probably want something faster, better looking, and with nicer features, but they can be tricky to figure out and install. I still prefer Tkinter for quick and dirty work or programs with simple interfaces. Pmw is a very nice system. I wish it was easily adapted to other GUI toolkits. Development on it has mostly ended, although not entirely, there was a new release within the last year. You will find it very useful if you write anything moderately interesting with Tkinter. This book does not cover the Tix widget set, which was originally created for Tcl/Tk and later included with Tkinter, after this book was published. I find that Pmw covers most of the problem space that Tix is suited for, but a beginner may have a different experience. I was disappointed when I heard that this book was no longer in print. I still have my copy, however, so all I need to do is make sure I clutch onto it tightly, and I'll be aright :) Cheers On Tuesday 17 March 2009 10:08, Wayne Watson wrote: > I've poked around at the pieces of the book in Subject, which are on the > web--two chapters. It was published in 2000, first ed. It looks quite good, > and certainly is big, 680 or so pages. He sells a digital version. It uses > Pmw, which I barely no more than how to spell it. Is that even current any > longer? I'd like to think the author is going to produce another version. > Anyone know? Here's a clipped version of the contents. It got good review > on Amazon. > > bout the cover xxii > author online xxiii > Part 1 Basic concepts 1 > > 1 Python 3 > 1.1 Introduction to Python programming and a feature review 3 > > Why Python? 4, Where can Python be used? 5 > > 1.2 Key data types: lists, tuples and dictionaries 5 > > Lists 5, Tuples 7, Dictionaries 8 > > 1.3 Classes 9 > > How do classes describe objects? 9, Defining classes 9, Neat Python > trick #10 9, Initializing an instance 10, Methods 10, Private and public > variables and methods 11, Inheritance 11, Multiple inheritance 11, Mixin > classes 11 > > 2 Tkinter 12 > 2.1 The Tkinter module 12 > > What is Tkinter? 12, What about performance? 13, How do I use Tkinter? > 13, Tkinter features 14 > > 2.2 Mapping Tcl/Tk to Tkinter 14 > 2.3 Win32 and Unix GUIs 15 > 2.4 Tkinter class hierarchy 16 > 2.5 Tkinter widget appearance 17 > 3 Building an application 18 > 3.1 Calculator example: key features 21 > 3.2 Calculator example: source code 21 > 3.3 Examining the application structure 27 > 3.4 Extending the application 28 > > Part 2 Displays 29 > > 4 Tkinter widgets 31 > 4.1 Tkinter widget tour 31 > > Toplevel 32, Frame 33, Label 35, Button 36, Entry 37, Radiobutton 37, > Checkbutton 38, Menu 39, Message 42, Text 43, Canvas 44, Scrollbar 45, > Listbox 45, Scale 46 > > 4.2 Fonts and colors 47 > > Font descriptors 47, X Window System font descriptors 47, Colors 48, > Setting application-wide default fonts and colors 49 > > 4.3 Pmw Megawidget tour 49 > > AboutDialog 50, Balloon 50, ButtonBox 51, ComboBox 52, ComboBoxDialog > 53, Counter 54, CounterDialog 55, Dialog 56, EntryField 56, Group 57, > LabeledWidget 58, MenuBar 59, MessageBar 59, MessageDialog 61, NoteBookR > 61, NoteBookS 62, NoteBook 63, OptionMenu 64, PanedWidget 65, PromptDialog > 66, RadioSelect 66, ScrolledCanvas 67, ScrolledField 68, ScrolledFrame 69, > ScrolledListbox 70, ScrolledText 70, SelectionDialog 71, TextDialog 72, > TimeCounter 73 ... snip > 8 Dialogs and forms 140 > 8.1 Dialogs 141 > > Standard dialogs 141, Data entry dialogs 142, Single-shot forms 146, > Tkinter variables 152 > > 8.2 A standard application framework 155 > 8.3 Data dictionaries 165 > 8.4 Notebooks 172 > 8.5 Browsers 175 > 8.6 Wizards 184 > 8.7 Image maps 191 > 8.8 Summary 198 > 9 Panels and machines 199 > 9.1 Building a front panel 199 > 9.2 Modularity 201 > 9.3 Implementing the front panel 201 > 9.4 GIF, BMP and overlays 215 > 9.5 And now for a more complete example 220 > 9.6 Virtual machines using POV-Ray 232 > > And now for something completely different... #10 The Example 233 > > 9.7 Summary 236 > 10 Drawing blobs and rubber lines 237 > 10.1 Drawing on a canvas 238 > > Moving canvas objects 243 > > 10.2 A more complete drawing program 244 > 10.3 Scrolled canvases 251 > 10.4 Ruler-class tools 254 > 10.5 Stretching canvas objects 258 > 10.6 Some finishing touches 262 > 10.7 Speed drawing 271 > 10.8 Summary 275 > 11 Graphs and charts 276 > 11.1 Simple graphs 276 > 11.2 A graph widget 279 > > Adding bargraphs 286, Pie charts 289 > > 11.3 3-D graphs 292 > 11.4 Strip charts 296 > 11.5 Summary 298 > 12
Re: [Tutor] Fun with Label and Entry--Why NoneType?
"Wayne Watson" wrote Yet the print "here" statement produces: here None I'm missing something. The NoneType causes the print of the self.lat to fail with get(). self.long=Entry(master, width=12).grid(row=0, column=3) The placement methods(pack, grod etc) all return None. You must run them as a separate line if you want to get a reference to the widget. self.long=Entry(master, width=12) self.long.grid(row=0, column=3) HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?
"Chris Fuller" wrote easy to use, and comes included with Python. Serious programmers will probably want something faster, better looking, and with nicer features, The next versions of Python/Tkinter will apparently be based on the new widget set of Tk which has native look n feel on each platform so the ugly factor should at least dissappear! This book does not cover the Tix widget set, which was originally created for Tcl/Tk and later included with Tkinter, after this book was published. I find that Pmw covers most of the problem space that Tix is suited for, but a beginner may have a different experience. Between the new Tkinter standard widgets (Paned Window, Spinbox etc) and Tix virtually everything in PMW is available in the standard library. and there are some extras not in PMW like a Grid and Tree for example. One of the things on my ToDo list is to add a couple of new topics to my tutorial giving simple examples for all the Tkinter and Tix widgets... As much for my own benefit as anything! HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] sets module equivalent with Python 2.6
Hello all, I want to use an equivalent of sets module with Python 2.6 ... but sets module is deprecated on 2.6 version. In fact I want to make that but with Python 2.6: >>> toto_1 = [0, 1, 2, 3, 4] >>> toto_2 = [1, 127, 4, 7, 12] >>> >>> import sets >>> a = sets.Set(toto_1) >>> b = sets.Set(toto_2) >>> c = a.symmetric_difference(b) >>> d = [p for p in c] >>> d.sort() >>> print d [0, 2, 3, 7, 12, 127] Can you help me ?. Thanks in advance. a+ -- http://ekd.tuxfamily.org ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
"Wayne Watson" wrote got shelled by: dialog = DialogPrototype(root) TclError: window ".60529560" was deleted before its visibility changed Thats the result of withdraw I think Try reversing the calls: root = Tk() dialog = DialogPrototype(root) root.withdraw() That way the withdraw happens after the dialog is created. root should not then be garbage collected since it is still referred to by the Dialog parent attribute. I think... :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] sets module equivalent with Python 2.6
On Tue, Mar 17, 2009 at 2:34 PM, PyProg PyProg wrote: > > I want to use an equivalent of sets module with Python 2.6 ... but > sets module is deprecated on 2.6 version. it is deprecated only because sets have been rolled into Python proper starting in 2.4. replace sets.Set() with set(), and there is frozenset() as well. > In fact I want to make that but with Python 2.6: > toto_1 = [0, 1, 2, 3, 4] toto_2 = [1, 127, 4, 7, 12] import sets a = sets.Set(toto_1) b = sets.Set(toto_2) c = a.symmetric_difference(b) d = [p for p in c] d.sort() print d > [0, 2, 3, 7, 12, 127] > > Can you help me ?. here is some code that works under Python 2.4, 2.5, and 2.6: $ python2.6 Python 2.6.1 (r261:67515, Feb 26 2009, 01:19:46) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> toto_1 = [0, 1, 2, 3, 4] >>> toto_2 = [1, 127, 4, 7, 12] >>> >>> a = set(toto_1) >>> b = set(toto_2) >>> c = a.symmetric_difference(b) >>> d = [p for p in c] >>> d.sort() >>> print d [0, 2, 3, 7, 12, 127] in 3.x, you also get set literals, meaning no more factory function calls are required! $ python3.0 Python 3.0.1 (r301:69556, Feb 26 2009, 01:01:25) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = {0, 1, 2, 3, 4} >>> b = {1, 127, 4, 7, 12} >>> c = a.symmetric_difference(b) >>> d = [p for p in c] >>> d.sort() >>> print(d) [0, 2, 3, 7, 12, 127] hope this helps! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 "Python Fundamentals", Prentice Hall, (c)2009 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] (no subject)
Alan Gauld wrote: Combine the two hints so far to improve it, then look even more closely at range() to see how to do the decreasing lengths. Thanks for the tips, I have been trying to figure it out also. I did get it after about 3 hours :) -david -- Powered by Gentoo GNU/LINUX http://www.linuxcrazy.com pgp.mit.edu ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?
What sets Pmw apart is the framework it provides for the creation of your own megawidgets. It handles labels, forwards options from the constructor to the constructors of the subcomponents, forwards method calls (say your megawidget is descended from a Frame, but the main feature is a Scale widget), includes a set of standard data validators, etc. Cheers On Tuesday 17 March 2009 16:27, Alan Gauld wrote: > "Chris Fuller" wrote > > This book does not cover the Tix widget set, which was originally > > created for > > Tcl/Tk and later included with Tkinter, after this book was > > published. I > > find that Pmw covers most of the problem space that Tix is suited > > for, but a > > beginner may have a different experience. > > Between the new Tkinter standard widgets (Paned Window, Spinbox etc) > and Tix virtually everything in PMW is available in the standard > library. and > there are some extras not in PMW like a Grid and Tree for example. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?
"Chris Fuller" wrote What sets Pmw apart is the framework it provides for the creation of your own megawidgets. I can't comment on the PMW framework and I haven't tried it in Python Tix but the Tcl documents claim Tix does a similar thing. Certainly insofar as it provides a framework for creating your own widgets. My Tcl/Tk Nutshell book says: "Tix adds an object oriented (AG: ie. to Tcl/Tk) framework for defining new widget types from existing widget types. Instances of these new widget types are called mega-widgets. Tix includes over 40... and several commands for designing new ones..." The main creation commands I see are tixWidgetClass, tixCallMethod, tixChainMethod. There are maybe half a dozen others. A quick look in Python Tix reveals a TixWidget class. But the other commands are not obvuiously available - but they may be hidden as methods of something else... It handles labels, forwards options from the constructor to the constructors of the subcomponents, forwards method calls (say your megawidget is descended from a Frame, but the main feature is a Scale widget), includes a set of standard data validators, etc. It can do the forwarding of methods but I can't see any validators etc. It would be interesting to do a bit of comparison, if only there were some decent documents for Python Tix! :-( Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Checking Entry Values in Tkinter Widgets
Yes, apply is invoked when I click OK. apply has one statement, and returns to the caller, which then checks the validity (try-except) of values passed back to it. It seems like apply should do all the try-except work instead. The code spends quite a few lines setting things up to pass back. I've thought this setup was odd when I first looked at it, and think the author went to too much trouble to put the try-except back to the caller to the dialog. What I really need are checks like is lat (latitude) from -90 to +90, and not -700, say. That is bound checking. I have implemented the config file stuff from weeks ago without need of any config libraries. I did that just to get on with matters, but I may have to use, say, ObjectConfig (or Parse-whatever) to do bound checking. I have no idea those config modules would help in this matter. If not, I'll just do it the old fashioned way -- if statements. Alan Gauld wrote: "Wayne Watson" wrote The program I'm modifying uses something of a primitive way to check the validity of values entered into widgets on a larger dialog. You can bind events to the individual entry widgets to check values when you navigate away from the widget. Or even on each keypress... ...Isn't this supposed to be done in the apply method for the dialog? I believe so. That is where you would check the data consisterncy/integrity across all the widgets in the dialog. From your question it seems you don't think the apply() is getting called? A typical data widget inside the set operations dialog class is: class OperationalSettingsDialog(tkSimpleDialog.Dialog): def __init__(self, parent, sdict): self.sdict = sdict tkSimpleDialog.Dialog.__init__(self, parent) def body(self,master): self.title("Operational Settings") ... # data widget Label( master, text="Max Hourly Event Rate: ").grid(row=5, sticky=W) self.rateVar = StringVar() Entry(master, width=10, textvariable=self.rateVar).grid(row=5, column=1) self.rateVar.set( "%s" % self.sdict["hourly_rate"] ) ... def apply(self): self.sdict["ok"] = True #END of class Furthermore, doesn't the use of tkSimpleDialog.Dialog provide an OK and Cancel button, which upon use causes the the invocation of the apply method to depart? Again I believe so but I'm no expert on SimpleDialog. I usually just write my own dialogs based on Toplevel... Just habit. -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
Title: Signature.html Unfortunately, that takes me back to the original situation. That is, the blank window appears along with the dialog window. It also ends badly with what looks like the same error messages(below). Maybe focus needs to be established. I'm really using this code to design a dialog for the larger application program, so I don't need to get too fussy about how it ends. I just want to see that I've got the elementary widgets place properly. ==msgs== setting here .85342728.85433640.85432520 Traceback (most recent call last): File "C:/Sandia_Meteors/Sentinel_Development/Development_Sentuser-Utilities/sentuser/NewSentDlg.py", line 34, in dialog = DialogPrototype(root) File "C:\Python25\lib\lib-tk\tkSimpleDialog.py", line 69, in __init__ self.wait_visibility() # window needs to be visible for the grab File "C:\Python25\lib\lib-tk\Tkinter.py", line 415, in wait_visibility self.tk.call('tkwait', 'visibility', window._w) TclError: window ".85342728" was deleted before its visibility changed Alan Gauld wrote: "Wayne Watson" wrote got shelled by: dialog = DialogPrototype(root) TclError: window ".60529560" was deleted before its visibility changed Thats the result of withdraw I think Try reversing the calls: root = Tk() dialog = DialogPrototype(root) root.withdraw() That way the withdraw happens after the dialog is created. root should not then be garbage collected since it is still referred to by the Dialog parent attribute. I think... :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
2009/3/18 Wayne Watson : > Unfortunately, that takes me back to the original situation. That is, the > blank window appears along with the dialog window. It also ends badly with > what looks like the same error messages(below). Maybe focus needs to be > established. I'm really using this code to design a dialog for the larger > application program, so I don't need to get too fussy about how it ends. I > just want to see that I've got the elementary widgets place properly. I didn't notice any call to root.mainloop() in your original code. Are you calling mainloop() anywhere? -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Checking Entry Values in Tkinter Widgets
"Wayne Watson" wrote Yes, apply is invoked when I click OK. apply has one statement, and returns to the caller, which then checks the validity (try-except) of values passed back to it. It seems like apply should do all the try-except work instead. Yes, I'd agree that is how it should work. What I really need are checks like is lat (latitude) from -90 to +90, and not -700, say. That is bound checking. Yes, that can be done with binding of validation code to the lat field. You could also use the FocusOut event for example to run something like: # in the create widget section self.lat.bind('', self.vLat) # validation handler def vLat(self, ev): if 90 < int(self.lat.get()) < -90: # beep, or error dialog self.lat.focus_set() Which would generate an alert and reset focus to the widget before even hitting apply(). HTH, -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
"Wayne Watson" wrote Unfortunately, that takes me back to the original situation. That is, the blank window appears along with the dialog window. OK Try this version: # Derived from Grayson 5_14.py from Tkinter import * from tkSimpleDialog import Dialog class DialogPrototype(Dialog): def body(self, master): self.title("Enter Site Data") Label(master, text='Latitude:').grid(row=0, sticky=W) self.lat=Entry(master, width=12) self.lat.grid(row=0, column=1) Label(master, text='Longitude:').grid(row=0, column=2) self.long=Entry(master, width=12) self.long.grid(row=0, column=3) self.master.withdraw() def apply(self): print "apply" print self.lat.get() print self.long.get() print "setting" lat=1.0 long=0.0 root = Tk() DialogPrototype(root) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
"John Fouhy" wrote Unfortunately, that takes me back to the original situation. That is, the blank window appears along with the dialog window. It also ends badly with I didn't notice any call to root.mainloop() in your original code. Are you calling mainloop() anywhere? I noticed that too but it doesn't seem to need a mainloop call, I assume that is happening somewhere in the inherited Dialog framework, but I've no idea how/where! But an event loop is surely running somewhere! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
2009/3/18 Wayne Watson : > Not at all. I took Grayson's example as it stood. However, as it might have > been noted above, he was working with Pmw, so the code may be a false > impression of how it works in Tkinter. > > This gave the same results: > root = Tk() > dialog = DialogPrototype(root) > root.mainloop() > > Extra blank window at start up and crashed the same way when pressing OK. > I'm using this code to prototype a larger dialog with more data entry, so it > doesn't really matter that it crashes when I exit. Well, my Tkinter is pretty rusty, but I'm guessing that your dialog may not work if there is no event loop running. Try this: root = Tk() root.after_idle(DialogPrototype, root) root.mainloop() See docs here for the after_idle() method: http://effbot.org/tkinterbook/widget.htm -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Checking Entry Values in Tkinter Widgets
As I thought this over, while on a long walk, apply might not be the place. That is, if pressing OK gets you to apply and the code discovers how do you get back to the dialog. I think you may have answered that below with the validation code. Alan Gauld wrote: "Wayne Watson" wrote Yes, apply is invoked when I click OK. apply has one statement, and returns to the caller, which then checks the validity (try-except) of values passed back to it. It seems like apply should do all the try-except work instead. Yes, I'd agree that is how it should work. What I really need are checks like is lat (latitude) from -90 to +90, and not -700, say. That is bound checking. Yes, that can be done with binding of validation code to the lat field. You could also use the FocusOut event for example to run something like: # in the create widget section self.lat.bind('', self.vLat) # validation handler def vLat(self, ev): if 90 < int(self.lat.get()) < -90: # beep, or error dialog self.lat.focus_set() Which would generate an alert and reset focus to the widget before even hitting apply(). HTH, -- Signature.html Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fun with Label and Entry--Why NoneType?
Title: Signature.html Not at all. I took Grayson's example as it stood. However, as it might have been noted above, he was working with Pmw, so the code may be a false impression of how it works in Tkinter. This gave the same results: root = Tk() dialog = DialogPrototype(root) root.mainloop() Extra blank window at start up and crashed the same way when pressing OK. I'm using this code to prototype a larger dialog with more data entry, so it doesn't really matter that it crashes when I exit. John Fouhy wrote: 2009/3/18 Wayne Watson : Unfortunately, that takes me back to the original situation. That is, the blank window appears along with the dialog window. It also ends badly with what looks like the same error messages(below). Maybe focus needs to be established. I'm really using this code to design a dialog for the larger application program, so I don't need to get too fussy about how it ends. I just want to see that I've got the elementary widgets place properly. I didn't notice any call to root.mainloop() in your original code. Are you calling mainloop() anywhere? -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python and Tkinter Programming by Grayson--New Version?
Title: Signature.html Working with Tkinter is like trying to dig through fossils. So much out there is old or incomplete. It's like the Tk species went extinct. The trail seems to end in 2005. I think I read it's not quite dead, and a newer looking is coming. Alan Gauld wrote: "Wayne Watson" wrote I've poked around at the pieces of the book in Subject, which are on the web It was published in 2000, first ed. It looks quite good, and certainly is big, About a third of it is reference material. Not a bad thing, I use it a lot, but other sources have the same stuff. A lot is PMW which although still active I think, is no longer the only add on toolkit. Indeed Tix is now partof the standard library and adds a lot of the same sort of things. (Tabbed notebooks etc) The other oddity is a fair portion of the book is taken up with building photo-realistic UIs. This is not something I've ever found a need for! It is quite impressive but of distinctly limitedvalue for most programmers IMHO. I'd like to think the author is going to produce another version. I've seen no signs of that. And although some of the newer widgets are not included very little of the book is out of date. OTOH if you just need a reference the "Tcl/Tk in a Nutshell" by O'Reilly might suit just as well and is available very cheaply second hand on Amazon... It is my second most used Tk source. (after Lundh's online reference, Grayson is my third!) It also covers Tix. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time) “Life is one damn thing after another." -- Mark Twain ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] combining Python 2.x and Python 3
> I think the intent of 2to3 is that you maintain the > Python 2.6 version and automatically create the Python 3 version from > it. So there is only one source file. At least one person found this > practical, for a large codebase (well, he says it "mostly works"): > http://wiki.python.org/moin/PortingDjangoTo3k > >> no one has addressed your original >> request directly, so i'll do it here: it is nearly impossible to have >> a sufficiently complex single .py source file that will run under both >> Python 3 and Python 2 -- one single print statement would ruin it, if >> you know what i mean. > > Here are three success stories of creating a single version of a > sizable project that runs in both 2.x and 3.0: > http://pythonology.blogspot.com/2009/02/making-code-run-on-python-20-through-30.html > http://mail.mems-exchange.org/durusmail/qp/441/ and followup > > The postings have a fair amount of detail. Durus, QP, QPy and evoque > are all open source so you can see how they did it. > http://www.mems-exchange.org/software/ - the latest releases include > the Py 3.0 code though the README files don't mention it. > http://evoque.gizmojo.org/ wow, great links Kent. i didn't think that people would be as bold as to do this, but i guess it was inevitable. it's interesting to see both the similarities and the differences for those who are trying to maintain a single version source. (in particular, the "if" statements checking versions with attributes of the sys module reminds me of old C code i worked on years ago when maintaining apps that had to run on both Unix and Windows systems.) it may be worthwhile to collate all of this info into a "2to3 FAQ" at some point. cheers, -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Python Web Development with Django", Addison Wesley, (c) 2009 http://withdjango.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor