Skip to content

Commit

Permalink
plot style pref
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnfarrell committed Oct 2, 2021
1 parent f88cfd7 commit dec8888
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* fix to saving when filtered
* align header labels left
* remember current sheet when saving
* added enlarge/reduce buttons to plotter
* icon size preference
* fix to plot style

-----
0.4.0
Expand Down
11 changes: 7 additions & 4 deletions tablexplore/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def loadSettings(self):
core.COLUMNWIDTH = int(s.value("columnwidth"))
core.TIMEFORMAT = s.value("timeformat")
core.SHOWPLOTTER = util.valueToBool(s.value("showplotter"))
core.PLOTSTYLE = s.value("plotstyle")
core.ICONSIZE = int(s.value("iconsize"))
r = s.value("recent_files")
if r != '':
Expand All @@ -129,6 +130,7 @@ def saveSettings(self):
self.settings.setValue('fontsize', core.FONTSIZE)
self.settings.setValue('timeformat', core.TIMEFORMAT)
self.settings.setValue('showplotter', core.SHOWPLOTTER)
self.settings.setValue('plotstyle', core.PLOTSTYLE)
self.settings.setValue('recent_files',','.join(self.recent_files))
self.settings.setValue('recent_urls','^^'.join(self.recent_urls))
if hasattr(self, 'plotgallery'):
Expand Down Expand Up @@ -566,7 +568,7 @@ def saveMeta(self, tablewidget):
#print (meta['plotviewer'])
#save child table if present
if tablewidget.subtable != None:
meta['subtable'] = tablewidget.subtable.table.model.df
meta['subtable'] = tablewidget.subtable.table.model.df

return meta

Expand Down Expand Up @@ -710,13 +712,14 @@ def addSheet(self, name=None, df=None, meta=None):
dfw = DataFrameWidget(sheet, dataframe=df, app=self,
font=core.FONT, fontsize=core.FONTSIZE,
columnwidth=core.COLUMNWIDTH, timeformat=core.TIMEFORMAT)
sheet.addWidget(dfw)

sheet.addWidget(dfw)
self.sheets[name] = dfw
self.currenttable = dfw
pf = dfw.createPlotViewer(sheet)
sheet.addWidget(pf)
sheet.setSizes((500,1000))
pf.generalopts.setWidgetValue('style', core.PLOTSTYLE)
#pf.applyPlotoptions()
#reload attributes of table and plotter if present
if meta != None:
self.loadMeta(dfw, meta)
Expand Down Expand Up @@ -1088,7 +1091,7 @@ def preferences(self):

from . import dialogs
opts = {'font':core.FONT, 'fontsize':core.FONTSIZE, 'showplotter': core.SHOWPLOTTER,
'iconsize':core.ICONSIZE,
'iconsize':core.ICONSIZE, 'plotstyle':core.PLOTSTYLE,
'columnwidth':core.COLUMNWIDTH, 'timeformat':core.TIMEFORMAT}
dlg = dialogs.PreferencesDialog(self, opts)
dlg.exec_()
Expand Down
11 changes: 11 additions & 0 deletions tablexplore/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
ROWHEIGHT = 20
SHOWPLOTTER = True
ICONSIZE = 26
PLOTSTYLE = 'default'

try:
_fromUtf8 = QtCore.QString.fromUtf8
Expand Down Expand Up @@ -1384,6 +1385,16 @@ def getSelectedDataFrame(self):
cols = list(dict.fromkeys(cols).keys())
return df.iloc[rows,cols]

def setSelected(self, row, col):
"""Set selection programmatically"""


top = self.model.index(row, 0)
lower = self.model.index(row, col)
selection = QItemSelection(top, lower)
self.selectionModel().select(selection, SelectionFlag.ClearAndSelect)
return

def handleDoubleClick(self, item):

cellContent = item.data()
Expand Down
29 changes: 18 additions & 11 deletions tablexplore/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ def __init__(self, parent, options={}):
super(PreferencesDialog, self).__init__(parent)
self.parent = parent
self.setWindowTitle('Preferences')
self.resize(700, 200)
self.resize(450, 200)
self.setGeometry(QtCore.QRect(300,300, 600, 200))
self.setMaximumWidth(600)
self.setMaximumHeight(300)
Expand All @@ -1169,22 +1169,28 @@ def createWidgets(self, options):
'%d-%b-%Y','%b-%d-%Y',
'%Y-%m-%d %H:%M:%S','%Y-%m-%d %H:%M',
'%d-%m-%Y %H:%M:%S','%d-%m-%Y %H:%M']
self.opts = {'rowheight':{'type':'spinbox','default':18,'range':(5,50),'label':'row height'},
'columnwidth':{'type':'spinbox','range':(10,300),
'default': options['columnwidth'], 'label':'column width'},
'alignment':{'type':'combobox','default':'w','items':['left','right','center'],'label':'text align'},
plotstyles = ['','default', 'classic', 'fivethirtyeight',
'seaborn-pastel','seaborn-whitegrid', 'ggplot','bmh',
'grayscale','dark_background']
self.opts = {'rowheight':{'type':'spinbox','default':18,'range':(5,50),'label':'Row height'},
#'columnwidth':{'type':'spinbox','range':(10,300),
#'default': options['columnwidth'], 'label':'column width'},
'alignment':{'type':'combobox','default':'w','items':['left','right','center'],'label':'Text Align'},
'font':{'type':'font','default':defaultfont,'default':options['font']},
'fontsize':{'type':'spinbox','default':options['fontsize'],'range':(5,40),
'interval':1,'label':'font size'},
'timeformat':{'type':'combobox','default':options['timeformat'],
'items':timeformats,'label':'Date/Time format'},
'showplotter': {'type':'checkbox','default':bool(options['showplotter']), 'label':'show plotter'},
'iconsize':{'type':'spinbox','default':options['iconsize'],'range':(16,64), 'label':'icon size'},
'showplotter': {'type':'checkbox','default':bool(options['showplotter']), 'label':'Show Plotter'},
'plotstyle':{'type':'combobox','default':options['plotstyle'],
'items':plotstyles,'label':'Plot Style'},
'iconsize':{'type':'spinbox','default':options['iconsize'],'range':(16,64), 'label':'Icon Size'},
#'floatprecision':{'type':'spinbox','default':2, 'label':'precision'},
}
sections = {'table':['alignment','rowheight','columnwidth'],
'view':['iconsize','showplotter'],
'formats':['font','fontsize','timeformat']}
sections = {'table':['alignment','rowheight',#'columnwidth',
'font','fontsize','timeformat'],
'view':['iconsize','plotstyle','showplotter']
}

dialog, self.widgets = dialogFromOptions(self, self.opts, sections)

Expand Down Expand Up @@ -1214,9 +1220,10 @@ def apply(self):
from . import core
core.FONT = kwds['font']
core.FONTSIZE = kwds['fontsize']
core.COLUMNWIDTH = kwds['columnwidth']
#core.COLUMNWIDTH = kwds['columnwidth']
core.TIMEFORMAT = kwds['timeformat']
core.SHOWPLOTTER = kwds['showplotter']
core.PLOTSTYLE = kwds['plotstyle']
core.ICONSIZE = kwds['iconsize']
self.parent.refresh()
self.parent.applySettings()
Expand Down
2 changes: 1 addition & 1 deletion tablexplore/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ def _doplot(self, data, ax, kind, axes_layout, errorbars, useindex, bw, yerr,
def setStyle(self):
"""Apply style"""

if self.style == None:
if self.style == None or self.style == '':
mpl.rcParams.update(mpl.rcParamsDefault)
else:
plt.style.use(self.style)
Expand Down

0 comments on commit dec8888

Please sign in to comment.