Skip to content

Commit

Permalink
Release 0.8.1-β
Browse files Browse the repository at this point in the history
Minor release with mainly visual improvements.

Code
* Pins now align themselves automatically.
* Blocks are round and transparent.
* Connections are bèzier curves instead of straight line.
* Added direction indicators.
* Connections go behind the blocks.
* Backgrounds looks good in all sizes.

Documentation
* Added image with new visual aspect.
* Added directions for use.

Package
* Added minimum python version.
  • Loading branch information
AlvarBer committed May 17, 2017
2 parents e1c8007 + b28567b commit 4e964aa
Show file tree
Hide file tree
Showing 34 changed files with 301 additions and 250 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ If you have pip (Python 3.5+) you can simply type

`$> pip install persimmon`

To execute use.

`$> python -m persimmon`

For windows self-contained executables can be found on the [releases page].


Expand Down
Binary file modified docs/images/final_aspect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/src/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ On this chapter Persimmon is introduced, along its main objectives and
motivations.
It also includes a section about topics that are related but beyond the scope
of this project.
Finally, it includes an overviewof the project report structure.
Finally, it includes an overview of the project report structure.


Description
Expand Down
9 changes: 4 additions & 5 deletions docs/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,10 @@
$endif$

% Make sections great again
\usepackage{titlesec}

\titleformat*{\section}{\sffamily\LARGE\bfseries}
\titleformat*{\subsection}{\sffamily\Large\bfseries}
\titleformat*{\subsubsection}{\sffamily\large\bfseries}
%\usepackage{titlesec}
%\titleformat*{\section}{\sffamily\LARGE\bfseries}
%\titleformat*{\subsection}{\sffamily\Large\bfseries}
%\titleformat*{\subsubsection}{\sffamily\large\bfseries}

% Better abstract
\renewenvironment{abstract}{
Expand Down
Binary file added persimmon/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified persimmon/border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed persimmon/circuit_board.png
Binary file not shown.
Binary file removed persimmon/connections.png
Binary file not shown.
48 changes: 22 additions & 26 deletions persimmon/view/blocks/block.kv
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
<Block>:
# Fixed options
size_hint: None, None
size: '200dp', '75dp'
drag_rectangle: self.x, self.y, self.width, self.height
drag_timeout: 10000000
drag_distance: 0
# Fixed options
size_hint: None, None
width: '200dp'
drag_rectangle: self.x, self.y, self.width, self.height
drag_timeout: 10000000
drag_distance: 0
label: label
canvas:
Color:
rgb: .2, .2, .2
Rectangle:
rgba: .15, .15, .15, .8
RoundedRectangle:
pos: self.pos
size: self.size
#canvas.before:
#Color:
#rgb: 1, 1, 1
#BorderImage:
#pos: self.x - 5, self.y - 5
#size: self.width + 10, self.height + 10
#source: 'tex2.png'
# Children
Label:
pos: root.x, root.y + root.height - 20
size_hint: None, None
height: '20dp'
# Children
Label:
id: label
pos: root.x, root.y + root.height - 20
size_hint: None, None
height: '20dp'
width: root.width
text: root.title
canvas.before:
Color:
rgb: root.block_color
Rectangle:
pos: self.pos
size: self.size
canvas.before:
Color:
rgba: [*root.block_color, 0.8]
RoundedRectangle:
pos: self.pos
size: self.size
radius: [(10, 10), (10, 10), (0, 0), (0, 0)]
40 changes: 33 additions & 7 deletions persimmon/view/blocks/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
from kivy.uix.behaviors import DragBehavior
from kivy.properties import ListProperty, StringProperty, ObjectProperty
from kivy.lang import Builder
from kivy.graphics import BorderImage, Color
from kivy.graphics import BorderImage, Color, RoundedRectangle
from kivy.uix.image import Image
# Types are fun
from typing import Optional
from abc import abstractmethod
from functools import partial


Builder.load_file('view/blocks/block.kv')

class Block(DragBehavior, FloatLayout, metaclass=AbstractWidget):
block_color = ListProperty([1, 1, 1])
title = StringProperty()
label = ObjectProperty()
inputs = ObjectProperty()
outputs = ObjectProperty()
input_pins = ListProperty()
Expand All @@ -26,18 +28,32 @@ class Block(DragBehavior, FloatLayout, metaclass=AbstractWidget):

def __init__(self, **kwargs):
super().__init__(**kwargs)

if self.inputs:
for pin in self.inputs.children:
self.input_pins.append(pin)
pin.block = self
self.gap = pin.width * 2
if self.outputs:
for pin in self.outputs.children:
self.output_pins.append(pin)
pin.block = self
self.gap = pin.width * 2
self.tainted_msg = 'Block {} has unconnected inputs'.format(self.title)
self._tainted = False
self.kindled = None
self.border_texture = Image(source='border.png').texture
# Make block taller if necessary
self.height = (max(len(self.output_pins), len(self.input_pins), 3) *
self.gap + self.label.height)
# Position pins nicely
y_origin = self.y + (self.height - self.label.height)
for i, in_pin in enumerate(list(self.input_pins[::-1]), 1):
self._bind_pin(self, (in_pin.x, in_pin.y), in_pin, i, False)
self.fbind('pos', self._bind_pin, pin=in_pin, i=i, output=False)
for i, out_pin in enumerate(list(self.output_pins[::-1]), 1):
self._bind_pin(self, (out_pin.x, out_pin.y), out_pin, i, True)
self.fbind('pos', self._bind_pin, pin=out_pin, i=i, output=True)

@property
def tainted(self):
Expand Down Expand Up @@ -72,14 +88,14 @@ def function(self):
raise NotImplementedError

# Kivy touch events override
def on_touch_down(self, touch):
def on_touch_down(self, touch) -> bool:
pin = self.in_pin(*touch.pos)
if pin: # if touch is on pin let them handle
return pin.on_touch_down(touch)
else: # else default behavior (drag if collide)
return super().on_touch_down(touch)

def on_touch_up(self, touch):
def on_touch_up(self, touch) -> bool:
pin = self.in_pin(*touch.pos)
if pin:
result = pin.on_touch_up(touch)
Expand All @@ -91,9 +107,9 @@ def kindle(self):
""" Praise the sun \[T]/ """
with self.canvas.before:
Color(1, 1, 1)
self.kindled = BorderImage(pos=(self.x - 5, self.y - 5),
size=(self.width + 10,
self.height + 10),
self.kindled = BorderImage(pos=(self.x - 2, self.y - 2),
size=(self.width + 4,
self.height + 4),
texture=self.border_texture)
self.fbind('pos', self._bind_border)

Expand All @@ -109,4 +125,14 @@ def unkindle(self):
# Auxiliary functions
def _bind_border(self, block, new_pos):
""" Bind border to position. """
self.kindled.pos = new_pos[0] - 5, new_pos[1] - 5
self.kindled.pos = new_pos[0] - 2, new_pos[1] - 2

def _bind_pin(self, block, new_pos, pin, i, output):
""" Keep pins on their respective places. """
pin.y = (block.y + (block.height - block.label.height) - i * self.gap +
pin.height / 2)
if output:
pin.x = block.x + block.width - self.gap
else:
pin.x = block.x + 5

8 changes: 0 additions & 8 deletions persimmon/view/blocks/crossvalidationblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,16 @@
id: inputs
InputPin:
id: data_input
x: root.x + 5
y: root.y + root.height - 15
_type: root.t.DATAFRAME
InputPin:
id: estimator_input
x: root.x + 5
y: root.y + root.height / 2 - 5
_type: root.t.CLASSIFICATOR
InputPin:
id: cross_val_input
x: root.x + 5
y: root.y + 5
_type: root.t.CROSS_VALIDATOR
Widget:
id: outputs
OutputPin:
id: cross_out
x: root.x + root.width - 15
y: root.y + root.height / 2
_type: root.t.ANY

2 changes: 0 additions & 2 deletions persimmon/view/blocks/csvinblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@
id: outputs
OutputPin:
id: out_1
x: root.x + root.width - 10 - 5
y: root.y + root.height / 2
_type: root.t.DATAFRAME
2 changes: 0 additions & 2 deletions persimmon/view/blocks/csvoutblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@
id: inputs
InputPin:
id: in_1
x: root.x + 5
y: root.y + root.height / 2
_type: root.t.DATAFRAME
2 changes: 0 additions & 2 deletions persimmon/view/blocks/dictblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
id: outputs
OutputPin:
id: dict_out
x: root.x + root.width - 15
y: root.y + root.height / 2 - 5
_type: root.t.STATE
TextInput:
id: tinput
Expand Down
6 changes: 0 additions & 6 deletions persimmon/view/blocks/fitblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@
id: inputs
InputPin:
id: data_in
x: root.x + 5
y: root.y + root.height - 35
_type: root.t.DATAFRAME
InputPin:
id: est_in
x: root.x + 5
y: root.y + 5
_type: root.t.CLASSIFICATOR
Widget:
id: outputs
OutputPin:
id: est_out
x: root.x + root.width - 15
y: root.y + root.height / 2 - 5
_type: root.t.CLASSIFICATOR
10 changes: 0 additions & 10 deletions persimmon/view/blocks/gridsearchblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,18 @@
id: inputs
InputPin:
id: data_in
x: root.x + 5
y: root.y + root.height - 15
_type: root.t.DATAFRAME
InputPin:
id: est_in
x: root.x + 5
y: root.y + root.height / 2 - 5
_type: root.t.CLASSIFICATOR
InputPin:
id: params_in
x: root.x + 5
y: root.y + 5
_type: root.t.STATE
Widget:
id: outputs
OutputPin:
id: est_out
x: root.x + root.width - 15
y: root.y + root.height - 35
_type: root.t.CLASSIFICATOR
OutputPin:
id: score_out
x: root.x + root.width - 15
y: root.y + 5
_type: root.t.ANY
2 changes: 0 additions & 2 deletions persimmon/view/blocks/knnblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
id: outputs
OutputPin:
id: est_out
x: root.x + root.width - 10 - 5
y: root.y + root.height / 2
_type: root.t.CLASSIFICATOR
7 changes: 1 addition & 6 deletions persimmon/view/blocks/predictblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@
id: inputs
InputPin:
id: est_in
x: root.x + 5
y: root.y + root.height - 35
_type: root.t.CLASSIFICATOR
InputPin:
id: data_in
x: root.x + 5
y: root.y + 5
_type: root.t.DATAFRAME
Widget:
id: outputs
OutputPin:
id: plain_out
x: root.x + root.width - 15
y: root.y + root.height / 2 - 5
_type: root.t.ANY

2 changes: 0 additions & 2 deletions persimmon/view/blocks/printblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
id: inputs
InputPin:
id: in_1
x: root.x + 5
y: root.y + root.height / 2
_type: root.t.ANY
2 changes: 0 additions & 2 deletions persimmon/view/blocks/randomforestblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
id: outputs
OutputPin:
id: out_1
x: root.x + root.width - 10 - 5
y: root.y + root.height / 2
_type: root.t.CLASSIFICATOR
2 changes: 0 additions & 2 deletions persimmon/view/blocks/sgdblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
id: outputs
OutputPin:
id: est_out
x: root.x + root.width - 10 - 5
y: root.y + root.height / 2
_type: root.t.CLASSIFICATOR
2 changes: 0 additions & 2 deletions persimmon/view/blocks/svmblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
id: outputs
OutputPin:
id: out_1
x: root.x + root.width - 10 - 5
y: root.y + root.height / 2
_type: root.t.CLASSIFICATOR
2 changes: 0 additions & 2 deletions persimmon/view/blocks/tenfoldblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
id: outputs
OutputPin:
id: out_1
x: root.x + root.width - 10 - 5
y: root.y + root.height / 2
_type: root.t.CROSS_VALIDATOR
2 changes: 0 additions & 2 deletions persimmon/view/blocks/tssplitblock.kv
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@
id: outputs
OutputPin:
id: out_1
x: root.x + root.width - 10 - 5
y: root.y + root.height / 2
_type: root.t.CROSS_VALIDATOR
3 changes: 2 additions & 1 deletion persimmon/view/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from .types import Type, BlockType, AbstractWidget
from .circularbutton import CircularButton
from .connection import Connection
from .filedialog import FileDialog
from .notification import Notification
from .types import Type, BlockType, AbstractWidget

from .pin import Pin
from .inpin import InputPin
from .outpin import OutputPin

Loading

0 comments on commit 4e964aa

Please sign in to comment.