tests/tools/test_CustomIntCtrl.py
author Edouard Tisserant
Fri, 25 Jan 2019 14:06:11 +0100
changeset 2483 6a7f92b84855
parent 2437 105c20fdeb19
permissions -rw-r--r--
Split IDE's frame OnCloseFrame() into TryCloseFrame() and OnCloseFrame(), to help further customization
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/env python
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     3
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     6
#
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     7
# Copyright (C) 2017: Andrey Skvortsov
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     8
#
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
     9
# See COPYING file for copyrights details.
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    10
#
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    11
# This program is free software; you can redistribute it and/or
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    12
# modify it under the terms of the GNU General Public License
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    13
# as published by the Free Software Foundation; either version 2
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    14
# of the License, or (at your option) any later version.
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    15
#
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    16
# This program is distributed in the hope that it will be useful,
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    19
# GNU General Public License for more details.
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    20
#
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    21
# You should have received a copy of the GNU General Public License
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    22
# along with this program; if not, write to the Free Software
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    24
1881
091005ec69c4 fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
    25
091005ec69c4 fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
    26
from __future__ import absolute_import
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
    27
from __future__ import division
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    28
import unittest
1832
0f1081928d65 fix wrong-import-order. first standard modules are imported, then others
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1811
diff changeset
    29
import time
0f1081928d65 fix wrong-import-order. first standard modules are imported, then others
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1811
diff changeset
    30
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    31
import wx
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    32
import conftest
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    33
import controls.CustomIntCtrl
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    34
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    35
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    36
class TestCustomIntCtrl(unittest.TestCase):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    37
    def setUp(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    38
        self.app = wx.App()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    39
        self.frame = wx.Frame(None)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    40
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    41
    def tearDown(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    42
        self.frame.Destroy()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    43
        wx.CallAfter(self.app.Exit)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    44
        self.app.MainLoop()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    45
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    46
    def testMaxLimit(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    47
        """Test working upper bound"""
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    48
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    49
        self.int_ctrl.SetValue(self.max_val + 100)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    50
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    51
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    52
        self.txt_ctrl.SetFocus()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    53
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    54
        self.assertEqual(self.int_ctrl.GetValue(), self.max_val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    55
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    56
    def testMinLimit(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    57
        """Test working lower bound"""
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    58
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    59
        self.int_ctrl.SetValue(self.min_val - 100)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    60
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    61
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    62
        self.txt_ctrl.SetFocus()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    63
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    64
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    65
        self.assertEqual(self.int_ctrl.GetValue(), self.min_val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    66
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    67
    def testCorrectValue(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    68
        """Test case if no limiting is necessary"""
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    69
        self.AddControls()
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
    70
        val = (self.max_val + self.min_val) // 2
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    71
        self.int_ctrl.SetValue(val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    72
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    73
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    74
        self.txt_ctrl.SetFocus()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    75
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    76
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    77
        self.assertEqual(self.int_ctrl.GetValue(), val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    78
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    79
    def testEventBinding(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    80
        """Test event sending after edit and bound checks are done"""
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    81
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    82
        self.event_happend = False
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    83
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    84
        def EventHandler(event):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    85
            self.event_happend = True
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    86
            event.Skip()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    87
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    88
        self.int_ctrl.Bind(controls.CustomIntCtrl.EVT_CUSTOM_INT, EventHandler)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    89
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1881
diff changeset
    90
        val = (self.max_val + self.min_val) // 2
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    91
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    92
        self.int_ctrl.SetValue(val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    93
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    94
        self.txt_ctrl.SetFocus()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    95
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    96
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    97
        self.txt_ctrl.SetFocus()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    98
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    99
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   100
        self.assertEqual(self.int_ctrl.GetValue(), val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   101
        self.assertTrue(self.event_happend)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   102
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   103
    def testLongNumbers(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   104
        """Test support of long integer"""
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   105
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   106
        val = 40000000000
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   107
        self.int_ctrl.SetMax(val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   108
        self.int_ctrl.SetValue(val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   109
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   110
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   111
        self.txt_ctrl.SetFocus()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   112
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   113
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   114
        self.assertEqual(val, val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   115
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   116
    def ProcessEvents(self):
1847
6198190bc121 explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1832
diff changeset
   117
        for dummy in range(0, 10):
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   118
            wx.Yield()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   119
            time.sleep(0.01)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   120
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   121
    def AddControls(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   122
        vs = wx.BoxSizer(wx.VERTICAL)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   123
        self.int_ctrl = controls.CustomIntCtrl(self.frame)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   124
        self.txt_ctrl = wx.TextCtrl(self.frame)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   125
        vs.Add(self.int_ctrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   126
        vs.Add(self.txt_ctrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   127
        self.frame.SetSizer(vs)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   128
        vs.Fit(self.frame)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   129
        self.frame.Show()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   130
        self.frame.Raise()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   131
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   132
        self.min_val = 50
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   133
        self.max_val = 100
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   134
        self.int_ctrl.SetBounds(self.min_val, self.max_val)
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   135
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   136
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   137
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   138
if __name__ == '__main__':
1850
614396cbffbf fix pylint warning '(unused-import), Unused import connectors'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1847
diff changeset
   139
    conftest.init_environment()
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   140
    unittest.main()