Skip to content

Commit

Permalink
fixups & formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzoic committed Mar 27, 2024
1 parent 8e88373 commit 68c0a61
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
5 changes: 4 additions & 1 deletion countess/core/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import importlib.metadata
import logging
import os.path
from collections.abc import Mapping, MutableMapping
from collections.abc import MutableMapping
from typing import Dict, Iterable, List, Optional, Union

import numpy as np
Expand Down Expand Up @@ -660,3 +660,6 @@ def read_file_to_dataframe(self, file_params, logger, row_limit=None) -> pd.Data

class PandasOutputPlugin(PandasProcessPlugin):
num_outputs = 0

def process(self, data: pd.DataFrame, source: str, logger: Logger) -> Iterable[pd.DataFrame]:
raise NotImplementedError(f"{self.__class__}.process")
20 changes: 10 additions & 10 deletions countess/gui/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def set_dataframe(self, dataframe: pd.DataFrame, offset: Optional[int] = 0):
return

title = tk.Label(self.subframe, text=f"Dataframe Preview {len(self.dataframe)} rows")
title.grid(row=0, column=0, columnspan=len(column_names)*2+1, sticky=tk.NSEW, pady=5)
title.grid(row=0, column=0, columnspan=len(column_names) * 2 + 1, sticky=tk.NSEW, pady=5)

### XXX add in proper handling for MultiIndexes here

Expand All @@ -156,17 +156,17 @@ def set_dataframe(self, dataframe: pd.DataFrame, offset: Optional[int] = 0):
image=get_icon(self, "sort_un"),
compound=tk.RIGHT,
)
label.grid(row=1, column=num*2, sticky=tk.EW)
label.grid(row=1, column=num * 2, sticky=tk.EW)
label.bind("<Button-1>", partial(self._label_button_1, num))
self.subframe.columnconfigure(num*2, minsize=10, weight=1)
self.subframe.columnconfigure(num * 2, minsize=10, weight=1)
self.labels.append(label)

# Between them are blank columns which provide a handle for adjusting the column
# widths left and right

for num in range(0, len(column_names)-1):
for num in range(0, len(column_names) - 1):
adjuster = tk.Frame(self.subframe, width=3, cursor="sb_h_double_arrow")
adjuster.grid(row=1, rowspan=2, column=num*2+1, sticky=tk.NSEW)
adjuster.grid(row=1, rowspan=2, column=num * 2 + 1, sticky=tk.NSEW)
adjuster.bind("<B1-Motion>", partial(self._column_adjust, num))

if len(self.dataframe) == 0:
Expand All @@ -176,7 +176,7 @@ def set_dataframe(self, dataframe: pd.DataFrame, offset: Optional[int] = 0):

self.columns = [tk.Text(self.subframe) for _ in column_names]
for num, column in enumerate(self.columns):
column.grid(sticky=tk.NSEW, row=2, column=num*2)
column.grid(sticky=tk.NSEW, row=2, column=num * 2)
column["wrap"] = tk.NONE
column["xscrollcommand"] = partial(self._column_xscrollcommand, num)
column["yscrollcommand"] = self._column_yscrollcommand
Expand All @@ -189,7 +189,7 @@ def set_dataframe(self, dataframe: pd.DataFrame, offset: Optional[int] = 0):
self.columns[0].bind("<Configure>", self._column_configure)

self.scrollbar = ttk.Scrollbar(self.subframe, orient=tk.VERTICAL)
self.scrollbar.grid(sticky=tk.NS, row=2, column=len(self.columns)*2-1)
self.scrollbar.grid(sticky=tk.NS, row=2, column=len(self.columns) * 2 - 1)
self.scrollbar["command"] = self._scrollbar_command
self.refresh(offset)

Expand Down Expand Up @@ -288,9 +288,9 @@ def _label_button_1(self, num, event):
def _column_adjust(self, num, event):
"""Adjust column widths left and right by dragging the dummy columns"""
w0 = self.labels[num].winfo_width()
w1 = self.labels[num+1].winfo_width()
self.subframe.columnconfigure(num*2, minsize=w0 + event.x)
self.subframe.columnconfigure(num*2+2, minsize=w1 - event.x)
w1 = self.labels[num + 1].winfo_width()
self.subframe.columnconfigure(num * 2, minsize=w0 + event.x)
self.subframe.columnconfigure(num * 2 + 2, minsize=w1 - event.x)

def _scrollbar_command(self, command, *parameters):
# Detect scrollbar movement and move self.offset
Expand Down
8 changes: 4 additions & 4 deletions countess/gui/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from countess.core.pipeline import PipelineNode
from countess.gui.widgets import get_icon


def _limit(value, min_value, max_value):
return max(min_value, min(max_value, value))

Expand Down Expand Up @@ -255,20 +256,19 @@ class DraggableLabel(DraggableMixin, FixedUnbindMixin, tk.Label):


class NodeWrapper(DraggableLabel):

def update_node(self, node, vertical=False):
input_bar = node.plugin and node.plugin.num_inputs == 0
output_bar = node.plugin and node.plugin.num_outputs == 0
if not input_bar and not output_bar:
image = None
compound = tk.NONE
elif vertical:
image=get_icon(self, "hbar")
image = get_icon(self, "hbar")
compound = tk.TOP if input_bar else tk.BOTTOM
else:
image=get_icon(self, "vbar")
image = get_icon(self, "vbar")
compound = tk.LEFT if input_bar else tk.RIGHT
self.configure( text=node.name, image=image, compound=compound)
self.configure(text=node.name, image=image, compound=compound)


class GraphWrapper:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ disable = [
"no-else-return",
"too-many-ancestors",
"too-many-arguments",
"too-many-boolean-expressions",
"too-many-branches",
"too-many-instance-attributes",
"too-many-locals",
Expand Down
2 changes: 1 addition & 1 deletion tests/gui/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_chooser():
callback = MagicMock()

root = make_root()
choose = PluginChooserFrame(root, "X", callback)
choose = PluginChooserFrame(root, "X", callback, True, True)

for x in descendants(choose):
if isinstance(x, tk.Button):
Expand Down

0 comments on commit 68c0a61

Please sign in to comment.