Re: python gui using boa
ash wrote: > Thanks Steve, i found out the solution to the problem. but a good > tutorial on sizers is still missing. Try this article I wrote a while back. It should at least help you get started. The code samples are written in C++, but they are trivially translated to python. (Change -> to ., change this to self, get rid of "new" and *) http://neume.sourceforge.net/sizerdemo/ -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: python gui using boa
ash wrote: > I have another query for you - how can i make a captionless frame > draggable in wxWindows? If you look at the wxPython demo, there's a Shaped Window demo under Miscellaneous that does this. The key portion is on line 86 in my version: #v+ def OnMouseMove(self, evt): if evt.Dragging() and evt.LeftIsDown(): x, y = self.ClientToScreen(evt.GetPosition()) fp = (x - self.delta[0], y - self.delta[1]) self.Move(fp) #v- -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Wheel-reinvention with Python
[EMAIL PROTECTED] wrote: > Torsten Bronger wrote: >> I've been having a closer look at wxPython which is not Pythonic at >> all and bad documented. Probably I'll use it nevertheless. > Aye. Couldn't agree more. You know, whenever someone mentions wxPython being badly documented, I have to wonder whether they know about the nearly 2000 page PDF of wxWidgets documentation, which is available in html at http://www.wxwidgets.org/manuals/2.6.1/wx_contents.html wxPython has the same API as wxWidgets, except where indicated in that manual. If in doubt, you can also consult http://wxpython.org/docs/api/ And of course, the gaps are filled in by the wxPython wiki: http://wiki.wxpython.org/ I apologize if you already know about these things, but I find myself continually surprised that "wxPython is badly documented" has become conventional wisdom when I have never found that to be the case. -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie]search string in tuples
Viper Jack wrote: > but i want check on several object inside the tuple so i'm trying this: > > list=["airplane","car","boat"] Note that this is actually a list, not a tuple as your subject suggests. For the difference, take a look at this: http://www.python.org/doc/faq/general.html#why-are-there-separate-tuple-and-list-data-types Also, it's generally considered bad form to shadow built-in type names like list. This prevents you from using methods in the list scope and makes for potentially confusing bugs. > while select != list[0] or list[1] or list[2]: This actually behaves as though you wrote this: while (select != list[0]) or list[1] or list[2]: The since list[1] always evaluates to a true value (non-empty strings are true), the while loop body will always execute. Fortunately, python has a very simple way of doing what you want: vehicles = ("airplane", "car", "boat") select = vars while select not in vehicles: select=raw_input("Wich vehicle?") -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Sizers VS window size
Deltones wrote: > However, if I add this part from the tutorial, I get a much smaller > window. Why is there an interference with the result I want when > adding the sizer code? [snip] > self.sizer.Fit(self) As noted in the the docs for Fit(): "Tell the sizer to resize the window to match the sizer's minimal size." Take this call out and the size should be as you expect. -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Fractions on musical notation
Gabriel Genellina wrote: > On 16 dic, 06:40, Lie <[EMAIL PROTECTED]> wrote: > >> [btw, off topic, in music, isn't 1/4 and 2/8 different? I'm not very >> keen of music though, so correct me if I'm wrong.] > As a time signature 1/4 has no sense Actually, I'm playing a show right now that has a one beat vamp. It's a single repeated measure in 1/4 time. To addres the real point, though, I don't think of a time signature as a rational number, although it correctly reflects what portion of a whole note can be found within a measure. I consider it to have two separate pieces of information: the length of the beat and the number of those beats per bar. When I've written code to represent music I have used rationals to represent when something occurs, but a different structure to represent time signatures. -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: shorten this: if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz":
cirfu wrote: > if char in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz": > > cant i write something like: > if char in "[A-Za-z]": Either of the following should do what you want, without resorting to regular expressions: import string if char in string.letters: or if char.isalpha(): -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython beginners problem
Ivan Reborin wrote: > win.Show This line isn't doing anything. It needs to be: win.Show() # note the parentheses -- Brian -- http://mail.python.org/mailman/listinfo/python-list
OpenGL on Intel Mac
I am attempting to build PyOpenGL on my Intel iMac. The transcript of the build failure is here: http://brianhv.org/temp/pyopengl-build.log I'm using the universal MacPython 2.4.3 and PyOpenGL-2.0.1.09. The highlight of the build log is: /System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:225: error: field 'st_atimespec' has incomplete type /System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:226: error: field 'st_mtimespec' has incomplete type /System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:227: error: field 'st_ctimespec' has incomplete type Anyone have tips on how to fix this? -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Solutions for hand injury from computer use
Emile van Sebille wrote: > When I started having trouble about ten years ago, I switched to a > keyboard with integrated mouse pad. No problems since... Where did you find that? I've been looking for one. (Assuming you mean a trackpad, and not a mouse pad.) That said, my own solution was the Kensington Expert Mouse. For some reason, the trackball hurts me much less than a real mouse, and keeps me from being disproportionately annoyed when I have to pick up my pointing device to move the cursor where I want it. ;) -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Accumulate function in python
dhruvbird wrote: > Hello, > I have a list of integers: x = [ 0, 1, 2, 1, 1, 0, 0, 2, 3 ] > And would like to compute the cumulative sum of all the integers > from index zero into another array. So for the array above, I should > get: [ 0, 1, 3, 4, 5, 5, 5, 7, 10 ] > What is the best way (or pythonic way) to get this. Now that Steven's given you the simple, pythonic way, I'll just mention the advanced, complicated and obscure way that might be vaguely familiar if you're coming from a functional programming background: x = [ 0, 1, 2, 1, 1, 0, 0, 2, 3 ] def running_sum(result, current_value): return result + [result[-1]+current_value if result else current_value] reduce(running_sum, x, []) Having offered this, I don't recall ever seeing reduce used in real python code, and explicit iteration is almost always preferred. -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?
Steven D'Aprano wrote: > On Sat, 31 Jul 2010 14:25:39 +1200, Gregory Ewing wrote: > >> Steven D'Aprano wrote: >> >>> A >>> / \ >>> C B >>> \ / >>> D >>> / \ >>> E F >>> >>> Yes, a super call might jog left from C to B, but only when being >>> called from one of the lower classes D-F. That's still an upwards call >>> relative to the originator, not sidewards. >> >> But it's not an upward call relative to the class mentioned in the >> super() call, which is why I say it's misleading. > > Which class would that be? > > I think I'm going to need an example that demonstrates what you mean, > because I can't make heads or tails of it. Are you suggesting that a call > to super(C, self).method() from within C might call B.method(self)? Yes, it would. class A(object): def test_mro(self): print "In A" class B(A): def test_mro(self): print "In B" super(B, self).test_mro() raise Exception() class C(A): def test_mro(self): print "In C" super(C, self).test_mro() class D(C, B): def test_mro(self): print "In D" super(D, self).test_mro() D().test_mro() Notice the exception being raised in B. This results in the following traceback: Traceback (most recent call last): File "mro.py", line 21, in D().test_mro() File "mro.py", line 19, in test_mro super(D, self).test_mro() File "mro.py", line 14, in test_mro super(C, self).test_mro() File "mro.py", line 9, in test_mro raise Exception() Exception Since the idea of super() as I understand it is to make sure every class in an object's hierarchy gets its method called, there's really no way to implement super() in a way that didn't involve a non-superclass being called by some class's super() call. -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: looping through possible combinations of McNuggets packs of 6,9 and 20
Baba wrote: > def can_buy(n_nuggets): [snip] > can_buy(55) > > as you can see i am trying to loop through all combinations of values > bewtween 1 and n_nuggets and when the equation resolves it should > return True, else it should return False. > > I was hoping that when i then call my function and ask it to test a > value nothing happens. What is wrong? My syntax? My semantic? Both? You're calling the function, but you're not doing anything with the result. If you use "print can_buy(55)" you'll see the result on the console. Presumably you'll actually want to use it in an if statement. -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic Form
victorsubervi wrote: > On Wed, Sep 23, 2009 at 9:13 PM, BJ Swope wrote: >> Is your web browser re-submitting the form with the same data if you >> refresh the screen? > yes I'm surprised no one has mentioned this before, but the standard approach to this problem is to redirect after a successful POST. That way refreshing the browser won't try to re-POST the form. http://en.wikipedia.org/wiki/Post/Redirect/Get -- Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)
Tim Harig wrote: > Posting two URLs rather defeats the purpose of using a URL shortening > service in the first place; but, if that is what you feel is effective, > then by all means, do so. You are the master of your posts and you have > the right to post them using whatever methods and formating that you > feel is most effect; but, other people should have the same priviledge. The thing I haven't seen anyone make explicit in this conversation is that URL shorteners remove all the information from a URL. When someone posts a URL, I very frequently find one of the following is true: * I've already read the article or doc page being linked to * I haven't read it, but I recognize the domain name and can guess what it says based on what I know about the author. * I haven't read it, but the title (which is often a slug in the URL) tells me that it's not relevant to my problem. In any of those cases, I don't even have to click the link, much less copy and paste and add "preview" to the URL to see if it's something I care to read. Given this, I concur that URL shortening makes sense as an addition to a full URL if you're concerned about line-breaking, but feels like a needless obstacle when presented alone. And as a datapoint on the topic of archiving, I search usenet archives regularly when faced with a problem. -- Brian -- http://mail.python.org/mailman/listinfo/python-list