def create_new_view(self): """Method called when the user selects a new view to be opened. Creates a new instance of the view and adds a QActiveViewsListWidgetItem to the list of open views (self.listViews). """ layout = config_loader(dataset="layout") view_window = None if self.sender() == self.actionTopView: # Top view. view_window = topview.MSSTopViewWindow(model=self.active_flight_track) view_window.mpl.resize(layout['topview'][0], layout['topview'][1]) if layout["immutable"]: view_window.mpl.setFixedSize(layout['topview'][0], layout['topview'][1]) elif self.sender() == self.actionSideView: # Side view. view_window = sideview.MSSSideViewWindow(model=self.active_flight_track) view_window.mpl.resize(layout['sideview'][0], layout['sideview'][1]) if layout["immutable"]: view_window.mpl.setFixedSize(layout['sideview'][0], layout['sideview'][1]) elif self.sender() == self.actionTableView: # Table view. view_window = tableview.MSSTableViewWindow(model=self.active_flight_track) view_window.centralwidget.resize(layout['tableview'][0], layout['tableview'][1]) if view_window is not None: # Make sure view window will be deleted after being closed, not # just hidden (cf. Chapter 5 in PyQt4). view_window.setAttribute(QtCore.Qt.WA_DeleteOnClose) # Open as a non-modal window. view_window.show() # Add an entry referencing the new view to the list of views. listitem = QActiveViewsListWidgetItem(view_window, self.listViews, self.viewsChanged) view_window.viewCloses.connect(listitem.view_destroyed) self.listViews.setCurrentItem(listitem) self.viewsChanged.emit()
def setup(self): self.application = QtWidgets.QApplication(sys.argv) self.port = PORTS.pop() self.tempdir = tempfile.mkdtemp() if not os.path.exists(self.tempdir): os.mkdir(self.tempdir) self.thread = multiprocessing.Process(target=application.run, args=("127.0.0.1", self.port)) self.thread.start() initial_waypoints = [ ft.Waypoint(40., 25., 0), ft.Waypoint(60., -10., 0), ft.Waypoint(40., 10, 0) ] waypoints_model = ft.WaypointsTableModel("") waypoints_model.insertRows(0, rows=len(initial_waypoints), waypoints=initial_waypoints) self.window = tv.MSSSideViewWindow(model=waypoints_model) self.window.show() QtWidgets.QApplication.processEvents() QtTest.QTest.qWait(2000) QtTest.QTest.qWaitForWindowExposed(self.window) QtWidgets.QApplication.processEvents() self.window.cbTools.currentIndexChanged.emit(1) QtWidgets.QApplication.processEvents() self.wms_control = self.window.docks[0].widget() self.wms_control.multilayers.cbWMS_URL.setEditText("")
def create_view_window(self, _type): for active_window in self.active_windows: if active_window.view_type == _type: active_window.raise_() active_window.activateWindow() return if _type == "topview": view_window = topview.MSSTopViewWindow(model=self.waypoints_model, parent=self.listProjects, _id=self.id_count) view_window.view_type = "topview" elif _type == "sideview": view_window = sideview.MSSSideViewWindow(model=self.waypoints_model, parent=self.listProjects, _id=self.id_count) view_window.view_type = "sideview" else: view_window = tableview.MSSTableViewWindow(model=self.waypoints_model, parent=self.listProjects, _id=self.id_count) view_window.view_type = "tableview" if self.access_level == "viewer": self.disable_navbar_action_buttons(_type, view_window) view_window.setAttribute(QtCore.Qt.WA_DeleteOnClose) view_window.show() view_window.viewClosesId.connect(self.handle_view_close) self.active_windows.append(view_window) # increment id_count self.id_count += 1
def setup(self): self.application = QtWidgets.QApplication(sys.argv) initial_waypoints = [ft.Waypoint(40., 25., 300), ft.Waypoint(60., -10., 400), ft.Waypoint(40., 10, 300)] waypoints_model = ft.WaypointsTableModel("") waypoints_model.insertRows( 0, rows=len(initial_waypoints), waypoints=initial_waypoints) self.window = tv.MSSSideViewWindow(model=waypoints_model) self.window.show() QtWidgets.QApplication.processEvents() QtTest.QTest.qWaitForWindowExposed(self.window) QtWidgets.QApplication.processEvents()