Re: wxPython Conventions

2006-02-01 Thread Johan Lindberg

Iain King skrev:

 How do you gain access to the system tray?

Use wx.TaskBarIcon.
See http://wiki.wxpython.org/index.cgi/FlashingTaskbarIcon for
snippets.

/Johan

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: finding sublist

2005-08-03 Thread Johan Lindberg
 thanks everyone. only a question. there is a way to advantage of binary
 sequences?

I doubt you'll find any way to optimize the code that somehow only
applies to binary sequences. You still have to find each possible
subsequence of minimum length within the sequence and compare it to all
other possible subsequences and that's what's going to take most of the
time.

If you haven't already, check out psyco
(http://psyco.sourceforge.net/). It will most definitely make your code
run faster.

BR
Johan Lindberg
[EMAIL PROTECTED]

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: finding sublist

2005-08-02 Thread Johan Lindberg
Hello.

 my target is implement a function controlla(string - a binary string-)
 that check if there is in a string two equal not overlapping
 subsequences at least of length limitem:

 my code:
 [snip]


I may have misunderstood it, but does your function work the way you
want it to?

controlla(testeststest)
no

I can't get it to print anything other than no. But then again, I'm
reading and posting via Google and I guess all those break statements
shouldn't be on the same indent-level.

 the question is: Is there a faster way doing that? I don't know,
 changing string into list or array, using map, or module, using
 different loop, regular expression,funcional programming , list
 comprehensions , sets, different looping techniques, i dont
 know...(!)

Since you're using nested for loops when searching the string you
should make sure not to perform more iterations than neccessary. The
function below returns a list of all, non-overlapping, substrings in
text where len(substring)= minLength. The outer loop is limited to
about half of the length of the text which is where most of the speed
comes from but I'm sure it can be tweaked for more.

def foo(text, minLength):
  result= []
  for length in range(minLength, len(text)/ 2+ 1):
for start in range(len(text)):
  end= start+ length
  if end len(text):
part= text[start:end]
if text.find(part, end)!= -1:
  if part not in result:
result.append(part)

  return result

foo(testeststest, 4)
['test', 'stes', 'stest']

foo(testeststest, 3)
['tes', 'est', 'ste', 'test', 'stes', 'stest']

HTH
Johan Lindberg
[EMAIL PROTECTED]

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Office COM automatisation - calling python from VBA

2005-06-25 Thread Johan Lindberg
Hi.

  If you are new to Python and want to use it with COM, definitely get
  yourself a copy of _Python Programming on Win32_ by Mark Hammond and
  Andy Robinson.

 ...or at least read the chapter available online:
 http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html

Also, check out the following tutorials:
http://www.reportlab.com/ftp/talks/PythonWindowsTutorial.doc
http://starship.python.net/crew/pirx/spam7/COMtut.PPT

...and if you're visiting EuroPython make sure to show up for Guy
Dalbertos tutorial on Python+ Excel. If you're not, download his
presentation and example code from:
http://www.python-in-business.org/ep2005/talk.chtml?talk=2626track=690

HTH
Johan Lindberg
[EMAIL PROTECTED]

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTML editor component?

2005-04-06 Thread Johan Lindberg
You could try the (very) simple HTML editor I use for my CM project. It
can only handle B, I, U and A, but then again, it was never meant to do
more. It's written in wxPython, based on Scintilla and can probably be
extended to fit your needs.

You can find it here:
http://sourceforge.net/project/showfiles.php?group_id=72786package_id=138707

BR
/Johan Lindberg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle and py2exe

2004-12-01 Thread Johan Lindberg
 Im trying to compile a script with py2exe. The pickle module is causing the
 program to give an error.
 
 Traceback (most recent call last):
   File SETIstat.pyw, line 330, in ?
   File SETIstat.pyw, line 84, in start_up
   File SETIstat.pyw, line 79, in config_load
   File pickle.pyc, line 1390, in load
   File pickle.pyc, line 872, in load
   File pickle.pyc, line 985, in load_string
 LookupError: unknown encoding: string-escape
 
 the data in the pickled file is a dictionary containing a couple strings. The
 strings do contain \n and \t charaters but no other special characters or
 anything. 
 
 Does anyone have any suggestions to what I can try to get around this? The
 pickle module works fine when the .pyw file is run. Its only when I compile
 this is there an issue. 
 
 Thanks for any help,
 
 Justin

Have you included string-escape encoding in your setup.py?
My guess is that you can fix the problem with something similar to:

 from distutils.core import setup
 import py2exe
 opts = { py2exe: { packages: [encodings], } }
 setup(windows= [spam.py], options= opts)

in your setup.py.

Hope it helps
/Johan Lindberg
-- 
http://mail.python.org/mailman/listinfo/python-list