hey all I've searched all over the web and i didn't get a solution!
what should i do to take the text from the 'urlT' line edit? is there another way?
Nameerror
"global name 'self' is not defined"
whats wrong with it?

from PyQt4 import QtCore, QtGui

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.setWindowModality(QtCore.Qt.NonModal)
        MainWindow.resize(640, 483)
        MainWindow.setMinimumSize(QtCore.QSize(640, 483))
        MainWindow.setMaximumSize(QtCore.QSize(640, 483))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/logo/welcome-logo.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        MainWindow.setWindowIcon(icon)
        MainWindow.setTabShape(QtGui.QTabWidget.Triangular)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.urlT = QtGui.QLineEdit(self.centralwidget)
        self.urlT.setEnabled(True)
        self.urlT.setGeometry(QtCore.QRect(10, 20, 521, 27))
        self.urlT.setObjectName("urlT")
        self.checkurlB = QtGui.QPushButton(self.centralwidget)
        self.checkurlB.setGeometry(QtCore.QRect(540, 20, 91, 27))
        self.checkurlB.setObjectName("checkurlB")



        QtCore.QObject.connect(self.checkurlB, QtCore.SIGNAL("clicked()"), checkurl())
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

def checkurl():
    import urllib2

    url=str(self.urlT.text()) #the error line
    try:
        response = urllib2.urlopen(url)
    except URLError,  e:
        #pass or do something
        pass

The way you wrote it, checkurl() is not a method of Ui_MainWindow class, but a standalone function. Give it a proper indentation.

There is no way to tell without a complete error message which the contains the errant line. Also, do you instantiate the class and then call the setupUI function with a parameter? As the code stands now, nothing will happen even if the code does not contain errors.

@woooee : the error line as i said is

url=str(self.urlT.text())

and for sure

if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

:)
@nezachem: then the 'self' defined in the class only!
thanks a lot it worked perfectly :)

i didn't post this post O.o is my account hacked or something !!?? O.o

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.