Re: [Gimp-developer] debugging and print messages in PyGimp for windows
So, the --verbose option definitely pops up a dos-looking window and prints lots of GIMP related messages, but it doesn't seem to get error messages from Python. I just accidentally tested this with a syntax error in a module of mine that my PyGIMP plugins import. In linux I get this very helpful message: r...@am2|07:02 AM|09_02_09$ gimp Traceback (most recent call last): File /home/ryan/.gimp-2.6/plug-ins/pygimp_lecture_utils.py, line 1, in module import os, rwkos, rwkmisc, re, time File /home/ryan/git/krauss_misc/rwkos.py, line 9 if not amiLinux() ^ SyntaxError: invalid syntax (gimp:17913): LibGimpBase-WARNING **: gimp: gimp_wire_read(): error and I can fix that in 30 seconds or so (it is a stupid syntax error on my part, missing the trailing colon). But in windows, I see no message related to it at all. The only indicator of a problem is that none of my PyGIMP plugins show up in the menus at all (none of them can register themselves because they all import this module). No idea how long it would take me to find the exact line that caused the problem if I didn't try it in Linux. Is there an easy solution to this? How do I get standard error messages from Python to display in Windows XP? Thanks, Ryan 2009/9/1 Jernej Simončič jer...@ena.si On Tuesday, September 1, 2009, 18:16:48, Ryan Krauss wrote: So, I have PyGIMP correctly installed in windows (I think). I am trying to port my plug-ins from Linux. One big annoyance is that print doesn't seem to work and error messages that probably go to standard out go no where. I really need those messages to debug. I tried launching gimp from the command line. Is there some other way? Where to standard out and standard error messages go on windows? Nowhere, by default. Run gimp-2.6.exe --verbose to get a console, which should also receive output from plugins. -- Jernej Simončič http://eternallybored.org/ In the fight between you and the world, back the world. -- Kafka's Law ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
Re: [Gimp-developer] PyGimp on Windows XP
So, I found this http://www.gimpusers.com/tutorials/install-python-for-gimp-2-6-windows.html and think I am going to get things working. It turns out that even though the GIMP installer will let me intall Python as long as PyGTK is installed, it also needs PyCairo and PyGObject to actually work. And the confirmation that it is working is a Python-Fu menu item with an option to launch a console under Filters. On Mon, Aug 31, 2009 at 7:05 PM, Ryan Krauss ryanli...@gmail.com wrote: I am trying to get PyGimp installed and working on Windows XP. It seems like this should be easier than it used to be. A quick google lead to several long install procedures. I have been using PyGimp in Ubuntu and am quite happy with it, but I know need to use it in windows. Preparation: My computer has Python 2.5 and PyGTK. Install: I ran the installer I downloaded from here: http://downloads.sourceforge.net/gimp-win/gimp-2.6.7-i686-setup.exe with PyGTK installed, if gives me the option to install the Python extension (I did this). I don't get any error messages, but it doesn't seem like PyGIMP is really working. Unlike in Ubuntu, I don't have any Python menu items under Filters, I don't see any place to launch a Python console, and it doesn't recognize any of the scripts I have in $HOME\\.gimp-2.6\\plug-ins Are there other installation steps I am missing? How would I know if PyGIMP was really working under windows? Thanks, Ryan ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
[Gimp-developer] debugging and print messages in PyGimp for windows
So, I have PyGIMP correctly installed in windows (I think). I am trying to port my plug-ins from Linux. One big annoyance is that print doesn't seem to work and error messages that probably go to standard out go no where. I really need those messages to debug. I tried launching gimp from the command line. Is there some other way? Where to standard out and standard error messages go on windows? Right now, when one of my plugins hits a python bug, it just stops and tells me nothing. I tried executing the plugin from the console and I just get execution error without even a line number to guide me. Thanks, Ryan ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
[Gimp-developer] PyGimp on Windows XP
I am trying to get PyGimp installed and working on Windows XP. It seems like this should be easier than it used to be. A quick google lead to several long install procedures. I have been using PyGimp in Ubuntu and am quite happy with it, but I know need to use it in windows. Preparation: My computer has Python 2.5 and PyGTK. Install: I ran the installer I downloaded from here: http://downloads.sourceforge.net/gimp-win/gimp-2.6.7-i686-setup.exe with PyGTK installed, if gives me the option to install the Python extension (I did this). I don't get any error messages, but it doesn't seem like PyGIMP is really working. Unlike in Ubuntu, I don't have any Python menu items under Filters, I don't see any place to launch a Python console, and it doesn't recognize any of the scripts I have in $HOME\\.gimp-2.6\\plug-ins Are there other installation steps I am missing? How would I know if PyGIMP was really working under windows? Thanks, Ryan ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
[Gimp-developer] PyGimp: letting the use pick coordinates
I am using the GIMP and a Wacom tablet as a digital blackboard for a course I am teaching this summer. With Python and PyGimp, it is going really well (other than my bad hand writing made worse by the tablet - it is weird writing on the tablet and having to look to the screen to see what you have written). Example lecture notes can be seen here: http://home.cs.siue.edu/rkrauss/452/lectures/07_02_09/index.html We are coming into a mathematically intensive part of the course and I feel like my handwritting has become a barrier. I am creating my own text tool that use Latex and dvipng. The hard part is already done: I have a wxPython application with a text control and a png preview portion and it is basically working. I am now working on better GIMP integration. Right now I type in the equations in my wxPython application and preview the png there. When I want to paste the png into my lecture slide, I have to switch back to GIMP and press a key that is a short cut for a PyGimp script to load the cached png. Then I position it on the slide with the move tool. Not bad, but not as nice as Gimp's text tool. I would like my Latex enabled approach to act like the regular text tool. The main thing I don't know how to do is allow the user (me) to click on a spot on the current image and pass those coordinates to PyGimp so that I can use that as the top left corner of my png. Does my question make sense? Is there an easy way to allow the user to click on a spot on the image and get the coordinates from PyGimp? Thanks, Ryan ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
[Gimp-developer] Creating a layer from a selection or pasting to a specified x, y coorinate
OK, so following Alexia's suggestion, I am going to plan on selecting ahead of time the rectangle I want my text to paste into. The upper left corner of this selection will then be the upper left corner that I want to paste my png to. How do I do that? I thought about creating a layer the same size as the selection rectangle and pasting to (0,0) on that layer. I see in the pdb how to create a layer with a certain width and height, but I don't see how to specify the offset. And I don't see how to paste to a specific set of coordinates. Can this be done? If I use pdb.gimp_edit_paste_as_new, can I get the coordinates of the pasted selection and then move the floating selection before anchoring? What is the right approach? Thanks, Ryan On Mon, Jul 6, 2009 at 9:37 AM, Alexia Death alexiade...@gmail.com wrote: On Mon, Jul 6, 2009 at 5:25 PM, Ryan Krauss ryanli...@gmail.com wrote: I would like my Latex enabled approach to act like the regular text tool. The main thing I don't know how to do is allow the user (me) to click on a spot on the current image and pass those coordinates to PyGimp so that I can use that as the top left corner of my png. Does my question make sense? Is there an easy way to allow the user to click on a spot on the image and get the coordinates from PyGimp? In various scripts when I have needed to indicate a location on a canvas Ive used selections. Id say using an upper left corner of a selection you draw first is as good as its going to get... -- --Alexia ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Creating a layer from a selection or pasting to a specified x, y coorinate
OK, I think I have solved my problem. You have to know what to search for in the pdb. I think this will do what I need: pdb.gimp_layer_set_offsets There is nothing in the pdb browser for moving a layer, you have to offset it. On Mon, Jul 6, 2009 at 10:15 AM, Ryan Krauss ryanli...@gmail.com wrote: OK, so following Alexia's suggestion, I am going to plan on selecting ahead of time the rectangle I want my text to paste into. The upper left corner of this selection will then be the upper left corner that I want to paste my png to. How do I do that? I thought about creating a layer the same size as the selection rectangle and pasting to (0,0) on that layer. I see in the pdb how to create a layer with a certain width and height, but I don't see how to specify the offset. And I don't see how to paste to a specific set of coordinates. Can this be done? If I use pdb.gimp_edit_paste_as_new, can I get the coordinates of the pasted selection and then move the floating selection before anchoring? What is the right approach? Thanks, Ryan On Mon, Jul 6, 2009 at 9:37 AM, Alexia Death alexiade...@gmail.comwrote: On Mon, Jul 6, 2009 at 5:25 PM, Ryan Krauss ryanli...@gmail.com wrote: I would like my Latex enabled approach to act like the regular text tool. The main thing I don't know how to do is allow the user (me) to click on a spot on the current image and pass those coordinates to PyGimp so that I can use that as the top left corner of my png. Does my question make sense? Is there an easy way to allow the user to click on a spot on the image and get the coordinates from PyGimp? In various scripts when I have needed to indicate a location on a canvas Ive used selections. Id say using an upper left corner of a selection you draw first is as good as its going to get... -- --Alexia ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
Re: [Gimp-developer] API for bringing up a Save dialog
pyGTK: http://www.pygtk.org/ On Sat, May 30, 2009 at 6:56 AM, Esteban Barahona bodig...@gmail.comwrote: speaking of python... are there any wrappers of python (or perl) in gtk? .../5/29 Ryan Krauss ryanli...@gmail.com No, I have no good reason :) I am not really familiar with any Python GUI toolkit other than wxPython. When I realized that wouldn't work, I googled for Tk because I thought that was the one that ships with Python. ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
Re: [Gimp-developer] API for bringing up a Save dialog
This is mildly hackish, but my approach is to pop up a Tk save as dialog: filetypes = [('png files', '*.png'), ('jpg files', '*.jpg'),\ ('all files', '.*')] def save_as(initialdir=None, initialfile=None): filename = tkFileDialog.asksaveasfilename(initialdir=initialdir, \ initialfile=initialfile, \ filetypes=filetypes) return filename It would prettier to do a wxPython gtk one, but that requires a parent frame AFAIK. FWIW, Ryan On Fri, May 29, 2009 at 12:18 PM, Akkana Peck akk...@shallowsky.com wrote: Martin Nordholts writes: IMO we should not reuse gimp_file_save() for this but instead introduce gimp_show_save_dialog() and gimp_show_export_dialog(). I am a bit worried however that plug-ins will abuse this power. In your case, why do you need to show these dialogs? Isn't it better if the user has to go through a single place to save or export? I need to show the dialogs because the plug-in needs to save a file (that's the whole point of the plug-in) and it seems like bad UI to pop up the JPEG save dialog without ever showing the user where the file is being saved, or offering them a chance to save it somewhere else. (Have you ever been frustrated when Firefox downloaded a file and you can't figure out where it ended up?) Seems like it's always better UI to go through this step, so the user knows what is being saved and where. Of course, this being python, I could put up my own save-as dialog and let the user choose the filename that way, then call gimp_file_save() on the result; but I'd rather go through GIMP's standard framework, with the File Type menu and other nice features. ...Akkana ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
Re: [Gimp-developer] API for bringing up a Save dialog
But how would you progromatically suggest a good filename before popping up the dialog? That is what my code does. On Fri, May 29, 2009 at 3:37 PM, Sven Neumann s...@gimp.org wrote: On Fri, 2009-05-29 at 10:18 -0700, Akkana Peck wrote: Martin Nordholts writes: IMO we should not reuse gimp_file_save() for this but instead introduce gimp_show_save_dialog() and gimp_show_export_dialog(). I am a bit worried however that plug-ins will abuse this power. In your case, why do you need to show these dialogs? Isn't it better if the user has to go through a single place to save or export? I need to show the dialogs because the plug-in needs to save a file (that's the whole point of the plug-in) and it seems like bad UI to pop up the JPEG save dialog without ever showing the user where the file is being saved, or offering them a chance to save it somewhere else. (Have you ever been frustrated when Firefox downloaded a file and you can't figure out where it ended up?) Seems like it's always better UI to go through this step, so the user knows what is being saved and where. Then please add a sane user interface to your plug-in and pop up a file-chooser. The PDB was designed to allow plug-ins and scripts to call procedures in GIMP, not to pop up specific user interface elements. It is totally not suited for this kind of usage. Sven ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
Re: [Gimp-developer] API for bringing up a Save dialog
No, I have no good reason :) I am not really familiar with any Python GUI toolkit other than wxPython. When I realized that wouldn't work, I googled for Tk because I thought that was the one that ships with Python. On Fri, May 29, 2009 at 4:57 PM, Sven Neumann s...@gimp.org wrote: Hi, On Fri, 2009-05-29 at 12:34 -0500, Ryan Krauss wrote: This is mildly hackish, but my approach is to pop up a Tk save as dialog: filetypes = [('png files', '*.png'), ('jpg files', '*.jpg'),\ ('all files', '.*')] def save_as(initialdir=None, initialfile=None): filename = tkFileDialog.asksaveasfilename(initialdir=initialdir, \ initialfile=initialfile, \ filetypes=filetypes) return filename It would prettier to do a wxPython gtk one, but that requires a parent frame AFAIK. Any particular reason you are not using a GtkFileChooserDialog? That is the dialog that the GIMP user expects and knows to use. GTK+ is the only toolkit that you can definitely rely on being installed and available. GTK+ is part of the GIMP plug-in API. Sen ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
Re: [Gimp-developer] Drawing a line in a GIMP plugin
The procedure browser is your best bet (should be under the help menu). gimp-pencil and gimp-paintbrush look the ones. On Fri, May 29, 2009 at 6:41 PM, Adam C Powell IV hazel...@debian.orgwrote: On Sat, 2009-05-30 at 00:00 +0200, Sven Neumann wrote: Hi, On Fri, 2009-05-29 at 17:51 -0400, Adam C Powell IV wrote: I'm a relative newbie trying to have a GIMP plugin draw a line (among other things). I found gdk_draw_line which seems to be what I want. It is not what you want. GDK is a drawing toolkit used by GTK+ for drawing user interfaces. It is not meant and not suited for drawing to GIMP drawables. You probably want to use the procedures gimp-paint or gimp-pencil that allow you to draw strokes using the paintbrush or pencil tools. I see. I was hoping to avoid the complexity of choosing brushes and whatnot, and just draw a simple line with squared-off end... But okay. A search for gimp plugin draw line doesn't turn up anything looking helpful. Can you point me to an object or method to get started? Thanks, -Adam -- GPG fingerprint: D54D 1AEE B11C CE9B A02B C5DD 526F 01E8 564E E4B6 Engineering consulting with open source tools http://www.opennovation.com/ ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
[Gimp-developer] PyGIMP question: saving PNG and XCF versions of the same image
I have a Python Gimp question. I don't know if it belongs on the user or developer list, but my feeling is that the people with the knowledge are more likely to read this list. Let me know if this is the wrong list to post to. I have written a script to create PNG and XCF versions of an image I want to save. I have a certain layer whose visibility I want to turn off before I save the PNG but I also want the XCF to give me more editting power if I want to alter the image later. I have this working fairly well, but the problem is that when my script finishes, I am looking at the flattened PNG version of the image. At that point, I would need to close the PNG and re-open the XCF if I want to edit the file. This is less than ideal. I think it could be solved by simply doing one undo step after saving the PNG (since flattening was the last thing I did), but I don't see in the procedural database a way to undo from a script. Is there a way to save a flattened PNG and then save an unflattened XCF of the same image and leave the XCF open? Here is my code: from gimpfu import * def my_save(img, drawable): ind = find_graph_ind(img) if ind: img.layers[ind].visible = False filename = save_as(initialdir=folder, initialfile=new_name)#--- get filename from Tk dialog print('filename = ' + filename) if filename: pne, ext = os.path.splitext(filename) xcf_path = pne+'.xcf' pdb.gimp_xcf_save(1, img, drawable, xcf_path, xcf_path) flat_layer = pdb.gimp_image_flatten(img) pdb.gimp_file_save(img, flat_layer, filename, filename)#--- filename ends in .png #pdb.file_png_save(img, flat_layer, filename, filename, \ # 0, 0, 0, 0, 0, \ # 1, 1) #pdb.gimp_image_clean_all(img) #gimp.displays_flush() Thanks, Ryan ___ Gimp-developer mailing list Gimp-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer