Skip to content

Commit

Permalink
fixes and snap re-added
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnfarrell committed Feb 23, 2020
1 parent 44ccbdd commit f782337
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Added editable parameter to Table
Added enable_menus parameter
Option to import numbers as string
Changed to pickle for dataexplore project files
Fixes to syncing of rowcolors

------
0.12.1
Expand Down
6 changes: 6 additions & 0 deletions gui/dataexplore.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Name=DataExplore
Exec=dataexplore
Type=Application
Icon=${SNAP}/meta/gui/icon.png
Categories=Education;
Binary file modified img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pandastable/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,13 @@ def loadProject(self, filename=None, asksave=False):
if ext != '.dexpl':
print ('does not appear to be a project file')
return
if os.path.isfile(filename):
if os.path.isfile(filename):
#new format uses pickle
try:
data = pickle.load(gzip.GzipFile(filename, 'r'))
except:
data = pd.read_msgpack(filename)
print ('your file is using the old format.')
print ('WARNING: your file is using the old format.')
#create backup file before we change anything
#backupfile = filename+'.bak'
#pd.to_msgpack(backupfile, data, encoding='utf-8')
Expand Down
47 changes: 33 additions & 14 deletions pandastable/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ def colorRows(self):
rows = self.visiblerows
offset = rows[0]
idx = df.index[rows]
#diff = df.index.difference(rc.index)
#print (diff)
#print (rc)
for col in self.visiblecols:
colname = df.columns[col]
if colname in list(rc.columns):
Expand Down Expand Up @@ -607,7 +610,8 @@ def setRowColors(self, rows=None, clr=None, cols=None):
for c in colnames:
if c not in rc.columns:
rc[c] = pd.Series(np.nan,index=df.index)
rc[c][idx] = clr
#rc[c][idx] = clr
rc.at[idx,c] = clr
self.redraw()
return

Expand Down Expand Up @@ -805,12 +809,12 @@ def sortTable(self, columnIndex=None, ascending=1, index=False):
columnIndex = 0
if isinstance(columnIndex, int):
columnIndex = [columnIndex]

if index == True:
df.sort_index(inplace=True)
else:
colnames = list(df.columns[columnIndex])
try:
else:
colnames = list(df.columns[columnIndex])
try:
df.sort_values(by=colnames, inplace=True, ascending=ascending)
except Exception as e:
print('could not sort')
Expand Down Expand Up @@ -872,6 +876,7 @@ def resetIndex(self, ask=True):
#self.drawSelectedCol()
if hasattr(self, 'pf'):
self.pf.updateData()
self.update_rowcolors()
self.tableChanged()
return

Expand Down Expand Up @@ -929,16 +934,26 @@ def set_rowcolors_index(self):
self.rowcolors.set_index(df.index, inplace=True)

def update_rowcolors(self):
"""Update row colors if present"""
"""Update row colors if present so that it syncs with current dataframe."""

df = self.model.df
rc = self.rowcolors
if len(df) == len(self.rowcolors):
self.rowcolors.set_index(df.index, inplace=True)
elif len(df)>len(self.rowcolors):
idx = df.index.difference(self.rowcolors.index)
self.rowcolors = self.rowcolors.append(pd.DataFrame(index=idx))

#print (self.rowcolors)
rc.set_index(df.index, inplace=True)
elif len(df)>len(rc):
idx = df.index.difference(rc.index)
self.rowcolors = rc.append(pd.DataFrame(index=idx))
else:
idx = rc.index.difference(df.index)
rc.drop(idx,inplace=True)
#check columns
cols = list(rc.columns.difference(df.columns))
if len(cols)>0:
rc.drop(cols,1,inplace=True)
cols = list(df.columns.difference(rc.columns))
if len(cols)>0:
for col in cols:
rc[col] = np.nan
return

def set_xviews(self,*args):
Expand Down Expand Up @@ -977,9 +992,9 @@ def addRows(self, num=None):
return
self.storeCurrent()
keys = self.model.autoAddRows(num)
self.update_rowcolors()
self.redraw()
self.tableChanged()
self.update_rowcolors()
return

def addColumn(self, newname=None):
Expand Down Expand Up @@ -1008,6 +1023,7 @@ def addColumn(self, newname=None):
self.storeCurrent()
self.model.addColumn(newname, dtype)
self.parentframe.configure(width=self.width)
self.update_rowcolors()
self.redraw()
self.tableChanged()
return
Expand All @@ -1025,6 +1041,7 @@ def deleteRow(self):
self.model.deleteRows(rows)
self.setSelectedRow(0)
self.clearSelected()
self.update_rowcolors()
self.redraw()
else:
n = messagebox.askyesno("Delete",
Expand All @@ -1036,6 +1053,7 @@ def deleteRow(self):
self.model.deleteRows([row])
self.setSelectedRow(row-1)
self.clearSelected()
self.update_rowcolors()
self.redraw()
return

Expand All @@ -1061,6 +1079,7 @@ def deleteColumn(self):
cols = self.multiplecollist
self.model.deleteColumns(cols)
self.setSelectedCol(0)
self.update_rowcolors()
self.redraw()
#self.drawSelectedCol()
self.tableChanged()
Expand Down Expand Up @@ -3500,7 +3519,7 @@ def saveAs(self, filename=None):
"""Save dataframe to file"""

if filename == None:
filename = filedialog.asksaveasfilename(parent=self.master,
filename = filedialog.asksaveasfilename(parent=self.master,
initialdir = self.currentdir,
filetypes=[("pickle","*.pickle"),
("All files","*.*")])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'datasets/*.csv',
'plugins/*.py','plugins/*.R']},
install_requires=['matplotlib>=2.0',
'pandas>=0.21',
'pandas>=0.24',
'numexpr>=2.4',
'xlrd>=0.9',
'future'],
Expand Down
43 changes: 43 additions & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: dataexplore
version: '0.12.2'
#version-script: git describe --abbrev=1 --tags
summary: data plotting and analysis package
description: |
DataExplore is an open source desktop application for data analysis and plotting
intended for use in both research and education. The program allows quick
visualization of data, table manipulation tools and supports large data tables.
base: core18
grade: stable
confinement: strict
icon: img/logo.png
#adopt-info: dataexplore

apps:
dataexplore:
command: desktop-launch $SNAP/bin/dataexplore
plugs: [desktop,desktop-legacy,unity7,home]

parts:
dataexplore:
plugin: python
python-version: python3
source: .
stage-packages:
[python3-tk,xsel,fontconfig-config,fonts-freefont-ttf,ttf-ubuntu-font-family,
fonts-liberation,ttf-dejavu-core,ttf-mscorefonts-installer]
after: [desktop-glib-only]

# files: #to deal with problem finding init.tcl
# plugin: dump
# source: /usr/share/tcltk/
# organize:
# '*': ./usr/lib/
desktop-glib-only:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: glib-only
plugin: make
build-packages:
- libglib2.0-dev
stage-packages:
- libglib2.0-bin

0 comments on commit f782337

Please sign in to comment.