Skip to content

Commit

Permalink
Fixing flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
slightlynybbled committed Jan 29, 2018
1 parent 1876923 commit ba6ca8a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 44 deletions.
19 changes: 12 additions & 7 deletions tk_tools/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def __init__(self, parent, size=100, **options):

def to_absolute(self, x, y):
"""
Converts coordinates provided with reference to the center of the
canvas (0, 0) to absolute coordinates which are used by the canvas
object in which (0, 0) is located in the top left of the object.
Converts coordinates provided with reference to the center \
of the canvas (0, 0) to absolute coordinates which are used \
by the canvas object in which (0, 0) is located in the top \
left of the object.
:param x: x value in pixels
:param y: x value in pixels
Expand Down Expand Up @@ -72,7 +73,8 @@ class RotaryScale(Dial):
:param size: the size in pixels
:param options: the frame options
"""
def __init__(self, parent, max_value: (float, int)=100.0, size: (float, int)=100,
def __init__(self, parent,
max_value: (float, int)=100.0, size: (float, int)=100,
unit: str=None, img_data: str=None,
needle_color='blue', needle_thickness=0,
**options):
Expand Down Expand Up @@ -104,7 +106,8 @@ def set_value(self, number: (float, int)):
"""
Sets the value of the graphic
:param number: the number (must be between 0 and 'max_range' or the scale will peg the limits
:param number: the number (must be between 0 and \
'max_range' or the scale will peg the limits
:return: None
"""
self.canvas.delete('all')
Expand Down Expand Up @@ -290,7 +293,8 @@ def plot_line(self, points: list, color='black', point_visibility=False):
:param points: a list of tuples, each tuple containing an (x, y) point
:param color: the color of the line
:param point_visibility: True if the points should be individually visible
:param point_visibility: True if the points \
should be individually visible
:return: None
"""
last_point = ()
Expand All @@ -311,7 +315,8 @@ def frange(start, stop, step, digits_to_round=3):
:param start: starting value
:param stop: ending value
:param step: the increment
:param digits_to_round: the digits to which to round (makes floating-point numbers much easier to work with)
:param digits_to_round: the digits to which to round \
(makes floating-point numbers much easier to work with)
:return: generator
"""
while start < stop:
Expand Down
55 changes: 18 additions & 37 deletions tk_tools/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@

# add this for sphinx autodoc to function properly
try:
from tk_tools.tkcalendar import Calendar
from tk_tools.tkcalendar import Calendar as DatePicker
except ImportError:
from tkcalendar import Calendar
from tkcalendar import Calendar as DatePicker


class Calendar(DatePicker):
pass


class Grid(tk.Frame):
padding = 3

r"""
Creates a grid of widgets (intended to be subclassed).
:param parent: the tk parent element of this frame
:param num_of_columns: the number of columns contained of the grid
:param headers: a list containing the names of the column headers
Expand Down Expand Up @@ -140,7 +144,9 @@ def __init__(self, parent,

def add_row(self, data: list=None):
r"""
Add a row of data to the current widget, add a <Tab> binding to the last element of the last row, and set the focus at the beginning of the next row.
Add a row of data to the current widget, add a <Tab> \
binding to the last element of the last row, and set \
the focus at the beginning of the next row.
:param data: a row of data
:return: None
Expand Down Expand Up @@ -219,7 +225,7 @@ def read(self, as_dicts=True):
r"""
Read the data from the entry fields
:param as_dicts: True if the data is desired as a list of dicts, else False
:param as_dicts: True if list of dicts required, else False
:return: entries as a dict or table
"""
if as_dicts:
Expand Down Expand Up @@ -323,13 +329,15 @@ def __init__(self, parent, keys: list, defaults: list=None,
enable=enables[i] if enables else None
)

def add_row(self, key: str, default: str=None, unit_label: str=None, enable: bool=None):
def add_row(self, key: str, default: str=None,
unit_label: str=None, enable: bool=None):
"""
Add a single row and re-draw as necessary
:param key: the name and dict accessor
:param default: the default value
:param unit_label: the label that should be applied at the right of the entry
:param unit_label: the label that should be \
applied at the right of the entry
:param enable: the 'enabled' state (defaults to True)
:return:
"""
Expand Down Expand Up @@ -426,7 +434,8 @@ def get(self):
"""
Retrieve the GUI elements for program use.
:return: a dictionary containing all of the data from the key/value entries
:return: a dictionary containing all \
of the data from the key/value entries
"""
data = dict()
for label, entry in zip(self.keys, self.values):
Expand All @@ -444,7 +453,7 @@ def __init__(self, parent, path, rows_to_display=20, cols_do_display=8,
text='Select the column you wish to import')
self.header.grid(row=0, column=0, columnspan=4)

self.entry_grid = tk_tools.EntryGrid(self, num_of_columns=8)
self.entry_grid = EntryGrid(self, num_of_columns=8)
self.entry_grid.grid(row=1, column=0, columnspan=4, rowspan=4)

self.move_page_up_btn = tk.Button(self, text='^\n^',
Expand Down Expand Up @@ -563,31 +572,3 @@ def move_up(self, page=False):
else:
self.current_position = (row_pos - 1, col_pos)
self.read_xl(*self.current_position, sheetname=self.sheetname)


if __name__ == '__main__':
root = tk.Tk()

entry_grid = EntryGrid(root, 3, ['L0', 'L1', 'L2'])
entry_grid.grid(row=0, column=0)

def add_row():
row = [1, 2, 3]
entry_grid.add_row(row)

add_row_btn = tk.Button(text='Add Row', command=add_row)
add_row_btn.grid(row=1, column=0)

def remove_row():
entry_grid.remove_row(0)

remove_row_btn = tk.Button(text='Remove Row', command=remove_row)
remove_row_btn.grid(row=2, column=0)

def read():
print(entry_grid.read(as_dicts=False))

read_btn = tk.Button(text='Read', command=read)
read_btn.grid(row=3, column=0)

root.mainloop()

0 comments on commit ba6ca8a

Please sign in to comment.