2 Replies - 1206 Views - Last Post: 27 February 2013 - 10:00 AM Rate Topic: -----

#1 stefanere2k9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 15-November 11

PYQT4 Python problem with buttons

Posted 26 February 2013 - 08:08 AM

I am trying to connect the buttons and keep getting a error AttributeError: 'MyForm' object has no attribute 'stopButton'

here is my python code
import sys
from PyQt4 import QtGui, QtCore
from ui_designer import *

class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        #build parent user interface
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # connecting the buttons
        
        QtCore.QObject.connect(self.ui.exitButton, QtCore.SIGNAL('clicked()'), self.doExit)
        QtCore.QObject.connect(self.ui.scanButton,QtCore.SIGNAL('clicked()'), self.doScan)
        QtCore.QObject.connect(self.ui.stopButton,QtCore.SIGNAL('clicked()'), self.doStop)
                 
if __name__ == "__main__":
	app = QtGui.QApplication(sys.argv)
	myapp = MyForm()
	myapp.show()
	sys.exit(app.exec_())



when i created the button in pyqt 4 i called all the buttons the following exitButton, scanButton, stopButton.

hope someone can help or put me in the right direction :)

Is This A Good Question/Topic? 0
  • +

Replies To: PYQT4 Python problem with buttons

#2 SegFaulty  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 35
  • Joined: 11-October 10

Re: PYQT4 Python problem with buttons

Posted 26 February 2013 - 12:05 PM

Could you please post the ui_designer code as well? It could possibly be a problem in there.
Was This Post Helpful? 0
  • +
  • -

#3 stefanere2k9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 15-November 11

Re: PYQT4 Python problem with buttons

Posted 27 February 2013 - 10:00 AM

yes here my ui code

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'ui_designer.ui'
#
# Created: Tue Feb 26 14:50:39 2013
#      by: PyQt4 UI code generator 4.9.6
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        Mainwindow.setObjectName(_fromUtf8("MainWindow"))
        Mainwindow.resize(500, 333)
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Times New Roman"))
        Mainwindow.setFont(font)
        Mainwindow.setIconSize(QtCore.QSize(50, 50))
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.exitButton = QtGui.QPushButton(self.centralwidget)
        self.exitButton.setGeometry(QtCore.QRect(260, 90, 75, 23))
        self.exitButton.setObjectName(_fromUtf8("exitButton"))
        self.scanButton = QtGui.QPushButton(self.centralwidget)
        self.scanButton.setGeometry(QtCore.QRect(260, 30, 75, 23))
        self.scanButton.setObjectName(_fromUtf8("scanButton"))
        self.stopButton = QtGui.QPushButton(self.centralwidget)
        self.stopButton.setGeometry(QtCore.QRect(260, 60, 75, 23))
        self.stopButton.setObjectName(_fromUtf8("stopButton"))
        self.progressBar = QtGui.QProgressBar(self.centralwidget)
        self.progressBar.setGeometry(QtCore.QRect(260, 170, 101, 16))
        self.progressBar.setProperty("value", 24)
        self.progressBar.setObjectName(_fromUtf8("progressBar"))
        self.fileList = QtGui.QListView(self.centralwidget)
        self.fileList.setGeometry(QtCore.QRect(0, 30, 256, 171))
        self.fileList.setObjectName(_fromUtf8("fileList"))
        self.listView_2 = QtGui.QListView(self.centralwidget)
        self.listView_2.setGeometry(QtCore.QRect(0, 210, 341, 81))
        self.listView_2.setObjectName(_fromUtf8("listView_2"))
        Mainwindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 500, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        Mainwindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        Mainwindow.setStatusBar(self.statusbar)

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

    def retranslateUi(self, MainWindow):
        Mainwindow.setWindowTitle(_translate("MainWindow", "Malware Scanner", None))
        self.exitButton.setText(_translate("MainWindow", "Exit", None))
        self.scanButton.setText(_translate("MainWindow", "Scan", None))
        self.stopButton.setText(_translate("MainWindow", "Stop", None))



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1