PyGTK Notebook button_press_event connection
Hi all!
I have an application that uses a gtk.Notebook to show the content of a
GUI. Each page of it has a gtk.Label with a text that explains the
content. Each page is added to the notebook with the method
append_page(child, tab_label=None), passing a gtk.Label instance as
tab_label variable.
Now I'd like to connect to the button_press_event of the gtk.Label a
function call. I've done something like this:
notebook = gtk.Notebook()
...
child = gtk.Frame()
...
label = gtk.Label('Any text')
label.connect('button_press_event', a_function)
...
notebook.append_page(child, label)
But the button_press_event event is not intercepted (nothing happens
when I click on the tab label).
Any idea to solve this question?
Thanks
Luigi
--
http://mail.python.org/mailman/listinfo/python-list
XML-RPC "filter"
Dear all,
I'm writing an XML-RPC server which should be able to modify the
incoming request before dispatching it. In particular I wand to added
two fixed parameters to the method called: one is the client host
address, and the other is the user name provided as for Basic
Authentication (http://[EMAIL PROTECTED]).
To do this, at the present I've overwritten the do_POST method of
SimpleXMLRPCRequestHandler, including at a certain point this code:
data = ''.join(L)
params, method = xmlrpclib.loads(data)
user = "unknown"
if self.headers.has_key('Authorization'):
# handle Basic authentication
(enctype, encstr) = self.headers.get('Authorization').split()
user, password = base64.standard_b64decode(encstr).split(':')
params = list(params)
params.append(self.address_string())
params.append(user)
params = tuple(params)
data = xmlrpclib.dumps(params, methodname=method)
(I slightly modified it to make it more readable at mail level)
It works, but I don't really like it because it completely overwrites
the do_POST method that in the future Python releases is going to
change (I verified it). Do you know a better way to do this?
Thanks in advance.
Luigi
--
http://mail.python.org/mailman/listinfo/python-list
Re: newbie questions
Hi! 1. Documentation... sorry... 2. There are no standars, it depends on the apidoc tool you want to use 3. I don't know, but when you extract the api documentation (using tools as epydoc or happydoc) you have all the information you need (I think) 4. As your python code is a script code, you don't need a main() function (like C): all the lines you write are directly executed. For example a code: --- #!/usr/bin/python a=5 b=a+3 print b --- is directly executed. If you are writing a class: --- #!/usr/bin/python class Test: _init__(self): self.name="My test" t = Test() print t.name This code instances a class Test and prints the name attribute. Note that if you import a file containing the code above as a python module, the last 2 lines are executed. In order to avoid it you must write: --- #!/usr/bin/python class Test: _init__(self): self.name="My test" if __name__ == "__main__": t = Test() print t.name Like this you execute the last two lines only if you execute directly your file with the python interpreter. I hope this can help you. Luigi -- http://mail.python.org/mailman/listinfo/python-list
Capturing stdout without waiting for the process end
Hi to all!
I'd like to execute an external program capturing the stdout/stderr
messages at "real-time". I mean that I don't want to wait for the end
of the process. If I write a code like this:
import os
import sys
class Runner:
def run(self, arg):
try:
fin, fout = os.popen4(arg)
self.outData = fout.readlines()
self.outStatus = fout.close()
except Exception, err:
print err
def printOut(self):
print "###"
print self.outStatus
print "###"
for line in self.outData:
print line
r = Runner()
r.run("ls /tmp")
r.printOut()
I can print out (in this case in the os.stdout, but it may be
elsewhere) the whole external program output only once it ends. How can
I do to intercept the external program output during the processing?
Thank you in advance
Luigi
--
http://mail.python.org/mailman/listinfo/python-list
Re: can I get the index number in for x in y loop?
Try this: >>> a='String' >>> i=0 >>> for x in a: ... print i, x ... i+=1 ... 0 S 1 t 2 r 3 i 4 n 5 g -- http://mail.python.org/mailman/listinfo/python-list
Re: Capturing stdout without waiting for the process end
I use Linux. So, if I modify my sdtout behaviour, when I execute: fin, fout = os.popen4(arg) this is executed asyncronously? And how can I intercept a fout.write() event? The question is that I have a C program (by third part) that streams the logs into the stderr and stdout devices. I need to create an envelopment that captures the outputs and puts them in a file generating log events (for a real-time view). Thanks Luigi -- http://mail.python.org/mailman/listinfo/python-list
Re: Modeling life on Earth –- an object-oriented (Python?) challenge
[...forgot to reply to the list...] Dear David, Thanks for your feedback -- you got right to the point: ...python would be more of a prototyping language, and later translated > into another language for faster maneuvering of data > exactly! I was hoping that, since the modeling framework is conceptually well developed (i.e., books, papers, analysis, etc. in 35+ years), most of the work would be towards getting the code up to the same conceptual (i.e., abstraction) level. Hence, I was thinking Python would be a good tool for that. Performance can be taken care of at a later stage, if needed. Please do not hesitate to drop a further line. Kind regards, Luigi On Tue, Jul 30, 2013 at 1:23 PM, David Hutto wrote: > Never used pascal, and python might not be the fastest way to implement a > program such as this. > > In a previous discussion, this was taken place by someone using a predator > prey brain class.. > > The simulation will vary, until a full refinement of forecast is above a > certainty percentage level. > > Visualization is needed as well. > > Collaboration is, of course > , the best possible route. However you need to start with certain > statistics, and know there will be an Uncerrtainty Principle rule applied. > > The algorithm for such massive amounts of data analysis in a simulation > forecast, will involve HD space and RAM > . > > You will also want to collaborate with certain databases in order to > refine the accuracy of your models. > > This is kind of what I would consider being a Dune(Frank Herbert) > planetary engineer. It also takes in other db data such as tagging marks of > animals percentiles of bacterias/viruses/etcSO it's not as simple as it > sounds, and python would be more of a prototyping language, and later > translated into another language for faster maneuvering of data. > > > > On Tue, Jul 30, 2013 at 4:57 AM, wrote: > >> Dear List, >> >> I have to start this email by saying that I have recently attended >> EuroPython in Florence, and it was the best and better organized conference >> I have ever attended in 14 years of international meetings. >> >> I apologize if this is off topic, but I read in the list's description >> that “[p]retty much anything Python-related is fair game for discussion”. >> >> Although I am not a Python developer, I decided to attend EuroPython in >> search for a programmer interested in collaborating in the Python project I >> briefly describe below. >> >> I use ecosystem models implemented with a procedural paradigm in a >> language different from Python (Pascal, for the records). I would like to >> migrate these ecosystem models (and code) to an object-oriented paradigm >> using Python, as I have come to believe its expressiveness would help a lot >> get the semantics right, rather than simply split procedural code into >> objects corresponding to ecological elements. What's more, our models use >> physiological analogies among the different levels of the food chain or >> web, and this makes them amenable to an even higher level of >> object-oriented abstraction given adequate expressiveness. >> >> The goal is to go beyond the currently (mostly) formal implementation of >> the object-oriented paradigm in ecological models. To do that, I would need >> help from an expert Python programmer (who also has some math skills, knows >> English, and can work in the Rome area, or at least central Italy). I need >> help because I am a Python beginner with limited programming experience in >> general, and hence my contribution will mainly be the ecosystem modeling >> insight. >> >> At EuroPython, I gave a lightning talk about the project that can be >> found on YouTube >> http://youtu.be/iUNbgNuN0qY?t=31m50s >> >> As I already made some very promising contacts at EuroPyton with >> developers that are interested and willing to help, and many people shared >> their views and provided useful insight into the issue (thanks!), this post >> is meant to get further feedback on my idea and possibly reach other >> interested developers. >> >> Kindly contact me if you have any interest in the idea and time to devote >> it, as it is becoming a funded project. >> >> Kind regards, thanks for any hint, and apologies for the many >> inaccuracies, >> >> Luigi >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Best Regards, > David Hutto > *CEO:* *http://www.hitwebdevelopment.com* > -- http://mail.python.org/mailman/listinfo/python-list
Custom handler for logging
Dear all, concerning the logging module, I have written a new Handler which stores the logging messages in an SQLite database. It works well, but when I try to use it exploiting a configuration file I have a problem since the "class" entry does not accept a class which is not within the logging name-space, while the class I implemented is coded in my personal module (thus another name-space). Is there a workaround to allow the usage of custom handlers? Thanks in advance. Luigi -- http://mail.python.org/mailman/listinfo/python-list
Re: Custom handler for logging
Thanks, it works perfectly! Luigi Peter Otten ha scritto: Luigi Paioro wrote: concerning the logging module, I have written a new Handler which stores the logging messages in an SQLite database. It works well, but when I try to use it exploiting a configuration file I have a problem since the "class" entry does not accept a class which is not within the logging name-space, while the class I implemented is coded in my personal module (thus another name-space). Is there a workaround to allow the usage of custom handlers? Maybe http://mail.python.org/pipermail/python-list/2003-October/232762.html Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: XML-RPC "filter"
On 9 Set, 17:55, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > I would go for a slightly different approach: make your server have a > dispatch-method that delegates the calls to the underlying actual > implementation. But *before* that happens, extract the information as > above, and either > > - prepend it to the argument list > > - stuff it into threadlocal variables, and only access these if needed in > your implementation. > > Diez Are you suggesting me to overwrite the _dispatch(self, method, params) method of SimpleXMLRPCDispatcher? I thought to this possibility, but it only accepts "method" and "params" as arguments, so, as far as I know, I have no way to get the user and host address to append. Perhaps I've misunderstood your suggestion... in that case can you post a short example? Thank you very much! Luigi -- http://mail.python.org/mailman/listinfo/python-list
Re: XML-RPC "filter"
On 11 Set, 18:45, Richard Levasseur <[EMAIL PROTECTED]> wrote: > Because he wants to insert parameters at the very start, he can > probably get away with modifying the xml directly. Just find the > position of the (i think thats the tag) and insert the xml > you need after it. Its pretty dirty, but would work. The wire format > isn't that complicated. I think this is exactly what I do... isn't it? -- http://mail.python.org/mailman/listinfo/python-list
