Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > [newbie] Python and Qt4 Designer

Reply
Thread Tools

[newbie] Python and Qt4 Designer

 
 
Jean Dubois
Guest
Posts: n/a
 
      07-11-2012
I'm trying to combine python-code made with QT4 designer with plain
python statements like
file = open("test","w")
Can anyone tell me what I have to add to the following code just to
open a file when clicking on the load-button and closing it by
clicking on the save button.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'test.ui'
#
# Created: Wed Jul 11 17:21:35 2012
# by: PyQt4 UI code generator 4.8.3
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s

class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(400, 300)
self.widget = QtGui.QWidget(Form)
self.widget.setGeometry(QtCore.QRect(10, 20, 146, 25))
self.widget.setObjectName(_fromUtf8("widget"))
self.horizontalLayout = QtGui.QHBoxLayout(self.widget)
self.horizontalLayout.setMargin(0)

self.horizontalLayout.setObjectName(_fromUtf8("hor izontalLayout"))
self.pushButton_2 = QtGui.QPushButton(self.widget)
self.pushButton_2.setObjectName(_fromUtf8("pushBut ton_2"))
self.horizontalLayout.addWidget(self.pushButton_2)
self.pushButton = QtGui.QPushButton(self.widget)
self.pushButton.setObjectName(_fromUtf8("pushButto n"))
self.horizontalLayout.addWidget(self.pushButton)

self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)

def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate(" Form",
"Form", None, QtGui.QApplication.UnicodeUTF)
self.pushButton_2.setText(QtGui.QApplication.trans late("Form",
"Save file", None, QtGui.QApplication.UnicodeUTF)
self.pushButton.setText(QtGui.QApplication.transla te("Form",
"Load file", None, QtGui.QApplication.UnicodeUTF)


if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())


thanks in advance
jean
 
Reply With Quote
 
 
 
 
Vincent Vande Vyvre
Guest
Posts: n/a
 
      07-12-2012
On 11/07/12 17:37, Jean Dubois wrote:
> I'm trying to combine python-code made with QT4 designer with plain
> python statements like
> file = open("test","w")
> Can anyone tell me what I have to add to the following code just to
> open a file when clicking on the load-button and closing it by
> clicking on the save button.
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> # Form implementation generated from reading ui file 'test.ui'
> #
> # Created: Wed Jul 11 17:21:35 2012
> # by: PyQt4 UI code generator 4.8.3
> #
> # WARNING! All changes made in this file will be lost!
>
> from PyQt4 import QtCore, QtGui
>
> try:
> _fromUtf8 = QtCore.QString.fromUtf8
> except AttributeError:
> _fromUtf8 = lambda s: s
>
> class Ui_Form(object):
> def setupUi(self, Form):
> Form.setObjectName(_fromUtf8("Form"))
> Form.resize(400, 300)
> self.widget = QtGui.QWidget(Form)
> self.widget.setGeometry(QtCore.QRect(10, 20, 146, 25))
> self.widget.setObjectName(_fromUtf8("widget"))
> self.horizontalLayout = QtGui.QHBoxLayout(self.widget)
> self.horizontalLayout.setMargin(0)
>
> self.horizontalLayout.setObjectName(_fromUtf8("hor izontalLayout"))
> self.pushButton_2 = QtGui.QPushButton(self.widget)
> self.pushButton_2.setObjectName(_fromUtf8("pushBut ton_2"))
> self.horizontalLayout.addWidget(self.pushButton_2)
> self.pushButton = QtGui.QPushButton(self.widget)
> self.pushButton.setObjectName(_fromUtf8("pushButto n"))
> self.horizontalLayout.addWidget(self.pushButton)
>
> self.retranslateUi(Form)
> QtCore.QMetaObject.connectSlotsByName(Form)
>
> def retranslateUi(self, Form):
> Form.setWindowTitle(QtGui.QApplication.translate(" Form",
> "Form", None, QtGui.QApplication.UnicodeUTF)
> self.pushButton_2.setText(QtGui.QApplication.trans late("Form",
> "Save file", None, QtGui.QApplication.UnicodeUTF)
> self.pushButton.setText(QtGui.QApplication.transla te("Form",
> "Load file", None, QtGui.QApplication.UnicodeUTF)
>
>
> if __name__ == "__main__":
> import sys
> app = QtGui.QApplication(sys.argv)
> Form = QtGui.QWidget()
> ui = Ui_Form()
> ui.setupUi(Form)
> Form.show()
> sys.exit(app.exec_())
>
>
> thanks in advance
> jean

Connect the signal clicked of your's buttons to your's functions.

self.pushButton.clicked.connect(self.my_func)

Here's all the truth:

http://www.riverbankcomputing.co.uk/...als_slots.html

--
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte+7
<https://launchpad.net/qarte+7> . PaQager <https://launchpad.net/paqager>

 
Reply With Quote
 
 
 
 
Jean Dubois
Guest
Posts: n/a
 
      07-12-2012
On 12 jul, 02:59, Vincent Vande Vyvre <vincent.vandevy...@swing.be>
wrote:
> On 11/07/12 17:37, Jean Dubois wrote:
>
>
>
>
>
>
>
> > I'm trying to combine python-code made with QT4 designer with plain
> > python statements like
> > file = open("test","w")
> > Can anyone tell me what I have to *add to the following code just to
> > open a file when clicking on the load-button and closing it by
> > clicking on the save button.

>
> > #!/usr/bin/env python
> > # -*- coding: utf-8 -*-

>
> > # Form implementation generated from reading ui file 'test.ui'
> > #
> > # Created: Wed Jul 11 17:21:35 2012
> > # * * *by: PyQt4 UI code generator 4.8.3
> > #
> > # WARNING! All changes made in this file will be lost!

>
> > from PyQt4 import QtCore, QtGui

>
> > try:
> > * * _fromUtf8 = QtCore.QString.fromUtf8
> > except AttributeError:
> > * * _fromUtf8 = lambda s: s

>
> > class Ui_Form(object):
> > * * def setupUi(self, Form):
> > * * * * Form.setObjectName(_fromUtf8("Form"))
> > * * * * Form.resize(400, 300)
> > * * * * self.widget = QtGui.QWidget(Form)
> > * * * * self.widget.setGeometry(QtCore.QRect(10, 20, 146, 25))
> > * * * * self.widget.setObjectName(_fromUtf8("widget"))
> > * * * * self.horizontalLayout = QtGui.QHBoxLayout(self.widget)
> > * * * * self.horizontalLayout.setMargin(0)

>
> > self.horizontalLayout.setObjectName(_fromUtf8("hor izontalLayout"))
> > * * * * self.pushButton_2 = QtGui.QPushButton(self.widget)
> > * * * * self.pushButton_2.setObjectName(_fromUtf8("pushBut ton_2"))
> > * * * * self.horizontalLayout.addWidget(self.pushButton_2)
> > * * * * self.pushButton = QtGui.QPushButton(self.widget)
> > * * * * self.pushButton.setObjectName(_fromUtf8("pushButto n"))
> > * * * * self.horizontalLayout.addWidget(self.pushButton)

>
> > * * * * self.retranslateUi(Form)
> > * * * * QtCore.QMetaObject.connectSlotsByName(Form)

>
> > * * def retranslateUi(self, Form):
> > * * * * Form.setWindowTitle(QtGui.QApplication.translate(" Form",
> > "Form", None, QtGui.QApplication.UnicodeUTF)
> > * * * * self.pushButton_2.setText(QtGui.QApplication.trans late("Form",
> > "Save file", None, QtGui.QApplication.UnicodeUTF)
> > * * * * self.pushButton.setText(QtGui.QApplication.transla te("Form",
> > "Load file", None, QtGui.QApplication.UnicodeUTF)

>
> > if __name__ == "__main__":
> > * * import sys
> > * * app = QtGui.QApplication(sys.argv)
> > * * Form = QtGui.QWidget()
> > * * ui = Ui_Form()
> > * * ui.setupUi(Form)
> > * * Form.show()
> > * * sys.exit(app.exec_())

>
> > thanks in advance
> > jean

>
> Connect the signal clicked of your's buttons to your's functions.
>
> * * self.pushButton.clicked.connect(self.my_func)
>
> Here's all the truth:
>
> http://www.riverbankcomputing.co.uk/...tml/new_style_...
>
> --
> Vincent V.V.
> Oqapy <https://launchpad.net/oqapy> . Qarte+7
> <https://launchpad.net/qarte+7> . PaQager <https://launchpad.net/paqager>


thanks for the reference, could you just supply a small example for
the code above to get me started?

thanks in advance
jean
 
Reply With Quote
 
Vincent Vande Vyvre
Guest
Posts: n/a
 
      07-13-2012
On 12/07/12 08:42, Jean Dubois wrote:
> On 12 jul, 02:59, Vincent Vande Vyvre <vincent.vandevy...@swing.be>
> wrote:
>> On 11/07/12 17:37, Jean Dubois wrote:
>>
>>
>>
>>
>>
>>
>>
>>> I'm trying to combine python-code made with QT4 designer with plain
>>> python statements like
>>> file = open("test","w")
>>> Can anyone tell me what I have to add to the following code just to
>>> open a file when clicking on the load-button and closing it by
>>> clicking on the save button.
>>> #!/usr/bin/env python
>>> # -*- coding: utf-8 -*-
>>> # Form implementation generated from reading ui file 'test.ui'
>>> #
>>> # Created: Wed Jul 11 17:21:35 2012
>>> # by: PyQt4 UI code generator 4.8.3
>>> #
>>> # WARNING! All changes made in this file will be lost!
>>> from PyQt4 import QtCore, QtGui
>>> try:
>>> _fromUtf8 = QtCore.QString.fromUtf8
>>> except AttributeError:
>>> _fromUtf8 = lambda s: s
>>> class Ui_Form(object):
>>> def setupUi(self, Form):
>>> Form.setObjectName(_fromUtf8("Form"))
>>> Form.resize(400, 300)
>>> self.widget = QtGui.QWidget(Form)
>>> self.widget.setGeometry(QtCore.QRect(10, 20, 146, 25))
>>> self.widget.setObjectName(_fromUtf8("widget"))
>>> self.horizontalLayout = QtGui.QHBoxLayout(self.widget)
>>> self.horizontalLayout.setMargin(0)
>>> self.horizontalLayout.setObjectName(_fromUtf8("hor izontalLayout"))
>>> self.pushButton_2 = QtGui.QPushButton(self.widget)
>>> self.pushButton_2.setObjectName(_fromUtf8("pushBut ton_2"))
>>> self.horizontalLayout.addWidget(self.pushButton_2)
>>> self.pushButton = QtGui.QPushButton(self.widget)
>>> self.pushButton.setObjectName(_fromUtf8("pushButto n"))
>>> self.horizontalLayout.addWidget(self.pushButton)
>>> self.retranslateUi(Form)
>>> QtCore.QMetaObject.connectSlotsByName(Form)
>>> def retranslateUi(self, Form):
>>> Form.setWindowTitle(QtGui.QApplication.translate(" Form",
>>> "Form", None, QtGui.QApplication.UnicodeUTF)
>>> self.pushButton_2.setText(QtGui.QApplication.trans late("Form",
>>> "Save file", None, QtGui.QApplication.UnicodeUTF)
>>> self.pushButton.setText(QtGui.QApplication.transla te("Form",
>>> "Load file", None, QtGui.QApplication.UnicodeUTF)
>>> if __name__ == "__main__":
>>> import sys
>>> app = QtGui.QApplication(sys.argv)
>>> Form = QtGui.QWidget()
>>> ui = Ui_Form()
>>> ui.setupUi(Form)
>>> Form.show()
>>> sys.exit(app.exec_())
>>> thanks in advance
>>> jean

>> Connect the signal clicked of your's buttons to your's functions.
>>
>> self.pushButton.clicked.connect(self.my_func)
>>
>> Here's all the truth:
>>
>> http://www.riverbankcomputing.co.uk/...tml/new_style_...
>>
>> --
>> Vincent V.V.
>> Oqapy <https://launchpad.net/oqapy> . Qarte+7
>> <https://launchpad.net/qarte+7> . PaQager <https://launchpad.net/paqager>

> thanks for the reference, could you just supply a small example for
> the code above to get me started?
>
> thanks in advance
> jean

Just add the connection at the end of the Ui_Form class and, of course,
your function.

You can find numbers of examples in your PyQt4 install folder.
On my machine is located at /usr/share/doc/python-qt4-doc/examples

And, for more inspiration, have a look at this site:
http://diotavelli.net/PyQtWiki/

--
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>

 
Reply With Quote
 
Jean Dubois
Guest
Posts: n/a
 
      07-13-2012
Op vrijdag 13 juli 2012 03:52:51 UTC+2 schreef Vincent Vande Vyvre het volgende:
> On 12/07/12 08:42, Jean Dubois wrote:
> &gt; On 12 jul, 02:59, Vincent Vande Vyvre &lt;vincent.vandevy...@swing.be&gt;
> &gt; wrote:
> &gt;&gt; On 11/07/12 17:37, Jean Dubois wrote:
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;&gt; I'm trying to combine python-code made with QT4 designer with plain
> &gt;&gt;&gt; python statements like
> &gt;&gt;&gt; file = open(&quot;test&quot;,&quot;w&quot
> &gt;&gt;&gt; Can anyone tell me what I have to add to the following code just to
> &gt;&gt;&gt; open a file when clicking on the load-button and closing it by
> &gt;&gt;&gt; clicking on the save button.
> &gt;&gt;&gt; #!/usr/bin/env python
> &gt;&gt;&gt; # -*- coding: utf-8 -*-
> &gt;&gt;&gt; # Form implementation generated from reading ui file 'test.ui'
> &gt;&gt;&gt; #
> &gt;&gt;&gt; # Created: Wed Jul 11 17:21:35 2012
> &gt;&gt;&gt; # by: PyQt4 UI code generator 4.8.3
> &gt;&gt;&gt; #
> &gt;&gt;&gt; # WARNING! All changes made in this file will be lost!
> &gt;&gt;&gt; from PyQt4 import QtCore, QtGui
> &gt;&gt;&gt; try:
> &gt;&gt;&gt; _fromUtf8 = QtCore.QString.fromUtf8
> &gt;&gt;&gt; except AttributeError:
> &gt;&gt;&gt; _fromUtf8 = lambda s: s
> &gt;&gt;&gt; class Ui_Form(object):
> &gt;&gt;&gt; def setupUi(self, Form):
> &gt;&gt;&gt; Form.setObjectName(_fromUtf8(&quot;Form&quot)
> &gt;&gt;&gt; Form.resize(400, 300)
> &gt;&gt;&gt; self.widget = QtGui.QWidget(Form)
> &gt;&gt;&gt; self.widget.setGeometry(QtCore.QRect(10, 20, 146, 25))
> &gt;&gt;&gt; self.widget.setObjectName(_fromUtf8(&quot;widget&q uot)
> &gt;&gt;&gt; self.horizontalLayout = QtGui.QHBoxLayout(self.widget)
> &gt;&gt;&gt; self.horizontalLayout.setMargin(0)
> &gt;&gt;&gt; self.horizontalLayout.setObjectName(_fromUtf8(&quo t;horizontalLayout&quot)
> &gt;&gt;&gt; self.pushButton_2 = QtGui.QPushButton(self.widget)
> &gt;&gt;&gt; self.pushButton_2.setObjectName(_fromUtf8(&quot;pu shButton_2&quot)
> &gt;&gt;&gt; self.horizontalLayout.addWidget(self.pushButton_2)
> &gt;&gt;&gt; self.pushButton = QtGui.QPushButton(self.widget)
> &gt;&gt;&gt; self.pushButton.setObjectName(_fromUtf8(&quot;push Button&quot)
> &gt;&gt;&gt; self.horizontalLayout.addWidget(self.pushButton)
> &gt;&gt;&gt; self.retranslateUi(Form)
> &gt;&gt;&gt; QtCore.QMetaObject.connectSlotsByName(Form)
> &gt;&gt;&gt; def retranslateUi(self, Form):
> &gt;&gt;&gt; Form.setWindowTitle(QtGui.QApplication.translate(& quot;Form&quot;,
> &gt;&gt;&gt; &quot;Form&quot;, None, QtGui.QApplication.UnicodeUTF)
> &gt;&gt;&gt; self.pushButton_2.setText(QtGui.QApplication.trans late(&quot;Form&quot;,
> &gt;&gt;&gt; &quot;Save file&quot;, None, QtGui.QApplication.UnicodeUTF)
> &gt;&gt;&gt; self.pushButton.setText(QtGui.QApplication.transla te(&quot;Form&quot;,
> &gt;&gt;&gt; &quot;Load file&quot;, None, QtGui.QApplication.UnicodeUTF)
> &gt;&gt;&gt; if __name__ == &quot;__main__&quot;:
> &gt;&gt;&gt; import sys
> &gt;&gt;&gt; app = QtGui.QApplication(sys.argv)
> &gt;&gt;&gt; Form = QtGui.QWidget()
> &gt;&gt;&gt; ui = Ui_Form()
> &gt;&gt;&gt; ui.setupUi(Form)
> &gt;&gt;&gt; Form.show()
> &gt;&gt;&gt; sys.exit(app.exec_())
> &gt;&gt;&gt; thanks in advance
> &gt;&gt;&gt; jean
> &gt;&gt; Connect the signal clicked of your's buttons to your's functions.
> &gt;&gt;
> &gt;&gt; self.pushButton.clicked.connect(self.my_func)
> &gt;&gt;
> &gt;&gt; Here's all the truth:
> &gt;&gt;
> &gt;&gt; http://www.riverbankcomputing.co.uk/...tml/new_style_...
> &gt;&gt;
> &gt;&gt; --
> &gt;&gt; Vincent V.V.
> &gt;&gt; Oqapy &lt;https://launchpad.net/oqapy&gt; . Qarte+7
> &gt;&gt; &lt;https://launchpad.net/qarte+7&gt; . PaQager &lt;https://launchpad.net/paqager&gt;
> &gt; thanks for the reference, could you just supply a small example for
> &gt; the code above to get me started?
> &gt;
> &gt; thanks in advance
> &gt; jean
> Just add the connection at the end of the Ui_Form class and, of course,
> your function.
>
> You can find numbers of examples in your PyQt4 install folder.
> On my machine is located at /usr/share/doc/python-qt4-doc/examples
>
> And, for more inspiration, have a look at this site:
> http://diotavelli.net/PyQtWiki/
>
> --
> Vincent V.V.
> Oqapy &lt;https://launchpad.net/oqapy&gt; . Qarte
> &lt;https://launchpad.net/qarte&gt; . PaQager &lt;https://launchpad.net/paqager&gt;


Thanks for the extra docu references

regards,

jean
 
Reply With Quote
 
Jean Dubois
Guest
Posts: n/a
 
      07-13-2012
Op vrijdag 13 juli 2012 03:52:51 UTC+2 schreef Vincent Vande Vyvre het volgende:
> On 12/07/12 08:42, Jean Dubois wrote:
> &gt; On 12 jul, 02:59, Vincent Vande Vyvre &lt;vincent.vandevy...@swing.be&gt;
> &gt; wrote:
> &gt;&gt; On 11/07/12 17:37, Jean Dubois wrote:
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;
> &gt;&gt;&gt; I'm trying to combine python-code made with QT4 designer with plain
> &gt;&gt;&gt; python statements like
> &gt;&gt;&gt; file = open(&quot;test&quot;,&quot;w&quot
> &gt;&gt;&gt; Can anyone tell me what I have to add to the following code just to
> &gt;&gt;&gt; open a file when clicking on the load-button and closing it by
> &gt;&gt;&gt; clicking on the save button.
> &gt;&gt;&gt; #!/usr/bin/env python
> &gt;&gt;&gt; # -*- coding: utf-8 -*-
> &gt;&gt;&gt; # Form implementation generated from reading ui file 'test.ui'
> &gt;&gt;&gt; #
> &gt;&gt;&gt; # Created: Wed Jul 11 17:21:35 2012
> &gt;&gt;&gt; # by: PyQt4 UI code generator 4.8.3
> &gt;&gt;&gt; #
> &gt;&gt;&gt; # WARNING! All changes made in this file will be lost!
> &gt;&gt;&gt; from PyQt4 import QtCore, QtGui
> &gt;&gt;&gt; try:
> &gt;&gt;&gt; _fromUtf8 = QtCore.QString.fromUtf8
> &gt;&gt;&gt; except AttributeError:
> &gt;&gt;&gt; _fromUtf8 = lambda s: s
> &gt;&gt;&gt; class Ui_Form(object):
> &gt;&gt;&gt; def setupUi(self, Form):
> &gt;&gt;&gt; Form.setObjectName(_fromUtf8(&quot;Form&quot)
> &gt;&gt;&gt; Form.resize(400, 300)
> &gt;&gt;&gt; self.widget = QtGui.QWidget(Form)
> &gt;&gt;&gt; self.widget.setGeometry(QtCore.QRect(10, 20, 146, 25))
> &gt;&gt;&gt; self.widget.setObjectName(_fromUtf8(&quot;widget&q uot)
> &gt;&gt;&gt; self.horizontalLayout = QtGui.QHBoxLayout(self.widget)
> &gt;&gt;&gt; self.horizontalLayout.setMargin(0)
> &gt;&gt;&gt; self.horizontalLayout.setObjectName(_fromUtf8(&quo t;horizontalLayout&quot)
> &gt;&gt;&gt; self.pushButton_2 = QtGui.QPushButton(self.widget)
> &gt;&gt;&gt; self.pushButton_2.setObjectName(_fromUtf8(&quot;pu shButton_2&quot)
> &gt;&gt;&gt; self.horizontalLayout.addWidget(self.pushButton_2)
> &gt;&gt;&gt; self.pushButton = QtGui.QPushButton(self.widget)
> &gt;&gt;&gt; self.pushButton.setObjectName(_fromUtf8(&quot;push Button&quot)
> &gt;&gt;&gt; self.horizontalLayout.addWidget(self.pushButton)
> &gt;&gt;&gt; self.retranslateUi(Form)
> &gt;&gt;&gt; QtCore.QMetaObject.connectSlotsByName(Form)
> &gt;&gt;&gt; def retranslateUi(self, Form):
> &gt;&gt;&gt; Form.setWindowTitle(QtGui.QApplication.translate(& quot;Form&quot;,
> &gt;&gt;&gt; &quot;Form&quot;, None, QtGui.QApplication.UnicodeUTF)
> &gt;&gt;&gt; self.pushButton_2.setText(QtGui.QApplication.trans late(&quot;Form&quot;,
> &gt;&gt;&gt; &quot;Save file&quot;, None, QtGui.QApplication.UnicodeUTF)
> &gt;&gt;&gt; self.pushButton.setText(QtGui.QApplication.transla te(&quot;Form&quot;,
> &gt;&gt;&gt; &quot;Load file&quot;, None, QtGui.QApplication.UnicodeUTF)
> &gt;&gt;&gt; if __name__ == &quot;__main__&quot;:
> &gt;&gt;&gt; import sys
> &gt;&gt;&gt; app = QtGui.QApplication(sys.argv)
> &gt;&gt;&gt; Form = QtGui.QWidget()
> &gt;&gt;&gt; ui = Ui_Form()
> &gt;&gt;&gt; ui.setupUi(Form)
> &gt;&gt;&gt; Form.show()
> &gt;&gt;&gt; sys.exit(app.exec_())
> &gt;&gt;&gt; thanks in advance
> &gt;&gt;&gt; jean
> &gt;&gt; Connect the signal clicked of your's buttons to your's functions.
> &gt;&gt;
> &gt;&gt; self.pushButton.clicked.connect(self.my_func)
> &gt;&gt;
> &gt;&gt; Here's all the truth:
> &gt;&gt;
> &gt;&gt; http://www.riverbankcomputing.co.uk/...tml/new_style_...
> &gt;&gt;
> &gt;&gt; --
> &gt;&gt; Vincent V.V.
> &gt;&gt; Oqapy &lt;https://launchpad.net/oqapy&gt; . Qarte+7
> &gt;&gt; &lt;https://launchpad.net/qarte+7&gt; . PaQager &lt;https://launchpad.net/paqager&gt;
> &gt; thanks for the reference, could you just supply a small example for
> &gt; the code above to get me started?
> &gt;
> &gt; thanks in advance
> &gt; jean
> Just add the connection at the end of the Ui_Form class and, of course,
> your function.
>
> You can find numbers of examples in your PyQt4 install folder.
> On my machine is located at /usr/share/doc/python-qt4-doc/examples
>
> And, for more inspiration, have a look at this site:
> http://diotavelli.net/PyQtWiki/
>
> --
> Vincent V.V.
> Oqapy &lt;https://launchpad.net/oqapy&gt; . Qarte
> &lt;https://launchpad.net/qarte&gt; . PaQager &lt;https://launchpad.net/paqager&gt;


Thanks for the extra docu references

regards,

jean
 
Reply With Quote
 
Michael Torrie
Guest
Posts: n/a
 
      07-14-2012
On 07/13/2012 03:12 PM, Jean Dubois wrote:
> Thanks for the extra docu references


In this day and age, I think compiling ui files to code is probably on
the way out. Instead you should consider using the ui files directly in
your code. This has the advantage of letting you change the gui
somewhat without having to recompile all the time.

Here is are some links that gives one way of loading and parsing the ui
file directly:

http://www.riverbankcomputing.com/pi...il/015902.html
http://bitesofcode.blogspot.ca/2011/...echniques.html


 
Reply With Quote
 
rusi
Guest
Posts: n/a
 
      07-14-2012
On Jul 14, 7:45*pm, Michael Torrie <torr...@gmail.com> wrote:
> On 07/13/2012 03:12 PM, Jean Dubois wrote:
>
> > Thanks for the extra docu references

>
> In this day and age, I think compiling ui files to code is probably on
> the way out. *Instead you should consider using the ui files directly in
> your code. *This has the advantage of letting you change the gui
> somewhat without having to recompile all the time.
>
> Here is are some links that gives one way of loading and parsing the ui
> file directly:
>
> http://www.riverbankcomputing.com/pi...ading-techniqu...


I looked at the second link and find code like this:

app = None
if ( not app ):
app = QtGui.QApplication([])

Maybe I'm dense but whats that if doing there?

Frankly I seem to be a bit jinxed with gui stuff. A few days ago
someone was singing the praises of some new themed tk stuff. I could
not get the first two lines -- the imports -- to work and then gave up
 
Reply With Quote
 
Michael Torrie
Guest
Posts: n/a
 
      07-15-2012
On 07/14/2012 11:13 AM, rusi wrote:
> I looked at the second link and find code like this:
>
> app = None if ( not app ): app = QtGui.QApplication([])
>
> Maybe I'm dense but whats that if doing there?
>
> Frankly I seem to be a bit jinxed with gui stuff. A few days ago
> someone was singing the praises of some new themed tk stuff. I could
> not get the first two lines -- the imports -- to work and then gave
> up


Since you haven't had any experience with gui development then probably
loading ui files isn't the right place to start. First principles
(creating gui widgets from scratch) would be it.

In any case, the line in question is quite simple. It creates a
QApplication object, which is basically the engine that drives all Qt
applications. Once you call .run() on it, it takes over and handles all
the mouse events and such for you. In fact you do not have any control
over the program's execution from this point on, other than to define
event call-back methods or functions that are called by the widgets when
things happen, like mouse clicks.

All gui toolkits operate this way. You set up the widgets, then you run
the main engine or main event loop and control never returns to your
main program until something triggers the end (like closing a window or
the quit menu item is pressed).

Probably a complete working example is what you need to see, that is
documented. I primarily work with Gtk, but I'll whip up a Qt one
tomorrow if I can.
 
Reply With Quote
 
Vincent Vande Vyvre
Guest
Posts: n/a
 
      07-15-2012
On 15/07/12 07:31, Michael Torrie wrote:
> On 07/14/2012 11:13 AM, rusi wrote:
>> I looked at the second link and find code like this:
>>
>> app = None if ( not app ): app = QtGui.QApplication([])
>>
>> Maybe I'm dense but whats that if doing there?
>>
>> Frankly I seem to be a bit jinxed with gui stuff. A few days ago
>> someone was singing the praises of some new themed tk stuff. I could
>> not get the first two lines -- the imports -- to work and then gave
>> up

> Since you haven't had any experience with gui development then probably
> loading ui files isn't the right place to start. First principles
> (creating gui widgets from scratch) would be it.
>
> In any case, the line in question is quite simple. It creates a
> QApplication object, which is basically the engine that drives all Qt
> applications. Once you call .run() on it, it takes over and handles all
> the mouse events and such for you. In fact you do not have any control
> over the program's execution from this point on, other than to define
> event call-back methods or functions that are called by the widgets when
> things happen, like mouse clicks.
>
> All gui toolkits operate this way. You set up the widgets, then you run
> the main engine or main event loop and control never returns to your
> main program until something triggers the end (like closing a window or
> the quit menu item is pressed).
>
> Probably a complete working example is what you need to see, that is
> documented. I primarily work with Gtk, but I'll whip up a Qt one
> tomorrow if I can.

Rusi is not the op, and his question is about these lines

app = None
if ( not app ):

not this one

app = QtGui.QApplication([])

which should be written like this

app = QtGui.QApplication(sys.argv)



--
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ruby-1.9, sqlite3 and qt4 on windows Martin DeMello Ruby 8 10-26-2009 06:00 AM
Perl and Qt4 John Bokma Perl Misc 0 01-23-2008 04:03 AM
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Building Controls 3 07-30-2007 09:09 PM
Sharepoint Designer/ Expression Web Designer : adding item in toolbox ? Steve B. ASP .Net 4 06-01-2007 04:29 AM
Qt4 designer, custom slots and rbuic4 Chris Ruby 2 03-04-2007 06:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57