Seconded there. If you are writing raw Qt UI I'd stick with it without
exiting that "scope". As for the complexity of your sample code, that seems
completely reasonable to me.

You could also subclass QListWidgetItem (not sure if that's the actual
class name...) and handle a lot of the customization there. For instance,
you could override its __str__ method to return the text attribute,
allowing you to print these items directly, or handle them as strings under
certain circumstances.

ex:
print my_itemtype_instance

Also, I think this *should* work:
print " ".join(my_itemtype_instance_array)

At any rate, the examples are not the best, and I'd probably never do
that:), but I think you're on the right track. Writing UI code is complex
and relatively voluminous when compared with other types of coding. For
every line of UI code you don't write, you are giving up some amount of
control, and buying into someone else's idea of what is acceptable in terms
of performance and behavior. If you handle this on your end, you will end
up with more code, but you will be able to form it as you need in your
particular use case.

-Judah



On Thu, Oct 25, 2012 at 9:34 AM, Justin Israel <[email protected]>wrote:

> Not sure why you would want to use pymel operations on the UI elements
> when you already have the more robust PyQt interface to them.
> The QListWidgetItem's being returned have a text() method already, so you
> won't need to look them up twice:
>
>
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlistwidgetitem.html#text
>
> for item in myListWidget.selectedItems():
>     print item.text()
>
> or, you can do it in a list comprehension:
>
> textValues = [item.text() for item in myListWidget.selectedItems()]
>
> There is more than one way to find an existing window...
> To find a window that already exists, by name, you can use
> OpenMayaUI.MQtUtil.findWindow()
> http://goo.gl/wV5CG
>
> from PyQt4 import QtGui
>
> win = QtGui.QDialog()
> win.setObjectName("fooWindow")
>
> import maya.OpenMayaUI as mui
> if mui.MQtUtil.findWindow("fooWindow"):
>     print "Exists!"
>
> This approach will return an actual QWidget swig pointer.
> If you just want to know if it exists, by name, you can use the
> cmds.window()
>
> cmds.window("fooWindow", exists=True)
>
>
>
>
>
> On Thu, Oct 25, 2012 at 6:02 AM, Ali Khanbabaei <[email protected]>wrote:
>
>> it is true.it should delete window.
>> send a part of your code that i see
>>
>> On Thursday, October 25, 2012 3:27:27 PM UTC+3:30, Panupat
>> Chongstitwattana wrote:
>>
>>> Ah that looks pretty neat. Thanks Ali, I should really learn pymel.
>>>
>>> Another question about PyQt .... when re-running the script, how can I
>>> close the previous UI if it already exists?
>>>
>>> I tried
>>>
>>> mc.windows(QtObjectName, exists=True)
>>>
>>> this returns True if the Qt window is opened. However,
>>>
>>> mc.deleteUI(QtObjectName)
>>>
>>> this one doesn't do anything. Is there different command I should use?
>>>
>>> Thanks :)
>>>
>>>  On Thu, Oct 25, 2012 at 6:34 PM, Ali Khanbabaei <[email protected]>wrote:
>>>
>>>> #you can use pymel
>>>> import pymel.core as pm
>>>> pm.uitypes.TextScrollList('listWidgetName').getSelectItem()
>>>>
>>>> On Thursday, October 25, 2012 2:39:08 PM UTC+3:30, Panupat
>>>> Chongstitwattana wrote:
>>>>>
>>>>> I'm wondering if there's a cleaner way to do this than the way I'm
>>>>> doing?
>>>>>
>>>>> Let's say I have "myListWidget" which is multiple-selection enabled
>>>>> QListWidget, I would then do this to print out the values of selected 
>>>>> rows.
>>>>>
>>>>> for item in list(myListWidget.selectedItems())
>>>>>     print myListWidget.item(myListWidget.row(item)).text()
>>>>>
>>>>> I feel like I'm going through a lot of things to get to that text().
>>>>> Is there a cleaner or shorter way to do what I'm doing?
>>>>>
>>>>> Thanks.
>>>>>
>>>>  --
>>>> view archives: http://groups.google.com/group/python_inside_maya
>>>> change your subscription settings:
>>>> http://groups.google.com/group/python_inside_maya/subscribe
>>>>
>>>
>>>  --
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings:
>> http://groups.google.com/group/python_inside_maya/subscribe
>>
>
>  --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to