(→loaddialog.py) |
(→loaddialog.py) |
||
| Line 24: | Line 24: | ||
This code really works. | This code really works. | ||
| − | === | + | ===callMainWindow.py=== |
<code python> | <code python> | ||
import sys | import sys | ||
| Line 55: | Line 55: | ||
</code> | </code> | ||
| − | You will need [[ | + | You will need [[User:Axiom/demo.ui|this file]] too. |
Contents |
I am just putting some stuff here right now, because you have such nice color coding in your wiki. Maybe I'll turn it into a tutorial if I figure out what I am doing.
I found this snippet here (french). I don't know if this is the right way to do it, but it seems to work.
import sys
from PyQt4 import QtGui, uic
app = QtGui.QApplication(sys.argv) widget = uic.loadUi("demo.ui") widget.show()
app.exec_() Of course you will need to make a ui file called demo.ui for this to work.
This code really works.
import sys
from PyQt4 import QtGui
from PyQt4 import uic
from PyQt4 import QtCore
class DemoImpl(QtGui.QMainWindow):
def __init__(self, *args):
QtGui.QMainWindow.__init__(self, *args)
# just pass self uic.loadUi("mainWindow.ui", self)
#this line makes sure that we are only looking for a string
#if we want a bool as well we can add @QtCore.pyqtSignature("bool")
@QtCore.pyqtSignature("")
def on_button1_clicked(self):
print "You Clicked the button!"
@QtCore.pyqtSignature("")
def on_button2_clicked(self):
print "You Clicked the button2!"
app = QtGui.QApplication(sys.argv)
widget = DemoImpl()
widget.show()
app.exec_()
You will need this file too.