[Python-de] PyQt4: WindowTitle ändern / Label-Text init. ... aber wie?
Gerhard Häring
gh at ghaering.de
Di Nov 6 23:39:36 CET 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Daniel Hagemeister-Biernath wrote:
> Hallo,
>
> wenn ich
>
> 1.) in einem Dialog zum Programmstart den Text eines Labels ändern will,
> klappt das nicht so, wie gedacht. Es geht nur, wenn ich das innerhalb der
> setupUi mache.
>
> 2.) ich den WindowTitle z. B. als Reaktion auf einen Klick auf einen Button
> ändern möchte, wird der Titel nicht geändert.
Du suchst glaub ich an der falschen Ecke. Änderungen waren nur in
Ui_test01.py nötig.
> [...]
> ------------------------------------------------------------------------------------------------------------------------
> Ui_test01.py:
>
> # -*- coding: utf-8 -*-
>
> # Form implementation generated from reading ui file
> '/home/daniel/Develop/PyDevel/projects/PyQt4Test/test01.ui'
> #
> # Created: Sun Nov 4 18:21:05 2007
> # by: PyQt4 UI code generator 4.3.1
> #
> # WARNING! All changes made in this file will be lost!
>
> from PyQt4 import QtCore, QtGui
>
> class Ui_Dialog(object):
>
> def setupUi(self, Dialog):
> Dialog.setObjectName("Dialog")
>
> Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,400,300).size()).expandedTo(Dialog.minimumSizeHint()))
>
> self.pushButton = QtGui.QPushButton(Dialog)
> self.pushButton.setGeometry(QtCore.QRect(200,250,76,28))
> self.pushButton.setObjectName("pushButton")
>
> self.label = QtGui.QLabel(Dialog)
> self.label.setGeometry(QtCore.QRect(40,30,271,61))
> self.label.setObjectName("label")
>
> self.retranslateUi(Dialog)
self.mainwindow = Dialog
> QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL("clicked()"),self.on_pushButton_clicked)
> QtCore.QMetaObject.connectSlotsByName(Dialog)
>
> def on_pushButton_clicked(self):
> """
> Slot documentation goes here.
> """
> # TODO: not implemented yet
self.mainwindow.setWindowTitle("TestApp v0.0.1")
return
> raise "Not implemented yet"
> [...]
HTH
- -- Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHMO0odIO4ozGCH14RAjXSAJ97E3u/LkzspjfSEF0Ft+jj+RLRqwCeN98g
UzavQwHVSXTAPgoLUOQudx4=
=3QZd
-----END PGP SIGNATURE-----
Mehr Informationen über die Mailingliste python-de