But now you are going back to that need for having these multiple case
tests with an arbitrary string identifier. I don't get why you need
that second string parameter.

If your argument is that you don't like the syntax of accessing
self.sender() in the slot, to know the calling object, you can just
pass it as an arg:

#
moveRequested = QtCore.pyqtSignal(int, object)
...
self.moveRequested.emit(event.key(), obj)
...
def moveLightItem(self, direction, selected_splitter):
   do something with selected_splitter
#

Why have all that redundant non-dynamic checks like:
if widget1:
  do something
elif widget2:
  do same thing
elif widget3
  ...

That means you would have to case out an "if" for every item in a fixed amount.



On Thu, Oct 11, 2012 at 3:06 PM, Berg Jones <bergjo...@gmail.com> wrote:
> Thanks for the tips. From the example you created the custom signal with
> only one parameter. If you use a second (str) param it can be a lot easier
> to comprehend and you can keep it in one class if you choose.
>
> moveRequested = QtCore.pyqtSignal(int,str)
>
>     self.moveRequested.connect(self.moveLightItem)
>     //////////////////
>
>     def eventFilter(self, obj, event):
>         if event.type() == QEvent.KeyPress:
>             key = event.key()
>             if key in (QtCore.Qt.Key_Up, QtCore.Qt.Key_Down):
>                 if obj == dynamicSidebarScroll_1:
>                     self.moveRequested.emit(event.key(), '1')
>                     return True
>                 if obj == dynamicSidebarScroll_2:
>                     self.moveRequested.emit(event.key(), '2')
>                     return True
>         return False
>
>
>     def moveLightItem(self, direction, widget):
>         if widget == '1':
>             selected_splitter = splitter_1
>         elif widget == '2':
>             selected_splitter = splitter_2
>
>         idx = insideTab_vertLayout.indexOf(selected_splitter)
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to