MCPcopy Index your code
hub / github.com/rawpython/remi / SignalConnection

Class SignalConnection

editor/editor_widgets.py:141–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139
140
141class SignalConnection(gui.HBox):
142 def __init__(self, widget, listenersList, eventConnectionFuncName, eventConnectionFunc, **kwargs):
143 super(SignalConnection, self).__init__(**kwargs)
144
145 self.style.update(
146 {'overflow': 'visible', 'height': '24px', 'outline': '1px solid lightgray'})
147 self.label = gui.Label(eventConnectionFuncName, width='32%')
148 self.label.style.update({'float': 'left', 'font-size': '10px',
149 'overflow': 'hidden', 'outline': '1px solid lightgray'})
150
151 self.label_do = gui.Label(".do ->", style={'white-space':'nowrap'})
152
153 self.dropdownListeners = gui.DropDown(width='32%', height='100%')
154 self.dropdownListeners.onchange.do(self.on_listener_selection)
155 self.dropdownListeners.attributes['title'] = "The listener who will receive the event"
156
157 self.dropdownMethods = gui.DropDown(width='32%', height='100%')
158 self.dropdownMethods.onchange.do(self.on_connection)
159 self.dropdownMethods.attributes['title'] = """The listener's method who will receive the event. \
160 A custom method is selected by default. You can select another method, but you should check the method parameters."""
161
162 self.eventConnectionFunc = eventConnectionFunc
163 self.eventConnectionFuncName = eventConnectionFuncName
164 self.refWidget = widget
165 self.listenersList = listenersList
166 self.dropdownListeners.append(gui.DropDownItem("None"))
167 for w in listenersList:
168 ddi = gui.DropDownItem(w.variable_name)
169 ddi.listenerInstance = w
170 self.dropdownListeners.append(ddi)
171
172 if not self.eventConnectionFunc.callback is None:
173 try:
174 connectedListenerName = ''
175 connectedListenerFunction = None
176 print(str(type(eventConnectionFunc.callback)))
177
178 if issubclass(type(eventConnectionFunc.callback), gui.ClassEventConnector):
179 connectedListenerName = eventConnectionFunc.callback.event_method_bound.__self__.variable_name
180 connectedListenerFunction = eventConnectionFunc.callback.event_method_bound
181 else:
182 connectedListenerName = eventConnectionFunc.callback.__self__.variable_name
183 connectedListenerFunction = eventConnectionFunc.callback
184
185 self.dropdownListeners.select_by_value(connectedListenerName)
186 # this to automatically populate the listener methods dropdown
187
188 self.on_listener_selection(
189 self.dropdownListeners, connectedListenerName)
190 print("connected function name:" +
191 connectedListenerFunction.__name__)
192 self.dropdownMethods.select_by_value(
193 connectedListenerFunction.__name__)
194 # force the connection
195 #self.on_connection(None, None)
196 except Exception:
197 print(traceback.format_exc())
198 print(dir(eventConnectionFunc.callback))

Callers 1

updateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected