"I have made a small app that get data from sqlite3.
I have added a function that moves some data from 1 table to 3 others. All work fine.... But I would like to connect the function with some progress bar to see the status.
so far i have this code
main.py
from PyQt5 import QtCore, QtGui, QtWidgets
import sqlFunctions as Database
import threading
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(600, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
self.progressBar.setGeometry(QtCore.QRect(170, 420, 391, 23))
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(300, 280, 93, 28))
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.pushButton.clicked.connect(self.MoveClientsToThred)
def MoveClientsToThred(self):
threading.Thread(target=self.MoveClientsTo, daemon=True).start()
def MoveClientsTo(self):
Database.MoveClientsToTables("2020")
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "Move Data"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
and my sql functions placed on this file
sqlFunctions.py
import sqlite3
# connect to Db file
connection = sqlite3.connect("mydb.db", check_same_thread=False)
connection.text_factory = lambda b: b.decode(errors='ignore')
def MoveClientsToTables(year):
cursor = connection.cursor()
cursor.execute(f"""SELECT costum_id FROM pelates""")
result = cursor.fetchall()
cursor = connection.cursor()
for i in result:
costum_id = (i[0])
cursor.execute('INSERT INTO Mytable( costum_id, year ) VALUES(?,?) ', (costum_id, year))
connection.commit()
I would like when pushbutton clicked to get percent of proccess
Thank you
Related
I want to get MsgBox after button click. I try to use PyQt5 for it. I make windows form with one button:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(320, 330, 251, 51))
self.pushButton.setObjectName("PushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "PushButton"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Then I try to enter button clicked function:
def buttonClicked(self):
msg = QMessageBox()
msg.setText("This is a message box")
But it doesn't work at all. How should I spent my problem?
Try it:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(320, 330, 251, 51))
self.pushButton.setObjectName("PushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "PushButton"))
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.buttonClicked) # +++
def buttonClicked(self):
msg = QtWidgets.QMessageBox.information(
self,
'Information',
'This is a message box')
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())
You have done well to create the QMessageBox but not shown them, so a possible solution is to use the exec_() method:
def buttonClicked(self):
msg = QMessageBox()
msg.setText("This is a message box")
msg.exec_()
I'm trying to make my PyQt5 GUI in OOP way for example class for window and another for Pushbutton I'm really confiuse how to make it.Here is my code and my try to make pushbutton class.also my goal is to make classes for each of the items in the window
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
#making Pushbutton
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(180, 210, 93, 28))
self.pushButton.setStyleSheet("QPushButton::setCheckable(bool)")
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "PushButton"))
# here I'm trying to make Buttom class
class Button(QtWidgets.QWidget):
def __init__(self, parent=None):
super(Button, self).__init__(parent)
# Main function
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
from Subclassing of QPushButton :
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 6 16:21:24 2020
#author: Pietro
"""
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
#making Pushbutton
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(180, 210, 93, 28))
self.pushButton.setStyleSheet("QPushButton::setCheckable(bool)")
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.pippo=CustomButtonClass(self.centralwidget)
self.pippo.show()
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "PushButton"))
# here I'm trying to make Buttom class
class CustomButtonClass(QtWidgets.QPushButton):
def __init__(self, *args, **kwargs):
QtWidgets.QPushButton.__init__(self,*args, **kwargs)
self.setGeometry(QtCore.QRect(280, 310, 93, 28))
self.setText('customized')
self.hide()
self.setStyleSheet("QPushButton{\n"
" background-color: #9de650;\n"
"}\n"
"\n"
"\n"
"QPushButton:hover{\n"
" background-color: green;\n"
"}\n"
"\n"
"")
# Main function
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
I have 3 programs here, and I have a problem in running those 3 programs because I want it to be all imported to the main file and connected to each other after clicking the buttons on each window. My problem here is that after I have reached the 2nd window, when I click the button there then it doesn't proceed to the last window but instead the window crashes. What would I change in my program so that it will not crash?
s1.py (main program)
from PyQt5 import QtCore, QtGui, QtWidgets
from s4 import *
from s3 import *
class Ui_MainWindow(object):
def ok (self):
self.window=QtWidgets.QMainWindow()
self.ui=Ui_MainWindow2()
self.ui.setup(self.window)
self.window.show()
MainWindow.hide()
def proceed (self):
self.window1=QtWidgets.QMainWindow()
self.ui1=Ui_MainWindow3()
self.ui1.setup1(self.window1)
self.window1.show()
MainWindow2.hide()
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(330, 220, 93, 28))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.ok)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "ok"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
s4.py (2nd program)
from PyQt5 import QtCore, QtGui, QtWidgets
from s3 import *
class Ui_MainWindow2(object):
def proceed (self):
self.window1=QtWidgets.QMainWindow()
self.ui1=Ui_MainWindow3()
self.ui1.setup1(self.window1)
self.window1.show()
MainWindow2.hide()
def setup(self, MainWindow2):
MainWindow2.setObjectName("MainWindow2")
MainWindow2.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow2)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(320, 270, 93, 28))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.proceed)
MainWindow2.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow2)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow2.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow2)
self.statusbar.setObjectName("statusbar")
MainWindow2.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow2)
QtCore.QMetaObject.connectSlotsByName(MainWindow2)
def retranslateUi(self, MainWindow2):
_translate = QtCore.QCoreApplication.translate
MainWindow2.setWindowTitle(_translate("MainWindow2", "MainWindow"))
self.pushButton.setText(_translate("MainWindow2", "PROCEED"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow2 = QtWidgets.QMainWindow()
ui = Ui_MainWindow2()
ui.setup(MainWindow2)
MainWindow2.show()
sys.exit(app.exec_())
s3.py(3rd program)
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow3(object):
def setup1(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(260, 190, 451, 181))
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "THIS IS MY LAST WINDOW"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow3()
ui.setup1(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
from PyQt5 import QtCore, QtGui, QtWidgets
from s4 import Ui_MainWindow2
class Ui_MainWindow(object):
def ok (self):
self.window=QtWidgets.QMainWindow()
self.ui=Ui_MainWindow2()
self.ui.setup(self.window)
self.window.show()
MainWindow.hide()
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(330, 220, 93, 28))
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.pushButton.clicked.connect(self.ok)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "ok"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
and import Ui_MainWindow3 from s3.py into s4 file and call proceed function as well as:
from s3 import Ui_MainWindow3
This question already has an answer here:
PyQT: how to open new window
(1 answer)
Closed 3 years ago.
I want, from my Index.py page, to open several times the page Form.py.
For the moment when i try to open Form a second time the first Form page closes.
There is my Index.py code :
from PyQt5 import QtCore, QtGui, QtWidgets
from Form import Ui_FormWindow
class Ui_MainWindow(object):
#The function to open the Form.py
def open(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_FormWindow()
self.ui.setupUi(self.window)
self.window.show()
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(230, 180, 93, 28))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.open)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "PushButton"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
And here is the page i want to open several times, Form.py :
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_FormWindow(object):
def setupUi(self, FormWindow):
FormWindow.setObjectName("FormWindow")
FormWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(FormWindow)
self.centralwidget.setObjectName("centralwidget")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(250, 190, 113, 22))
self.lineEdit.setObjectName("lineEdit")
FormWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(FormWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
FormWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(FormWindow)
self.statusbar.setObjectName("statusbar")
FormWindow.setStatusBar(self.statusbar)
self.retranslateUi(FormWindow)
QtCore.QMetaObject.connectSlotsByName(FormWindow)
def retranslateUi(self, FormWindow):
_translate = QtCore.QCoreApplication.translate
FormWindow.setWindowTitle(_translate("FormWindow", "FormWindow"))
self.lineEdit.setText(_translate("FormWindow", "Page to open"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
FormWindow = QtWidgets.QMainWindow()
ui = Ui_FormWindow()
ui.setupUi(FormWindow)
FormWindow.show()
sys.exit(app.exec_())
I checked this answer but i don't understand how to make it work in my code.
I also edited my question in order to be a minimal reproducible example but my english is not perfect and i fear to not understand perfectly what i read on the mre tutotial so sorry
I haven't done QT stuff in a while but could it be the fact that you're instancing QtWidgets.QMainWindow again? That'd be my first guess.
I am trying to create a table in PyQt using the QTableView object. My data is stored in a Pandas dataframe.
Here is the code:
from PyQt5 import QtCore, QtGui, QtWidgets
import pandas as pd
cust_data = pd.read_csv('C:\\Users\\utkarsh.a.ranjan\\Documents\\final_datasets\\minimal_data.csv')
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(524, 424)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tableView = QtWidgets.QTableView(self.centralwidget)
self.tableView.setGeometry(QtCore.QRect(60, 20, 411, 351))
self.tableView.setMouseTracking(False)
self.tableView.setObjectName("custData")
self.tableView.setRowCount(cust_data.head().shape[0])
self.tableView.setColumnCount(cust_data.head().shape[1])
for i in range(cust_data.head().shape[0]):
for j in range(cust_data.head().shape[0]):
self.tableWidget.setItem(i,j, QTableWidgetItem(cust_data.iloc[i, j])
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 524, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
if __name__ == "__main__":
import sys
if not QtWidgets.QApplication.instance():
app = QtWidgets.QApplication(sys.argv)
else:
app = QtWidgets.QApplication.instance()
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
I am getting a syntax error in the line just after the for loops. I am failing to spot any syntax issues. If I remove the nested for loops, the error goes away. I am running the code on spyder IDE
You are missing a closing parenthesis at the end of self.tableWidget.setItem(...