adamerose / PandasGUI

A GUI for Pandas DataFrames
MIT No Attribution
3.19k stars 233 forks source link

Output signal and specified cell contents when a row is clicked, and make possible to embed in a section of a PYQT5 main window #161

Open Animalwithstix opened 3 years ago

Animalwithstix commented 3 years ago

Hello, I first want to thank you for a great tool, which has made things much easier for a project I am working on. There is a feature in PyQt5 QTableView that I am hoping can be implemented in pandas gui, if it is not already. In QTableView I can set it so that when I click anywhere in a row, it will highlight the whole row like a big single button and it will return the contents of the cell in a particular pre-set column, which I can then use as a variable for further searching. for example: if I have a dataframe in a table with 5 rows and 3 columns, titled A, B, C, I can click on any row have have it return only what is in column B.

adamerose commented 3 years ago

In QTableView I can set it so that when I click anywhere in a row, it will highlight the whole row like a big single button and it will return the contents of the cell in a particular pre-set column, which I can then use as a variable for further searching.

I don't understand this - could you link to an example or give a code snippet to demo it? Specifically I'm not sure what "return" means in the context of a GUI widget

Animalwithstix commented 3 years ago

Hey,

I will try to explain better, but first here is the code I use: self.table.setSelectionBehavior(QtWidgets.QTableView.SelectRows) self.table.selectionModel().selectionChanged.connect(self.selectionChanged) def selectionChanged(self, selected, deselected): index = (self.table.selectionModel().currentIndex()) print(index) value = index.siblingAtColumn(4).data() object_id = value print(object_id) request.get(base_url + value) I originally search an API and get results back as a JSON, which I turn into a dataframe and format, and then use the show(df) so that the table gets displayed in pandasgui. So the pandasgui window is showing a table and let's say it has 5 rows and 3 columns. The columns are “object”, “id”, “type”. When I select the row I want I can get the contents of the “id” column only, or the contents of the “id” and “type” column. When I say RETURN I mean being able to use the contents of the selected row and specified column and not just printed to the python console.

Here is a YouTube video explaining it: https://www.youtube.com/watch?v=BH19o9GlN20 https://www.youtube.com/watch?v=BH19o9GlN20

One other thing is that when I show a Dataframe with pandasgui, the style of my MainWindow changes to match the style of the pandasgui window. Is there any way to avoid this? I am using pyqt5 and my main window is coded in “class MainWindow(QWidget):”

Once pandasgui is working with pyside6, I am going to switch over to that.

Thanks so much!

On Jul 22, 2021, at 12:12 PM, Adam Rose @.***> wrote:

In QTableView I can set it so that when I click anywhere in a row, it will highlight the whole row like a big single button and it will return the contents of the cell in a particular pre-set column, which I can then use as a variable for further searching.

I don't understand this - could you link to an example or give a code snippet to demo it? Specifically I'm not sure what "return" means in the context of a GUI widget

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/adamerose/PandasGUI/issues/161#issuecomment-885166522, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOQDZZDKI5HK4W64PJR52QTTZBUS3ANCNFSM5A2TOSBA.