Re: [PyQt] need help with sizing QStackedWidgets

2013-08-26 Thread Eric Frederich
Would appreciate some help here.
I don't like how these stacked widgets take up all of this vertical space
when the window is resized.
I have tried setting a size policy to minimum on the stacked widgets but no
luck.


On Fri, Aug 23, 2013 at 4:02 PM, Eric Frederich eric.freder...@gmail.comwrote:

 Here is a small example.
 I tried putting a vertical spacer on the bottom yet these stacked widgets
 want to take up space when resized.

 #!/usr/bin/env python

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *

 class TestWidget(QWidget):
 def __init__(self, labels, parent=None):
 super(TestWidget, self).__init__(parent)

 layout = QGridLayout()
 for i, output in enumerate(labels):

 layout.addWidget(QLabel(output), i, 0)
 combo = QComboBox()
 combo.addItems([
 Slider,
 Spinner,
 ])
 layout.addWidget(combo, i, 1)

 stack = QStackedWidget()

 horizontalSlider = QSlider()
 horizontalSlider.setOrientation(Qt.Horizontal)

 spinner = QSpinBox()

 spinner.valueChanged.connect(horizontalSlider.setValue)
 horizontalSlider.valueChanged.connect(spinner.setValue)

 stack.addWidget(horizontalSlider)
 stack.addWidget(spinner)

 combo.currentIndexChanged.connect(stack.setCurrentIndex)

 layout.addWidget(stack, i, 2)

 vertical_spacer = QSpacerItem(0, 0, QSizePolicy.Minimum,
 QSizePolicy.Expanding)
 layout.addItem(vertical_spacer, len(labels), 0, 1, 3)

 self.setLayout(layout)

 if __name__ == '__main__':
 import sys
 app = QApplication(sys.argv)
 ocw = TestWidget(['a', 'b', 'c', 'd', 'e'])
 ocw.show()
 sys.exit(app.exec_())


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

Re: [PyQt] need help with sizing QStackedWidgets

2013-08-26 Thread Eric Frederich
Replying to self with a solution in case someone else comes across this
problem.
david_boddie on freenode's #pyqt channel helped me out.

A solution was to call
layout.setRowStretch(len(labels), 1)
... after adding the spacer.

Another solution was to nest the grid layout into a BoxLayout and call
addStretch.


On Mon, Aug 26, 2013 at 9:36 AM, Eric Frederich eric.freder...@gmail.comwrote:

 Would appreciate some help here.
 I don't like how these stacked widgets take up all of this vertical space
 when the window is resized.
 I have tried setting a size policy to minimum on the stacked widgets but
 no luck.


 On Fri, Aug 23, 2013 at 4:02 PM, Eric Frederich 
 eric.freder...@gmail.comwrote:

 Here is a small example.
 I tried putting a vertical spacer on the bottom yet these stacked widgets
 want to take up space when resized.

 #!/usr/bin/env python

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *

 class TestWidget(QWidget):
 def __init__(self, labels, parent=None):
 super(TestWidget, self).__init__(parent)

 layout = QGridLayout()
 for i, output in enumerate(labels):

 layout.addWidget(QLabel(output), i, 0)
 combo = QComboBox()
 combo.addItems([
 Slider,
 Spinner,
 ])
 layout.addWidget(combo, i, 1)

 stack = QStackedWidget()

 horizontalSlider = QSlider()
 horizontalSlider.setOrientation(Qt.Horizontal)

 spinner = QSpinBox()

 spinner.valueChanged.connect(horizontalSlider.setValue)
 horizontalSlider.valueChanged.connect(spinner.setValue)

 stack.addWidget(horizontalSlider)
 stack.addWidget(spinner)

 combo.currentIndexChanged.connect(stack.setCurrentIndex)

 layout.addWidget(stack, i, 2)

 vertical_spacer = QSpacerItem(0, 0, QSizePolicy.Minimum,
 QSizePolicy.Expanding)
 layout.addItem(vertical_spacer, len(labels), 0, 1, 3)

 self.setLayout(layout)

 if __name__ == '__main__':
 import sys
 app = QApplication(sys.argv)
 ocw = TestWidget(['a', 'b', 'c', 'd', 'e'])
 ocw.show()
 sys.exit(app.exec_())



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

[PyQt] PyQt 5.1 App doesn't exit after QQuickView closed

2013-08-26 Thread Glenn Ramsey

Hi,

In the following example, the application doesn't exit after the QQuickView 
window is closed. Is this the correct behaviour or is it a bug? This is using 
snapshot-693a95fde3fa on OSX 10.8.4 with Qt 5.1, PyQt 5.1 and macports python 
built as 32 bit.


Glenn

import sys
import os

from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtQuick

def main():
app = QtWidgets.QApplication(sys.argv)
quickview = QtQuick.QQuickView()
if getattr(sys, 'frozen', None):
basedir = sys._MEIPASS
else:
basedir = os.path.dirname(__file__)
quickview.setSource(QtCore.QUrl.fromLocalFile(os.path.join(basedir, 
'hello.qml')))

quickview.show()

app.exec_()

if __name__ == __main__:
main()


hello.qml:

import QtQuick 2.0

Rectangle {
width: 360
height: 360
Text {
anchors.centerIn: parent
text: Hello World
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}

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


[PyQt] Using SWIG to wrap application written in QT

2013-08-26 Thread Kenneth Miller
So I have this application that I'm writing that uses the Qt libraries. I want 
to wrap the my application and all of it's objects so that I can call it from a 
scripting language quickly, be it python, or ocaml or whatever. Anyway, for the 
last bit I've been trying to get a module compiled that will allow me to 
dynamically call into the classes  functions that I've defined. SWIG seems to 
work right, and recently I even got my own self defined class within a module 
from my C++ source to run, although it segfaulted and I have yet to find out 
exactly why. 



Can this be done? I mean, I was wondering it would be more appropriate that I 
use SIP. One of the problems that I'm facing (I think) is that some arguments 
to my classes and functions are Qt objects. But I can't export those functions 
in my SWIG module without also writing a wrapper to the Qt objects manually (is 
that right?). I'm very new to SWIG, but I definitely need the speed of a 
scripting language for my development, because the compile cycle with Qt and 
C++ is slow. In addition, I'm kind of considering SIP in parallel, so I need 
advice as to which is more appropriate. 

Can anybody advise me what the best route is in order to get what I want? SIP 
or SWIG?___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] PyQt5 Support for Qt v5.1

2013-08-26 Thread Glenn Ramsey

Hi Phil,

On 25/08/13 20:11, Phil Thompson wrote:

For those interested, the current PyQt5 snapshot now fully supports Qt
v5.1 in all existing modules. The new modules (QtSensors and QtSerialPort)
are still to do.


On Windows using VS2010 (32 bit) snapshot-693a95fde3fa fails to build for me.

Compiling...
sipQtGuiQOpenGLTimeMonitor.cpp
.\sipQtGuiQOpenGLTimeMonitor.cpp(82) : error C2504: 'QOpenGLTimeMonitor' : base 
class undefined


It built successfully on OSX 10.8.4 (as 32 bit).

Glenn

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