18.06.121414
Python & Qt-Designer 3
Home Impressum Tipps auf wlsoft.de www.wlsoft.de
Programmieren weil es Spa├č macht.
Hardware
Matrox-Grafikkarte
Nvidia-Grafikkarte
DVD-RAM
Scanner UMAX Astra 1220U
Externe Festplatte 500GB

Offene Fragen
VAIO VGN-CR11Z
Chemnitzer Linuxtage 2008

Tipps
Kernel-Update
Samba Installation
Samba Tipps
W2K und Linux
Vista und Linux
Port 113
Grub
fstab
VMware
Thunderbird
CapiSuite
VNC-Server
Bluetooth
Softmaker
Kopierer
Fotos
Soundprobleme
Antivirus-ClamAV
KDE Tipps
apt-get
Superkaramba
Firefox
Lazarus
Backup
Recoll
gpg
hibiscus
cups
Netzwerk
Rechteverwaltung
Dienste (daemons)
Firefox und Akregator
apt-proxy

Dateisysteme

Shell-Befehle
Fehlersuche
Fehlersuche fsck
Screenshots erstellen

meine Programme
wnfDesktopkalender
meine Scripte

EEE-PC
Tipps zum EEE-PC

NetBeans
Installation
HelloWorld
HelloWorld-2
Wichtige Dateien
Tipps
Jaybird

CrossKylix
Tipps

Drupal
Tipps

Python
Python & Qt-Designer 3
Python & Qt-Designer 4
Python & KDevelop
Python & Apache
Tipps
CherryPy
Ausprobiert am 22.06.2008 unter Ubuntu 8.04

Mit designer (QT Designer) habe ich mir einen sch÷nen Dialog gebastelt der als am_main.ui abgespeichert wurde.
$ designer-qt3

Damit der Dialog in Python verwendet werden kann muss er in eine Python-Klasse gewandelt werden.
$ pyuic -o am_main.py  am_main.ui

Hier die Datei am_main.py
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'am_main.ui'
#
# Created: So Jun 22 14:40:15 2008
#      by: The PyQt User Interface Compiler (pyuic) 3.17.4
#
# WARNING! All changes made in this file will be lost!


from qt import *


class MyDialog(QDialog):
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):
        QDialog.__init__(self,parent,name,modal,fl)

        if not name:
            self.setName("MyDialog")

        self.setSizeGripEnabled(1)


        LayoutWidget = QWidget(self,"Layout1")
        LayoutWidget.setGeometry(QRect(20,240,476,33))
        Layout1 = QHBoxLayout(LayoutWidget,0,6,"Layout1")

        self.buttonHelp = QPushButton(LayoutWidget,"buttonHelp")
        self.buttonHelp.setAutoDefault(1)
        Layout1.addWidget(self.buttonHelp)
        Horizontal_Spacing2 = QSpacerItem(20,20,
           QSizePolicy.Expanding,QSizePolicy.Minimum)
        Layout1.addItem(Horizontal_Spacing2)

        self.buttonOk = QPushButton(LayoutWidget,"buttonOk")
        self.buttonOk.setAutoDefault(1)
        self.buttonOk.setDefault(1)
        Layout1.addWidget(self.buttonOk)

        self.buttonCancel = QPushButton(LayoutWidget,"buttonCancel")
        self.buttonCancel.setAutoDefault(1)
        Layout1.addWidget(self.buttonCancel)

        self.languageChange()

        self.resize(QSize(511,282).expandedTo(self.minimumSizeHint()))
        self.clearWState(Qt.WState_Polished)

        self.connect(self.buttonOk,SIGNAL("clicked()"),self.accept)
        self.connect(self.buttonCancel,SIGNAL("clicked()"),self.reject)


    def languageChange(self):
        self.setCaption(self.__tr("MyDialog"))
        self.buttonHelp.setText(self.__tr("&Help"))
        self.buttonHelp.setAccel(QKeySequence(self.__tr("F1")))
        self.buttonOk.setText(self.__tr("&OK"))
        self.buttonOk.setAccel(QKeySequence(QString.null))
        self.buttonCancel.setText(self.__tr("&Cancel"))
        self.buttonCancel.setAccel(QKeySequence(QString.null))


    def __tr(self,s,c = None):
        return qApp.translate("MyDialog",s,c)

Und hier das Programm das den Dialog aufruft:
#!/usr/bin/env python
import sys
from qt import *
from am_main import MyDialog as Dlg

class Download_Dlg(Dlg):
    def __init__(self):
        Dlg.__init__(self)

if __name__ == '__main__':
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL('lastWindowClosed()'),a,SLOT('quit()'))
    w = Download_Dlg()
    a.setMainWidget(w)
    w.show()
    a.exec_loop()

gunther logo  Letzte Änderung: 18.06.121414 - 00:00:00