示例#1
0
    def __init__(self, stv, ui):
        self.MDI_ON = True

        self.stv = stv  # SimpleTabView
        self.UI = ui  # UserInterface

        QMdiArea.__init__(self, ui)
        # QMdiArea.__init__(self, parent)

        self.scrollView = QScrollArea(self)
        self.scrollView.setBackgroundRole(QPalette.Dark)
        self.scrollView.setVisible(False)

        #had to introduce separate scrollArea for 2D and 3D widgets. for some reason switching graphics widgets in Scroll area  did not work correctly.
        self.scrollView3D = QScrollArea(self)
        self.scrollView3D.setBackgroundRole(QPalette.Dark)
        self.scrollView3D.setVisible(False)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        pass
        # self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        # self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        self.win_inventory = WindowInventory()
        self.lastActiveRealWindow = None  # keeps track of the last active real window
示例#2
0
class MainArea(QMdiArea):
    def __init__(self, stv, ui):
        self.MDI_ON = True

        self.stv = stv  # SimpleTabView
        self.UI = ui  # UserInterface

        QMdiArea.__init__(self, ui)
        # QMdiArea.__init__(self, parent)

        self.scrollView = QScrollArea(self)
        self.scrollView.setBackgroundRole(QPalette.Dark)
        self.scrollView.setVisible(False)

        #had to introduce separate scrollArea for 2D and 3D widgets. for some reason switching graphics widgets in Scroll area  did not work correctly.
        self.scrollView3D = QScrollArea(self)
        self.scrollView3D.setBackgroundRole(QPalette.Dark)
        self.scrollView3D.setVisible(False)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        pass
        # self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        # self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        self.win_inventory = WindowInventory()
        self.lastActiveRealWindow = None  # keeps track of the last active real window

    def suggested_window_position(self):
        '''
        returns suggested position of the next window. For MainAreaMdi it returns QPoint(-1,-1)
        indicating that client code shuld use QMdiArea functionality to place windows
        :return:QPoint - position of the next window
        '''

        return QPoint(-1, -1)

    def addSubWindow(self, widget):

        import Graphics
        obj_type = 'other'
        if isinstance(widget,
                      Graphics.GraphicsFrameWidget.GraphicsFrameWidget):
            # obj_type = 'graphics'
            obj_type = GRAPHICS_WINDOW_LABEL
        elif isinstance(widget, Graphics.PlotFrameWidget.PlotFrameWidget):
            obj_type = PLOT_WINDOW_LABEL
            # obj_type = 'plot'

        window_name = obj_type + ' ' + str(self.win_inventory.get_counter())

        mdi_sub_window = QMdiArea.addSubWindow(self, widget)

        mdi_sub_window.setWindowTitle(window_name)

        self.win_inventory.add_to_inventory(obj=mdi_sub_window,
                                            obj_type=obj_type)

        return mdi_sub_window
    def __init__(self, stv, ui):

        self.MDI_ON = False

        self.stv = stv  # SimpleTabView
        self.UI = ui  # UserInterface

        self.win_inventory = WindowInventory()

        self.lastActiveRealWindow = None  # keeps track of the last active real window
        self.last_suggested_window_position = QPoint(0, 0)
示例#4
0
    def __init__(self, stv,  ui ):
        # self.mdiarea = self
        self.MDI_ON = True

        self.stv = stv # SimpleTabView
        self.UI = ui # UserInterface

        QMdiArea.__init__(self, ui)
        # QMdiArea.__init__(self, parent)

        self.scrollView = QScrollArea(self)
        self.scrollView.setBackgroundRole(QPalette.Dark)
        self.scrollView.setVisible(False)

        #had to introduce separate scrollArea for 2D and 3D widgets. for some reason switching graphics widgets in Scroll area  did not work correctly.
        self.scrollView3D = QScrollArea(self)
        self.scrollView3D.setBackgroundRole(QPalette.Dark)
        self.scrollView3D.setVisible(False)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        pass
        # self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        # self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        self.win_inventory = WindowInventory()
        self.lastActiveRealWindow = None # keeps track of the last active real window
示例#5
0
    def __init__(self, stv,  ui ):

        self.MDI_ON = False

        self.stv = stv # SimpleTabView
        self.UI = ui # UserInterface

        self.win_inventory = WindowInventory()

        self.lastActiveRealWindow = None # keeps track of the last active real window
        self.last_suggested_window_position = QPoint(0,0)
class MainArea(QWidget):
    def __init__(self, stv, ui):

        self.MDI_ON = False

        self.stv = stv  # SimpleTabView
        self.UI = ui  # UserInterface

        self.win_inventory = WindowInventory()

        self.lastActiveRealWindow = None  # keeps track of the last active real window
        self.last_suggested_window_position = QPoint(0, 0)

    def suggested_window_position(self):
        '''
        returns suggested position of the next window
        :return:QPoint - position of the next window
        '''

        rec = QApplication.desktop().screenGeometry()

        if self.last_suggested_window_position.x(
        ) == 0 and self.last_suggested_window_position.y() == 0:

            self.last_suggested_window_position = QPoint(
                rec.width() / 5,
                rec.height() / 5)
            return self.last_suggested_window_position
        else:
            from random import randint
            self.last_suggested_window_position = QPoint(
                randint(rec.width() / 5,
                        rec.width() / 2),
                randint(rec.height() / 5,
                        rec.height() / 2))
            return self.last_suggested_window_position

    def addSubWindow(self, widget):
        '''
        adds subwindow containing widget to the player
        :param widget: widget to be added to sub windows
        :return:None
        '''

        import Graphics
        print 'INSTANCE OF GraphicsFrameWidget =  ', isinstance(
            widget, Graphics.GraphicsFrameWidget.GraphicsFrameWidget)
        obj_type = 'other'
        if isinstance(widget,
                      Graphics.GraphicsFrameWidget.GraphicsFrameWidget):
            obj_type = GRAPHICS_WINDOW_LABEL

        elif isinstance(widget, Graphics.PlotFrameWidget.PlotFrameWidget):
            obj_type = PLOT_WINDOW_LABEL

        window_name = obj_type + ' ' + str(self.win_inventory.get_counter())

        subWindow = self.createSubWindow(name=window_name)  # sub window
        self.setupSubWindow(subWindow, widget, self.trUtf8(window_name))

        # inserting widget into dictionary
        self.win_inventory.add_to_inventory(obj=subWindow, obj_type=obj_type)

        return subWindow

    def tileSubWindows(self):
        '''
        dummy function to make conform to QMdiArea API
        :return: None
        '''
        pass

    def cascadeSubWindows(self):
        '''
        dummy function to make conform to QMdiArea API
        :return: None
        '''
        pass

    def activeSubWindow(self):
        '''
        returns last active subwindow
        :return: SubWindow object
        '''
        print 'returning lastActiveRealWindow=', self.lastActiveRealWindow
        return self.lastActiveRealWindow

    def setActiveSubWindow(self, win):
        '''
        Activates subwindow win
        :param: win - SubWindow object
        :return: None
        '''
        win.activateWindow()
        self.lastActiveRealWindow = win

    def subWindowList(self):
        '''
        returns list of all open subwindows
        :return: python list of SubWindow objects
        '''
        return self.win_inventory.values()

    def createSubWindow(self, name):
        '''
        Creates SubWindow with title specified using name parameter
        :param: name -  subwindow title
        :return: SubWindow object
        '''

        sub_window = SubWindow(self)
        sub_window.setObjectName(name)
        return sub_window

    def setupSubWindow(self, sub_window, widget, caption):
        '''
        Configures subwindow by placing widget in to qframe layout, setting window title (caption)
        and showing subwindow
        :param: sub_window - SubWindow object
        :param: widget - widget to be placed into sub_window
        :param: caption - subwindow title
        :return: None
        '''

        if caption is None:
            caption = QString()

        sub_window.setWindowTitle(caption)
        sub_window.setWidget(widget)
        sub_window.show()
示例#7
0
class MainArea(QMdiArea):
    def __init__(self, stv,  ui ):
        # self.mdiarea = self
        self.MDI_ON = True

        self.stv = stv # SimpleTabView
        self.UI = ui # UserInterface

        QMdiArea.__init__(self, ui)
        # QMdiArea.__init__(self, parent)

        self.scrollView = QScrollArea(self)
        self.scrollView.setBackgroundRole(QPalette.Dark)
        self.scrollView.setVisible(False)

        #had to introduce separate scrollArea for 2D and 3D widgets. for some reason switching graphics widgets in Scroll area  did not work correctly.
        self.scrollView3D = QScrollArea(self)
        self.scrollView3D.setBackgroundRole(QPalette.Dark)
        self.scrollView3D.setVisible(False)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        pass
        # self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        # self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        self.win_inventory = WindowInventory()
        self.lastActiveRealWindow = None # keeps track of the last active real window

    def suggested_window_position(self):
        '''
        returns suggested position of the next window. For MainAreaMdi it returns QPoint(-1,-1)
        indicating that client code shuld use QMdiArea functionality to place windows
        :return:QPoint - position of the next window
        '''

        return QPoint(-1, -1)

    def addSubWindow(self, widget):
        '''Creates QMdiSubwindow containing widget and adds it to QMdiArea

        :param widget: widget that will be placed in the qmdisubwindow
        :return: None
        '''

        import Graphics
        obj_type = 'other'
        if isinstance(widget, Graphics.GraphicsFrameWidget.GraphicsFrameWidget):
            # obj_type = 'graphics'
            obj_type = GRAPHICS_WINDOW_LABEL
        elif isinstance(widget, Graphics.PlotFrameWidget.PlotFrameWidget):
            obj_type = PLOT_WINDOW_LABEL
            # obj_type = 'plot'

        window_name = obj_type + ' ' + str(self.win_inventory.get_counter())

        # mdi_sub_window = QMdiSubWindow()
        mdi_sub_window = SubWindow(self)
        mdi_sub_window.setWidget(widget)
        mdi_sub_window.setAttribute(Qt.WA_DeleteOnClose)
        mdi_sub_window.setWindowTitle(window_name)

        QMdiArea.addSubWindow(self, mdi_sub_window)

        # old code that did not use SubWindow subclass
        # mdi_sub_window = QMdiArea.addSubWindow(self, widget)
        # mdi_sub_window.setWindowTitle(window_name)

        self.win_inventory.add_to_inventory(obj=mdi_sub_window, obj_type=obj_type)

        return mdi_sub_window
示例#8
0
class MainArea(QWidget):
    def __init__(self, stv,  ui ):

        self.MDI_ON = False

        self.stv = stv # SimpleTabView
        self.UI = ui # UserInterface

        self.win_inventory = WindowInventory()

        self.lastActiveRealWindow = None # keeps track of the last active real window
        self.last_suggested_window_position = QPoint(0,0)


    def suggested_window_position(self):
        '''
        returns suggested position of the next window
        :return:QPoint - position of the next window
        '''

        rec = QApplication.desktop().screenGeometry()

        if self.last_suggested_window_position.x() == 0 and self.last_suggested_window_position.y() == 0:

            self.last_suggested_window_position = QPoint(rec.width()/5, rec.height()/5)
            return self.last_suggested_window_position
        else:
            from random import randint
            self.last_suggested_window_position = QPoint(randint(rec.width()/5, rec.width()/2), randint(rec.height()/5, rec.height()/2))
            return self.last_suggested_window_position

    def addSubWindow(self, widget):
        '''
        adds subwindow containing widget to the player
        :param widget: widget to be added to sub windows
        :return:None
        '''

        import Graphics
        print 'INSTANCE OF GraphicsFrameWidget =  ', isinstance(widget, Graphics.GraphicsFrameWidget.GraphicsFrameWidget)
        obj_type = 'other'
        if isinstance(widget, Graphics.GraphicsFrameWidget.GraphicsFrameWidget):
            obj_type = GRAPHICS_WINDOW_LABEL

        elif isinstance(widget, Graphics.PlotFrameWidget.PlotFrameWidget):
            obj_type = PLOT_WINDOW_LABEL

        window_name = obj_type + ' ' + str(self.win_inventory.get_counter())

        subWindow = self.createSubWindow(name=window_name) # sub window
        self.setupSubWindow(subWindow, widget, self.trUtf8(window_name))

        # inserting widget into dictionary
        self.win_inventory.add_to_inventory(obj = subWindow, obj_type=obj_type)

        return subWindow

    def tileSubWindows(self):
        '''
        dummy function to make conform to QMdiArea API
        :return: None
        '''
        pass

    def cascadeSubWindows(self):
        '''
        dummy function to make conform to QMdiArea API
        :return: None
        '''
        pass

    def activeSubWindow(self):
        '''
        returns last active subwindow
        :return: SubWindow object
        '''
        print 'returning lastActiveRealWindow=', self.lastActiveRealWindow
        return self.lastActiveRealWindow

    def setActiveSubWindow(self, win):
        '''
        Activates subwindow win
        :param: win - SubWindow object
        :return: None
        '''
        win.activateWindow()
        self.lastActiveRealWindow = win

    def subWindowList(self):
        '''
        returns list of all open subwindows
        :return: python list of SubWindow objects
        '''
        return self.win_inventory.values()

    def createSubWindow(self, name):
        '''
        Creates SubWindow with title specified using name parameter
        :param: name -  subwindow title
        :return: SubWindow object
        '''

        sub_window = SubWindow(self)
        sub_window .setObjectName(name)
        return sub_window

    def setupSubWindow(self, sub_window, widget, caption):
        '''
        Configures subwindow by placing widget in to qframe layout, setting window title (caption)
        and showing subwindow
        :param: sub_window - SubWindow object
        :param: widget - widget to be placed into sub_window
        :param: caption - subwindow title
        :return: None
        '''

        if caption is None:
            caption = QString()

        sub_window.setWindowTitle(caption)
        sub_window.setWidget(widget)
        sub_window.show()
示例#9
0
class MainArea(QMdiArea):
    def __init__(self, stv,  ui ):
        # self.mdiarea = self
        self.MDI_ON = True

        self.stv = stv # SimpleTabView
        self.UI = ui # UserInterface

        QMdiArea.__init__(self, ui)
        # QMdiArea.__init__(self, parent)

        self.scrollView = QScrollArea(self)
        self.scrollView.setBackgroundRole(QPalette.Dark)
        self.scrollView.setVisible(False)

        #had to introduce separate scrollArea for 2D and 3D widgets. for some reason switching graphics widgets in Scroll area  did not work correctly.
        self.scrollView3D = QScrollArea(self)
        self.scrollView3D.setBackgroundRole(QPalette.Dark)
        self.scrollView3D.setVisible(False)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        pass
        # self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        # self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)

        self.win_inventory = WindowInventory()
        self.lastActiveRealWindow = None # keeps track of the last active real window

    def suggested_window_position(self):
        '''
        returns suggested position of the next window. For MainAreaMdi it returns QPoint(-1,-1)
        indicating that client code shuld use QMdiArea functionality to place windows
        :return:QPoint - position of the next window
        '''

        return QPoint(-1, -1)

    def addSubWindow(self, widget):
        '''Creates QMdiSubwindow containing widget and adds it to QMdiArea

        :param widget: widget that will be placed in the qmdisubwindow
        :return: None
        '''

        import Graphics
        obj_type = 'other'
        if isinstance(widget, Graphics.GraphicsFrameWidget.GraphicsFrameWidget):
            # obj_type = 'graphics'
            obj_type = GRAPHICS_WINDOW_LABEL
        elif isinstance(widget, Graphics.PlotFrameWidget.PlotFrameWidget):
            obj_type = PLOT_WINDOW_LABEL
            # obj_type = 'plot'

        window_name = obj_type + ' ' + str(self.win_inventory.get_counter())

        # mdi_sub_window = QMdiSubWindow()
        mdi_sub_window = SubWindow(self)
        mdi_sub_window.setWidget(widget)
        mdi_sub_window.setAttribute(Qt.WA_DeleteOnClose)
        mdi_sub_window.setWindowTitle(window_name)

        QMdiArea.addSubWindow(self, mdi_sub_window)

        # old code that did not use SubWindow subclass
        # mdi_sub_window = QMdiArea.addSubWindow(self, widget)
        # mdi_sub_window.setWindowTitle(window_name)

        self.win_inventory.add_to_inventory(obj=mdi_sub_window, obj_type=obj_type)

        return mdi_sub_window

    def addSteeringSubWindow(self, widget):
        '''Creates QMdiSubwindow containing widget and adds it to QMdiArea

        :param widget: widget that will be placed in the qmdisubwindow
        :return: None
        '''


        # mdi_sub_window = QMdiSubWindow()
        mdi_sub_window = PythonSteeringSubWindow(self)
        mdi_sub_window.setWidget(widget)
        mdi_sub_window.setAttribute(Qt.WA_DeleteOnClose)
        mdi_sub_window.setWindowTitle('Steering Panel')

        QMdiArea.addSubWindow(self, mdi_sub_window)

        # old code that did not use SubWindow subclass
        # mdi_sub_window = QMdiArea.addSubWindow(self, widget)
        # mdi_sub_window.setWindowTitle(window_name)

        # self.win_inventory.add_to_inventory(obj=mdi_sub_window, obj_type=obj_type)

        self.win_inventory.add_to_inventory(obj=mdi_sub_window, obj_type=STEERING_PANEL_LABEL)
        return mdi_sub_window