Commit eb1c1467 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

Merge branch 'rel/0.8.2' into 'v0.8'

Rel/0.8.2

See merge request fsl/fsleyes/widgets!47
parents 52d1eb0f d4dcdade
......@@ -4,7 +4,7 @@ set -e
source /test.venv/bin/activate
pip install wheel setuptools twine
pip install --upgrade pip wheel setuptools twine
python setup.py sdist
python setup.py bdist_wheel
twine check dist/*
......
......@@ -142,31 +142,30 @@ variables:
- bash ./.ci/test_template.sh
test:3.5:
test:3.6:
stage: test
image: pauldmccarthy/fsleyes-py35-wxpy4-gtk2
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3
<<: *test_template
test:3.6:
test:3.7:
stage: test
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk2
image: pauldmccarthy/fsleyes-py37-wxpy4-gtk3
<<: *test_template
test:3.7:
test:3.8:
stage: test
image: pauldmccarthy/fsleyes-py37-wxpy4-gtk2
image: pauldmccarthy/fsleyes-py38-wxpy4-gtk3
<<: *test_template
test:build-pypi-dist:
stage: test
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk2
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3
<<: *except_releases
tags:
- docker
script:
- source /test.venv/bin/activate
- bash ./.ci/build_pypi_dist.sh
......@@ -177,7 +176,7 @@ test:build-pypi-dist:
style:
stage: style
image: pauldmccarthy/fsleyes-py35-wxpy4-gtk2
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3
<<: *test_template
variables:
TEST_STYLE: "true"
......@@ -194,7 +193,7 @@ build-doc:
- docker
stage: doc
image: python:3.5
image: python:3.6
script:
- bash ./.ci/build_doc.sh
......@@ -215,7 +214,7 @@ build-pypi-dist:
<<: *check_version
stage: build
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk2
image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3
tags:
- docker
......@@ -239,7 +238,7 @@ deploy-doc:
<<: *setup_ssh
stage: deploy
when: manual
image: python:3.5
image: python:3.6
tags:
- docker
......@@ -256,7 +255,7 @@ deploy-pypi:
<<: *setup_ssh
stage: deploy
when: manual
image: python:3.5
image: python:3.6
tags:
- docker
......
......@@ -2,6 +2,24 @@ This document contains the ``fsleyes-widgets`` release history in reverse
chronological order.
0.8.2 (Wednesday September 18th 2019)
-------------------------------------
Changed
^^^^^^^
* ``fsleyes-widgets`` is now tested against Python 3.6, 3.7 and 3.8, and GTK3.
Fixed
^^^^^
* Fixed minor mis-usage of ``wx.BoxSizer`` in the :class:`.Notebook` class.
0.8.1 (Tuesday September 10th 2019)
-----------------------------------
......
......@@ -18,7 +18,7 @@ This file is used to store the current ``fsleyes-widgets`` version.
"""
__version__ = '0.8.1'
__version__ = '0.8.2'
from fsleyes_widgets.utils import (WX_PYTHON, # noqa
......
......@@ -91,7 +91,7 @@ class Notebook(wx.Panel):
self.__sizer.Add(
self.__dividerLine,
border=self.__border,
flag=wx.EXPAND | wx.ALIGN_CENTER | borderflags & ~btnside)
flag=wx.EXPAND | borderflags & ~btnside)
# a row of buttons for each page
if btnside in (wx.TOP, wx.LEFT): idx = 0
......@@ -100,14 +100,14 @@ class Notebook(wx.Panel):
idx,
self.__buttonPanel,
border=self.__border,
flag=wx.EXPAND | wx.ALIGN_CENTER | self.__borderflags)
flag=wx.EXPAND | self.__borderflags)
# a vertical line at the start of the button row
self.__buttonSizer.Insert(
0,
wx.StaticLine(self.__buttonPanel, style=invbtnorient),
border=3,
flag=wx.EXPAND | wx.ALIGN_CENTER | borderflags)
flag=wx.EXPAND | borderflags)
self.__pages = []
self.__buttons = []
......@@ -254,7 +254,7 @@ class Notebook(wx.Panel):
buttonIdx + 1,
wx.StaticLine(self.__buttonPanel, style=self.__invbtnorient),
border=3,
flag=wx.EXPAND | wx.ALIGN_CENTER | self.__borderflags)
flag=wx.EXPAND | self.__borderflags)
button.Bind(wx.EVT_LEFT_DOWN, self.__onButton)
......
......@@ -67,18 +67,15 @@ class NumberDialog(wx.Dialog):
wx.Dialog.__init__(self, parent, title=title)
self.__value = None
self.__cancelled = False
self.__panel = wx.Panel(self)
self.__sizer = wx.BoxSizer(wx.VERTICAL)
self.__panel.SetSizer(self.__sizer)
self.__buttonPanel = wx.Panel(self.__panel)
self.__value = None
self.__cancelled = False
self.__sizer = wx.BoxSizer(wx.VERTICAL)
self.__buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
self.__buttonPanel.SetSizer(self.__buttonSizer)
self.SetSizer(self.__sizer)
if message is not None:
self.__label = wx.StaticText(self.__panel, label=message)
self.__label = wx.StaticText(self, label=message)
else:
self.__label = (0, 0)
......@@ -89,14 +86,14 @@ class NumberDialog(wx.Dialog):
style |= floatspin.FSC_NO_LIMIT
self.__spinCtrl = floatspin.FloatSpinCtrl(
self.__panel,
self,
minValue=minValue,
maxValue=maxValue,
value=initial,
style=style)
self.__okButton = wx.Button(self.__buttonPanel, label=okText)
self.__cancelButton = wx.Button(self.__buttonPanel, label=cancelText)
self.__okButton = wx.Button(self, label=okText)
self.__cancelButton = wx.Button(self, label=cancelText)
self.__buttonSizer.Add(self.__okButton,
flag=wx.EXPAND | wx.ALL,
......@@ -111,8 +108,7 @@ class NumberDialog(wx.Dialog):
self.__sizer.Add(self.__spinCtrl,
flag=(wx.EXPAND | wx.LEFT | wx.RIGHT),
border=15)
self.__sizer.Add(self.__buttonPanel,
self.__sizer.Add(self.__buttonSizer,
flag=wx.EXPAND | wx.ALL,
border=10)
......@@ -120,9 +116,7 @@ class NumberDialog(wx.Dialog):
self.__okButton .Bind(wx.EVT_BUTTON, self.__onOk)
self.__cancelButton.Bind(wx.EVT_BUTTON, self.__onCancel)
self.__panel.Layout()
self.__panel.Fit()
self.Layout()
self.Fit()
self.CentreOnParent()
......
......@@ -127,8 +127,8 @@ class TextPanel(TextPanelBase):
paneW, paneH = dc.GetSize().Get()
textW, textH = self.__size
x = (paneW - textW) / 2.0
y = (paneH - textH) / 2.0
x = int((paneW - textW) / 2.0)
y = int((paneH - textH) / 2.0)
if self.__orient == wx.VERTICAL:
dc.DrawRotatedText(self.__text, x, paneH - y, 90)
......
......@@ -41,8 +41,8 @@ def textOverlay(target,
w = dc.DeviceToLogicalX(w)
h = dc.DeviceToLogicalY(h)
tw, th = dc.GetTextExtent(text).Get()
x = (w - tw) / 2
y = (h - th) / 2
x = int((w - tw) / 2)
y = int((h - th) / 2)
if box:
dc.SetBrush(wx.Brush(wx.Colour(bgColour)))
......
......@@ -88,7 +88,7 @@ def runWithBounce(task, *args, **kwargs):
dlg.DoBounce()
thread.start()
timer.Start(polltime * 1000, wx.TIMER_CONTINUOUS)
timer.Start(int(polltime * 1000), wx.TIMER_CONTINUOUS)
dlg.Bind(wx.EVT_TIMER, poll)
dlg.Show()
......
......@@ -1501,7 +1501,7 @@ class WidgetGrid(wx.ScrolledWindow):
self.__dragCurrentCol = currentcol
dc.Clear()
dc.DrawBitmap(self.__dragIcon, xpos, 0, False)
dc.DrawBitmap(self.__dragIcon, int(xpos), 0, False)
WG_SELECTABLE_CELLS = 1
......
......@@ -145,19 +145,46 @@ def simclick(sim, target, btn=wx.MOUSE_BTN_LEFT, pos=None, stype=0):
return self.evo
parent = target.GetParent()
if GTK:
if type(target).__name__ == 'StaticTextTag' and \
type(parent).__name__ == 'TextTagPanel':
parent._TextTagPanel__onTagLeftDown(FakeEv(target))
realYield()
return
if type(target).__name__ == 'StaticText' and \
type(parent).__name__ == 'TogglePanel':
parent.Toggle(FakeEv(target))
realYield()
return
# event simulation is super flaky
if type(target).__name__ == 'StaticTextTag' and \
type(parent).__name__ == 'TextTagPanel':
parent._TextTagPanel__onTagLeftDown(FakeEv(target))
realYield()
return
if type(target).__name__ == 'StaticText' and \
type(parent).__name__ == 'TogglePanel':
parent.Toggle(FakeEv(target))
realYield()
return
if type(target).__name__ == 'BitmapToggleButton':
target.SetValue(not target.GetValue())
target._BitmapToggleButton__onToggle(FakeEv(target))
realYield()
return
if type(target).__name__ == 'ColourButton':
target._ColourButton__onClick(FakeEv(target))
realYield()
return
if type(target).__name__ == 'Button' and \
type(parent).__name__ == 'SliderSpinPanel':
parent._SliderSpinPanel__onLimitButton(FakeEv(target))
realYield()
return
if type(target).__name__ == 'Button' and \
type(parent).__name__ == 'RangeSliderSpinPanel':
parent._RangeSliderSpinPanel__onLimitButton(FakeEv(target))
realYield()
return
if type(parent).__name__ == 'NumberDialog' and \
type(target).__name__ == 'Button':
if target.GetLabel().lower() == 'ok':
parent._NumberDialog__onOk(FakeEv(target))
else:
parent._NumberDialog__onCancel(FakeEv(target))
realYield()
return
w, h = target.GetClientSize().Get()
x, y = target.GetScreenPosition()
......@@ -168,7 +195,7 @@ def simclick(sim, target, btn=wx.MOUSE_BTN_LEFT, pos=None, stype=0):
x += w * pos[0]
y += h * pos[1]
sim.MouseMove(x, y)
sim.MouseMove(int(x), int(y))
realYield()
if stype == 0: sim.MouseClick(btn)
elif stype == 1: sim.MouseDblClick(btn)
......
......@@ -187,6 +187,12 @@ def _test_popup_focusback():
def test_popup_dblclick():
run_with_wx(_test_popup_dblclick)
def _test_popup_dblclick():
class FakeEv:
def Skip(self):
pass
sim = wx.UIActionSimulator()
parent = wx.GetApp().GetTopWindow()
atc = autott.AutoTextCtrl(parent, ownloop=False)
......@@ -196,6 +202,8 @@ def _test_popup_dblclick():
addall(parent, [atc])
simkey( sim, atc.textCtrl, wx.WXK_RETURN)
simclick(sim, atc.popup.listBox, stype=1, pos=[0.5, 0.05])
atc.popup.listBox.SetSelection(0)
atc.popup._AutoCompletePopup__onListMouseDblClick(FakeEv())
realYield()
assert atc.GetValue() == 'aaa'
......@@ -306,7 +306,7 @@ def _test_SliderSpinPanel_show_edit_limits():
]
with mock.patch('fsleyes_widgets.floatslider.numberdialog.NumberDialog',
with mock.patch('fsleyes_widgets.numberdialog.NumberDialog',
return_value=numberdlg):
for btn, val, expected, shouldEv in testcases:
......@@ -315,6 +315,7 @@ def _test_SliderSpinPanel_show_edit_limits():
numberdlg.GetValue.return_value = val
realYield()
simclick(sim, btn)
assert tuple(panel.GetRange()) == expected
......
......@@ -16,7 +16,7 @@ from .test_floatslider import (_test_widget_logic,
_test_widget_logic_integer,
_test_widget_changeRange)
from . import run_with_wx, simclick, simtext, simkey, simfocus, realYield
from . import run_with_wx, simclick, simtext, simkey, simfocus, realYield, addall
......@@ -159,6 +159,8 @@ def _test_FloatSpinCtrl_text():
spin = floatspin.FloatSpinCtrl(frame)
sim = wx.UIActionSimulator()
addall(frame, [spin])
spin.SetRange(0, 100)
result = [0]
......@@ -200,7 +202,9 @@ def _test_FloatSpinCtrl_text():
oldValue = spin.GetValue()
result[0] = None
enter[0] = False
simtext(sim, spin.textCtrl, text)
spin.textCtrl.ChangeValue(text)
spin._FloatSpinCtrl__onText(None)
realYield()
assert spin.GetValue() == expected
try:
......
......@@ -58,8 +58,8 @@ def _test_StaticTextTag_Close():
tag.Bind(tt.EVT_STT_CLOSE, handler)
tag.SetText('Blah')
simclick(sim, closeBtn, stype=2)
tag._StaticTextTag__onCloseButton(None)
realYield()
assert called[0]
......@@ -208,11 +208,13 @@ def _test_TextTagPanel_close_event():
panel.AddTag('MyTag2')
realYield()
simclick(sim, panel.tags[1].closeButton, stype=2)
panel.tags[1]._StaticTextTag__onCloseButton(None)
realYield()
assert result[0] == 'MyTag2'
assert panel.GetTags() == ['MyTag1']
simclick(sim, panel.tags[0].closeButton, stype=2)
panel.tags[0]._StaticTextTag__onCloseButton(None)
realYield()
assert result[0] == 'MyTag1'
assert panel.GetTags() == []
......
#!/usr/bin/env python
import wx
from unittest import mock
import numpy as np
from . import run_with_wx, simmove, realYield
......@@ -75,6 +75,35 @@ def _test_reorder():
cells = [cells[ i] for i in neworder]
class FakeMouseState(object):
def __init__(self):
self.pos = wx.Point(0, 0)
def GetPosition(self):
return self.pos
class FakeEV(object):
def __init__(self, evo):
self.evo = evo
def Skip(self):
pass
def GetEventObject(self):
return self.evo
def cxy(target, pos):
w, h = target.GetClientSize().Get()
x, y = target.GetScreenPosition()
x += w * pos[0]
y += h * pos[1]
return int(x), int(y)
def test_reorder_events():
run_with_wx(_test_reorder_events)
def _test_reorder_events():
......@@ -99,17 +128,6 @@ def _test_reorder_events():
grid.Refresh()
frame.Layout()
class FakeEV(object):
def __init__(self, evo):
self.evo = evo
def Skip(self):
pass
def GetEventObject(self):
return self.evo
# (clicked column, drop column, drop pos, expected order)
tests = [
(0, 0, 0.25, [0, 1, 2, 3, 4]),
......@@ -139,27 +157,32 @@ def _test_reorder_events():
realYield()
for clickcol, dropcol, droppos, exporder in tests:
cwidget = grid.colLabels[clickcol].GetParent()
dwidget = grid.colLabels[dropcol] .GetParent()
fakestate = FakeMouseState()
with mock.patch('wx.GetMouseState', return_value=fakestate):
simmove(sim, cwidget, [0.5, 0.5])
ev = FakeEV(cwidget)
grid._WidgetGrid__onColumnLabelMouseDown(ev)
realYield(50)
simmove(sim, dwidget, [droppos, 0.5])
realYield(50)
grid._WidgetGrid__onColumnLabelMouseDrag(ev)
realYield(50)
ev.evo = dwidget
grid._WidgetGrid__onColumnLabelMouseUp(ev)
realYield(50)
cwidget = grid.colLabels[clickcol].GetParent()
dwidget = grid.colLabels[dropcol] .GetParent()
explabels = [labels[i] for i in exporder]
gotlabels = grid.GetColLabels()
ev = FakeEV(cwidget)
grid._WidgetGrid__onColumnLabelMouseDown(ev)
realYield()
assert explabels == gotlabels
fakestate.pos = wx.Point(*cxy(dwidget, (droppos, 0.5)))
with mock.patch('wx.FindWindowAtPointer',
return_value=[dwidget]):
grid._WidgetGrid__onColumnLabelMouseDrag(ev)
realYield()
ev.evo = dwidget
grid._WidgetGrid__onColumnLabelMouseUp(ev)
realYield()
labels = gotlabels
explabels = [labels[i] for i in exporder]
gotlabels = grid.GetColLabels()
assert explabels == gotlabels
labels = gotlabels
def test_reorder_events_draglimit():
......@@ -187,17 +210,6 @@ def _test_reorder_events_draglimit():
grid.Refresh()
frame.Layout()
class FakeEV(object):
def __init__(self, evo):
self.evo = evo
def Skip(self):
pass
def GetEventObject(self):
return self.evo
# (clicked column, drop column, drop pos, expected order)
tests = [
(0, 1, 0.75, [1, 0, 2, 3, 4]),
......@@ -218,24 +230,29 @@ def _test_reorder_events_draglimit():
realYield()
for clickcol, dropcol, droppos, exporder in tests:
cwidget = grid.colLabels[clickcol].GetParent()
dwidget = grid.colLabels[dropcol] .GetParent()
fakestate = FakeMouseState()
with mock.patch('wx.GetMouseState', return_value=fakestate):
cwidget = grid.colLabels[clickcol].GetParent()
dwidget = grid.colLabels[dropcol] .GetParent()
ev = FakeEV(cwidget)
grid._WidgetGrid__onColumnLabelMouseDown(ev)
realYield()
simmove(sim, cwidget, [0.5, 0.5])
ev = FakeEV(cwidget)
grid._WidgetGrid__onColumnLabelMouseDown(ev)
realYield(50)
simmove(sim, dwidget, [droppos, 0.5])
realYield(50)
grid._WidgetGrid__onColumnLabelMouseDrag(ev)
realYield(50)
ev.evo = dwidget
grid._WidgetGrid__onColumnLabelMouseUp(ev)
realYield(50)
fakestate.pos = wx.Point(*cxy(dwidget, (droppos, 0.5)))
with mock.patch('wx.FindWindowAtPointer',
return_value=[dwidget]):
grid._WidgetGrid__onColumnLabelMouseDrag(ev)
realYield()
ev.evo = dwidget
grid._WidgetGrid__onColumnLabelMouseUp(ev)
realYield()
explabels = [labels[i] for i in exporder]
gotlabels = grid.GetColLabels()
explabels = [labels[i] for i in exporder]
gotlabels = grid.GetColLabels()
assert explabels == gotlabels
assert explabels == gotlabels
labels = gotlabels
labels = gotlabels
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment