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


On Tue, 4 Nov 2014 2:22 AM rob lee Jones <[email protected]> wrote:

Hi there,

This is a question to the community at large for some fastrack help in
converting a simple tutorial.exercise 'wall builder' script written in
python using Maya's native UI functionality to one that deploys Pyside
instead.

I'm aware that there is a growing repository of intro to PySide in Maya
type tutorials...but they don't seem to go much beyond the very first
'hello world' button push. I'm happy to stand corrected on this observation
by the way.

So here's a little exercise I would like to convert as a way of
understanding how user input can be captured and used inside a python
function.

If anyone can knock up a solution which I imagine would be real quick if
you are already fluent with pyQT/PySide it would be most appreciated.

Basically the script below *accepts two integers from the User* (width,
height of wall to be built) and when the 'create wall' b*utton is pushed
these values are then passed to a python function that uses them *to
generate the wall of the required dimensions.

I've started to look through the docs but was hoping to get a heads up from
anyone that is willing to shed light on how to do this in PySide.

Here's the original python script with native Maya UI functionality to be
converted to using PySide instead....

import maya.cmds as cmds

if cmds.window("brickGen", exists=True):

    cmds.deleteUI( "brickGen")

window = cmds.window("brickGen", title = "Brick Wall Generator")

cmds.columnLayout()

*cmds.intField("wallHeight", minValue=1, maxValue=30, value=1) *

*cmds.intField("wallLength", minValue=1, maxValue=30, value=1) *

*cmds.button(label="create wall", command="brickGen()")*

def brickGen():

    # question ....how to do the next two lines or equivalent in PySide.....

*    col = cmds.intField("wallHeight", q=True, value=True)*

*    row = cmds.intField("wallLength" , q=True, value=True)*

    i=0

    j=0

    offset=-1.5

    brickHeight=1

    while i < col:

        h= brickHeight*i

        if (i%2==0):

            print 'even brick'

            while j < row:

                cmds.polyCube(w=1,h=1,d=3)

                cmds.move(3*j, z=True, r=True)

                cmds.move(h, y=True, r=True)

                j+=1

        else:

            print 'odd brick'

            while j < row:

                cmds.polyCube(w=1,h=1,d=3)

                cmds.move(3*j, z=True, r=True)

                cmds.move(h, y=True, r=True)

                cmds.move(offset,z=True,r=True)

                j+=1

        i+=1

        j=0



cmds.showWindow()

Thanks in advance to anyone for any help with this request.

Regards

Rob.

-- 
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/9ca1d797-894a-472f-97ac-4fa84cc24b56%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/9ca1d797-894a-472f-97ac-4fa84cc24b56%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Op_BUNX4OCoMNRSwdHq_AAc2AX%2BYgWf4uYsbPUV4sNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to