Hey Justin!
The syntax isn't correct :) Though I figured it all out. I'm writing (or
improving) a update for my mini-asset system that I have for projects. And
being swedish I named it "meatball" :)
It's was quite tricky to find out how to use ui files directly, but I
managed to convert everything and I must say it's a lot better and not have
to convert the ui files to python code. It was a good sunday exercise and
skimming through this group helped a lot of the way. Some of the
not-yet-cleaned-up code (pasted below) looks like this.

regards
stefan


#--- snip ---
from meatball.util import uic

__uiFile__ = os.path.join(os.path.dirname(__file__), "gather.ui")

form_class, base_class = uic.loadUiType(__uiFile__)

class GatherAsset(form_class, base_class):
    def __init__(self, parent=None):
        super(GatherAsset, self).__init__(parent)
        self.setupUi(self)
        self.projectAssets = os.environ["ASSETS"]
        category = [folder for folder in os.listdir(self. projectAssets) if
os.path.isdir(os.path.join(self. projectAssets,folder))]
        category.sort(key=lambda v: v.upper())
        QtGui.QListWidget(self.listCategory.addItems(category))
        QtGui.QGroupBox(self.infoBoxProject.setTitle("Assets for Project:
%s" % os.path.basename(os.environ["JOB"])))
        QtGui.QGroupBox(self.infoBoxAsset.setTitle("INFO:"))
        self.ui_signals()

    def ui_signals(self):
        self.btnGather.clicked.connect(self.on_btnGather_clicked)
        self.listCategory.itemClicked.connect(self.on_listCategory_clicked)
        self.listName.itemClicked.connect(self.on_listName_clicked)
        self.listVersions.itemClicked.connect(self.on_listVersions_clicked)




On Sun, Apr 27, 2014 at 8:53 PM, Justin Israel <[email protected]>wrote:

> Hey Stefan,
>
> Are you sure that is the right syntax to be using?
>
> a = QtGui.QListWidget(self.listCategory.addItems( category))
>
> This is adding your items to and existing list widget from your UI file,
> and then creating a new list widget with the None return value. This widget
> will then most likely be garbage collected after the function scope ends
> because it didn't have a parent.
>
> It is effectively the same as writting:
>
> self.listCategory.addItems(category)
> a = QtGui.QListWidget(None)
>
> Because addItems() doesn't return anything. Isn't the first line all you
> want? listCategory comes from the name you gave your list widget in Qt
> Designer.
> On Apr 28, 2014 2:32 AM, "[email protected]" <[email protected]>
> wrote:
>
>> never mind......
>>
>>
>> a = QtGui.QListWidget(self.listCategory.addItems(category))
>>
>>
>> Sorry for the noise
>>
>> regards
>> stefan
>>
>>
>> On Sunday, April 27, 2014 2:41:39 PM UTC+1, [email protected] wrote:
>>>
>>>  Hi Guys!
>>>
>>> I'm trying to learn how to use ui files instead of converting the ui
>>> files to python all the time. I use Nathan's
>>> http://dl.dropboxusercontent.com/u/1633130/PyQt%20tuts/
>>> PySide_loadUiType.py (but import it as "uic")
>>>
>>>
>>> # --------------- file called myAwesome.py
>>> __uiFile__ = path/ui.ui
>>>
>>> form_class, base_class = uic.loadUiType(__uiFile__)
>>>
>>> class AweSome(form_class, base_class):
>>>     def __init__(self, parent=None):
>>>         super(AweSome, self).__init__(parent)
>>>         self.setupUi(self)
>>> #---------------------------------------------------------
>>>
>>> import myAwesome
>>> a = myAwesome.AweSome()
>>> a.show()
>>>
>>> So that works and I see my ui. And I can also connect signals to my
>>> buttons using
>>>
>>> self.btnPressMe.connect.clicked(self.btnPressMe_clicked())
>>>
>>> But how to I populate QListWidgets? I normally get a list using this
>>> command.
>>>
>>> category = [folder for folder in os.listdir(self.ASSETPATH) if
>>> os.path.isdir(os.path.join(self.ASSETPATH,folder))]
>>>
>>> and then use: self.categorys.addItems(category)
>>>
>>> But how to I use the QtGui.QListWidget.addItems() command now that I
>>> import my ui file? Does it make sense? Sorry for the n00b quesiton about
>>> this.
>>>
>>> regards
>>> stefan andersson
>>>
>>>
>>>  --
>> 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/7c0a0efe-0abc-434e-acc1-25a0193d8885%40googlegroups.com<https://groups.google.com/d/msgid/python_inside_maya/7c0a0efe-0abc-434e-acc1-25a0193d8885%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/CAPGFgA32di%3Dx4rkZsyTv8U_kgeNoXRBAytxoM_V0L%3DQRMR8i7g%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA32di%3Dx4rkZsyTv8U_kgeNoXRBAytxoM_V0L%3DQRMR8i7g%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Stefan Andersson | Digital Janitor
social media -> "sanders3d"

-- 
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/CAKW24e0%3Ds%3DyiqY_w%3DJWCa%3DDhFQaiUPyEoaED9sx9TcxKj5Mdzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to