Basically it looks for a pattern like "$i = " and creates a list and then I split the list based on the index and retrieve the text from the selected indexes. I would guess it it would take less lines in regex but i do not have much experience with regex.

All right, got some progress I can show, added options to choose what type of render you want to do, added tooltips and QValidator for frames, added settings tab that will store the location of maya executable or render.exe . The code is now at pastebin

for a while i did thought making UI in QtDesigner would be better choice when adding all those layouts but idea of using LC was time saver.

So yesterday , I worked out on the previous demonstration of different types of Window, and added some widgets to it. My objective was to learn how to take advantage of a model approach so that data comes from a single source and is not unique to its view, the advantage of this is if you update data in one widget it is reflected in other widgets instantaneously and that too without signals and slots. which means so less code and simpler approach, I will paste the code below but before i would like to show you screenshot of the three types of window holding data.

QDialog window

QWidget Window

QMainWindow

1: from PyQt4 import QtCore,QtGui

2:

3: import sys

4:

5:

6:

7: if __name__=='__main__':

8: app = QtGui.QApplication(sys.argv)

9: app.setStyle("cleanlooks")

10:

11: dialogWin=QtGui.QDialog()

12: dialogWin.setWindowTitle("QDialog Window")

13: dialogWin.setGeometry(100,230,270,210)

14: data=QtCore.QStringList()

15: data << "one" << "two" << "three" << "four" << "five"

16: layout = QtGui.QVBoxLayout(dialogWin)

17: layout.setMargin(0)

18:

19: #Create a model

20: model = QtGui.QStringListModel(data)

21: comboBox= QtGui.QComboBox()

22: # add data to combo box using model

23: comboBox.setModel(model)

24:

25: label=QtGui.QLabel("Item based widget has unique items from data")

26:

27: listWidget=QtGui.QListWidget()

28: listWidget.addItems(data)

29: count = listWidget.count()

30:

31: for i in range(count):

32: item = listWidget.item(i)

33: item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable)

34:

35:

36: layout.addWidget(comboBox)

37: layout.addWidget(label)

38: layout.addWidget(listWidget)

39:

40: ##layout.addStretch(0)

41: dialogWin.show()

42:

43: widgetWin=QtGui.QWidget()

44: widgetWin.setWindowTitle("QWidget Window")

45: widgetWin.setGeometry(400,230,270,210)

46: # add layout to widget

47: widLayout=QtGui.QVBoxLayout(widgetWin)

48: # add listView

49: listView =QtGui.QListView()

50: listView.setModel(model)

51: widLayout.addWidget(listView)

52: widgetWin.show()

53:

54: mainWindow=QtGui.QMainWindow()

55: mainWindow.setWindowTitle("QMainWindow")

56: mainWindow.setGeometry(700,230,270,210)

57:

58: mlabel=QtGui.QLabel("All of them updates at same\n time becuase all of them uses\n same model, the model\n keeps only one instance of\n the data")

59: vlabel=QtGui.QLabel("The Views interface that model and submit\n when we rename or retrieve \nwhen it shows the data.")

Demonstrating the difference & similarity between QDialog, QWidget and QMainWindow

Run this code and the difference will be clear and you will be ready to go what to choose out of QDialog, QWidget or QMainWindow, QMainWindow is at the topmost level.

1: from PyQt4 import QtCore,QtGui

2:

3: import sys

4:

5: def setToolbar(type):

6: layout = QtGui.QVBoxLayout(type)

7: layout.setMargin(0)

8: tool = QtGui.QToolBar("MyTools", type)

9: a = tool.addAction(QtGui.QAction("Foo", type))

10: layout.addWidget(tool)

11: layout.addStretch()

12:

13: if __name__=='__main__':

14: app = QtGui.QApplication(sys.argv)

15: app.setStyle("CleanLooks")

16:

17: dialogWin=QtGui.QDialog()

18: dialogWin.setWindowTitle("QDialog Window")

19: dialogWin.setGeometry(100,230,270,210)

20: setToolbar(dialogWin)

21: dialogWin.show()

22:

23: widgetWin=QtGui.QWidget()

24: widgetWin.setWindowTitle("QWidget Window")

25: widgetWin.setGeometry(400,230,270,210)

26: setToolbar(widgetWin)

27: widgetWin.show()

28:

29: mainWindow=QtGui.QMainWindow()

30: mainWindow.setWindowTitle("QMainWindow")

31: mainWindow.setGeometry(700,230,270,210)

32: setToolbar(mainWindow)

33: mainWindow.show()

34:

35:

36: sys.exit(app.exec_())

I have made a function to set the toolbar for every type of window. After you run the code you will notice you can do most of the work with each type if window except you cannot minimize or maximize the QDialog window, and QMainWindow has advantage of giving floating toolbar by default.

Note: you are not suppose to run this code from Maya, because maya window itself is running the main thread.

in this template beside just importation of PyQt4 , I have made an import of SIP module,SIP is the communication layer between PyQt wrapping and actual Qt binaries. This does the communication between the C++ object and the Python object.

Browser not compatible.

Note, that I have used QMainWindow as the base class from which I inherit, but instead we can also use QWidget or QDialog . Although using QWidget would make more sense if you are making a window that is going to dock or just be part of maya main window because maya main window itself is a QMainWindow. However using QMainWindow provides immediate methods for managing toolbars, menus, and statusbar, along with dock widgets.

This site contains actual content, written by an actual person. All of this stuff is mine. Even though it may read like it was written by monkeys on typewriters, I actually wrote it. If you want to use my stuff, you can't. At least, not without contacting me first. I also have a privacy policy that I guard fiercely. Any information you provide on this website will not be used by anyone else but me.
Blog, Website Content, VFX Showreel work & Tools & Scripts by Sanjeev Kumar is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

>

Powered by Create your own unique website with customizable templates.