tests/tools/test_CustomIntCtrl.py
author Edouard Tisserant
Mon, 06 Aug 2018 13:14:50 +0200
changeset 2244 42566291b9bc
parent 1881 091005ec69c4
child 2437 105c20fdeb19
permissions -rw-r--r--
Make some POU libraries selected by default or not. This changes structure of features.libraries, please check and update your extensions if they use libraries
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
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    27
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
    28
import time
0f1081928d65 fix wrong-import-order. first standard modules are imported, then others
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1811
diff changeset
    29
1811
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    30
import wx
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    31
import conftest
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    32
import controls.CustomIntCtrl
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    33
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
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
    36
    def setUp(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    37
        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
    38
        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
    39
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    40
    def tearDown(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    41
        self.frame.Destroy()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    42
        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
    43
        self.app.MainLoop()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    44
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    45
    def testMaxLimit(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    46
        """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
    47
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    48
        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
    49
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    50
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    51
        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
    52
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    53
        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
    54
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    55
    def testMinLimit(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    56
        """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
    57
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    58
        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
    59
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    60
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    61
        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
    62
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    63
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    64
        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
    65
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    66
    def testCorrectValue(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    67
        """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
    68
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    69
        val = (self.max_val + self.min_val) / 2
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    70
        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
    71
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    72
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    73
        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
    74
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    75
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    76
        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
    77
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    78
    def testEventBinding(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    79
        """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
    80
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    81
        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
    82
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    83
        def EventHandler(event):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    84
            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
    85
            event.Skip()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    86
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    87
        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
    88
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    89
        val = (self.max_val + self.min_val) / 2
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    90
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    91
        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
    92
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    93
        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
    94
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    95
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    96
        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
    97
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    98
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
    99
        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
   100
        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
   101
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   102
    def testLongNumbers(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   103
        """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
   104
        self.AddControls()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   105
        val = 40000000000
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   106
        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
   107
        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
   108
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   109
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   110
        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
   111
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   112
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   113
        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
   114
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   115
    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
   116
        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
   117
            wx.Yield()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   118
            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
   119
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   120
    def AddControls(self):
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   121
        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
   122
        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
   123
        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
   124
        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
   125
        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
   126
        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
   127
        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
   128
        self.frame.Show()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   129
        self.frame.Raise()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   130
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   131
        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
   132
        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
   133
        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
   134
        self.ProcessEvents()
4e3c78a84c64 add custom TextCtrl allowed to enter long integer with bounds checking
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff changeset
   135
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
if __name__ == '__main__':
1850
614396cbffbf fix pylint warning '(unused-import), Unused import connectors'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1847
diff changeset
   138
    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
   139
    unittest.main()