Thank you, It worked. <br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 10, 2018 at 5:44 AM Maurizio Berti <<a href="mailto:maurizio.berti@gmail.com">maurizio.berti@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Well, it looks like there are some issues in your code.<div><br></div><div>First of all, you should avoid using ls and parsing its output to populate your model. You can use QDir or directly QFileSystemModel.<br>You are connecting to cellClicked within updateUi, which is called only by the updateUiCellClick (hence, the model is never updated, obviously).</div><div>And you are trying to connect it within a for cycle, which would eventually result in the updateUiCellClick being called once for every cycle.</div><div><br></div><div>Also, your syntax in the signal connection is wrong.</div><div>You should use this, and only once:</div><div><br></div><div><font face="monospace, monospace" size="1">self.filesTable.cellClicked.connect(self.updateUiCellClick)</font><br></div><div><br></div><div>Once that's set in the __init__, the signal is fired correctly (but the script will give an error, since the method is incomplete and has other issues).</div><div><br></div><div>Maurizio</div></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">2018-04-10 4:01 GMT+02:00 Python3 Lover <span dir="ltr"><<a href="mailto:kenxshiba@gmail.com" target="_blank">kenxshiba@gmail.com</a>></span>:<br></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I am trying to make a simple files app (or, file explorer app) and I am using the QTableWidget to Display the files and directories. When the user clicks an directory, I want the program to jump to that directory. I have used the QTableWidget.cellClicked signal, and it does not currently work.</div><div><br></div><div>The signal part:</div><div><font face="monospace">self.filesTable.connect(print)#self.updateUiCellClick)</font><br></div><div>Added <font face="monospace">print</font> instead of <font face="monospace">self.updateUiCellClick</font> for debugging purposes.</div><div><font face="monospace"><br></font></div><div>Code (probably you do not need this):</div><div><div><font face="monospace">#!/usr/bin/python3</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">print('i Import Modules')</font></div><div><font face="monospace">print(' | Import sys')</font></div><div><font face="monospace">import sys</font></div><div><font face="monospace">print(' | Import PyQt5.QtCore')</font></div><div><font face="monospace">from PyQt5.QtCore import *</font></div><div><font face="monospace">print(' | Import PyQt5.QtGui')</font></div><div><font face="monospace">from PyQt5.QtGui import *</font></div><div><font face="monospace">print(' | Import PyQt5.QtWidgets')</font></div><div><font face="monospace">from PyQt5.QtWidgets import * # PyQt5 Support</font></div><div><font face="monospace">print(' | Import os')</font></div><div><font face="monospace">import os</font></div><div><font face="monospace">print(' | Import subprocess.Popen') # For backward-compatibility</font></div><div><font face="monospace">from subprocess import Popen, PIPE</font></div><div><font face="monospace">print(' | Done')</font></div><div><font face="monospace">print('i Define class Form')</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">class root(QMainWindow):</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> def __init__(self, parent=None):</font></div><div><font face="monospace"> '''self.__init__ - Initializes QMainWindow'''</font></div><div><font face="monospace"> print(' self.__init__ - Initializes QMainWindow')</font></div><div><font face="monospace"> super(root, self).__init__(parent)</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> # Create Variables</font></div><div><font face="monospace"> self.currentPath = '/'</font></div><div><font face="monospace"> os.chdir(self.currentPath)</font></div><div><font face="monospace"> self.currentItems = os.listdir()</font></div><div><font face="monospace"> self.currentItemsLsProcess = Popen(['ls','-l'], stdout=PIPE, stderr=PIPE)</font></div><div><font face="monospace"> self.currentItemsLsProcessResult = self.currentItemsLsProcess.communicate()</font></div><div><font face="monospace"> if self.currentItemsLsProcessResult[1].decode('utf-8'):</font></div><div><font face="monospace"> QMessageBox.warning(self,'Files - ls -l Error','ls -l responded with non-blank stderr.Error is shown here:<br><code>{}</code><br><hr><br>Error LsStderr (e-lsstderr)<br><hr><br>If you want to support the team, go to the <a href="<a href="https://github.com/" target="_blank">https://github.com/</a>">GitHub Repository</a>.'.format(self.currentItemsLsProcessResult[1].decode('utf-8')))</font></div><div><font face="monospace"> self.currentItemsLs = self.currentItemsLsProcessResult[0].decode('utf-8').split('\n')[1:-1]</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> # Create Table Widget</font></div><div><font face="monospace"> self.filesTable = QTableWidget()</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> # Init Table Widget</font></div><div><font face="monospace"> self.filesTable.clear()</font></div><div><font face="monospace"> self.filesTable.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)</font></div><div><font face="monospace"> self.filesTable.setRowCount(len(self.currentItems))</font></div><div><font face="monospace"> self.filesTable.setColumnCount(4)</font></div><div><font face="monospace"> self.filesTable.setHorizontalHeaderLabels(['Name','TimeStamp','Type','ls -l'])</font></div><div><font face="monospace"> # self.filesTable.setReadOnly(1)</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> # Create & Add Items</font></div><div><font face="monospace"> self.itemWidgets = [[],[],[],[]]</font></div><div><font face="monospace"> for i in range(len(self.currentItems)):</font></div><div><font face="monospace"> self.itemWidgets[0].append(QTableWidgetItem(self.currentItems[i]))</font></div><div><font face="monospace"> self.filesTable.setItem(i,0,self.itemWidgets[0][-1])</font></div><div><font face="monospace"> self.itemWidgets[3].append(QTableWidgetItem(self.currentItemsLs[i]))</font></div><div><font face="monospace"> self.filesTable.setItem(i,3,self.itemWidgets[3][-1])</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> # Init Widgets</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> # Align Widgets to root</font></div><div><font face="monospace"> self.setCentralWidget(self.filesTable)</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> # Signals-and-Slots</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> print('i Set self title')</font></div><div><font face="monospace"> self.setWindowTitle('{}'.format(self.currentPath))</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> def updateUi(self):</font></div><div><font face="monospace"> '''self.updateUi - None'''</font></div><div><font face="monospace"> os.chdir(self.currentPath)</font></div><div><font face="monospace"> self.currentItems = os.listdir()</font></div><div><font face="monospace"> self.currentItemsLsProcess = Popen(['ls','-l'], stdout=PIPE, stderr=PIPE)</font></div><div><font face="monospace"> self.currentItemsLsProcessResult = self.currentItemsLsProcess.communicate()</font></div><div><font face="monospace"> if self.currentItemsLsProcessResult[1].decode('utf-8'):</font></div><div><font face="monospace"> QMessageBox.warning(self,'Files - ls -l Error','ls -l responded with non-blank stderr.Error is shown here:<br><code>{}</code><br><hr><br>Error LsStderr (e-lsstderr)<br><hr><br>If you want to support the team, go to the <a href="<a href="https://github.com/" target="_blank">https://github.com/</a>">GitHub Repository</a>.'.format(self.currentItemsLsProcessResult[1].decode('utf-8')))</font></div><div><font face="monospace"> self.currentItemsLs = self.currentItemsLsProcessResult[0].decode('utf-8').split('\n')[1:-1]</font></div><div><font face="monospace"> self.filesTable.clear()</font></div><div><font face="monospace"> self.filesTable.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)</font></div><div><font face="monospace"> self.filesTable.setRowCount(len(self.currentItems))</font></div><div><font face="monospace"> self.filesTable.setColumnCount(4)</font></div><div><font face="monospace"> self.filesTable.setHorizontalHeaderLabels(['Name','TimeStamp','Type','ls -l'])</font></div><div><font face="monospace"> self.itemWidgets = [[],[],[],[]]</font></div><div><font face="monospace"> for i in range(len(self.currentItems)):</font></div><div><font face="monospace"> self.itemWidgets[0].append(QTableWidgetItem(self.currentItems[i]))</font></div><div><font face="monospace"> self.filesTable.setItem(i,0,self.itemWidgets[0][-1])</font></div><div><font face="monospace"> self.filesTable..connect(print)#self.updateUiCellClick)</font></div><div><font face="monospace"> self.itemWidgets[3].append(QTableWidgetItem(self.currentItemsLs[i]))</font></div><div><font face="monospace"> self.filesTable.setItem(i,3,self.itemWidgets[3][-1])</font></div><div><font face="monospace"> self.filesTable.resizeColumnsToContents()</font></div><div><font face="monospace"> self.setWindowTitle('{}'.format(self.currentPath))</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"> def updateUiCellClick(self, row, column):</font></div><div><font face="monospace"> '''self.updateUiCellClick - None'''</font></div><div><font face="monospace"> print('self.updateUiCellClick - None')</font></div><div><font face="monospace"> self.currentpath += self.itemWidgets[0][row].text+'/'</font></div><div><font face="monospace"> self.updateUi()</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">print(' | Done')</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">if __name__ == '__main__':</font></div><div><font face="monospace"> print('i Execute instance')</font></div><div><font face="monospace"> app = QApplication(sys.argv)</font></div><div><font face="monospace"> root = root()</font></div><div><font face="monospace"> root.show()</font></div><div><font face="monospace"> app.exec_()</font></div><div><font face="monospace"> print(' | Done')</font></div></div><div><font face="monospace"><br></font></div><div>Any help would be appreciated,</div><div>Ken</div><div><br></div></div>
<br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div></div><div class="gmail_extra"><br><br clear="all"><div><br></div>-- <br><div class="m_9205270809522047379gmail_signature" data-smartmail="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div>
</div></blockquote></div>