Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8088095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:59:23+00:00 2026-06-05T18:59:23+00:00

I’m creating a User Interface using PyQt4 module . the problem i’am facing is

  • 0

I’m creating a User Interface using PyQt4 module . the problem i’am facing is that i’m not able to access “self.ftp_tableWidget” variable

class Ui_MainWindow(object):
def setupUi(self, MainWindow):
    MainWindow.setObjectName(_fromUtf8("MainWindow"))
    MainWindow.resize(790, 610)
    self.FTP = QtGui.QWidget()
    self.FTP.setObjectName(_fromUtf8("FTP"))
    self.ftp_tableWidget = QtGui.QTableWidget(self.FTP)
    self.ftp_tableWidget.setGeometry(QtCore.QRect(40, 90, 411, 192))
    self.ftp_tableWidget.setMinimumSize(QtCore.QSize(331, 0))
    self.ftp_tableWidget.setObjectName(_fromUtf8("ftp_tableWidget"))
    self.ftp_tableWidget.setColumnCount(2)
    self.ftp_tableWidget.setRowCount(31)
    item = QtGui.QTableWidgetItem()
    self.ftp_tableWidget.setHorizontalHeaderItem(0, item)
    item = QtGui.QTableWidgetItem()
    self.ftp_tableWidget.setHorizontalHeaderItem(1, item)
    self.update_table()

This where the ftp_tableWidget is intialized.

  def update_table(self):
    cursor.execute('''SELECT MAX(SNO) FROM ftp_auth_table1''')
    entry=cursor.fetchall()
    entry=entry[0]
    count=entry[0]
    self.ftp_tableWidget.setRowCount(count)
    cursor.execute('''SELECT * FROM ftp_auth_table1''')
    entry=cursor.fetchall()

This is the code that updates the table widget.

 def adding(self):
    self.msg=add_to()
    self.msg.show()

This piece of code is calling a class which adds data to the database.

class add_to(QtGui.QDialog,Ui_MainWindow):
def __init__(self):
    super(add_to,self).__init__()
    Ui_MainWindow.__init__(self)

This piece of code is initializes the class which appends data to the database and calls the update_table function to update the table widget .

This the Error that im getting

    self.ftp_tableWidget.setRowCount(count)
    AttributeError: 'add_to' object has no attribute 'ftp_tableWidget'  

specs :
im using python 2.7 and PyQt4 module .

after editing the code according to the answere given by “notbad jpeg”:
class Ui_MainWindow(object):
def init(self,mainwindow):
self.setupUi(mainwindow)
def setupUi(self, MainWindow):

this is giving me a problem :

class add_to(QtGui.QDialog,Ui_MainWindow):
   def __init__(self):
    super(add_to,self).__init__()
    self.window=QtGui.QMainWindow()
    self.MainWindow=Ui_MainWindow(self.window)
    Ui_MainWindow.__init__(self,self.MainWindow)

this gives an error:

MainWindow.setObjectName(_fromUtf8("MainWindow"))
AttributeError: 'Ui_MainWindow' object has no attribute 'setObjectName'

Pls can anyone help Me .

Thanx in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:59:24+00:00Added an answer on June 5, 2026 at 6:59 pm

    That comment is stating your problem. You need to add an __init__() method to your Ui_MainWindow class that calls self.setupUi()so that everything in your setupUi() gets called right away when you call super().

    Edit: So now that you changed your code a bit and you’re getting the __init__() takes two arguments error, I looked around and saw your inline code that shows that you need to pass a MainWindow argument to your Ui_MainWindow.__init__(self, MainWindow). And then, pass that MainWindow to your setupUi method.

    Edit #2: Change

    class add_to(QtGui.QDialog,Ui_MainWindow):
       def __init__(self):
           super(add_to,self).__init__()
           self.window=QtGui.QMainWindow()
           self.MainWindow=Ui_MainWindow(self.window)
           Ui_MainWindow.__init__(self,self.MainWindow)
    

    to…

    class add_to(QtGui.QDialog,Ui_MainWindow):
       def __init__(self):
           super(add_to,self).__init__()
           self.window=QtGui.QMainWindow()
           self.MainWindow=Ui_MainWindow(self.window)
    

    The call to Ui_MainWindow.__init__() was redundant, since it gets called automatically when you create and instance of the class: self.MainWindow=Ui_MainWindow(self.window). Plus, you were passing an instance of itself as an argument to itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.