Re: [PyQt] sip fails with "[CLASSNAME] has not been defined"

2012-05-01 Thread tuxor1337
You are right, that's indeed a rather obvious option. Thanks again for 
your patience :)



You use SIP to describe the bindings you want to create - this is not
necessarily the same as the API of the underlying library. In other words
you don't teach SIP to cut off the "ui" from the namespace, just don't tell
it about it in the first place. The issue then is to make sure that the
generated code compiles - probably by including appropriate "using"
statements in the right places. Take a look at the use of the
%UnitPostIncludeCode directive in the PyQtMobility bindings.

Phil


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Segmentation fault. What could be the cause?

2012-05-01 Thread tuxor1337

Thanks, that worked :) Now everything is running fine.


You definitely need to remove all the /TransferThis/ except for the
one on the parent argument.

Phil


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Segmentation fault. What could be the cause?

2012-05-01 Thread tuxor1337

Hi all,

in one of my SIP files I have this line (a class constructor):

MessageDialog(QMessageBox::Icon icon /TransferThis/,
   const QString & title /TransferThis/,
   const QString & text /TransferThis/,
   QMessageBox::StandardButtons buttons /TransferThis/ = 
QMessageBox::NoButton,

   QWidget * parent /TransferThis/ = 0);

When refering to this constructor later in my Python code, the following 
lines will cause a segmentation fault


app = QApplication(argv)
about = ui.MessageDialog(QMessageBox.Icon(QMessageBox.Information), 
app.tr(argv[1]), app.tr(argv[2]), QMessageBox.No | QMessageBox.Yes)


Can this be caused by the TransferThis annotation? Or by the "&" C++ 
reference to the QString? Or do you see something else, that's wrong 
with this?



##
If you want to have a closer look at the project, see here:

https://github.com/tuxor1337/PyOnyx

The problematic line is in ui/message_dialog.sip.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] sip fails with "[CLASSNAME] has not been defined"

2012-05-01 Thread tuxor1337
I think, I can answer my own question. But only with respect to the 
_reason_ for this behaviour. I have to admit, that I don't like this 
behaviour:


The problem is the "namespace ui". Because OnyxDialog is defined in that 
namespace, it has to be referred to as ui::OnyxDialog in 
"message_dialog.sip", even though it's being referred to in the very 
same namespace.


What I don't like about that revelation: It seems like there is no way 
to teach SIP to cut off the "ui" from the namespace. In Python, I will 
always have to refer to the classes via PyOnyx.ui.ui.MessageDialog. Of 
course, that alone is not the problem. But the problem is, that I can do 
things like "from PyOnyx.ui import ui", but not something like "from 
PyOnyx.ui.ui import *". And later, when I have a namespace called "sys", 
this is even going to conflict with the Python module of the same name.


I would love to have a module called "PyOnyx.ui" and the classes 
"MessageDialog" and "OnyxDialog" as direct parts of that module. Is 
there any possibility to achieve this with SIP 4.12.2?


Am 01.05.2012 00:32, schrieb tuxor1...@web.de:

Hi all,

maybe somebody can help me with this. I'm using SIP 4.12.2.

My configure.py script is executing the following sip command line:

/opt/python/bin/sip -c . -b ui/ui.sbf -I /opt/python/share/sip/PyQt4 -x
PyQt_Accessibility -x PyQt_Cursor -x PyQt_ImageFormat_JPEG -x
PyQt_Picture -x PyQt_PrintDialog -x PyQt_Printer -x PyQt_ProgressDialog
-x PyQt_QWS_Cursor -x PyQt_SessionManager -x PyQt_Sound -x VendorID -t
WS_QWS -x PyQt_Accessibility -x PyQt_SessionManager -x PyQt_PrintDialog
-x PyQt_Printer -x PyQt_PrintPreviewDialog -x PyQt_PrintPreviewWidget -x
PyQt_NoPrintRangeBug -x PyQt_qreal_double -t Qt_4_7_2 -x Py_v3 -g
ui/uimod.sip

... which looks okay to me.

But it fails with this error message:

sip: OnyxDialog has not been defined

The sip-file "ui/uimod.sip" looks like this:


%Module PyOnyx.ui

%Include onyx_dialog.sip
%Include message_dialog.sip


The error is obviously related to the file "message_dialog.sip", because
when I leave out that file, everything is fine.

## message_dialog.sip 
%Import QtGui/QtGuimod.sip

namespace ui
{

class MessageDialog : OnyxDialog
{

%TypeHeaderCode
#include "onyx/ui/message_dialog.h"
%End

public:
MessageDialog(QMessageBox::Icon icon,
const QString & title,
const QString & text,
QMessageBox::StandardButtons buttons = QMessageBox::NoButton,
QWidget * parent = 0);
~MessageDialog();

public:
int exec();
void updateInformation(const QString & text);
};

};
## End: message_dialog.sip 


## onyx_dialog.sip 
%Import QtGui/QtGuimod.sip

namespace ui
{

class OnyxDialog : QDialog
{

%TypeHeaderCode
#include "onyx/ui/onyx_dialog.h"
%End

public:
OnyxDialog(QWidget *parent, bool show_shadow = true);
~OnyxDialog();
};

};
## End: onyx_dialog.sip 
___
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] sip fails with "[CLASSNAME] has not been defined"

2012-04-30 Thread tuxor1337

Hi all,

maybe somebody can help me with this. I'm using SIP 4.12.2.

My configure.py script is executing the following sip command line:

/opt/python/bin/sip -c . -b ui/ui.sbf -I /opt/python/share/sip/PyQt4 -x 
PyQt_Accessibility -x PyQt_Cursor -x PyQt_ImageFormat_JPEG -x 
PyQt_Picture -x PyQt_PrintDialog -x PyQt_Printer -x PyQt_ProgressDialog 
-x PyQt_QWS_Cursor -x PyQt_SessionManager -x PyQt_Sound -x VendorID -t 
WS_QWS -x PyQt_Accessibility -x PyQt_SessionManager -x PyQt_PrintDialog 
-x PyQt_Printer -x PyQt_PrintPreviewDialog -x PyQt_PrintPreviewWidget -x 
PyQt_NoPrintRangeBug -x PyQt_qreal_double -t Qt_4_7_2 -x Py_v3 -g 
ui/uimod.sip


... which looks okay to me.

But it fails with this error message:

sip: OnyxDialog has not been defined

The sip-file "ui/uimod.sip" looks like this:


%Module PyOnyx.ui

%Include onyx_dialog.sip
%Include message_dialog.sip


The error is obviously related to the file "message_dialog.sip", because 
when I leave out that file, everything is fine.


## message_dialog.sip 
%Import QtGui/QtGuimod.sip

namespace ui
{

class MessageDialog : OnyxDialog
{

%TypeHeaderCode
#include "onyx/ui/message_dialog.h"
%End

public:
MessageDialog(QMessageBox::Icon icon,
  const QString & title,
  const QString & text,
  QMessageBox::StandardButtons buttons = 
QMessageBox::NoButton,

  QWidget * parent = 0);
~MessageDialog();

public:
int exec();
void updateInformation(const QString & text);
};

};
## End: message_dialog.sip 


## onyx_dialog.sip 
%Import QtGui/QtGuimod.sip

namespace ui
{

class OnyxDialog : QDialog
{

%TypeHeaderCode
#include "onyx/ui/onyx_dialog.h"
%End

public:
OnyxDialog(QWidget *parent, bool show_shadow = true);
~OnyxDialog();
};

};
## End: onyx_dialog.sip 
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] SIP fails with "syntax error" on simple class inheritance

2012-04-30 Thread tuxor1337

Thanks for your quick response!


What version of SIP are you using? Assuming it's older than v4.13.1 then
you need to remove the "public" (as it says in the documentation for your
version).


Yes, you are right. I'm using 4.12.2, so next time I'm going to refer to 
the documentation provided with my source tarball. There it's mentioned 
in the chapter "Using SIP".


But to be honest, I'm still a bit puzzled by the usage of SIP. For 
example, where do I learn what to do with such an excerpt from a header 
file:


enum WaitMode {
  WAIT_NONE   = 0,
  WAIT_BEFORE_UPDATE  = 0x01,
  WAIT_COMMAND_FINISH = 0x02,
  WAIT_NORMAL = WAIT_BEFORE_UPDATE,
  WAIT_ALL= WAIT_BEFORE_UPDATE | WAIT_COMMAND_FINISH
};

SIP will complain about the "WAIT_ALL" line ("syntax error"). Is this 
due to the "|" operator or what's the problem here? And where in the 
documentation would I find an appropriate answer to this?

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] SIP fails with "syntax error" on simple class inheritance

2012-04-30 Thread tuxor1337
Why does the attached sip-file always fail to be "sipped" with the 
following error message:


sip: my_dialog.sip:15: syntax error

(line 15 is "class MyDialog : public QDialog {")

I tried to use a configure.py or directly call sip command line, but it 
always fails with the same error message.


What am I doing wrong? Is there a tutorial out there that's a bit easier 
to understand than the official documentation 
(http://www.riverbankcomputing.co.uk/static/Docs/sip4/using.html)? The 
documentation is rather useless when using SIP for bigger or more 
complex libraries.


## Code of my_dialog.sip ###

%Module myDialog

%Import QtGui/QtGuimod.sip

%If (Qt_4_2_0 -)

namespace ui {

%TypeHeaderCode
#include "my/ui/buttons.h"
#include "my/ui/label.h"
#include "my/ui/soft_shadow.h"
%End

class MyDialog : public QDialog {

public:
MyDialog(QWidget *parent, bool show_shadow = true);
~MyDialog(void);

void updateTitle(const QString &message);

public Q_SLOTS:
virtual void done(int);
};

%End

};
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt