SetBackgroundColor doesn't work for me
Hi, I'm on Linux Ubuntu Breezy with wxPython 2.6.1 and Python 2.4.1 installed. I've made an app, but the BackgroundColors won't work on any of my ListBoxes, they only work with Windows XP. Does someone had this problem before ? Any suggestion ? thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyQt v4.1 Released
Thanks Phil, Can you put some hints about how to build QScintilla2 on Windows please ? -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyQt v4.1 Released
Hi Phil, I followed the docs to build qscintilla2, all is going well with no errors, but when I launched the PyQt Syntax Highlighter Example, nothing is highlighted but the first line of text, whereas the C++ sample works well in the demo. Any hints ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyQt v4.1 Released
David Boddie a écrit : > Do you mean the example from the PyQt4 distribution? Yes, that was it. > That uses a port of an old syntax highlighting example from Qt 4.0. Someone > needs to > "port" the C++ example from Qt 4.2 to PyQt4. So, we've got no sample to use QScintilla2 ?? Thanks, 6TooL9 -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyQt v4.1 Released
Thanks David, your sample works nicely ! -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyQt v4.1 Released
Sorry, I just tried with other lexers, but I'm having some errors (names not defined errors) with those ones : 1.lexer = QsciLexerRuby() 2.lexer = QsciLexerTeX() Are they implemented ? -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: PyQt v4.1 Released
Shame on me, I forgot to import the lexers. -- http://mail.python.org/mailman/listinfo/python-list
ini files and plugins
Hi, I've made a basic LaTeX file editor in wxPython, but now I wanted to add it some features : 1 - create a sort of ini file where I can put the user configuration that will load itself on the application startup ; 2 - a simple plugin system with python files ( maybe to add new langages, etc.) ; I'm looking for simple articles, modules or code snippets on these subjects; thanks, 6TooL9 -- http://mail.python.org/mailman/listinfo/python-list
Re: ini files and plugins
Fredrik Lundh a écrit : > "tool69" wrote: > >> 1 - create a sort of ini file where I can put the user configuration >> that will load itself on the application startup ; > > http://docs.python.org/lib/module-ConfigParser.html ? > >> 2 - a simple plugin system with python files ( maybe to add new >> langages, etc.) ; > > http://effbot.org/zone/import-string.htm ? > > > > > Thanks Fredrik, I'll take a look. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Zopyrus] A python IDE for teaching that supports cyrillic i/o
Sorry, but did someone knows if Pida works under Windows ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: The Python Papers Edition One
I've recently tried the docutils's reST module with Pygments ( to highlight Python sources), so you can have LaTeX + HTML + PDF output (You can see what it renders here : h**p://kib2.free.fr/geoPyX/geoPyX.html ). It worked fine, but needs a little work to suit your needs (you'll have to write your own CSS, and maybe your LaTeX preambule ). For OpenOffice, a friend wrote a little Python script that colourize a Python source inside a document. I think It will be possible to write your own for HTML output, but the ooo API docs aren't well documented for Python. Chears, 6Tool9 -- http://mail.python.org/mailman/listinfo/python-list
Finding the carret position in a regular expression
Hi, supposed I've got the following text : mytext = "for in :" with the following simple pattern : pattern = "<[a-z]+>" I use re.findall(pattern, mytext) wich returns : ['',''] Now, I want my prog to return the positions of the returned list elements, ie : was found at position 5 in mytext was found at position 16 in mytext How can I implement this ? Sorry if it's trivial, that's the first time I use regular expressions. Thanks, 6Tool9 -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the carret position in a regular expression
Thanks Fredrik, I was not aware of finditer. Iterators are very usefull ! -- http://mail.python.org/mailman/listinfo/python-list
Re: Pydev configuration
Sébastien Boisgérault a écrit : > Hi, > > Did anyone managed to change the code font family/size > in Pydev (Python Editor Plugin for Eclipse) ? I found how > to change the color mapping (Windows/Preference/Pydev) > but did not found the font setting. > > Cheers, > > SB > Salut Sébastien, Preferences/General/Appearence/Colors&Fonts/ in the right menu choose Basic/Text Font 6TooL9 -- http://mail.python.org/mailman/listinfo/python-list
Re: oo problem
Dennis Lee Bieber a écrit : > On 10 Dec 2006 03:47:21 -0800, "Tool69" <[EMAIL PROTECTED]> > declaimed the following in gmane.comp.python.general: > > > Thanks for your answers, > > I though about the first solution too, but I've redundant code, say ie: > > p = Paper(100,200) > > p.draw( Rectangle(p,10,20,50,60) ) <-- we're forced to write 'p' two > > times. > > > > I'd suggest not passing an instance initialization to your "Paper" > draw() method... > > p = Paper(100, 200) > p.add(Rectangle(10, 20, 50, 60)) > p.add(OtherPrimitives()) > p.draw() > > where p.draw() (Paper.draw(self) really) does something like: > > self.whatever_is_needed_for_Paper_itself > for prm = self.primitives: #list of stuff from p.add(...) calls > prm.draw(self) #pass current paper to the > primitive > #which draws > itself on the paper > #and can do > whatever calculations > #(CLIPPING > perhaps) needed Thanks for all your comments and suggestions. Denis, I would like to know how I can made a draw method for a primitive without a Paper instance inside ...that's always the same problem as only my Paper instance knows the Paper sizes ! -- http://mail.python.org/mailman/listinfo/python-list
Re: oo problem
Dennis Lee Bieber a écrit : > > Perhaps you missed that the loop (in Paper) that invokes each > primitive's draw() is passing itself (the Paper instance)... > Oops, sorry I missed it in fact. But I still have a problem with my the primitives (some pathes I had to build ): i.e a mathematical ray is infinite, so I must draw a segment on screen and need the paper sizes to calculate the segments starts and ends ( I've got a lot of objects like this ). I don't know how to build them without passing a paper instance. The actual implementation of some primitives uses : def __init__(self, paper_instance, etc. ): do something But I as mentioned before, I'm not satisfied with it since I shall write this do draw a Line :* paper.draw( Line( paper, x1, y1, x2, y2) This is what I don't find aesthetic : the repetition of "paper" calls. -- http://mail.python.org/mailman/listinfo/python-list
Re: oo problem
Hi, First, let me thanks you for all your clear comments. > > This is, in my mind, both a usage and a design flaw. > > You are creating (and throwing away) instances of drawable > objects to the draw method of a paper instance. But what does > paper.draw() actually do with the drawable object? Call a draw method > within it? No, actually the paper instance is a subclass of a canvas from an external module. And this one have a stroke() method. In reading your comments, I think it's now clear that I must get back and let any primitive have an inner draw() method ( a subclass of Drawable object in our case). > If so, that is when you should pass the paper instance (or > just the part needed -- clipping rectangle perhaps?). In fact, my approach was a bad one : in initialising the paper instance, I was already clipping it. If I wrote : p = Paper(-5,-5,5,5), all drawings made on that paper will be clipped inside a rectangle with lower-left corner (-5,-5) and upper-right corner (5,5). Now, I think it's better to clip after all primitives have been added to the paper. > > The actual implementation of draw() for each primitive will have > to handle clipping to the boundaries of the Canvas object that is passed > to it. > > You'll notice that the only place the primitive needs to know > about the canvas is in its specific draw method. And only at that time > is the canvas (paper) passed to it. > > Instead of the concept; > > Paper, draw a line from x to y > > (and having to pass the "paper" to the initializer of the line > primitive), you have to think in terms of: > > Line, draw yourself on this paper > > Or, if you consider the last example above… Compare that to your > example: > > -=-=-=-=- > paper.draw( Line( paper, x1, y1, x2, y2) ) > -=-=-=-=-=- > > Here, you are telling the paper to do the drawing, and passing > it a Line instance (and passing it the paper it is supposed to be drawn > on). Why? The paper isn't drawing the line on itself… While > > -=-=-=-=- > Line(Point(x1, y1), Point(x2, y2)).draw(paper) > -=-=-=-=- > > initializes a Line instance, then asks it to draw itself using paper as > the surface to be drawn upon. Yes I was wrong, that's all clear now. Thanks again, this was very helpfull. 6TooL9 -- http://mail.python.org/mailman/listinfo/python-list
need clarification with import statements
Hi, I've got the following hierarchy: mainprog/ __init__.py prog.py utils/ __init__.py myutils.py others/ __init__.py myothers.py Inside prog.py I need to have full access to myutils.py and myothers.py; Inside myutils.py, I need to access two classes from myothers.py (ie myotherClass1 and myotherClass2); Inside myothers.py, I need some functions of myutils.py (ie myutils_func1 and myutils_func2); Do you have some hints please ? I'm trying to avoid name conflicts, so I haven't used "from ... import *". I suspect ther's something wrong, but I think I really don't understand what's going on internally (no errors (for the moment !)) Inside prog.py : from utils.myutils import myotherClass1, myotherClass2 + some functions of myutils I need Inside myutils.py : from other.myothers import myotherClass1, myotherClass2 Inside others.py : import utils.myutils Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: need clarification with import statements
Hi John, > 1. Your directory/package hierarchy is far too complicated. Flatten it. Ok. > 2. You have circular references: the others module will import from > utils, but utils wants to import from others. This is prima facie > evidence that your modules are not structured properly Yes, that's why I asked the question in fact, circular references are a bit hazardous. >. Rule 1: Modules should contain /related/ classes and functions. > Rule 2: A graph of what imports what should not have loops. > > Consider combining others and utils -- does that make sense? Yes, I can combine them as they need eachother. > Another alternative: split out those "some functions of myutils.py (ie > myutils_func1 and myutils_func2)" into a fourth module. This module > might be the nucleus of a tool-kit of miscellaneous functions that you > might import in /any/ app -- in that case, move it outside the current > package. Good idea indeed, Thanks for all, 6TooL9 -- http://mail.python.org/mailman/listinfo/python-list
Re: running a Delphi part from Python ?
Stef Mientki a écrit : > AFAIK, Scintilla is a code editor. > What I need looks more like ms-word, > handling lists, tables, images, formulas. > > thanks, > Stef Mientki So you'll need the RichTextCtrl http://www.wxpython.org/docs/api/wx.richtext.RichTextCtrl-class.html See a sample in the demo under "Recent Additions". -- http://mail.python.org/mailman/listinfo/python-list
Re: preferred windows text editor?
Notepad++ with NppExec plugin and you can launch your scripts inside Np++. some others, very Powerfull : http://e-texteditor.com/ http://intype.info/home/index.php -- http://mail.python.org/mailman/listinfo/python-list
Re: NLTK: Natural language processing in Python
NLTK seems very interesting, and the tutorial are very well done. Thanks for it ! Kib² -- http://mail.python.org/mailman/listinfo/python-list
Re: New UI Toolkit
Gerdus van Zyl a écrit : Seems very promising. But I'm afraid with the Swing-like interface, i.e : did you use the same widget positionning ? -- http://mail.python.org/mailman/listinfo/python-list
encoding problems
Hi, I would like to transform reST contents to HTML, but got problems with accented chars. Here's a rather simplified version using SVN Docutils 0.5: %- #!/usr/bin/env python # -*- coding: utf-8 -*- from docutils.core import publish_parts class Post(object): def __init__(self, title='', content=''): self.title = title self.content = content def _get_html_content(self): return publish_parts(self.content, writer_name="html")["html_body"] html_content = property(_get_html_content) # Instanciate 2 Post objects p1 = Post() p1.title = "First post without accented chars" p1.content = """This is the first. ...blabla ... end of post...""" p2 = Post() p2.title = "Second post with accented chars" p2.content = """Ce poste possède des accents : é à ê è""" for post in [p1,p2]: print post.title, "\n" +"-"*30 print post.html_content %- The output gives me : First post without accented chars -- This is the first. ...blabla ... end of post... Second post with accented chars -- Traceback (most recent call last): File "C:\Documents and Settings\kib\Bureau\Projets\python\dbTest\rest_error.py", line 30, in print post.html_content UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 39: ordinal not in range(128) Any idea of what I've missed ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding problems
Lawrence D'Oliveiro a écrit : > In message <[EMAIL PROTECTED]>, tool69 wrote: > >> p2.content = """Ce poste possède des accents : é à ê è""" > > My guess is this is being encoded as a Latin-1 string, but when you try to > output it it goes through the ASCII encoder, which doesn't understand the > accents. Try this: > > p2.content = u"""Ce poste possède des accents : é à ê è""".encode("utf8") > Thanks for your answer Lawrence, but I always got the error. Any other idea ? -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding problems
Diez B. Roggisch a écrit : > tool69 wrote: > >> Hi, >> >> I would like to transform reST contents to HTML, but got problems >> with accented chars. >> >> Here's a rather simplified version using SVN Docutils 0.5: >> >> %- >> >> #!/usr/bin/env python >> # -*- coding: utf-8 -*- > > > This declaration only affects unicode-literals. > >> from docutils.core import publish_parts >> >> class Post(object): >> def __init__(self, title='', content=''): >> self.title = title >> self.content = content >> >> def _get_html_content(self): >> return publish_parts(self.content, >> writer_name="html")["html_body"] >> html_content = property(_get_html_content) > > Did you know that you can do this like this: > > @property > def html_content(self): > ... > > ? > I only took some part of code from someone else (an old TurboGears tutorial if I remember). But you're right : decorators are better. >> # Instanciate 2 Post objects >> p1 = Post() >> p1.title = "First post without accented chars" >> p1.content = """This is the first. >> ...blabla >> ... end of post...""" >> >> p2 = Post() >> p2.title = "Second post with accented chars" >> p2.content = """Ce poste possède des accents : é à ê è""" > > > This needs to be a unicode-literal: > > p2.content = u"""Ce poste possède des accents : é à ê è""" > > Note the u in front. > > > You need to encode a unicode-string into the encoding you want it. > Otherwise, the default (ascii) is taken. > > So > > print post.html_content.encodec("utf-8") > > should work. > That solved it : thank you so much. > Diez -- http://mail.python.org/mailman/listinfo/python-list
Parsing nested constructs
Hi, I need to parse some source with nested parenthesis, like this : >cut- { {item1} { {item2} {item3} } } >cut- In fact I'd like to get all start indexes of items and their end (or lenght). I know regexps are rather limited for this type of problems. I don't need an external module. What would you suggest me ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing nested constructs
David a écrit : > On 9/8/07, tool69 <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I need to parse some source with nested parenthesis, like this : >> > > If this is exactly how your data looks, then how about a loop which > searches for "{item" and the following "}"? You can use the "find" > string method for that. > > Otherwise, if the items don't look exactly like "{item", but the > formatting is otherwise exactly the same as above, then look for lines > that have both "{" and "}" on them, then get the string between them. > > Otherwise, if { and } and the item aren't always on the same line, > then go through the string character by character, keep track of when > you encounter "{" and "}". When you encounter a "}" and there was a > "{" before (ie, not a "}"), then get the string between the "{" and > the "}" Hi David, thanks for answering, I will choose the last one as my strings are not on the same line and may contain a lot of stuff inside. cheers, 6TooL9 -- http://mail.python.org/mailman/listinfo/python-list
cyclic iterators ?
Hi, Let say I've got a simple list like my_list = [ 'a', ',b', 'c' ]. We can have an iterator from it by k = iter( my_list), then we can access each of her (his ?) element by k.next(), etc. Now, I just wanted k to have the following cyclic behaviour (without rising the ) : >> k.next() 'a' >> k.next() 'b' >> k.next() 'c' >> k.next() -> not raising StopIteration error 'a' >> k.next() 'b' etc. I've tried something like this to have a cyclic iterator without sucess: def iterate_mylist(my_list): k = len((my_list) i=0 while i <= k : yield my_list[i] i += 1 i = 0 yield my_list[0] I missed something, but I don't know what exactly. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Test
On 3 mar, 01:44, Nicholas Parsons <[EMAIL PROTECTED]> wrote: > Greetings, > > This is just a test to see if I can post to this mailing list. Can > someone from the list please respond to this email so I know it worked? > > Thanks in advance! > --Nick Hi Nicholas, Does it work for you ? -- http://mail.python.org/mailman/listinfo/python-list
Re: cyclic iterators ?
Paul Rubin a écrit : > > As Bruno says, you can use itertools.cycle, but the problem above is > that you're not looping repeatedly through the list; you yield all the > elements, then yield the first element again, then stop. So for > ['a','b','c'] you'd yield the sequence a,b,c,a. Yes, that was the problem. Thanks for the explanation and for the cycle() function from itertool that I missed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Magazine: Issue 1 Free!
Thanks for it, what tools did you use to build the mag : Scribus ? -- http://mail.python.org/mailman/listinfo/python-list
Vim scripting with python
Hi, I saw several old posts speaking of vim scripting in Python. This one in particular : http://www.velocityreviews.com/forums/t351303-re-pythonising-the-vim-eg-syntax-popups-gt-vimpst.html But I didn't find where to put this "vimrc.py" on my Windows machine. My "normal" _vimrc file is in C:\Documents and Settings\my_name . Does anyone have any advice, and more genraly how to script Vim with Python ? I know I can put some python functions inside my vimrc file like this : function! My_function() python << EOF import vim, string ...blablabla EOF endfunction but I would like to use external ".py" files. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Vim scripting with python
Thanks Stuart, I'll take a look at it. Another thing : Is there any way to made some modification de the python.syntax file to highlight the functions call, i.e : os.popen(...) ---> "popen(...)" will be highlighted. Cheers. -- http://mail.python.org/mailman/listinfo/python-list
question with inspect module
Hi, I would like to retrieve all the classes, methods and functions of a module. I've used the inspect module for this, but inside a given class (subclass of some other one), I wanted to retrieve only the methods I've written, not the inherited one. How can I do ? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: question with inspect module
Thanks Miki, that's exactly what I need :) -- http://mail.python.org/mailman/listinfo/python-list
need some help in serving static files inside a wsgi apps
Hi, Until now, I was running my own static site with Python, but I'm in need of dynamism. After reading some cgi tutorials, I saw Joe Gregorio's old article "Why so many Python web frameworks?" about wsgi apps [http:// bitworking.org/news/Why_so_many_Python_web_frameworks] and have a question about it. The code he gave works like a charm (I had to make a little change because SQLAlchemy has changed since), but how the hell can I serve static files (css, js, images, etc.) within an wsgi app, ie inside a '/static' directory ?! Sorry if my question is a stupid one, but I cannot find an easy way to do this. Each tutorial I'm reading out there does not talk about them at all. All of my python books didn't mention wsgi either. I know I could use web.py, web2py, Cherrypy, Django, Pylons, etc. but I'm trying to understand basics of web dev. from their roots. thanks in advance for any advice , Kib. -- http://mail.python.org/mailman/listinfo/python-list