Running test01.py under Windows (basic level)
I have v2.5.2 installed and i've composed a source code i'm sure everybody will be impressed by. It goes like this. def bloppA (): print "a very advanced piece of code" What i get to work is to make it run from the the snakes shell. Then, i realised that such a masterpiece needs storing in a file. So i saved it in a file called great.py but when i executed: exec "c:\loj\python\great.py" i got errors and the pointer showed the colon claiming it's invalid syntax. Of course, everybody will agree it's right syntax and that the computer is stupid. But let's pretend it has won and try to make it happy. How? (Background: I'm a programmer since a few years back but it's mostly Java/C/C++/C# and Python way is very new to me.) -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Running test01.py under Windows (basic level)
>> I have v2.5.2 installed and i've composed >> a source code i'm sure everybody will be >> impressed by. It goes like this. >> >> def bloppA (): >> print "a very advanced piece of code" >> >> What i get to work is to make it run from >> the the snakes shell. Then, i realised >> that such a masterpiece needs storing in >> a file. So i saved it in a file called >> great.py but when i executed: > > python great.py > from the system prompt (cmd). > Or, if you are using IDLE ... > File -> Open, open your saved file, and use > the Run menu (or press F5). There will be poking around with %PATH%, i can tell. Never liked to do that under Windows. > Beware of \ as it's the escape character, so > you have to use "c:\\loj\\python\\great.py" > or r"c:\loj\python\great.py"... I've tried to add the extra backslashes (or "r" attribute) but i still get the same error at the colon. Should i understand that i made two mistakes (the first being not using double "\" and the second calling exec alltogether)? > http://wiki.python.org/moin/BeginnersGuide - > have you worked out the Tutorial? Not yet. I started off using some small things. I tend to learn by doing. Or rather making. A lot of errors, that is. :) >> (Background: I'm a programmer since a few >> years back but it's mostly Java/C/C++/C# >> and Python way is very new to me.) > > You may benefit from the Dive into Python > http://www.diveintopython.org I'll do that. Thank you. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Running test01.py under Windows (basic level)
>> def bloppA (): >> print "a very advanced piece of code" > > go to File -> Open, open your saved file, > and use the Run menu (or press F5). When i try that i get this. >>> == RESTART === >>> And nothing more. Do i use wrong "print"?! -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: SV: Running test01.py under Windows (basic level)
>> There will be poking around with %PATH%, i can >> tell. Never liked to do that under Windows. > > No need to do that... Create an "alias.txt" file containing: > python=c:\path\to\your\python.exe $* > Execute (once, logged as administrator): > reg add "HKLM\SOFTWARE\Microsoft\Command Processor" > /v AutoRun /t REG_SZ /d > "doskey /macrofile=path\to\your\alias.txt" > Open a new cmd console. Typing python is enough to invoke the interpreter. > Documentation for the DOSKEY command: > http://technet2.microsoft.com/WindowsServer/en/library/f7f45601-5178-48c6-9219-51bd6f7abd3f1033.mspx > > If you don't like the above recipe, create a "python.cmd" file containing: > @c:\path\to\your\python.exe %* > and save it somewhere in your PATH. It worked. Thanks! >>> have you worked out the Tutorial? >> >> Not yet. I started off using some small things. >> I tend to learn by doing. Or rather making. A >> lot of errors, that is. :) > > At least overview it. Python syntax is very clear and legible, so probably > you can figure yourself a lot of things, but there are some important > topics that you have to know and are explained in the Tutorial. It isn't > very long. Naa, reading tutorials is for idiots... You can answer my questions instead. It's not like you've got anything better to do. I bet you've read the tutorial, haven't you? (a period of awkward silence...) (a short while of WTF?!) Oh, ah! This guy was joking. Pfew... Yes, i was definitely joking here. :) I do intend to go through the tutorial and i do deeply appreciate all the help i've received/ i'll receive. If all goes the way i hope, i'll be at a new project soon and it's written in Python. Great opportunity to learn it, right? By the way - thanks! -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: SV: Running test01.py under Windows (basic level)
def bloppA (): print "a very advanced piece of code" >>> >>> go to File -> Open, open your saved file, >>> and use the Run menu (or press F5). >> >> When i try that i get this. >> > == RESTART === > >> >> And nothing more. Do i use wrong "print"?! > > You *defined* a function, but aren't *executing* > it. Append a line: > > bloppA() > > and try again. Rookie mistake. Thank you. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
Surprised by the command "del"
I'm reading the docs and at 5.2 the del statement is discussed. At first, i thought i've found a typo but as i tried that myself, it turns it actually does work so. a = ["alpha", "beta", "gamma"] del a[2:2] a Now, i expected the result to be that the "beta" element has been removed. Obviously, Python thinks otherwise. Why?! Elaboration: I wonder why such an unintuitive effect has been implemented. I'm sure it's for a very good reason not clear to me due to my ignorance. Alternatively - my expectations are not so intuitive as i think. :) -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Surprised by the command "del"
>> I'm reading the docs and at 5.2 the del >> statement is discussed. At first, i thought >> i've found a typo but as i tried that >> myself, it turns it actually does work so. >> >> a = ["alpha", "beta", "gamma"] >> del a[2:2] >> a >> >> Now, i expected the result to be that the >> "beta" element has been removed. Obviously, >> Python thinks otherwise. Why?! > > Remember that slices are specified as half-open > intervals. So a[m:n] includes m-n elements, > those indexed from m to n-1. Got it. Thanks! -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
Where's GUI for Python?
I'm certain there is an API for creating GUI's but as far i can find it in the http://docs.python.org/tut/tut.html the only "gui" is in "Guido". What do i miss? -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Surprised by the command "del"
>>I'm reading the docs and at 5.2 the del >>statement is discussed. At first, i thought >>i've found a typo but as i tried that >>myself, it turns it actually does work so. >> >> a = ["alpha", "beta", "gamma"] >> del a[2:2] >> a >> >>Now, i expected the result to be that the >>"beta" element has been removed. Obviously, >>Python thinks otherwise. Why?! >> >>Elaboration: >>I wonder why such an unintuitive effect has >>been implemented. I'm sure it's for a very >>good reason not clear to me due to my >>ignorance. Alternatively - my expectations >>are not so intuitive as i think. :) > > I think it should say > del a[1:2] > then it works While i'm thankful for the advice, i need to point out that the question wasn't "how to" but "why". Anyhow, it's been explained as a matter of definition of a "slice". -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Where's GUI for Python?
>>import tkininter >> > When that fails, try without the stutter > > import tkinter I must be doing something wrong because neither tkinter nor tkininter works. I tried both with and without stuttering. I even asked my wife to stutter some but, sadly, to no avail. When Tim Chase mentioned "battery-installed", i interpreted it as "all is there". It seems that either a) not all the batteries are installed in my version (v2.5.2) or b) some setup/linkage needs to be performed in order to get the GUI running. The error itself is: ImportError: No module named tkinter Suggestions? -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Where's GUI for Python?
>> When that fails, try without the stutter >> >> import tkinter > > I must be doing something wrong because > neither tkinter nor tkininter works. > I tried both with and without stuttering. > I even asked my wife to stutter some but, > sadly, to no avail. > > When Tim Chase mentioned "battery-installed", > i interpreted it as "all is there". It seems > that either > a) not all the batteries are installed in my > version (v2.5.2) > or > b) some setup/linkage needs to be performed > in order to get the GUI running. > > The error itself is: > ImportError: No module named tkinter > > Suggestions? Here's a suggestion. Python is case-sensitive, while the users trying to help you are not. When they say "tininkerbell", they may mean "Tinkerbell". Check with "help()", then "modules" and see if it's installed or not. Sincerely Yourself :) (Seriously speaking - i'm thankful.) -- http://mail.python.org/mailman/listinfo/python-list
Keeping the console window
I've proudly connected Notepad++ to edit and run my fantastic software. When that started to work, i noticed that all the printing disappears as the console window vanishes upon the program completion. How can i trick Python program to keep on running even if the actual statements have been exectuted? Some kind of reading from keyboard? -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Where's GUI for Python?
>> You should also take a look at wxGlade: >> >> http://wxglade.sourceforge.net/ >> >> which sits on top of wxPython: >> >> http://wxpython.org/ >> >> which wraps wxWidgets: >> >> http://www.wxwindows.org/ > > I have used wxGlade, and while it worked well > enough, it didn't seem to fit my brain. I > always found myself "thinking backwards" in order > to guess how the tool needed me to do things. > For me, though, everytime I see raw wxPython code > these days I cringe, and am thankful that I don't > have to deal with it anymore. May i see a short sample of the two different ways of coding, please? I'm very curious how they differ (and of course, decide what's the most pleasurable way for me). As long as we're on the subject, i also wonder if there's a general concensus on which technology is recommended in the different types of projects that are developed. (E.g. "use A for small/fast fixes, use B for stuff you'll need to maintain later on".) -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Keeping the console window
> You may use python in interactive mode: > > $ python -i yourScript.py > > Or use a blocking readline: > > $ cat yourScript.py > import sys > sys.stdin.readline() Thanks guys! -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
Polymorphism using constructors
I'm writing a class for rational numbers and besides the most obvious constructor def __init__ (self, nomin, denom): i also wish to have two supporting ones def __init__ (self, integ): self.__init__ (integ, 1) def __init__ (self): self.__init__ (0, 1) but for some reason (not known to me at this point) i get errors. My suspicion is that it's a syntax issue. Suggestions? -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Polymorphism using constructors
"Carl Banks" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] > On Mar 3, 4:17 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote: >> Since Python doesn't support having two methods with the same name, >> the usual solution is to provide alternative constructors using >> classmethod(): >> >> @classmethod >> def from_decimal(cls, d) >> sign, digits, exp = d.as_tuple() >> digits = int(''.join(map(str, digits))) >> if sign: >> digits = -digits >> if exp >= 0: >> return cls(digits * 10 ** exp) >> return cls(digits, 10 ** -exp) > > > Note that even some of Python's built in types (dict *cough*) > implement homemade function overloading. > > The OP wanted to write a constructor that could accept either a pair > of integers or a rational, there would be a good precedent for it. > > However, I would advise the OP to use the constructor only for the > most common arguments, and use classmethods for more obscure, less > common arguments (such as decimal or even float). OP understands and thanfully accepts the suggestion. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Polymorphism using constructors
"Diez B. Roggisch" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] >K Viltersten schrieb: >> I'm writing a class for rational numbers >> and besides the most obvious constructor >> >> def __init__ (self, nomin, denom): >> >> i also wish to have two supporting ones >> >> def __init__ (self, integ): >>self.__init__ (integ, 1) >> def __init__ (self): >>self.__init__ (0, 1) >> >> but for some reason (not known to me at >> this point) i get errors. My suspicion is that it's a syntax issue. > > "errors" is not much of an error-description. That's what stacktraces are > for. I assumed that the error was so obvious to a seasoned Pytonist (Pythoner?) that a trace didn't matter. Your help below proves it. :) Nevertheless, i'll be careful in the future and make sure to post the traces too. Sorry. > Apart from that, you won't succeed with the above. Python has no > signature-based polymorphism. Instead, you use default arguments, like > this: > > def __init__(nomin=0, denom=1): > ... Thank you. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: SV: Polymorphism using constructors
> What does "SV" in the subject mean? Probably, it's an abbreviation of "svar", which means "reply". -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
Quit-command not quiting
I entered the code from tkinter.pdf, section 2 but for reason, the application doesn't close as i press the quit-button. The wondow itself vanishes if i click the cross in the upper-right corner but pressing the quit-button only makes it "pressed". Then, the program freezes. This is the code. from Tkinter import * class Demo (Frame): def __init__ (self, master = None): Frame.__init__ (self, master) self.grid () self.doLayout () def doLayout (self): self.quitButton = Button ( self, text = "Quit", command = self.quit) self.quitButton.grid () d = Demo () d.master.title ("the coolest demo ever") d.mainloop () -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Quit-command not quiting
>> The window itself vanishes if i click the >> cross in the upper-right corner but pressing >> the quit-button only makes it "pressed". >> Then, the program freezes. > > How did you run it? From inside IDLE? IDLE itself is written > using Tk, and I think that your mainloop interferes with the > one inside it. If you run your program from the command line > it should work fine. I press F5 while in the editor window. Is there a way to run the program without going to the console window? Perhaps i'm just making things unneccesarily complicated and Python IS supposed to be run from console window? >> from Tkinter import * >> class Demo (Frame): >> def __init__ (self, master = None): >> Frame.__init__ (self, master) >> self.grid () >> self.doLayout () >> def doLayout (self): >> self.quitButton = Button ( >> self, >> text = "Quit", >> command = self.quit) >> self.quitButton.grid () >> >> d = Demo () >> d.master.title ("the coolest demo ever") >> d.mainloop () > > There is only one thing I hate more than spaces after a > parens: spaces before it :) > Please read PEP8, about the suggested style for writting > Python code. http://www.python.org/dev/peps/pep-0008/ I've got no issues one way or the other. Most likely i'll forget from time to time but other than that, i'll try to keep it in mind. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
Regarding coding style
I've been recommended reading of: http://www.python.org/dev/peps/pep-0008/ and in there i saw two things that i need to get elaborated. 1. When writing English, Strunk and White apply. Where can i download it? Am i actually expected to read the whole book? How many people actually do aply it? 2. You should use two spaces after a sentence-ending period. For heavens sake, why? I've always been obstructed by the double blanks but tolerated them. Now, that i read that it actually is a recommendation, i need to ask about the purpose. Thanks for the input in advance. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Regarding coding style
>> 2. You should use two spaces after a >> sentence-ending period. >> >> For heavens sake, why? I've always been >> obstructed by the double blanks but >> tolerated them. Now, that i read that >> it actually is a recommendation, i need >> to ask about the purpose. > > (a) It makes the ends of sentences more visually obvious. > (b) It makes text easier to parse reliably from scripts. > (c) Some text-editors can navigate such sentences out of > the box, whereas others cannot. Got it. Thanks. :) -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Regarding coding style
>> Personally, I dislike double spaces after >> sentences, but it is not wrong to put them >> there any more than it is wrong not to put >> them there. > > You're lucky my high school typing teacher > didn't hear you say that... I'm unclear if your teacher was a double or single spacer. It's only implied that he felt strongly one way. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
Location and size of a frame
I'm disliking the size of my frame and also i'm disappointed regarding it's location. So, i wish to change them. At this link http://infohost.nmt.edu/tcc/help/pubs/tkinter/frame.html the frame object is discussed but as far i can tell, there are only suggestions regarding what to put in the constructor. So, how/where do i check how to affect the location and size? I'm guessing it has to do with "location", "width" and "heinght" but i didn't make it work. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Regarding coding style
> What I really can't stand are the > pointy-haired comment blocks at the > beginnings of C/C++ functions that do > things like tell you the name and return > type of the function and list the names > and types of the parameters. Gee, thanks. > I never could have figured that out from > looking at the source code itself. Coming from C++/Java camp i can't help noticing that in most cases, when i'm using a class written by somebody else, i don't want to see his/her code. I only want to know WHAT the function does (is intended to be doing, at least). I don't want to look at the source code (in some cases i can't even see the code because it's compiled). I only care that when i execute SomeType obj = SomeType(); obj.aggregate(); the object gets aggregated. How it's done will be up to the author. I'm just a user of the product. Now, i'm getting the signal that it's done in a different way in Python. Please elaborate. I'm very new to snakeology. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
Adjust a canvas as the window is resized
Do i need to set a callback to a canvas in order to "listen" to the root window being resized in order to make it adjust its contents? If so, how? If not, how do i make the canvas draw a line from one corner to an other? from Tkinter import * class Demo(Frame): def __init__(self, master = None): Frame.__init__(self, master) self.grid() self.doLayout() master.geometry("800x600") def doLayout(self): canvas = Canvas(self, bd = 3, bg = "#93F") canvas.grid(column = 0, row = 0) canvas.create_line(0, 0, 100, 200, fill = "#FFF") def callback(self): print "callback from canvas" root = Tk() demo = Demo(root) root.mainloop() -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: SV: Regarding coding style
> If you can't/don't look at the source file, > then comments aren't going to help (except > in the case of something like docstrings in > Python). I strongly disagree. Now, perhaps we're talking about different things, here? Usually, in the header file (C++), there won't be any source code, except for method declarations. A common example: /** Projects an object from 3D to 2D using the method of Alexander The Great. \param 3D structure to be projected \returns 2D projection */ public Proj2D get2Dfrom3D(Proj3D param); The above is, to me, very clear and consistent. Not to mention, easily handled with e.g. Doxygen to create a readable documentation. I don't see how this is dislikeable. Please explain. Perhaps the above IS what you ment by "docstrings"? For Java, one has the JavaDocs, a great tool, provided one will comment each method and variable used. >> Now, i'm getting the signal that it's done > in a different way in Python. > > I'm not sure how you concluded that from this thread. The below, more or less. :) "What I really can't stand are the pointy-haired comment blocks at the beginnings of C/C++ functions that do things like tell you the name and return type of the function and list the names and types of the parameters." Please note that i DO NOT argue against one way or another. I simply expressed surprise since i've been tought otherwise earlier and, maybe, there's a larger picture than what i've seen this far. As stated before, snakeology is a very new area to me. Yet. ;) -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: SV: Quit-command not quiting
"Gabriel Genellina" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] > En Fri, 07 Mar 2008 13:56:45 -0200, K Viltersten <[EMAIL PROTECTED]> > escribi�: > >>>> The window itself vanishes if i click the >>>> cross in the upper-right corner but pressing >>>> the quit-button only makes it "pressed". >>>> Then, the program freezes. >>> >>> How did you run it? From inside IDLE? IDLE itself is written >>> using Tk, and I think that your mainloop interferes with the >>> one inside it. If you run your program from the command line >>> it should work fine. >> >> I press F5 while in the editor window. Is there a way to run the >> program without going to the console window? >> Perhaps i'm just making things unneccesarily complicated >> and Python IS supposed to be run from console window? > > No, use IDLE if you prefer, or any other editor/IDE. But in your case > there is an unfortunate coupling between IDLE and your script. Fix: change > the quit method as suggested in this thread: > http://groups.google.com/group/comp.lang.python/browse_thread/thread/92bee52a3e2a325e/ > > def quit(self): > self.master.destroy() > > This is OK if used on the top level widget on the application (your Demo > class, for instance). A more general solution: > > def quit(self): > parent = self > while parent.winfo_class() != 'Tk': > if parent.master is None: > break; > parent = parent.master > else: > parent.destroy() > > (from > https://sourceforge.net/tracker/index.php?func=detail&aid=661324&group_id=9579&atid=109579 > > ) > > This appears to work fine. But the loop, as written, could exit without > calling destroy() on anything; perhaps some other people knowing better > how Tkinter and Tk work could improve it or confirm it's fine as it is. Thank you. I'll try that tomorrow. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: SV: SV: Regarding coding style
>>> If you can't/don't look at the source file, >>> then comments aren't going to help (except >>> in the case of something like docstrings in >>> Python). >> >> I strongly disagree. Now, perhaps we're >> talking about different things, here? >> Usually, in the header file (C++), there >> won't be any source code, except for >> method declarations. A common example: >> >> /** Projects an object from 3D to 2D using >> the method of Alexander The Great. >> \param 3D structure to be projected >> \returns 2D projection >> */ >> public Proj2D get2Dfrom3D(Proj3D param); >> >> The above is, to me, very clear and >> consistent. Not to mention, easily >> handled with e.g. Doxygen to create a >> readable documentation. >> >> I don't see how this is dislikeable. Please >> explain. Perhaps the above IS what you >> ment by "docstrings"? For Java, one has the >> JavaDocs, a great tool, provided one will >> comment each method and variable used. > > The problem is that tools like Doxygen and > JavaDocs generate warnings and errors and > things if everything isn't documented > "completely". So you end up with a lot of > silly boilerplate. > /** > * Get the width of a box > * > * @param box the box > * @returns its width > */ > extern int box_get_width(box box); Oh, yes. This is stupid. I agree with you. If one's supposed to comment, let him comment RIGHT. Otherwise, let it be. Usually, when i comment my code, it's a blessing. If not, i don't comment at all. > You are right that is it often useful to > document what to pass to a method and > what to expect back and that if this is > done well in many cases it isn't > necessary to see the implementation. > But in many other cases it's obvious, and > in other cases it's obvious if you just > look at the source which you've got. I agree. Sometimes, there's a demand from the customer to comment all methods. Then, and then only, i'll go commenting all. But i believe strongly that we think alike on this one. When it's suitable, it should be there. Otherwise - why bother. Right? > The lack of fascism is the big innovation. > It sounds simple but it makes a huge > difference: it's much easier to find (and > keep up to date) the real documentation if > it's not hidden in a forest of bogus > documentation. I couldn't agree with you more on this one! Thank you for an interesting discussion. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Regarding coding style
>> /** Projects an object from 3D to 2D using >> the method of Alexander The Great. >> \param 3D structure to be projected >> \returns 2D projection >> */ >> public Proj2D get2Dfrom3D(Proj3D param); >> >> The above is, to me, very clear and >> consistent. Not to mention, easily >> handled with e.g. Doxygen to create a >> readable documentation. >> >> I don't see how this is dislikeable. Please >> explain. > > When get2Dfrom3D changes its signature but > the comment is not changed. That's where I > have a problem, and it's only a matter of > time before it happens. I think we've arrived at the spot where i'll claim that a _always_ update my comments, and you'll question that i can (in the long run). Let's agree on that! :) -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
Changing the size of a Button
How do i change the size of a Button (using Tkinter), other than to set it during construction? I've found methods for getting the size but not applying them. I've been laborating with .setvar(*) but i've been unsuccessful. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Changing the size of a Button
>> How do i change the size of a Button >> (using Tkinter), other than to set it >> during construction? > In Tkinter, usually the geometry managers > (such as pack) are the ones who size the > widgets. If you run something like: >import Tkinter as tk > >root = tk.Tk() >def change_size(): >b["text"] = "More text" > >b = tk.Button(root, text="Text", command=change_size) >b.pack() > >root.mainloop() Thanks for the answer. Unfortunately, that won't help me at all, since i, apparently, asked the wrong question. Let me refrain myself. What i wish to do is to affect the size of the button but not due to change of text but due to resize of the frame it resides in. This far i've managed to get a callback to a function as the resize occurs and to print the sizes. However, i'd like to assign these values to the button so it always stays the same width as the frame. -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: SV: Changing the size of a Button
>> What i wish to do is to affect the size >> of the button but not due to change of >> text but due to resize of the frame it >> resides in. > > This is done by the layout manager, too: > > import Tkinter as tk > > root = tk.Tk() > button = tk.Button(root, text="42") > button.pack(fill=tk.BOTH, expand=True) > root.mainloop() > > Alternatively, with a grid layout: > > button.grid(row=0, column=0, sticky="nsew") > root.rowconfigure(0, weight=1) > root.columnconfigure(0, weight=1) Ah, great! I'll try that right away. After breakfast, of course! Thanks! -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list
SV: Adjust a canvas as the window is resized
>> Do i need to set a callback to a canvas >> in order to "listen" to the root window >> being resized in order to make it adjust >> its contents? >> >> If so, how? If not, how do i make the >> canvas draw a line from one corner to >> an other? > > import Tkinter as tk > > root = tk.Tk() > canvas = tk.Canvas(root) > canvas.pack(expand=True, fill=tk.BOTH) > line = canvas.create_line(0, 0, 0, 0) > > def resize(event): >canvas.coords(line, 0, 0, event.width, event.height) > canvas.bind("", resize) > > root.mainloop() Super nice! Thanks a million! -- -- Regards Konrad Viltersten sleep- a substitute for coffee for the poor ambition - lack of sense to be lazy -- http://mail.python.org/mailman/listinfo/python-list