editors/ConfTreeNodeEditor.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 05 Oct 2018 14:22:01 +0300
changeset 2437 105c20fdeb19
parent 2182 eeca1aff0691
child 2450 5024c19ca8f0
permissions -rw-r--r--
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
     1
#!/usr/bin/env python
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
     2
# -*- coding: utf-8 -*-
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
     3
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
     6
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
1696
8043f32de7b8 make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1562
diff changeset
     8
# Copyright (C) 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com>
1511
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
     9
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    10
# See COPYING file for copyrights details.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    11
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    12
# This program is free software; you can redistribute it and/or
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    13
# modify it under the terms of the GNU General Public License
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    14
# as published by the Free Software Foundation; either version 2
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    15
# of the License, or (at your option) any later version.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    16
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    17
# This program is distributed in the hope that it will be useful,
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    20
# GNU General Public License for more details.
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    21
#
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    22
# You should have received a copy of the GNU General Public License
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    23
# along with this program; if not, write to the Free Software
91538d0c242c add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1451
diff changeset
    24
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    25
1853
47a3f39bead0 fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
    26
47a3f39bead0 fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
    27
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: 2182
diff changeset
    28
from __future__ import division
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    29
import types
413946c04c87 refactoring
laurent
parents:
diff changeset
    30
413946c04c87 refactoring
laurent
parents:
diff changeset
    31
import wx
413946c04c87 refactoring
laurent
parents:
diff changeset
    32
1853
47a3f39bead0 fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1850
diff changeset
    33
from editors.EditorPanel import EditorPanel
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 781
diff changeset
    34
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 781
diff changeset
    35
from IDEFrame import TITLE, FILEMENU, PROJECTTREE, PAGETITLES
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 781
diff changeset
    36
2001
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
    37
from controls import TextCtrlAutoComplete, UriLocationEditor
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 781
diff changeset
    38
from dialogs import BrowseValuesLibraryDialog
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 781
diff changeset
    39
from util.BitmapLibrary import GetBitmap
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    40
413946c04c87 refactoring
laurent
parents:
diff changeset
    41
if wx.Platform == '__WXMSW__':
1747
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    42
    faces = {
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    43
        'times': 'Times New Roman',
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    44
        'mono':  'Courier New',
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    45
        'helv':  'Arial',
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    46
        'other': 'Comic Sans MS',
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    47
        'size':  16,
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    48
    }
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    49
else:
1747
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    50
    faces = {
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    51
        'times': 'Times',
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    52
        'mono':  'Courier',
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    53
        'helv':  'Helvetica',
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    54
        'other': 'new century schoolbook',
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    55
        'size':  18,
6046ffa2280f clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    56
    }
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    57
413946c04c87 refactoring
laurent
parents:
diff changeset
    58
SCROLLBAR_UNIT = 10
413946c04c87 refactoring
laurent
parents:
diff changeset
    59
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1734
diff changeset
    60
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    61
class GenBitmapTextButton(wx.lib.buttons.GenBitmapTextButton):
413946c04c87 refactoring
laurent
parents:
diff changeset
    62
    def _GetLabelSize(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
    63
        """ used internally """
413946c04c87 refactoring
laurent
parents:
diff changeset
    64
        w, h = self.GetTextExtent(self.GetLabel())
413946c04c87 refactoring
laurent
parents:
diff changeset
    65
        if not self.bmpLabel:
413946c04c87 refactoring
laurent
parents:
diff changeset
    66
            return w, h, False       # if there isn't a bitmap use the size of the text
413946c04c87 refactoring
laurent
parents:
diff changeset
    67
413946c04c87 refactoring
laurent
parents:
diff changeset
    68
        w_bmp = self.bmpLabel.GetWidth()+2
413946c04c87 refactoring
laurent
parents:
diff changeset
    69
        h_bmp = self.bmpLabel.GetHeight()+2
413946c04c87 refactoring
laurent
parents:
diff changeset
    70
        height = h + h_bmp
413946c04c87 refactoring
laurent
parents:
diff changeset
    71
        if w_bmp > w:
413946c04c87 refactoring
laurent
parents:
diff changeset
    72
            width = w_bmp
413946c04c87 refactoring
laurent
parents:
diff changeset
    73
        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
    74
            width = w
413946c04c87 refactoring
laurent
parents:
diff changeset
    75
        return width, height, False
413946c04c87 refactoring
laurent
parents:
diff changeset
    76
413946c04c87 refactoring
laurent
parents:
diff changeset
    77
    def DrawLabel(self, dc, width, height, dw=0, dy=0):
413946c04c87 refactoring
laurent
parents:
diff changeset
    78
        bmp = self.bmpLabel
1743
c3c3d1318130 clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
    79
        if bmp is not None:     # if the bitmap is used
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    80
            if self.bmpDisabled and not self.IsEnabled():
413946c04c87 refactoring
laurent
parents:
diff changeset
    81
                bmp = self.bmpDisabled
413946c04c87 refactoring
laurent
parents:
diff changeset
    82
            if self.bmpFocus and self.hasFocus:
413946c04c87 refactoring
laurent
parents:
diff changeset
    83
                bmp = self.bmpFocus
413946c04c87 refactoring
laurent
parents:
diff changeset
    84
            if self.bmpSelected and not self.up:
413946c04c87 refactoring
laurent
parents:
diff changeset
    85
                bmp = self.bmpSelected
1740
b789b695b5c6 clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1739
diff changeset
    86
            bw, bh = bmp.GetWidth(), bmp.GetHeight()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    87
            if not self.up:
413946c04c87 refactoring
laurent
parents:
diff changeset
    88
                dw = dy = self.labelDelta
1743
c3c3d1318130 clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
    89
            hasMask = bmp.GetMask() is not None
738
413946c04c87 refactoring
laurent
parents:
diff changeset
    90
        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
    91
            bw = bh = 0     # no bitmap -> size is zero
413946c04c87 refactoring
laurent
parents:
diff changeset
    92
413946c04c87 refactoring
laurent
parents:
diff changeset
    93
        dc.SetFont(self.GetFont())
413946c04c87 refactoring
laurent
parents:
diff changeset
    94
        if self.IsEnabled():
413946c04c87 refactoring
laurent
parents:
diff changeset
    95
            dc.SetTextForeground(self.GetForegroundColour())
413946c04c87 refactoring
laurent
parents:
diff changeset
    96
        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
    97
            dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT))
413946c04c87 refactoring
laurent
parents:
diff changeset
    98
413946c04c87 refactoring
laurent
parents:
diff changeset
    99
        label = self.GetLabel()
413946c04c87 refactoring
laurent
parents:
diff changeset
   100
        tw, th = dc.GetTextExtent(label)        # size of text
413946c04c87 refactoring
laurent
parents:
diff changeset
   101
        if not self.up:
413946c04c87 refactoring
laurent
parents:
diff changeset
   102
            dw = dy = self.labelDelta
413946c04c87 refactoring
laurent
parents:
diff changeset
   103
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   104
        pos_x = (width - bw) // 2 + dw      # adjust for bitmap and text to centre
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   105
        pos_y = (height - bh - th) // 2 + dy
1743
c3c3d1318130 clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1742
diff changeset
   106
        if bmp is not None:
1737
a39c2918c015 clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
   107
            dc.DrawBitmap(bmp, pos_x, pos_y, hasMask)  # draw bitmap if available
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   108
            pos_x = (width-tw)//2+dw      # adjust for bitmap and text to centre
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   109
            pos_y += bh + 2
413946c04c87 refactoring
laurent
parents:
diff changeset
   110
413946c04c87 refactoring
laurent
parents:
diff changeset
   111
        dc.DrawText(label, pos_x, pos_y)      # draw the text
413946c04c87 refactoring
laurent
parents:
diff changeset
   112
413946c04c87 refactoring
laurent
parents:
diff changeset
   113
1162
a2b4d366bc66 Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents: 1111
diff changeset
   114
class GenStaticBitmap(wx.StaticBitmap):
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   115
    """ Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32,
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   116
    and accept image name as __init__ parameter, fail silently if file do not exist"""
413946c04c87 refactoring
laurent
parents:
diff changeset
   117
    def __init__(self, parent, ID, bitmapname,
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1743
diff changeset
   118
                 pos=wx.DefaultPosition, size=wx.DefaultSize,
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1743
diff changeset
   119
                 style=0,
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1743
diff changeset
   120
                 name="genstatbmp"):
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   121
1162
a2b4d366bc66 Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents: 1111
diff changeset
   122
        bitmap = GetBitmap(bitmapname)
a2b4d366bc66 Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents: 1111
diff changeset
   123
        if bitmap is None:
a2b4d366bc66 Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents: 1111
diff changeset
   124
            bitmap = wx.EmptyBitmap(0, 0)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   125
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   126
        wx.StaticBitmap.__init__(self, parent, ID,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   127
                                 bitmap,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   128
                                 pos, size,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   129
                                 style,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   130
                                 name)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   131
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1734
diff changeset
   132
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   133
class ConfTreeNodeEditor(EditorPanel):
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   134
775
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   135
    SHOW_BASE_PARAMS = True
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 751
diff changeset
   136
    SHOW_PARAMS = True
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 846
diff changeset
   137
    CONFNODEEDITOR_TABS = []
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   138
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   139
    def _init_Editor(self, parent):
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 846
diff changeset
   140
        tabs_num = len(self.CONFNODEEDITOR_TABS)
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   141
        if self.SHOW_PARAMS and len(self.Controler.GetParamsAttributes()) > 0:
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 846
diff changeset
   142
            tabs_num += 1
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   143
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   144
        if tabs_num > 1 or self.SHOW_BASE_PARAMS:
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   145
            self.Editor = wx.Panel(parent,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   146
                                   style=wx.SUNKEN_BORDER | wx.SP_3D)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   147
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   148
            self.MainSizer = wx.BoxSizer(wx.VERTICAL)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   149
775
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   150
            if self.SHOW_BASE_PARAMS:
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   151
                baseparamseditor_sizer = wx.BoxSizer(wx.HORIZONTAL)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   152
                self.MainSizer.AddSizer(baseparamseditor_sizer, border=5,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   153
                                        flag=wx.GROW | wx.ALL)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   154
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   155
                self.FullIECChannel = wx.StaticText(self.Editor, -1)
775
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   156
                self.FullIECChannel.SetFont(
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   157
                    wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL,
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1743
diff changeset
   158
                            wx.BOLD, faceName=faces["helv"]))
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   159
                baseparamseditor_sizer.AddWindow(self.FullIECChannel,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   160
                                                 flag=wx.ALIGN_CENTER_VERTICAL)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   161
775
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   162
                updownsizer = wx.BoxSizer(wx.VERTICAL)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   163
                baseparamseditor_sizer.AddSizer(updownsizer, border=5,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   164
                                                flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL)
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   165
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   166
                self.IECCUpButton = wx.lib.buttons.GenBitmapTextButton(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   167
                    self.Editor,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   168
                    bitmap=GetBitmap('IECCDown'),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   169
                    size=wx.Size(16, 16),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   170
                    style=wx.NO_BORDER)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   171
                self.IECCUpButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(1),
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   172
                                       self.IECCUpButton)
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   173
                updownsizer.AddWindow(self.IECCUpButton, flag=wx.ALIGN_LEFT)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   174
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   175
                self.IECCDownButton = wx.lib.buttons.GenBitmapButton(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   176
                    self.Editor, bitmap=GetBitmap('IECCUp'),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   177
                    size=wx.Size(16, 16), style=wx.NO_BORDER)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   178
                self.IECCDownButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(-1),
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   179
                                         self.IECCDownButton)
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   180
                updownsizer.AddWindow(self.IECCDownButton, flag=wx.ALIGN_LEFT)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   181
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   182
                self.ConfNodeName = wx.TextCtrl(self.Editor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   183
                                                size=wx.Size(150, 25))
775
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   184
                self.ConfNodeName.SetFont(
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   185
                    wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL,
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1743
diff changeset
   186
                            wx.BOLD, faceName=faces["helv"]))
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   187
                self.ConfNodeName.Bind(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   188
                    wx.EVT_TEXT,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   189
                    self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name", True),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   190
                    self.ConfNodeName)
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   191
                baseparamseditor_sizer.AddWindow(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   192
                    self.ConfNodeName, border=5,
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   193
                    flag=wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   194
775
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   195
                buttons_sizer = self.GenerateMethodButtonSizer()
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   196
                baseparamseditor_sizer.AddSizer(buttons_sizer, flag=wx.ALIGN_CENTER)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   197
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   198
            if tabs_num > 1:
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   199
                self.ConfNodeNoteBook = wx.Notebook(self.Editor)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   200
                parent = self.ConfNodeNoteBook
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   201
                self.MainSizer.AddWindow(self.ConfNodeNoteBook, 1, flag=wx.GROW)
775
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   202
            else:
1059
50246061d5c6 Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents: 1055
diff changeset
   203
                parent = self.Editor
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   204
                self.ConfNodeNoteBook = None
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   205
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   206
            self.Editor.SetSizer(self.MainSizer)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   207
        else:
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   208
            self.ConfNodeNoteBook = None
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   209
            self.Editor = None
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   210
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   211
        for title, create_func_name in self.CONFNODEEDITOR_TABS:
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   212
            editor = getattr(self, create_func_name)(parent)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   213
            if self.ConfNodeNoteBook is not None:
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   214
                self.ConfNodeNoteBook.AddPage(editor, title)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   215
            elif self.SHOW_BASE_PARAMS:
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   216
                self.MainSizer.AddWindow(editor, 1, flag=wx.GROW)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   217
            else:
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   218
                self.Editor = editor
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   219
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   220
        if self.SHOW_PARAMS and len(self.Controler.GetParamsAttributes()) > 0:
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   221
1745
f9d32913bad4 clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1744
diff changeset
   222
            panel_style = wx.TAB_TRAVERSAL | wx.HSCROLL | wx.VSCROLL
1059
50246061d5c6 Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents: 1055
diff changeset
   223
            if self.ConfNodeNoteBook is None and parent != self.Editor:
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   224
                panel_style |= wx.SUNKEN_BORDER
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   225
            self.ParamsEditor = wx.ScrolledWindow(parent,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   226
                                                  style=panel_style)
1180
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   227
            self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnParamsEditorResize)
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   228
            self.ParamsEditor.Bind(wx.EVT_SCROLLWIN, self.OnParamsEditorScroll)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   229
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   230
            self.ParamsEditorSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=5)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   231
            self.ParamsEditorSizer.AddGrowableCol(0)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   232
            self.ParamsEditorSizer.AddGrowableRow(0)
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   233
            self.ParamsEditor.SetSizer(self.ParamsEditorSizer)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   234
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 751
diff changeset
   235
            self.ConfNodeParamsSizer = wx.BoxSizer(wx.VERTICAL)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   236
            self.ParamsEditorSizer.AddSizer(self.ConfNodeParamsSizer, border=5,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   237
                                            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   238
775
172be32a2482 Adding support for hiding node base params controls if needed
laurent
parents: 767
diff changeset
   239
            self.RefreshConfNodeParamsSizer()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   240
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 846
diff changeset
   241
            if self.ConfNodeNoteBook is not None:
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 846
diff changeset
   242
                self.ConfNodeNoteBook.AddPage(self.ParamsEditor, _("Config"))
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   243
            elif self.SHOW_BASE_PARAMS:
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   244
                self.MainSizer.AddWindow(self.ParamsEditor, 1, flag=wx.GROW)
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 846
diff changeset
   245
            else:
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 846
diff changeset
   246
                self.Editor = self.ParamsEditor
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 751
diff changeset
   247
        else:
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 751
diff changeset
   248
            self.ParamsEditor = None
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   249
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   250
    def __init__(self, parent, controler, window, tagname=""):
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   251
        EditorPanel.__init__(self, parent, tagname, window, controler)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   252
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   253
        icon_name = self.Controler.GetIconName()
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   254
        if icon_name is not None:
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   255
            self.SetIcon(GetBitmap(icon_name))
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   256
        else:
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   257
            self.SetIcon(GetBitmap("Extension"))
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   258
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   259
    def __del__(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
   260
        self.Controler.OnCloseEditor(self)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   261
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   262
    def GetTagName(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
   263
        return self.Controler.CTNFullName()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   264
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   265
    def GetTitle(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
   266
        fullname = self.Controler.CTNFullName()
413946c04c87 refactoring
laurent
parents:
diff changeset
   267
        if self.Controler.CTNTestModified():
413946c04c87 refactoring
laurent
parents:
diff changeset
   268
            return "~%s~" % fullname
413946c04c87 refactoring
laurent
parents:
diff changeset
   269
        return fullname
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   270
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   271
    def HasNoModel(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
   272
        return False
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   273
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   274
    def GetBufferState(self):
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   275
        return False, False
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   276
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   277
    def Undo(self):
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   278
        pass
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   279
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   280
    def Redo(self):
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   281
        pass
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   282
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 744
diff changeset
   283
    def RefreshView(self):
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 744
diff changeset
   284
        EditorPanel.RefreshView(self)
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   285
        if self.SHOW_BASE_PARAMS:
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   286
            self.ConfNodeName.ChangeValue(self.Controler.MandatoryParams[1].getName())
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   287
            self.RefreshIECChannelControlsState()
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 751
diff changeset
   288
        if self.ParamsEditor is not None:
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 751
diff changeset
   289
            self.RefreshConfNodeParamsSizer()
840
980863738cf6 Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents: 814
diff changeset
   290
            self.RefreshScrollbars()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   291
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   292
    def RefreshIECChannelControlsState(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
   293
        self.FullIECChannel.SetLabel(self.Controler.GetFullIEC_Channel())
413946c04c87 refactoring
laurent
parents:
diff changeset
   294
        self.IECCDownButton.Enable(self.Controler.BaseParams.getIEC_Channel() > 0)
1059
50246061d5c6 Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents: 1055
diff changeset
   295
        self.MainSizer.Layout()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   296
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   297
    def RefreshConfNodeParamsSizer(self):
413946c04c87 refactoring
laurent
parents:
diff changeset
   298
        self.Freeze()
413946c04c87 refactoring
laurent
parents:
diff changeset
   299
        self.ConfNodeParamsSizer.Clear(True)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   300
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   301
        confnode_infos = self.Controler.GetParamsAttributes()
413946c04c87 refactoring
laurent
parents:
diff changeset
   302
        if len(confnode_infos) > 0:
413946c04c87 refactoring
laurent
parents:
diff changeset
   303
            self.GenerateSizerElements(self.ConfNodeParamsSizer, confnode_infos, None, False)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   304
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   305
        self.ParamsEditorSizer.Layout()
413946c04c87 refactoring
laurent
parents:
diff changeset
   306
        self.Thaw()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   307
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   308
    def GenerateMethodButtonSizer(self):
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   309
        normal_bt_font = wx.Font(faces["size"] // 3,    wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"])
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   310
        mouseover_bt_font = wx.Font(faces["size"] // 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   311
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   312
        msizer = wx.BoxSizer(wx.HORIZONTAL)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   313
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   314
        for confnode_method in self.Controler.ConfNodeMethods:
1740
b789b695b5c6 clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1739
diff changeset
   315
            if "method" in confnode_method and confnode_method.get("shown", True):
1055
da483f620668 Fixed ConfTreeNodeEditor layout
Laurent Bessard
parents: 920
diff changeset
   316
                button = GenBitmapTextButton(self.Editor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   317
                                             bitmap=GetBitmap(confnode_method.get("bitmap", "Unknown")),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   318
                                             label=confnode_method["name"],
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   319
                                             style=wx.NO_BORDER)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   320
                button.SetFont(normal_bt_font)
413946c04c87 refactoring
laurent
parents:
diff changeset
   321
                button.SetToolTipString(confnode_method["tooltip"])
767
36e823a90d94 Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents: 762
diff changeset
   322
                if confnode_method.get("push", False):
36e823a90d94 Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents: 762
diff changeset
   323
                    button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True))
36e823a90d94 Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents: 762
diff changeset
   324
                else:
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   325
                    button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), button)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   326
                # a fancy underline on mouseover
1750
acf02488f37f clean-up: fix PEP8 E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1748
diff changeset
   327
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   328
                def setFontStyle(b, s):
413946c04c87 refactoring
laurent
parents:
diff changeset
   329
                    def fn(event):
413946c04c87 refactoring
laurent
parents:
diff changeset
   330
                        b.SetFont(s)
413946c04c87 refactoring
laurent
parents:
diff changeset
   331
                        b.Refresh()
413946c04c87 refactoring
laurent
parents:
diff changeset
   332
                        event.Skip()
413946c04c87 refactoring
laurent
parents:
diff changeset
   333
                    return fn
413946c04c87 refactoring
laurent
parents:
diff changeset
   334
                button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font))
413946c04c87 refactoring
laurent
parents:
diff changeset
   335
                button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font))
1733
dea107dce0c4 clean-up: fix some PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1712
diff changeset
   336
                # hack to force size to mini
1740
b789b695b5c6 clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1739
diff changeset
   337
                if not confnode_method.get("enabled", True):
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   338
                    button.Disable()
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   339
                msizer.AddWindow(button, flag=wx.ALIGN_CENTER)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   340
        return msizer
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   341
2001
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   342
    def UriOptions(self, event):
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   343
        CTR = self.ParentWindow.CTR
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   344
        CTR_BeremizRoot = CTR.BeremizRoot
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   345
        CTR_AppFrame = CTR.AppFrame
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   346
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   347
        # Get connector uri
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   348
        uri = CTR_BeremizRoot.getURI_location().strip()
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   349
        dialog = UriLocationEditor.UriLocationEditor(CTR_AppFrame, uri)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   350
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   351
        if dialog.ShowModal() == wx.ID_OK:
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   352
            CTR_BeremizRoot.setURI_location(dialog.GetURI())
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   353
            if CTR._View is not None:
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   354
                CTR._View.RefreshView()
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   355
            if CTR_AppFrame is not None:
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   356
                CTR_AppFrame.RefreshTitle()
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   357
                CTR_AppFrame.RefreshFileMenu()
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   358
                CTR_AppFrame.RefreshEditMenu()
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   359
                CTR_AppFrame.RefreshPageTitles()
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   360
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   361
        dialog.Destroy()
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   362
1744
69dfdb26f600 clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1743
diff changeset
   363
    def GenerateSizerElements(self, sizer, elements, path, clean=True):
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   364
        if clean:
413946c04c87 refactoring
laurent
parents:
diff changeset
   365
            sizer.Clear(True)
413946c04c87 refactoring
laurent
parents:
diff changeset
   366
        first = True
413946c04c87 refactoring
laurent
parents:
diff changeset
   367
        for element_infos in elements:
413946c04c87 refactoring
laurent
parents:
diff changeset
   368
            if path:
1734
750eeb7230a1 clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1733
diff changeset
   369
                element_path = "%s.%s" % (path, element_infos["name"])
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   370
            else:
413946c04c87 refactoring
laurent
parents:
diff changeset
   371
                element_path = element_infos["name"]
413946c04c87 refactoring
laurent
parents:
diff changeset
   372
            if element_infos["type"] == "element":
1282
f427352f9727 Added support for left panel add menu with multiple levels
laurent
parents: 1281
diff changeset
   373
                name = element_infos["name"]
f427352f9727 Added support for left panel add menu with multiple levels
laurent
parents: 1281
diff changeset
   374
                value = element_infos["value"]
f427352f9727 Added support for left panel add menu with multiple levels
laurent
parents: 1281
diff changeset
   375
                label = _(name)
f427352f9727 Added support for left panel add menu with multiple levels
laurent
parents: 1281
diff changeset
   376
                if value is not None:
f427352f9727 Added support for left panel add menu with multiple levels
laurent
parents: 1281
diff changeset
   377
                    label += " - %s" % _(value)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   378
                staticbox = wx.StaticBox(self.ParamsEditor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   379
                                         label=_(label), size=wx.Size(10, 0))
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   380
                staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
1562
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   381
                flags = (wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   382
                if first:
1562
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   383
                    flags |= wx.TOP
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   384
                sizer.AddSizer(staticboxsizer, border=5, flag=flags)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   385
                self.GenerateSizerElements(staticboxsizer,
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   386
                                           element_infos["children"],
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   387
                                           element_path)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   388
            else:
413946c04c87 refactoring
laurent
parents:
diff changeset
   389
                boxsizer = wx.FlexGridSizer(cols=3, rows=1)
413946c04c87 refactoring
laurent
parents:
diff changeset
   390
                boxsizer.AddGrowableCol(1)
1562
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   391
                flags = (wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   392
                if first:
1562
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   393
                    flags |= wx.TOP
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   394
                sizer.AddSizer(boxsizer, border=5, flag=flags)
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   395
                staticbitmap = GenStaticBitmap(
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   396
                    ID=-1, bitmapname=element_infos["name"],
1734
750eeb7230a1 clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1733
diff changeset
   397
                    name="%s_bitmap" % element_infos["name"], parent=self.ParamsEditor,
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   398
                    pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   399
                boxsizer.AddWindow(staticbitmap, border=5, flag=wx.RIGHT)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   400
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   401
                statictext = wx.StaticText(self.ParamsEditor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   402
                                           label="%s:" % _(element_infos["name"]))
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   403
                boxsizer.AddWindow(statictext, border=5,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   404
                                   flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   405
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   406
                if isinstance(element_infos["type"], types.ListType):
413946c04c87 refactoring
laurent
parents:
diff changeset
   407
                    if isinstance(element_infos["value"], types.TupleType):
413946c04c87 refactoring
laurent
parents:
diff changeset
   408
                        browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL)
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   409
                        boxsizer.AddSizer(browse_boxsizer)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   410
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   411
                        textctrl = wx.TextCtrl(self.ParamsEditor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   412
                                               size=wx.Size(275, -1), style=wx.TE_READONLY)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   413
                        if element_infos["value"] is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
   414
                            textctrl.SetValue(element_infos["value"][0])
413946c04c87 refactoring
laurent
parents:
diff changeset
   415
                            value_infos = element_infos["value"][1]
413946c04c87 refactoring
laurent
parents:
diff changeset
   416
                        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
   417
                            value_infos = None
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   418
                        browse_boxsizer.AddWindow(textctrl)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   419
1696
8043f32de7b8 make all dialog have non-fixed size
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1562
diff changeset
   420
                        button = wx.Button(self.ParamsEditor, label="...")
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   421
                        browse_boxsizer.AddWindow(button)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   422
                        button.Bind(wx.EVT_BUTTON,
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   423
                                    self.GetBrowseCallBackFunction(element_infos["name"], textctrl, element_infos["type"],
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   424
                                                                   value_infos, element_path),
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   425
                                    button)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   426
                    else:
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   427
                        combobox = wx.ComboBox(self.ParamsEditor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   428
                                               size=wx.Size(300, -1), style=wx.CB_READONLY)
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   429
                        boxsizer.AddWindow(combobox)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   430
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   431
                        if element_infos["use"] == "optional":
413946c04c87 refactoring
laurent
parents:
diff changeset
   432
                            combobox.Append("")
413946c04c87 refactoring
laurent
parents:
diff changeset
   433
                        if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType):
1847
6198190bc121 explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1846
diff changeset
   434
                            for choice, _xsdclass in element_infos["type"]:
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   435
                                combobox.Append(choice)
413946c04c87 refactoring
laurent
parents:
diff changeset
   436
                            name = element_infos["name"]
413946c04c87 refactoring
laurent
parents:
diff changeset
   437
                            value = element_infos["value"]
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   438
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   439
                            staticbox = wx.StaticBox(self.ParamsEditor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   440
                                                     label="%s - %s" % (_(name), _(value)),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   441
                                                     size=wx.Size(10, 0))
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   442
                            staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL)
1562
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   443
                            sizer.AddSizer(staticboxsizer, border=5, flag=wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   444
                            self.GenerateSizerElements(staticboxsizer, element_infos["children"], element_path)
413946c04c87 refactoring
laurent
parents:
diff changeset
   445
                            callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, element_path)
413946c04c87 refactoring
laurent
parents:
diff changeset
   446
                        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
   447
                            for choice in element_infos["type"]:
413946c04c87 refactoring
laurent
parents:
diff changeset
   448
                                combobox.Append(choice)
413946c04c87 refactoring
laurent
parents:
diff changeset
   449
                            callback = self.GetChoiceCallBackFunction(combobox, element_path)
413946c04c87 refactoring
laurent
parents:
diff changeset
   450
                        if element_infos["value"] is None:
413946c04c87 refactoring
laurent
parents:
diff changeset
   451
                            combobox.SetStringSelection("")
413946c04c87 refactoring
laurent
parents:
diff changeset
   452
                        else:
1712
c1987ef148e4 Backout changeset 92537edeb2052d53ba5cad8b6da8463dbc660bb1
Surkov Sergey <surkovsv93@gmail.com>
parents: 1707
diff changeset
   453
                            combobox.SetStringSelection(element_infos["value"])
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   454
                        combobox.Bind(wx.EVT_COMBOBOX, callback, combobox)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   455
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   456
                elif isinstance(element_infos["type"], types.DictType):
413946c04c87 refactoring
laurent
parents:
diff changeset
   457
                    scmin = -(2**31)
413946c04c87 refactoring
laurent
parents:
diff changeset
   458
                    scmax = 2**31-1
413946c04c87 refactoring
laurent
parents:
diff changeset
   459
                    if "min" in element_infos["type"]:
413946c04c87 refactoring
laurent
parents:
diff changeset
   460
                        scmin = element_infos["type"]["min"]
413946c04c87 refactoring
laurent
parents:
diff changeset
   461
                    if "max" in element_infos["type"]:
413946c04c87 refactoring
laurent
parents:
diff changeset
   462
                        scmax = element_infos["type"]["max"]
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   463
                    spinctrl = wx.SpinCtrl(self.ParamsEditor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   464
                                           size=wx.Size(300, -1),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   465
                                           style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT)
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   466
                    spinctrl.SetRange(scmin, scmax)
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   467
                    boxsizer.AddWindow(spinctrl)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   468
                    if element_infos["value"] is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
   469
                        spinctrl.SetValue(element_infos["value"])
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   470
                    spinctrl.Bind(wx.EVT_SPINCTRL,
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   471
                                  self.GetTextCtrlCallBackFunction(spinctrl, element_path),
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   472
                                  spinctrl)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   473
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   474
                else:
413946c04c87 refactoring
laurent
parents:
diff changeset
   475
                    if element_infos["type"] == "boolean":
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   476
                        checkbox = wx.CheckBox(self.ParamsEditor, size=wx.Size(17, 25))
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   477
                        boxsizer.AddWindow(checkbox)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   478
                        if element_infos["value"] is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
   479
                            checkbox.SetValue(element_infos["value"])
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   480
                        checkbox.Bind(wx.EVT_CHECKBOX,
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   481
                                      self.GetCheckBoxCallBackFunction(checkbox, element_path),
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   482
                                      checkbox)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   483
1740
b789b695b5c6 clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1739
diff changeset
   484
                    elif element_infos["type"] in ["unsignedLong", "long", "integer"]:
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   485
                        if element_infos["type"].startswith("unsigned"):
413946c04c87 refactoring
laurent
parents:
diff changeset
   486
                            scmin = 0
413946c04c87 refactoring
laurent
parents:
diff changeset
   487
                        else:
413946c04c87 refactoring
laurent
parents:
diff changeset
   488
                            scmin = -(2**31)
413946c04c87 refactoring
laurent
parents:
diff changeset
   489
                        scmax = 2**31-1
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   490
                        spinctrl = wx.SpinCtrl(self.ParamsEditor,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   491
                                               size=wx.Size(300, -1),
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   492
                                               style=wx.SP_ARROW_KEYS | wx.ALIGN_RIGHT)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   493
                        spinctrl.SetRange(scmin, scmax)
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   494
                        boxsizer.AddWindow(spinctrl)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   495
                        if element_infos["value"] is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
   496
                            spinctrl.SetValue(element_infos["value"])
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   497
                        spinctrl.Bind(wx.EVT_SPINCTRL,
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   498
                                      self.GetTextCtrlCallBackFunction(spinctrl, element_path),
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   499
                                      spinctrl)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   500
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   501
                    else:
413946c04c87 refactoring
laurent
parents:
diff changeset
   502
                        choices = self.ParentWindow.GetConfigEntry(element_path, [""])
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   503
                        textctrl = TextCtrlAutoComplete(name=element_infos["name"],
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   504
                                                        parent=self.ParamsEditor,
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   505
                                                        choices=choices,
781
cdc6393705ce Adding support using plcopeneditor bitmap library for icon request
laurent
parents: 775
diff changeset
   506
                                                        element_path=element_path,
846
26836e421e19 Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents: 844
diff changeset
   507
                                                        size=wx.Size(300, -1))
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   508
2001
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   509
                        if element_infos["name"] == "URI_location":
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   510
                            uriSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   511
                            uriSizer.AddGrowableCol(0)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   512
                            uriSizer.AddGrowableRow(0)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   513
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   514
                            self.EditButton = wx.Button(self.ParamsEditor, label='...', size=wx.Size(30, -1))
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   515
                            self.Bind(wx.EVT_BUTTON, self.UriOptions, self.EditButton)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   516
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   517
                            uriSizer.AddWindow(textctrl, flag=wx.GROW)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   518
                            uriSizer.AddWindow(self.EditButton, flag=wx.GROW)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   519
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   520
                            boxsizer.AddWindow(uriSizer)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   521
                        else:
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   522
                            boxsizer.AddWindow(textctrl)
bcbd41efd846 #2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents: 1991
diff changeset
   523
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   524
                        if element_infos["value"] is not None:
413946c04c87 refactoring
laurent
parents:
diff changeset
   525
                            textctrl.ChangeValue(str(element_infos["value"]))
1180
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   526
                        callback = self.GetTextCtrlCallBackFunction(textctrl, element_path)
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   527
                        textctrl.Bind(wx.EVT_TEXT_ENTER, callback)
1991
34a9287b6c7d #2476 Fix for saving text in URI edit text box. No need to click out of URI edit text box to save edited text.
dporopat <denis.poropat@smarteh.si>
parents: 1853
diff changeset
   528
                        textctrl.Bind(wx.EVT_TEXT, callback)
1180
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   529
                        textctrl.Bind(wx.EVT_KILL_FOCUS, callback)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   530
            first = False
1562
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   531
        sizer.Layout()
6e38f13d4b7b fix borders of pull-down choice list box in Config tab, in Project Properties
Sergey Surkov <surkovsv93@gmail.com>
parents: 1511
diff changeset
   532
        self.RefreshScrollbars()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   533
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   534
    def GetItemChannelChangedFunction(self, dir):
413946c04c87 refactoring
laurent
parents:
diff changeset
   535
        def OnConfNodeTreeItemChannelChanged(event):
413946c04c87 refactoring
laurent
parents:
diff changeset
   536
            confnode_IECChannel = self.Controler.BaseParams.getIEC_Channel()
1846
14b40afccd69 remove unused variables found by pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1768
diff changeset
   537
            self.SetConfNodeParamsAttribute("BaseParams.IEC_Channel", confnode_IECChannel + dir)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   538
            wx.CallAfter(self.RefreshIECChannelControlsState)
413946c04c87 refactoring
laurent
parents:
diff changeset
   539
            wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE)
413946c04c87 refactoring
laurent
parents:
diff changeset
   540
            event.Skip()
413946c04c87 refactoring
laurent
parents:
diff changeset
   541
        return OnConfNodeTreeItemChannelChanged
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   542
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   543
    def SetConfNodeParamsAttribute(self, *args, **kwargs):
413946c04c87 refactoring
laurent
parents:
diff changeset
   544
        res, StructChanged = self.Controler.SetParamsAttribute(*args, **kwargs)
1111
ee1a8c961f11 Fixed bug when changing IEC_Channel of node without params
Laurent Bessard
parents: 1105
diff changeset
   545
        if StructChanged and self.ParamsEditor is not None:
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   546
            wx.CallAfter(self.RefreshConfNodeParamsSizer)
413946c04c87 refactoring
laurent
parents:
diff changeset
   547
        wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU)
413946c04c87 refactoring
laurent
parents:
diff changeset
   548
        return res
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   549
767
36e823a90d94 Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents: 762
diff changeset
   550
    def GetButtonCallBackFunction(self, method, push=False):
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   551
        """ Generate the callbackfunc for a given confnode method"""
413946c04c87 refactoring
laurent
parents:
diff changeset
   552
        def OnButtonClick(event):
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   553
            # Disable button to prevent re-entrant call
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   554
            event.GetEventObject().Disable()
413946c04c87 refactoring
laurent
parents:
diff changeset
   555
            # Call
1740
b789b695b5c6 clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1739
diff changeset
   556
            getattr(self.Controler, method)()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   557
            # Re-enable button
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   558
            event.GetEventObject().Enable()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   559
767
36e823a90d94 Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents: 762
diff changeset
   560
            if not push:
36e823a90d94 Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents: 762
diff changeset
   561
                event.Skip()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   562
        return OnButtonClick
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   563
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   564
    def GetChoiceCallBackFunction(self, choicectrl, path):
413946c04c87 refactoring
laurent
parents:
diff changeset
   565
        def OnChoiceChanged(event):
413946c04c87 refactoring
laurent
parents:
diff changeset
   566
            res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection())
1315
ff14a66bbd12 Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents: 1282
diff changeset
   567
            if res is None:
ff14a66bbd12 Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents: 1282
diff changeset
   568
                res = ""
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   569
            choicectrl.SetStringSelection(res)
413946c04c87 refactoring
laurent
parents:
diff changeset
   570
            event.Skip()
413946c04c87 refactoring
laurent
parents:
diff changeset
   571
        return OnChoiceChanged
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   572
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   573
    def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, path):
413946c04c87 refactoring
laurent
parents:
diff changeset
   574
        def OnChoiceContentChanged(event):
1846
14b40afccd69 remove unused variables found by pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1768
diff changeset
   575
            self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection())
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 744
diff changeset
   576
            wx.CallAfter(self.RefreshConfNodeParamsSizer)
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   577
            event.Skip()
413946c04c87 refactoring
laurent
parents:
diff changeset
   578
        return OnChoiceContentChanged
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   579
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 744
diff changeset
   580
    def GetTextCtrlCallBackFunction(self, textctrl, path, refresh=False):
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   581
        def OnTextCtrlChanged(event):
413946c04c87 refactoring
laurent
parents:
diff changeset
   582
            res = self.SetConfNodeParamsAttribute(path, textctrl.GetValue())
413946c04c87 refactoring
laurent
parents:
diff changeset
   583
            if res != textctrl.GetValue():
844
ec9e6ef49878 Fixing bug when spinctrl new value is changed by ConfTreeNode
laurent
parents: 840
diff changeset
   584
                if isinstance(textctrl, wx.SpinCtrl):
ec9e6ef49878 Fixing bug when spinctrl new value is changed by ConfTreeNode
laurent
parents: 840
diff changeset
   585
                    textctrl.SetValue(res)
1179
3e7bd88fcff7 Fixed inconsistency in value display when setting integer value for float parameter
Laurent Bessard
parents: 1162
diff changeset
   586
                elif res is not None:
3e7bd88fcff7 Fixed inconsistency in value display when setting integer value for float parameter
Laurent Bessard
parents: 1162
diff changeset
   587
                    textctrl.ChangeValue(str(res))
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 744
diff changeset
   588
            if refresh:
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   589
                wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE, PAGETITLES)
413946c04c87 refactoring
laurent
parents:
diff changeset
   590
                wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, self.GetTagName())
413946c04c87 refactoring
laurent
parents:
diff changeset
   591
            event.Skip()
413946c04c87 refactoring
laurent
parents:
diff changeset
   592
        return OnTextCtrlChanged
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   593
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   594
    def GetCheckBoxCallBackFunction(self, chkbx, path):
413946c04c87 refactoring
laurent
parents:
diff changeset
   595
        def OnCheckBoxChanged(event):
413946c04c87 refactoring
laurent
parents:
diff changeset
   596
            res = self.SetConfNodeParamsAttribute(path, chkbx.IsChecked())
413946c04c87 refactoring
laurent
parents:
diff changeset
   597
            chkbx.SetValue(res)
413946c04c87 refactoring
laurent
parents:
diff changeset
   598
            event.Skip()
413946c04c87 refactoring
laurent
parents:
diff changeset
   599
        return OnCheckBoxChanged
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   600
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   601
    def GetBrowseCallBackFunction(self, name, textctrl, library, value_infos, path):
413946c04c87 refactoring
laurent
parents:
diff changeset
   602
        infos = [value_infos]
1750
acf02488f37f clean-up: fix PEP8 E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1748
diff changeset
   603
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   604
        def OnBrowseButton(event):
413946c04c87 refactoring
laurent
parents:
diff changeset
   605
            dialog = BrowseValuesLibraryDialog(self, name, library, infos[0])
413946c04c87 refactoring
laurent
parents:
diff changeset
   606
            if dialog.ShowModal() == wx.ID_OK:
413946c04c87 refactoring
laurent
parents:
diff changeset
   607
                value, value_infos = self.SetConfNodeParamsAttribute(path, dialog.GetValueInfos())
413946c04c87 refactoring
laurent
parents:
diff changeset
   608
                textctrl.ChangeValue(value)
413946c04c87 refactoring
laurent
parents:
diff changeset
   609
                infos[0] = value_infos
413946c04c87 refactoring
laurent
parents:
diff changeset
   610
            dialog.Destroy()
413946c04c87 refactoring
laurent
parents:
diff changeset
   611
            event.Skip()
413946c04c87 refactoring
laurent
parents:
diff changeset
   612
        return OnBrowseButton
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   613
840
980863738cf6 Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents: 814
diff changeset
   614
    def RefreshScrollbars(self):
746
2e09777a40d3 Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents: 744
diff changeset
   615
        self.ParamsEditor.GetBestSize()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   616
        xstart, ystart = self.ParamsEditor.GetViewStart()
413946c04c87 refactoring
laurent
parents:
diff changeset
   617
        window_size = self.ParamsEditor.GetClientSize()
413946c04c87 refactoring
laurent
parents:
diff changeset
   618
        maxx, maxy = self.ParamsEditorSizer.GetMinSize()
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   619
        posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT))
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   620
        posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT))
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   621
        self.ParamsEditor.Scroll(posx, posy)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   622
        self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT,
2437
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   623
                                        maxx // SCROLLBAR_UNIT,
105c20fdeb19 python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2182
diff changeset
   624
                                        maxy // SCROLLBAR_UNIT,
1768
691083b5682a clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1758
diff changeset
   625
                                        posx, posy)
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   626
1180
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   627
    def OnParamsEditorResize(self, event):
840
980863738cf6 Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents: 814
diff changeset
   628
        self.RefreshScrollbars()
738
413946c04c87 refactoring
laurent
parents:
diff changeset
   629
        event.Skip()
1451
94e620cbd9de Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents: 1315
diff changeset
   630
1180
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   631
    def OnParamsEditorScroll(self, event):
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   632
        control = self.ParamsEditor.FindFocus()
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   633
        if isinstance(control, TextCtrlAutoComplete):
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   634
            control.DismissListBox()
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   635
            self.Refresh()
276a30c68eaa Fixed bugs with TextCtrlAutoComplete
Laurent Bessard
parents: 1179
diff changeset
   636
        event.Skip()