--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9ca1d797-894a-472f-97ac-4fa84cc24b56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hey Rob
One of the important concepts to have down when getting into Qt is classes. If you understand those, then you should be good to go.
The approach you would take is to create a QDialog subclass. This will have some kind of layout attached, such as a QFormLayout.
Then you will add QLabel and QSpinBox instances for your width and height. And then a QPushButton. All of these should be member attributes of the QDialog.
Qt uses signal/slot communication. You would create a method on your subclass that would perform the wall building when called. It should look at the member QSpinBox instances to grab their current int values. Then you connect your push button clicked signal to your builder method. All of the widget setup and connection happens in the constructor of your class.
Then you will have this complete QDialog subclass that can be created and shown.
I could write out an example, but if you are only just getting started, it may be best to grab a book or watch a video (I have a PyQt training video at cmiVfx), as the example would most likely lead to a bunch of extra getting-started questions covered in training material
- justin
--
Thanks Marcus and Justin on that initial round of advice and support. Well I happen to have recently purchased both the Rapid GUI Programming with Python and QT book and the cmiVFX pyQT/Maya training. The book I've been dipping into/skimming and thinking yikes theres a lot to learn and the training I've yet to find a sustained period of time to work through end to end. So all tooled up and no excuses really I guess - it's just a case of really applying myself. That said….I would greatly appreciate it Justin if you could knock up an example solution to the specific task I had in mind (i.e. accept 2 integer inputs from the user and feed them into a python function via a button click) and then I'll fill in all the other gaps in my current knowledge and hope to start making more progress with this transition to QT-based Maya UI design…I just need to get beyond the early hurdles and get up and running…I'm fine with classes pretty much and general oops concepts, however my earlier forays into pyQT/pySide have been a series of false starts to date with numerous technical issues getting in the way. However, now feels like the right time to move on.
Thanks again for your advice and support so far.
Regards
Rob.
Here is an example of what it might look like
from PySide import QtCore, QtGui
class BrickWallGenDialog(QtGui.QDialog):
def __init__(self, parent=None):
super(BrickWallGenDialog, self).__init__(parent)
self.setObjectName("brickGen")
self.setWindowTitle("Brick Wall Generator")
self._heightInput = QtGui.QSpinBox()
self._heightInput.setRange(1, 30)
self._lengthInput = QtGui.QSpinBox()
self._lengthInput.setRange(1, 30)
self._button = QtGui.QPushButton("Create Wall")
layout = QtGui.QFormLayout(self)
layout.addRow("Wall Height:", self._heightInput)
layout.addRow("Wall Length:", self._lengthInput)
layout.addRow(self._button)
# Connections
self._button.clicked.connect(self.brickGen)
def brickGen(self):
height = self._heightInput.value()
length = self._lengthInput.value()
print "Do brickGen with %d x %d" % (height, length)
win = BrickWallGenDialog()
win.resize(200, 100)
win.show()
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/905651234.753810.1415133822608.JavaMail.yahoo%40jws11118.mail.ir2.yahoo.com.
Hi Justin,
I've just seen your latest reply and wanted to say many thanks as that as actually helped a lot and has made the road ahead much clearer.
In fact I now realise that I already understand everything else in the example solution but seeing it contextualised with this almost trivial little example has really helped to clarify the general approach.
Once again many thanks for your support.
Regards
Rob.