Re: [Gimp-developer] Calling a function from a custom module

2010-04-19 Thread Roman Joost
On Mon, Apr 19, 2010 at 12:52:41AM -0400, 
saulgo...@flashingtwelve.brickfilms.com wrote:
 Quoting Jason S. for...@gimpusers.com:
  def fout:
  f = open(C:\testFile.dat)
  f.write(Hello World!)
  f.close()
 
 Doesn't the backslash need to be escaped in Python string constants?
I guess that could be it. I just wonder why it throws an execution
error and not an IOError...

Cheers,
-- 
Roman Joost
www: http://www.romanofski.de
email: romanof...@gimp.org


signature.asc
Description: Digital signature
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] Calling a function from a custom module

2010-04-19 Thread Jason S.
Yeah, it was the backslashes.

I needed to use \\ :$

Python reminds me of BASIC I guess lol. Gotta get out of that mindset :P

Thanks every1 who replied.

-- 
Jason S. (via www.gimpusers.com)
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] Calling a function from a custom module

2010-04-18 Thread Jason S.
Hey all. I'm more or less a beginner when it comes to GIMP scripting (though I
do have a few years of exp in general development) and I've run into a bump
with PyGimp that I was hoping someone might be able to give me a hand with.

As general practice, I've written a function that I put inside a file called
ofstream.py (placed in the same folder as gimpfu.py), which consists of:

def fout:
f = open(C:\testFile.dat)
f.write(Hello World!)
f.close()

I then have another script (placed in my plugins folder, to be picked up by
Gimp) which contains:

import math
from gimpfu import *
from ofstream import *

def testFile:
fout()

#register code follows...

But I keep getting an 'execution error' linked to the fout statement. If I
comment out that line and replace it with something else, it works fine. The
'import ofstream' line gives me no trouble; its the function call thats the
problem.

Why am I having this issue? I can use functions located in gimpfu.py just
fine (register, main, etc). Why can't I use my own function?

Thanks in advance everyone.

Cheers.

-- 
Jason S. (via www.gimpusers.com)
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Calling a function from a custom module

2010-04-18 Thread Roman Joost
On Sun, Apr 18, 2010 at 11:12:05AM +0200, Jason S. wrote:
 As general practice, I've written a function that I put inside a file called
 ofstream.py (placed in the same folder as gimpfu.py), which consists of:
 [...] example code
 But I keep getting an 'execution error' linked to the fout statement.
Could you paste the error as well?

 If I comment out that line and replace it with something else, it
 works fine. The 'import ofstream' line gives me no trouble; its the
 function call thats the problem.
IMHO it's better do use absolute imports like:

import ofstream

ofstream.fout()

But that will not fix your problem.

 Why am I having this issue? I can use functions located in gimpfu.py
 just fine (register, main, etc). Why can't I use my own function?
It would be much more helpful if you could paste the whole traceback...

If you can import your module, it should also be possible to access your
function. What will happen if you you explicitly import your function:

from ofstrem import fout

Cheers
-- 
Roman Joost
www: http://www.romanofski.de
email: romanof...@gimp.org


signature.asc
Description: Digital signature
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Gimp-developer] Calling a function from a custom module

2010-04-18 Thread Jason S.
Thanks for the reply.

I tried importing the 'fout' function explicitly; it worked. 

from ofstream import fout

worked just fine. No problems. I still have an issue using the 'fout'
function though. I know its not a problem with the code within the function;
I've tried copying the fout function code and placing it within my module
directly- that works fine. 

The only error info I get is:

Traceback (most recent call last):
File input, line 1, in module
RuntimeError: execution error

which really isnt much to work with- this is what makes PyGimp debugging so
frustrating. When you're working with .NET, Flash or even C/C++, your compiler
/ interpreter at least gives you some insight into your problem with its error
messages. PyGimp won't even give me a line number .

Anyways, any help is much appreciated. Thanks heaps every1.

Cheers,
  Jay.

-- 
Jason S. (via www.gimpusers.com)
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Calling a function from a custom module

2010-04-18 Thread Roman Joost
On Sun, Apr 18, 2010 at 02:22:44PM +0200, Jason S. wrote:
 I tried importing the 'fout' function explicitly; it worked. 
 
 from ofstream import fout
 
 worked just fine. No problems. 
Maybe you're overwriting a function or method which is declared elsewere
with the same name and that's why you get your mysterious results?

 The only error info I get is:
 
 Traceback (most recent call last):
 File input, line 1, in module
 RuntimeError: execution error
Hm.. You're right - not really helpful. Where is 'input' coming from?
Hm... maybe it is passed as a text or string and executed ...

 which really isnt much to work with- this is what makes PyGimp debugging so
 frustrating. When you're working with .NET, Flash or even C/C++, your compiler
 / interpreter at least gives you some insight into your problem with its error
 messages. PyGimp won't even give me a line number .
Does this code work if you put it into a Python module and don't execute
it from within GIMP afterall? There is also a Python console available
in GIMP from where you can start trying to debug your program.


Cheers,
-- 
Roman Joost
www: http://www.romanofski.de
email: romanof...@gimp.org


signature.asc
Description: Digital signature
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] Calling a function from a custom module

2010-04-18 Thread saulgoode
Quoting Jason S. for...@gimpusers.com:

 Hey all. I'm more or less a beginner when it comes to GIMP scripting  
  (though I
 do have a few years of exp in general development) and I've run into a bump
 with PyGimp that I was hoping someone might be able to give me a hand with.

 As general practice, I've written a function that I put inside a file called
 ofstream.py (placed in the same folder as gimpfu.py), which consists of:

 def fout:
 f = open(C:\testFile.dat)
 f.write(Hello World!)
 f.close()

Doesn't the backslash need to be escaped in Python string constants?

___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer