Re: How to import other modules from my own code?



Hi Bao,

On 30.06.2013 03:56, Bao Niu wrote:
dia_rotate.py is located in Home/.dia/python . The code doesn't work. If I
try importing from the python console, it simply gives me an ImportError,
simply can't find them. What should I do to import it?

That's strange. Have you checked that your dia_rotate.py is the original one from [1]?

[1] https://git.gnome.org/browse/dia/tree/plug-ins/python/dia_rotate.py

Below is a Python Dia Console log that shows a successful import.
Do other scripts get loaded from your Home/.dia/python ?

Steffen

>>> import dia_rotate
>>> dia_rotate
<module 'dia_rotate' from '/home/user/.dia/python/dia_rotate.pyc'>
>>> help(dia_rotate)
Help on module dia_rotate:

NAME
    dia_rotate

FILE
    /home/user/.dia/python/dia_rotate.py

DESCRIPTION
    # PyDia Rotation
    # Copyright (c) 2003, Hans Breuer <hans breuer org>
    # Copyright (c) 2009, 2011  Steffen Macke <sdteffen sdteffen de
    #
    #  This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

CLASSES
    CRotateDialog

    class CRotateDialog
     |  Methods defined here:
     |
     |  __init__(self, d, data)
     |
     |  on_delete(self, *args)
     |
     |  on_rotate(self, *args)

FUNCTIONS
    SimpleRotate(data, angle)

    rotate_cb(data, flags)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]