Perhaps this is a 1.6 issue, but I think I'm just missing something. I want to create a spinner widget that allows me to enter a number and increment/decrement it via two buttons (up and down). I have commented out much to isolate what I am doing wrong. On pythonista 1.6, this give me a ivory filled square with a bottom and right black shadow. No upper or left "border". And no uparrow. There is no pyui file, as I want to build this on the fly.
# spinner class
import ui
class Spinner(ui.View):
''' creates a view with a data entry field and up/down arrows which allow for increment/decrement
valid types are int, list, float. A list will be fixed possibilities and limits are ignored
'''
def __init__(self, parent,
initialValue= 10,
increment=1,
frame=(20,20, 200,200),
limits=(0,100),
dataType='int',
action=None
):
self.parent = parent
self.initialValue = initialValue
self._value = initialValue
self.increment = increment
self.action = action
self.dataType = dataType
self.limits = limits
self.frame = frame
self.list = []
def buildView(self):
# build the view here
self.v = ui.View(frame=self.frame)
self.v.background_color = "white"
self.border_color = 'black'
self.border_width = 3
self.parent.add_subview(self.v)
# self.vInput = ui.Label( )
# self.vInput.text = "{}".format(self.initialValue)
# self.vInput.bounds = (0,0,40,40)
# self.vInput.text_color = 'black'
# self.vInput.border_color = 'black'
# self.vInput.alignment = ui.ALIGN_CENTER
# self.vInput.border_width = 1
# self.v.add_subview(self.vInput)
# self.vInput.bring_to_front()
# self.vInput.hidden = False
self.upArrow= ui.Button()
self.upArrow.bounds = (0,60,50,50)
self.upArrow.bg_color = 'ivory'
self.upArrow.border_color = 'black'
self.upArrow.border_width = 1
self.upArrow.name = 'upBtn'
self.upArrow.action = self.onArrow
self.upArrow.background_image = ui.Image.named('ionicons-arrow-up-b-24')
self.upArrow.enabled = True
self.v.add_subview(self.upArrow)
self.parent.add_subview(self.v)
#
# self.dnArrow = ui.Button()
# self.v.add_subview(self.dnArrow)
# self.dnArrow.name = 'dnBtn'
# self.dnArrow.action = self.onArrow
@property
def value(self):
return self._value
@value.setter
def value(self,input):
self._value = input
def onArrow(self,sender):
pass
def reset(self):
self.value = initialValue
if __name__ == '__main__':
view = ui.View(background_color = 'white')
spinner = Spinner(view,frame=(200,200,100,100),initialValue = 500,
limits=(0,1000),increment=10)
spinner.buildView()
view.present('full_screen')