today I was having Fun with PyQt4
so came up with this
from PyQt4 import QtCore,QtGui
import sys
def setToolbar(type):
layout = QtGui.QVBoxLayout(type)
layout.setMargin(0)
tool = QtGui.QToolBar("MyTools", type)
a = tool.addAction(QtGui.QAction("Foo", type))
layout.addWidget(tool)
layout.addStretch()
if __name__=='__main__':
app = QtGui.QApplication(sys.argv)
app.setStyle("cleanlooks")
dialogWin=QtGui.QDialog()
dialogWin.setWindowTitle("QDialog Window")
dialogWin.setGeometry(100,230,270,210)
setToolbar(dialogWin)
dialogWin.show()
widgetWin=QtGui.QWidget()
widgetWin.setWindowTitle("QWidget Window")
widgetWin.setGeometry(400,230,270,210)
setToolbar(widgetWin)
widgetWin.show()
mainWindow=QtGui.QMainWindow()
mainWindow.setWindowTitle("QMainWindow")
mainWindow.setGeometry(700,230,270,210)
setToolbar(mainWindow)
mainWindow.show()
sys.exit(app.exec_())
learning by coding self, is lot more satisfying .
On Wed, Dec 5, 2012 at 12:17 AM, Justin Israel <[email protected]>wrote:
> Again, what you decide to subclass depends on what you will do with it. If
> it is going to be a tool type pop up, then a QDialog makes a lot of sense.
> If it is going to be just a composite widget to be placed into something
> else, then a QWidget might make more sense.
>
> You are correct that a QMainWindow provides you with immediate methods for
> managing toolbars, menus, and statusbar, along with dock widgets. But you
> are still free to add toolbars and statusbars to QDialog or QWidget. It is
> just more manual:
>
> d = QtGui.QDialog() # or even QtGui.QWidget()
> d.resize(800,600)
> layout = QtGui.QVBoxLayout(d)
> layout.setMargin(0)
> tool = QtGui.QToolBar("MyTools", d)
> a = tool.addAction(QtGui.QAction("Foo", d))
> layout.addWidget(tool)
> layout.addStretch()
> d.show()
>
>
> On Tuesday, December 4, 2012 10:18:02 AM UTC-8, san wrote:
>
>> i remember you showed in Custom Channel Box example by getting the
>> fullname using sip.unwrapinstance
>>
>> the modalpanel is a QWidget in maya ! so if Maya window itself is a
>> QMainWindow it makes me feel that making a class inherit from QWidget (in a
>> template )would make more sense.
>>
>> if I use QDialog in that case how to implement Menubar or toolbar like we
>> can setup with QMainWindow?
>>
>> as an advantage of QMainWindow (what I also remember from Qt Designer)
>> that it has placement of Menubar or status bar at a predefined place
>> ..!!!
>>
>> I feel like i should dig more into code
>>
>> On Tue, Dec 4, 2012 at 11:03 PM, Justin Israel <[email protected]>wrote:
>>
>>> QWidget
>>
>>
>>
>>
>> --
>> **
>>
>> [image: San's personal blog] <http://feeds.feedburner.com/SanLuthraBlog>
>>
>> *
>> *
>>
>> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
--
**
[image: San's personal blog] <http://feeds.feedburner.com/SanLuthraBlog>
*
*
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe