python and xulrunner

2006-04-30 Thread joe . hrbek
Hi everyone, sorry, this post is a bit off topic.  I posted this on a
devel xul thread on the mozilla groups but didn't get a response.  My
hope is that some of you may have interest in this and have tried it
yourself.

I've been trying to get xulrunner compiled with python (in windows) but
have been unsuccessful.  I've been following this:
.

I know it's a linux based tutorial, but the steps are generally the
same aside from required os linkers/compilers - which i've obtained
reading the standard mozilla compile instructions for windows.

Has anyone else tried this and had luck with it?

-j

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


Re: python and xulrunner

2006-05-01 Thread joe . hrbek
Well, it's my understanding (I could be wrong), that pyxpcom is to
enable firefox/mozilla to use python.  My interest is more in the area
of xulrunner.  I've read that page several times and pulled
compiler/linker build steps from it, but never followed it exactly. I
suppose I can try pyxpcom instead.  Maybe if i can compile that i could
coax xulrunner into compiling. Unfortunately, most of the windows
pieces are listed as "todo" and "there are no special build
instructions", which is why i've been taking pieces from several
different sources and trying to make it work. :(

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


using os.walk to generate objects

2008-12-03 Thread Joe Hrbek
The code below works (in linux), but I'm wondering if there is a
better/easier/cleaner way?  It works on directory trees that don't
have a lot of "."s in them or other special characters. I haven't
implemented a good handler for that yet, so if you run this in your
system, choose/make a simple directory structure to use as your root
for os.walk().  Also, you must start from the top most directory
level, like /test.  /tmp/test as a root will not work (yet). :)

I wanted to know if I could use os.walk() to construct an object based
off of a directory tree. So, the following path: "/test/home/user"
would get converted into "test.home.user" and I could then work with
it that way in my python program, attaching attributes to those
"directories" that I could use to keep track of things.  This was more
of an exercise in learning than anything, I wanted to see if I could
do it.  I've never used "type()" before to create new objects, so
really that was the point.  Can I do this an easier way though?


import os
from os.path import join, getsize

def remove_hidden(dirlist):
"""For a list containing directory names, remove
   any that start with a dot"""
dirlist[:] = [d for d in dirlist if not d.startswith('.')]

def recurse_dir_tree(context,dirs):
"""recurse through tree structure and add attributes
as necessary"""
for directory in dirs:
fixedDir = directory.replace('.','_').lower()
#print ("directory is:%s" % fixedDir)
newAttrObj = type(("%s" % fixedDir),(),{})
if newAttrObj.__name__:
#print newAttrObj.__name__
#print "context is "+context
print "tree."+context
setattr(eval
("tree."+context),newAttrObj.__name__,newAttrObj)

class Tree(object):
def __init__(self,wd):
self.__name__ = wd


pathroot = '/test'
tree = Tree(pathroot)


for root, dirs, files in os.walk(pathroot):
tree.currentRoot = ".".join(map(str,root.split('/')[1:]))
tree.currentRoot = tree.currentRoot.lower()
print "currentRoot:" + tree.currentRoot
if pathroot == root:
#this is the start of the object tree
tree.baseRoot = pathroot.split('/')[1]
newAttrObj = type(("%s" % tree.currentRoot),(),{})
setattr(tree,newAttrObj.__name__,newAttrObj)
#print dirs
remove_hidden(dirs)
#print dirs
if dirs:
recurse_dir_tree(tree.currentRoot,dirs)
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Python GUI development using XULRunner

2008-09-24 Thread Joe Hrbek
Todd, this is great!  Thanks for your work on this.  I've been using
your extension for awhile, successfully creating little apps.  Your
gui_app template has been a huge help in advancing my understanding of
how things fit together...takes some of the guesswork out. :)  Thanks
again,

-j

On Sep 16, 8:29 pm, Todd Whiteman <[EMAIL PROTECTED]> wrote:
> I've put together a tutorial that shows off how to build a GUI
> application using XULRunner (same architectural components as Firefox
> uses) that can be used in conjunction with the Python programming language.
>
> The tutorial covers how to build a Python/XULRunner GUI 
> application:http://pyxpcomext.mozdev.org/no_wrap/tutorials/pyxulrunner/python_xul...
>
> The details in this tutorial covers the initial setup to full
> packaging/deployment, mostly targeting a Windows/Linux platform (MacOSX
> is possible with a few deviations, I have tried to cover these
> deviations where applicable).
>
> Feedback is welcome.
>
> Cheers,
> Todd

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


javascript to python

2008-10-02 Thread Joe Hrbek
Could someone help me translate to something that would close to it in
python?  The anonymous functions are giving me problems.

var dataListener = {
  data : "",
  onStartRequest: function(request, context){},
  onStopRequest: function(request, context, status){
instream.close();
outstream.close();
listener.finished(this.data);
  },
  onDataAvailable: function(request, context, inputStream, offset,
count){
this.data += instream.read(count);
  },
};

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


strange math?

2006-03-18 Thread joe . hrbek
Hello everyone,  I'm experimenting with python and i'm following this
tutorial:
http://docs.python.org/tut/node6.html#SECTION00640  I'm
in section 4.7.5 Lambda Forms.  In this section I was working along and
I noticed something strange.  It happened because of a typo.  Below is
a copy/paste from my idle session:

>>>def make_incrementor(n):
  return lambda x: x+n

>>>f=make_incrementor(42)
>>>f(0)
42
>>>f(1)
43
>>>f(10)
52
>>>f(0)
42
>>>f(01)
43
>>>f(02)
44
>>>f(010)
50
>>>42+010
50

The first f(01) was a mistake.  I accidentally forgot to delete the
zero, but to my suprise, it yielded the result I expected.  So, I tried
it again, and viola, the right answer.  So, I decided to really try and
throw it for a loop, f(010), and it produced 50.  I expected 52
(42+10).  Why doesn't python ignore the first zero and produce a result
of 52?  It ignored the first zero for f(01) and f(02).  Hmm.  I know, I
know, why am I sending it a 01,02, or a 010 to begin with?  Like I
said, it was an accident, but now i'm curious.  I'm not a computer
science major so please be kind with any explanations.

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


Re: strange math?

2006-03-18 Thread joe . hrbek
Thanks for the great reply, Steve, et al.

-j

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