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

Reply via email to