1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 QT_SALOME_VERSION=@QT_SALOME_VERSION@
24 from PyQt@QT_SALOME_VERSION@.Qt import *
33 Connects signal of sender to slot of reciever or function.
37 1. Connect(sender, signal, reciever, slot)
38 - sender: sender of the signal
39 - signal: string value in the form 'signal_name(type1,type2,...)'
40 - reciever: reciever of the signal
41 - slot: string value in the form 'slot_name(type1,type2,...)'
43 2. Connect(sender, signal, function)
44 - sender: sender of the signal
45 - signal: string value in the form 'signal_name(type1,type2,...)'
46 - function: function instance
49 _process(args[0], args[1], args[2], args[3], __CONNECT__)
51 _process(args[0], args[1], None, args[2], __CONNECT__)
53 RuntimeError("Bad number of arguments, expected 3 or 4 !!!")
55 def Disconnect(*args):
57 Disconnects signal of sender to slot of reciever or function.
61 1. Disconnect(sender, signal, reciever, slot)
62 - sender: sender of the signal
63 - signal: string value in the form 'signal_name(type1,type2,...)'
64 - reciever: reciever of the signal
65 - slot: string value in the form 'slot_name(type1,type2,...)'
67 2. Disconnect(sender, signal, function)
68 - sender: sender of the signal
69 - signal: string value in the form 'signal_name(type1,type2,...)'
70 - function: function instance
73 _process(args[0], args[1], args[2], args[3], __DISCONNECT__)
75 _process(args[0], args[1], None, args[2], __DISCONNECT__)
77 RuntimeError("Bad number of arguments, expected 3 or 4 !!!")
79 def _process(sender,signal,reciever,slot,operation):
82 if isinstance(slot, str):
90 if QT_SALOME_VERSION == 4:
92 if operation == __CONNECT__:
93 _call = QObject.connect
94 elif operation == __DISCONNECT__:
95 _call = QObject.disconnect
97 _call(sender,SIGNAL(signal),slot)
99 _call(sender,SIGNAL(signal),reciever,SLOT(slot))
110 if len(signame) > 0 and (len(slotname) > 0 or isFunc):
115 if len(types.strip()) > 0:
116 arg1 = "[" + types + "]"
117 if operation == __DISCONNECT__:
119 if reciever is not None and not isFunc:
126 command = "sender." + signame + arg1 + "." + op + "connect(" + rcv + arg2 + ")"
129 raise RuntimeError("Bad signal '%s' or slot '%s' format !!!"%(signal, slot))