Using python to extend a python app
I'm writing a python app that works as a replacement for the menu that comes with most minimalist wms when you right click the root window. It's prettier and written completely in python. I'd like to provide hooks or some system so that people can write their own extensions to the app, for example adding fluxbox options, and then fluxbox users can choose to use that extension. But I'm not sure how to implement it. Right now the best idea I have is to have all desired extensions in a folder, import each .py file in that folder as a module using __import__, and then call some predetermined method, say "start", and pass it the menu as it exists so far so they can add to it, start(menu). This seems kind of hackish. I looked at how gdesklets handles this, but its solution looks way more complex than I'd prefer to have to dive into for this tiny app. What's the most pythonic way to do this? How do apps that extend themselves with python usually do this? -- http://mail.python.org/mailman/listinfo/python-list
PyGTK Popup menu?
I want to make a pygtk app that consists completely of a window. When I run it, a menu should appear where the mouse cursor is. I've been looking at the official pygtk tutorial and documentation, but everything seems to assume that I'm either creating a window to put the menu in (I just want it to be the menu floating by itself) or that I want a button press to trigger the menu appearing (it should just pop into existence when I run it). I've tried just creating some menu items, appending them to a menu and then calling menu.popup(None,None,None,0,0) but nothing happens :/ -- http://mail.python.org/mailman/listinfo/python-list
Python, Matlab and AI question
I'm a student who's considering doing a project for a Machine Learning class on pathing (bots learning to run through a maze). The language primarily used by the class has been Matlab. I would prefer to do the bulk of the project in python because I'm familiar with pygame (for the visuals) but I already have a lot of AI code written in Matlab. I'd like to be able to call Matlab code from within python. I'm not sure this is possible. My code runs in Octave just fine. I've heard about numerical python and scipy, but I'm not sure what tool is going to mean the least amount of recoding for me. At the very least I need to find a really fast package for matrix operations. Anyone have any input on what the best tool for the job would be? I've googled, but I figure it's best to ask experience ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: deriving from str
Paolo Veronelli wrote: I want to add some methods to str class ,but when I change the __init__ methods I break into problems class Uri(str): def __init__(self,*inputs): print inputs if len(inputs)>1: str.__init__(self,'<%s:%s>'%inputs[:2]) else: str.__init__(self,inputs[0]) print inputs a=Uri('ciao','gracco') Traceback (most recent call last): File "prova.py", line 9, in ? a=Uri('ciao','gracco') TypeError: str() takes at most 1 argument (2 given) where is the str() wrong call.I suppose It's the __new__ method which is wrong or me .Thanks for help I think the problem is that you're not callinig the init method for str by hand, so it's caling it automatically and passing to it the same paramters you gave Uri's init. str just expects self to be passed, not also *inputs, so you get that error. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE
fuzzylollipop wrote: TruStudio for Eclipse is nice for those everything must be free socialists. ActiveState Komodo is probably the best commerical Python IDE and the ActiveState Python plugin for Visual Studio is great for those that do VS. It's also great for those college students looking to save money. It feels nice to not fit into somebody's ill constructed stereotype =) -- http://mail.python.org/mailman/listinfo/python-list
Cool object trick
I read some discussion on this list before about how sometimes it's useful to create a generic object class that you can just stick attributes to. I was reading the PyPanel source (not written by me) and I came across this: # class Obj(object): # """ Multi-purpose class """ # def __init__(self, **kwargs): # self.__dict__.update(kwargs) Normally I'd just use class Obj(object): pass, but the advantage to this method is you can create an Obj like this: Obj(id="desktop", last=0, color=self.getColor(DESKTOP_COLOR)) You can pass all the attributes you want the object to have this way. Nifty :) Sorry if this has been posted before, but I haven't seen it. -- http://mail.python.org/mailman/listinfo/python-list