How to link two Windows in pyqt5?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
Good night. Don't understand how to implement this in pyqt5:
There is the initial code:

The main window

# -*- coding: utf-8 -*- # Form implementation generated from reading ui file './main_gui.ui' # # Created by: PyQt5 UI code generator 5.10.1 # # WARNING! All changes made in this file will be lost! 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.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(680, 0, 121, 51)) self.label.setBaseSize(QtCore.QSize(4, 5)) self.label.setStyleSheet("font: 24pt \\".SF NS Text\\";") self.label.setObjectName("label") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(330, 230, 113, 32)) self.pushButton.setObjectName("pushButton") self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_2.setGeometry(QtCore.QRect(0, 0, 113, 32)) self.pushButton_2.setObjectName("pushButton_2") self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_3.setGeometry(QtCore.QRect(330, 270, 113, 32)) self.pushButton_3.setObjectName("pushButton_3") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22)) self.menubar.setObjectName("menubar") self.menuFile = QtWidgets.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.toolBar = QtWidgets.QToolBar(MainWindow) self.toolBar.setObjectName("toolBar") MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) self.actionOpen = QtWidgets.QAction(MainWindow) self.actionOpen.setObjectName("actionOpen") self.actionOpen_2 = QtWidgets.QAction(MainWindow) self.actionOpen_2.setObjectName("actionOpen_2") self.menuFile.addAction(self.actionOpen_2) self.menubar.addAction(self.menuFile.menuAction()) self.retranslateUi(MainWindow) self.pushButton_2.clicked.connect(MainWindow.close) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.label.setText(_translate("MainWindow", "Twitter")) self.pushButton.setText(_translate("MainWindow", "Start")) self.pushButton_2.setText(_translate("MainWindow", "Quit")) self.pushButton_3.setText(_translate("MainWindow", "Open CSV")) self.menuFile.setTitle(_translate("MainWindow", "File")) self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar")) self.actionOpen.setText(_translate("MainWindow", "Open")) self.actionOpen_2.setText(_translate("MainWindow", "Open"))

Add the event on the button
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QCalendarWidget, QFontDialog, QColorDialog, QTextEdit, QFileDialog, QTableWidgetItem, QTableWidget, QMainWindow import sys import os import csv from Desktop.main_gui import Ui_MainWindow from Twitter.twitter import AppTwitter class GuiTwitter(Ui_MainWindow): def main(self): self.pushButton.clicked.connect(AppTwitter) self.pushButton_3.clicked.connect(Sheet) class MyTable(QTableWidget): def open_sheet(self): path = QFileDialog.getOpenFileName(self, 'Open CSV', os.getenv('Diplom'), 'CSV(*.csv)') if path[0] != ": with open(path[0], newline=", encoding='UTF-8') as csv_file: self.setRowCount(0) self.setColumnCount(30) my_file = csv.reader(csv_file, delimiter=',', quotechar='|') for row_data in my_file: row = self.rowCount() self.insertRow(row) if len(row_data) > 30: self.setColumnCount(len(row_data)) for column, stuff in enumerate(row_data): item = QTableWidgetItem(stuff) self.setItem(row, column, item) class Sheet(QMainWindow): def __init__(self): super().__init__() self.form_widget = MyTable(30, 30) self.setCentralWidget(self.form_widget) self.form_widget.open_sheet() if __name__ == '__main__': import sys app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = GuiTwitter() ui.setupUi(MainWindow) ui.main() sys.exit(app.exec_())

Actually here I have a question.
Class GuiTwitter originally contained only a click of a pushButton ( not + pushButton_3).
Class MyTable / Sheet serve to open the system window and correctly display csv files.
Actually with them and the problem. I don't understand how to implement
Program is launched, the main window, click on the Open CSV - Choose the file - Displays table and CSV. Here is a table and not displayed. I understand that it is inserted correctly, because of this, and asking for help.

Took it originally from here
by | 21 views

1 Answer

0 like 0 dislike
def getfiles(self): global fname fname = QFileDialog.getOpenFileName(self, "Open a PNG", f"{cwd}/", "PNG (*.png);;GIF (*.gif);;JPG (*.jpg *.jpe *.JPEG );;TIFF (*.tiff);;All (*)")[0] if fname == ": QFileDialog(self, quit()) with open(fname, 'rb') as data: self.ui.mylabel_2.setScaledContents(True) self.ui.mylabel.setText(f"File: {fname}") self.ui.mylabel_2.setPixmap(QtGui.Qpixmaps(f"{fname}"))

And so(third line) is displayed.
cwd - variable with the path.
For example:
cwd = os.path.expanduser('~')

Related questions

0 like 0 dislike
1 answer
asked Apr 12, 2019 by TchernyavskyDaniil
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
asked Aug 12, 2019 by Bruceee
0 like 0 dislike
2 answers
asked Jul 14, 2019 by Bruceee
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
35,573 users