def __init__(self, parent=None, model=None, _id=None): """ """ super(MSSTableViewWindow, self).__init__(parent, model, _id) self.setupUi(self) self.setWindowIcon(QtGui.QIcon(icons('64x64'))) self.setFlightTrackModel(model) self.tableWayPoints.setItemDelegate(ft.WaypointDelegate(self)) toolitems = ["(select to open control)", "Hexagon Control"] self.cbTools.clear() self.cbTools.addItems(toolitems) self.tableWayPoints.dropEvent = types.MethodType( dropEvent, self.tableWayPoints) self.tableWayPoints.dragEnterEvent = types.MethodType( dragEnterEvent, self.tableWayPoints) # Dock windows [Hexagon]. self.docks = [None] # Connect slots and signals. self.btAddWayPointToFlightTrack.clicked.connect(self.addWayPoint) self.btCloneWaypoint.clicked.connect(self.cloneWaypoint) self.btDeleteWayPoint.clicked.connect(self.removeWayPoint) self.btInvertDirection.clicked.connect(self.invertDirection) self.btViewPerformance.clicked.connect(self.settingsDlg) # Tool opener. self.cbTools.currentIndexChanged.connect(self.openTool) self.resizeColumns()
def __init__(self, parent=None, model=None, _id=None): """Set up user interface, connect signal/slots. """ super(MSSSideViewWindow, self).__init__(parent, model, _id) self.setupUi(self) self.setWindowIcon(QtGui.QIcon(icons('64x64'))) # Dock windows [WMS]: self.cbTools.clear() self.cbTools.addItems(["(select to open control)", "Vertical Section WMS"]) self.docks = [None] self.setFlightTrackModel(model) self.settings_tag = "sideview" self.load_settings() # Connect slots and signals. # ========================== # Buttons to set sideview options. self.btOptions.clicked.connect(self.set_options) # Tool opener. self.cbTools.currentIndexChanged.connect(self.openTool)
def __init__(self, parent=None, model=None, _id=None): """Set up user interface, connect signal/slots. """ super(MSSTopViewWindow, self).__init__(parent, model, _id) logging.debug(_id) self.setupUi(self) self.setWindowIcon(QtGui.QIcon(icons('64x64'))) # Dock windows [WMS, Satellite, Trajectories, Remote Sensing, KML Overlay]: self.docks = [None, None, None, None, None] self.settings_tag = "topview" self.load_settings() # Initialise the GUI elements (map view, items of combo boxes etc.). self.setup_top_view() # Boolean to store active wms connection self.wms_connected = False # Connect slots and signals. # ========================== # Map controls. self.btMapRedraw.clicked.connect(self.mpl.canvas.redraw_map) self.cbChangeMapSection.activated.connect(self.changeMapSection) # Settings self.btSettings.clicked.connect(self.settings_dialogue) # Tool opener. self.cbTools.currentIndexChanged.connect(self.openTool)
def _icon(self, name, *args): """ wrapper around base method to inject our own icons. """ myname = icons("32x32", name) if os.path.exists(myname): return QtGui.QIcon(myname) else: return super(NavigationToolbar, self)._icon(name, *args)
def main(): try: prefix = os.environ["CONDA_DEFAULT_ENV"] except KeyError: prefix = "" app_prefix = prefix if prefix: app_prefix = "-{}".format(prefix) icon_hash = hashlib.md5('.'.join([__version__, app_prefix]).encode('utf-8')).hexdigest() parser = argparse.ArgumentParser() parser.add_argument("-v", "--version", help="show version", action="store_true", default=False) parser.add_argument("--debug", help="show debugging log messages on console", action="store_true", default=False) parser.add_argument("--logfile", help="Specify logfile location. Set to empty string to disable.", action="store", default=os.path.join(constants.MSS_CONFIG_PATH, "mss_pyui.log")) parser.add_argument("-m", "--menu", help="adds mss to menu", action="store_true", default=False) parser.add_argument("-d", "--deinstall", help="removes mss from menu", action="store_true", default=False) args = parser.parse_args() if args.version: print("***********************************************************************") print("\n Mission Support System (mss)\n") print("***********************************************************************") print("Documentation: http://mss.rtfd.io") print("Version:", __version__) sys.exit() setup_logging(args) if args.menu: # Experimental feature to get mss into application menu if platform.system() == "Linux": icon_size = '48x48' src_icon_path = icons(icon_size) icon_destination = constants.POSIX["icon_destination"].format(icon_size, icon_hash) dirname = os.path.dirname(icon_destination) if not os.path.exists(dirname): os.makedirs(dirname) shutil.copyfile(src_icon_path, icon_destination) desktop = constants.POSIX["desktop"] application_destination = constants.POSIX["application_destination"].format(app_prefix) dirname = os.path.dirname(application_destination) if not os.path.exists(dirname): os.makedirs(dirname) if prefix: prefix = "({})".format(prefix) desktop = desktop.format(prefix, os.path.join(sys.prefix, "bin", "mss"), icon_destination) with open(application_destination, 'w') as f: f.write(desktop) logging.info("menu entry created") sys.exit() if args.deinstall: application_destination = constants.POSIX["application_destination"].format(app_prefix) if os.path.exists(application_destination): os.remove(application_destination) icon_size = '48x48' icon_destination = constants.POSIX["icon_destination"].format(icon_size, icon_hash) if os.path.exists(icon_destination): os.remove(icon_destination) logging.info("menu entry removed") sys.exit() logging.info("MSS Version: %s", __version__) logging.info("Python Version: %s", sys.version) logging.info("Platform: %s (%s)", platform.platform(), platform.architecture()) logging.info("Launching user interface...") application = QtWidgets.QApplication(sys.argv) application.setWindowIcon(QtGui.QIcon(icons('128x128'))) application.setApplicationDisplayName("MSS") mainwindow = MSSMainWindow() mainwindow.create_new_flight_track() mainwindow.show() sys.exit(application.exec_())
def __init__(self, *args): super(MSSMainWindow, self).__init__(*args) self.setupUi(self) self.setWindowIcon(QtGui.QIcon(icons('32x32'))) # This code is required in Windows 7 to use the icon set by setWindowIcon in taskbar # instead of the default Icon of python/pythonw try: import ctypes myappid = "mss.mss_pyui.{}".format(__version__) # arbitrary string ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) except (ImportError, AttributeError) as error: logging.debug("AttributeError, ImportError Exception %s", error) # Reference to the flight track that is currently displayed in the # views. self.active_flight_track = None self.last_save_directory = config_loader(dataset="data_dir", default=mss_default.data_dir) self.mscolab_window = None self.config_editor = None # Connect Qt SIGNALs: # =================== # File menu. self.actionNewFlightTrack.triggered.connect(functools.partial(self.create_new_flight_track, None, None)) self.actionOpenFlightTrack.triggered.connect(self.open_flight_track) self.actionActivateSelectedFlightTrack.triggered.connect(self.activate_selected_flight_track) self.actionCloseSelectedFlightTrack.triggered.connect(self.close_selected_flight_track) self.actionSaveActiveFlightTrack.triggered.connect(self.save_flight_track) self.actionSaveActiveFlightTrackAs.triggered.connect(self.save_flight_track_as) # Views menu. self.actionTopView.triggered.connect(self.create_new_view) self.actionSideView.triggered.connect(self.create_new_view) self.actionTableView.triggered.connect(self.create_new_view) # mscolab menu self.actionMscolabProjects.triggered.connect(self.activate_mscolab_window) # Help menu. self.actionOnlineHelp.triggered.connect(self.show_online_help) self.actionAboutMSUI.triggered.connect(self.show_about_dialog) # Config self.actionConfiguration.triggered.connect(self.open_config_file) # Flight Tracks. self.listFlightTracks.itemActivated.connect(self.activate_flight_track) # Views. self.listViews.itemActivated.connect(self.activate_sub_window) self.add_import_filter("CSV", "csv", load_from_csv, pickertag="filepicker_flightrack") self.add_export_filter("CSV", "csv", save_to_csv, pickertag="filepicker_flightrack") self._imported_plugins, self._exported_plugins = {}, {} self.add_plugins() preload_urls = config_loader(dataset="WMS_preload", default=[]) self.preload_wms(preload_urls) # Status Bar self.labelStatusbar.setText(self.status())
def __init__(self, parent=None): super(EditorMainWindow, self).__init__(parent) self.path = None self.file_content = None self.layout = QtWidgets.QVBoxLayout() # Could also use a QTextEdit and set self.editor.setAcceptRichText(False) self.editor = QtWidgets.QPlainTextEdit() # Setup the QTextEdit editor configuration fixedfont = QtGui.QFontDatabase.systemFont( QtGui.QFontDatabase.FixedFont) fixedfont.setPointSize(12) self.editor.setFont(fixedfont) # self.path holds the path of the currently open file. # If none, we haven't got a file open yet (or creating new). self.path = constants.MSS_CONFIG_PATH self.layout.addWidget(self.editor) self.container = QtWidgets.QWidget() self.container.setLayout(self.layout) self.setCentralWidget(self.container) self.status = QtWidgets.QStatusBar() self.setStatusBar(self.status) self.file_toolbar = QtWidgets.QToolBar("File") self.file_toolbar.setIconSize(QtCore.QSize(14, 14)) self.addToolBar(self.file_toolbar) self.file_menu = self.menuBar().addMenu("&File") self.open_file_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Folder-new.svg')), "Open file...", self) self.open_file_action.setStatusTip("Open file") self.open_file_action.triggered.connect(self.file_open) self.file_menu.addAction(self.open_file_action) self.file_toolbar.addAction(self.open_file_action) self.save_file_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Document-save.svg')), "Save", self) self.save_file_action.setStatusTip("Save current page") self.save_file_action.triggered.connect(self.file_save) self.file_menu.addAction(self.save_file_action) self.file_toolbar.addAction(self.save_file_action) self.saveas_file_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Document-save-as.svg')), "Save As...", self) self.saveas_file_action.setStatusTip( "Save current page to specified file") self.saveas_file_action.triggered.connect(self.file_saveas) self.file_menu.addAction(self.saveas_file_action) self.file_toolbar.addAction(self.saveas_file_action) self.print_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Document-print.svg')), "Print...", self) self.print_action.setStatusTip("Print current page") self.print_action.triggered.connect(self.file_print) self.file_menu.addAction(self.print_action) self.file_toolbar.addAction(self.print_action) self.edit_toolbar = QtWidgets.QToolBar("Edit") self.edit_toolbar.setIconSize(QtCore.QSize(16, 16)) self.addToolBar(self.edit_toolbar) self.edit_menu = self.menuBar().addMenu("&Edit") self.undo_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Edit-undo.svg')), "Undo", self) self.undo_action.setStatusTip("Undo last change") self.undo_action.triggered.connect(self.editor.undo) self.edit_menu.addAction(self.undo_action) self.redo_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Edit-redo.svg')), "Redo", self) self.redo_action.setStatusTip("Redo last change") self.redo_action.triggered.connect(self.editor.redo) self.edit_toolbar.addAction(self.redo_action) self.edit_menu.addAction(self.redo_action) self.edit_menu.addSeparator() self.cut_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Edit-cut.svg')), "Cut", self) self.cut_action.setStatusTip("Cut selected text") self.cut_action.triggered.connect(self.editor.cut) self.edit_toolbar.addAction(self.cut_action) self.edit_menu.addAction(self.cut_action) self.copy_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Edit-copy.svg')), "Copy", self) self.copy_action.setStatusTip("Copy selected text") self.copy_action.triggered.connect(self.editor.copy) self.edit_toolbar.addAction(self.copy_action) self.edit_menu.addAction(self.copy_action) self.paste_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Edit-paste.svg')), "Paste", self) self.paste_action.setStatusTip("Paste from clipboard") self.paste_action.triggered.connect(self.editor.paste) self.edit_toolbar.addAction(self.paste_action) self.edit_menu.addAction(self.paste_action) self.select_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Edit-select-all.svg')), "Select all", self) self.select_action.setStatusTip("Select all text") self.select_action.triggered.connect(self.editor.selectAll) self.edit_menu.addAction(self.select_action) self.edit_menu.addSeparator() self.wrap_action = QtWidgets.QAction( QtGui.QIcon(icons('config_editor', 'Go-next.svg')), "Wrap text to window", self) self.wrap_action.setStatusTip("Toggle wrap text to window") self.wrap_action.setCheckable(True) self.wrap_action.setChecked(True) self.wrap_action.triggered.connect(self.edit_toggle_wrap) self.edit_menu.addAction(self.wrap_action) self.update_title() self.show()