Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy entire row #256

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pandastable.egg-info/
pandastable/__pycache__/
examples.egg-info/
examples/__pycache__/
.vscode/
.idea/
21 changes: 14 additions & 7 deletions pandastable/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def __init__(self, parent=None, model=None, dataframe=None,
self.plotted = False
self.importpath = None
self.prevdf = None
self.__last_left_click_src = "column"
return

def close(self, evt=None):
Expand Down Expand Up @@ -3107,14 +3108,17 @@ def getSelectedDataFrame(self):
types to float so that plotting works."""

df = self.model.df
rows = self.multiplerowlist
if not type(rows) is list:
cols, rows = self.multiplecollist, self.multiplerowlist
if not type(rows) is list: # or self.allcols == True:
rows = list(rows)
if len(rows)<1 or self.allrows == True:
rows = list(range(self.rows))
cols = self.multiplecollist
#if len(cols) < 1 or self.allcols == True:
# cols = list(range(self.cols))
if self.__last_left_click_src == "row":
if len(cols) < 1:
cols = list(range(self.cols))
rows = [self.currentrow]
else:
if len(rows) < 1 or self.allrows == True:
rows = list(range(self.rows))
cols = [self.currentcol]
try:
data = df.iloc[rows,cols]
except Exception as e:
Expand Down Expand Up @@ -3726,6 +3730,9 @@ def clearFormatting(self):
self.redraw()
return

def setLeftClickSrc(self, src):
self.__last_left_click_src = src

class ToolBar(Frame):
"""Uses the parent instance to provide the functions"""
def __init__(self, parent=None, parentapp=None):
Expand Down
3 changes: 3 additions & 0 deletions pandastable/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def handle_left_click(self,event):
self.table.drawSelectedCol()
self.table.drawMultipleCells()
self.table.drawMultipleRows(self.table.multiplerowlist)
self.table.setLeftClickSrc("column")
return

def handle_left_release(self,event):
Expand Down Expand Up @@ -647,6 +648,7 @@ def handle_left_click(self, event):
self.table.setSelectedRow(rowclicked)
self.table.drawSelectedRow()
self.drawSelectedRows(self.table.currentrow)
self.table.setLeftClickSrc("row")
return

def handle_left_release(self,event):
Expand Down Expand Up @@ -855,4 +857,5 @@ def redraw(self, align='w'):
def handle_left_click(self, event):
"""Handle mouse left mouse click"""
self.table.selectAll()
self.table.setLeftClickSrc("")
return