class PopupMenu(object): __slots__ = [ '__about', '__client', '__master', '__notifier', '__tray', '__widget' ] def __init__(self, client, tray): xml = gtk.glade.XML(Paths.glade, 'popup') Signals.autoconnect(self, xml) self.__about = AboutDialog(client) self.__client = client self.__master = xml.get_widget('menu-master') self.__notifier = MasterNotifier(self.__client, self.__master.set_active) self.__tray = tray self.__widget = xml.get_widget('popup') def popup(self, button, activate_time): self.__widget.popup(None, None, gtk.status_icon_position_menu, button, activate_time, self.__tray) def on_master_toggled(self, item): import Keys active = item.get_active() self.__client.set_bool(Keys.master, active) def on_preferences_activate(self, item): __pychecker__ = 'no-argsused' import PreferencesDialog PreferencesDialog.present() def on_about_activate(self, item): __pychecker__ = 'no-argsused' self.__about.present()
def on_actionAbout_triggered(self): """ Slot documentation goes here. """ aboutDialog = AboutDialog(self) if aboutDialog.exec_() == QDialog.Accepted: print 'ok'
def __init__(self, client, tray): xml = gtk.glade.XML(Paths.glade, 'popup') Signals.autoconnect(self, xml) self.__about = AboutDialog(client) self.__client = client self.__master = xml.get_widget('menu-master') self.__notifier = MasterNotifier(self.__client, self.__master.set_active) self.__tray = tray self.__widget = xml.get_widget('popup')
def main(): os.chdir(os.path.dirname(sys.argv[0])) app = QApplication(sys.argv) QApplication.setQuitOnLastWindowClosed(False) settings = Settings('facelock') aboutDialog = AboutDialog() settingsDialog = SettingsDialog(settings) ConfigurationChecker(settingsDialog).fixConfiguration() cameraProbe = CameraProbe() faceRecognitionBuilder=FaceRecognitionBuilder()\ .withSettings(settings)\ .withCameraProperties(cameraProbe.getFps(), cameraProbe.getWidth(), cameraProbe.getHeight()) trayIconGUI = SystemTrayGUIBuilder().\ withSettings(settings).\ withAboutDialog(aboutDialog).\ withSettingsDialog(settingsDialog).\ withFaceRecognitionBuilder(faceRecognitionBuilder).\ build() trayIconGUI.show() app.exec_()
def onClick(self, sender): if (sender == self.signOutLink): Window.alert("If this were implemented, you would be signed out now.") elif (sender == self.aboutLink): # When the 'About' item is selected, show the AboutDialog. # Note that showing a dialog box does not block -- execution continues # normally, and the dialog fires an event when it is closed. dlg = AboutDialog() # Position it roughly in the middle of the screen. left = (Window.getClientWidth() - 512) / 2 top = (Window.getClientHeight() - 256) / 2 #Logger("TopPanel", "left: " + left) #Logger("TopPanel", "top: " + top) dlg.setPopupPosition(left, top) dlg.show()
def __handle_button(self, identifier): dialog = None # FIXME: ignore identifiers that will not be handled if identifier == 'action_create_environment': self.__ascii_to_fds() return elif identifier == 'action_import_environment': self.__import_environment() return elif identifier == 'action_import_fuel_map': self.__import_fuel_map() return elif identifier == 'action_import_dem': self.__import_dem() return elif identifier == 'action_export_fuel_map': self.__export_fuel_map() elif identifier == 'action_export_dem': self.__export_dem() return elif identifier == 'action_run_sim': self.__run_simulation() elif identifier == 'action_view_sim': # We do not care about return value of QMessageBox self.__view_simulation() return elif identifier == 'action_user_setting': dialog = UserSettingsForm() elif identifier == 'action_select_output_files': dialog = SelectOutputFileTypesForm() self._output_file_types = dialog.get_file_types() return # Dialog will run itself, so we can return. elif identifier == 'action_about': dialog = AboutDialog() else: print('UNRECOGNIZED IDENTIFIER:', identifier) return if dialog is not None: dialog.setAttribute(QtCore.Qt.WA_DeleteOnClose ) # Ensure resources are freed when dlg closes dialog.exec_() # Executes dialog
def __init__(self, parent = None): QMainWindow.__init__(self, parent) self.setupUi(self) self.console = QDialog() self.te = QTextEdit(self.console) self.te.setReadOnly(True) vl = QVBoxLayout() vl.addWidget(self.te) self.console.setLayout(vl) # Set status Offline self.statusBox.setCurrentIndex(5) self.statusEdit.hide() # Set connect self.connect(self.statusBox, SIGNAL("currentIndexChanged(int)"), self.changeStatus) self.connect(self.statusEdit, SIGNAL("returnPressed()"), self.changeStatus) # Set BuddyList self.BuddyList = BuddyList(self) self.vboxlayout.insertWidget(0, self.BuddyList) self.connect(self.BuddyList, SIGNAL("rename"), self.addBuddy) # Connection connection = ConnectionDialog(self) self.connect(self.actionConnection, SIGNAL("triggered()"), connection, SLOT("exec()")) self.connect(self.actionDeconnection, SIGNAL("triggered()"), self.disconnect) self.connect(connection, SIGNAL("configured()"), self.connection) # Contacts self.connect(self.actionAdd_a_buddy, SIGNAL("triggered()"), self.addBuddy) self.connect(self.actionAdd_a_group, SIGNAL("triggered()"), self.addGroup) # View self.connect(self.actionAway_buddies, SIGNAL("toogled()"), self.setAway) self.connect(self.actionOffline_buddies, SIGNAL("toogled()"), self.setOffline) self.connect(self.actionAway_buddies, SIGNAL("triggered()"), self.setAway) self.connect(self.actionOffline_buddies, SIGNAL("triggered()"), self.setOffline) # Tools self.connect(self.actionConsole, SIGNAL("triggered()"), self.swapConsole) # About Dialog about = AboutDialog(self) self.connect(self.actionAbout, SIGNAL("triggered()"), about, SLOT("exec()")) self.connect(self.actionAboutQt, SIGNAL("triggered()"), QApplication.instance(), SLOT("aboutQt()")) # Quit Signal connection self.connect(self.actionQuit, SIGNAL("triggered()"), self.quit)
def __init__(self, application): self._application = application builder = gtk.Builder() builder.add_from_file(os.path.join(self._application.cli_options.share_dir, UNIX_APPNAME, "ui", "ui.glade")) self._window = builder.get_object("main_window") self._window.add_accel_group(builder.get_object("main_accelgroup")) self._window.set_title(_(APPNAME)) self._window.set_size_request(self._application.config["UI/width"], self._application.config["UI/height"]) self._maximized = self._application.config["UI/maximized"] if self._maximized: self._window.maximize() self._webview = webkit.WebView() builder.get_object("webview_container").add(self._webview) self._webview.get_settings().set_property('enable-file-access-from-file-uris', 1) self._webview.get_settings().set_property('enable-default-context-menu', 0) self._webview.connect("script-alert", self._on_webview_script_alert) self._webview_load_finished = False self._webview_pending_commands = [] self._statusbar = builder.get_object("statusbar") self._load_main_window() self._window.connect("delete_event", self._on_window_delete_event) builder.get_object("quit_menu_item").connect("activate", self._on_quit_clicked) builder.get_object("open_book_menuitem").connect("activate", self._on_open_book_clicked) builder.get_object("save_book_menuitem").connect("activate", self._on_save_book_clicked) builder.get_object("close_book_menuitem").connect("activate", self._on_close_book_clicked) builder.get_object("about_menuitem").connect("activate", self._on_about_clicked) self._open_book_dialog = OpenBookDialog(self._application, self._window) self._about_dialog = AboutDialog(self._window) self._save_quit_dialog = SaveQuitDialog(self._window) self._image_browser_dialog = ImageBrowserDialog(self._application, self._window) self._mapped = False self._window.connect("size-allocate", self._on_size_allocate) self._window.connect("window-state-event", self._on_window_state_event) self._window.connect("map-event", self._on_map_event)
def onClick(self, sender): if (sender == self.signOutLink): Window.alert( "If this were implemented, you would be signed out now.") elif (sender == self.aboutLink): # When the 'About' item is selected, show the AboutDialog. # Note that showing a dialog box does not block -- execution continues # normally, and the dialog fires an event when it is closed. dlg = AboutDialog() # Position it roughly in the middle of the screen. left = (Window.getClientWidth() - 512) / 2 top = (Window.getClientHeight() - 256) / 2 Logger("TopPanel", "left: %d" % left) Logger("TopPanel", "top: %d" % top) dlg.setPopupPosition(left, top) dlg.show()
def openAboutDialog(self): ad = AboutDialog(self) ad.exec_()
def doClickEvent(self, index, tag): if self.is_loading == True: # block click event if loading data in process return if tag.find('check#') != -1: print('index: %s label: %s' % (index, tag)) print(self.check[index].get()) else: if tag is 'Open': self.filename = filedialog.askopenfilename( initialdir="/", title=self.openfdialog_filter, filetypes=(("Supported Files (*.py)", "*.py"), ("All Files", "*.*"))) print(self.filename) elif tag.find('Server') != -1: s = ServerDialog(self.parent, title=tag) elif tag is 'SaveAs': self.filename = filedialog.asksaveasfilename( initialdir="/", title=self.savefdialog_filter, filetypes=(("Supported Files (*.py)", "*.py"), ("All Files", "*.*"))) elif tag is 'Recipients': r = RecipientDialog(self.parent, title="Email Addresses ") elif tag is 'New': c = ConfigCrawlDialog(self.parent, title="New Crawl") self.init_settings() self.init_workspaces() elif tag.find('Preferences') != -1: o = OptionsDialog(self.parent, title=tag) elif tag.find('About') != -1: a = AboutDialog(self.parent, title=tag) elif tag.find('Dispatchers') != -1: self.settings.SetSettings( 'selected_table', 'dispatchers') # set an action button that in dialog d = DispatcherDialog(self.parent, title=tag) elif tag.find('Companies') != -1: self.settings.SetSettings( 'selected_table', 'companies') # set an action button that in dialog d = DispatcherDialog(self.parent, title=tag) elif tag.find('Refresh') != -1: self.init_workspaces() self.start_dataThread() elif tag.find('All') != -1: res = messagebox.askquestion( 'Load All Crawled Data', 'This may take a few time.\nAre you sure you want to load all crawled data from WFM?' ) if res == 'yes': self.set_WFMTable(TABLE_ALLDATA) self.start_dataThread() elif tag.find('Status') != -1: self.settings.SetSettings( 'selected_table', 'status') # set an action button that in dialog d = DispatcherDialog(self.parent, title=tag) elif tag.find('Exit') != -1: self.onExit() elif tag.find('StartCrawl') != -1: if self.kill_ie.get() == 1: self.process.kill_process('iexplore.exe') self.crawlDialog = CrawlerDialog(self.parent) # init GUI #self.crawler = Crawler(self.crawlDialog) #init Controller #self.crawler.startCrawler() else: print('doClickEvent index: %s label: %s' % (index, tag))
def on_about_clicked(self): about_dialog = AboutDialog() about_dialog.exec_()
def initUI(self): self.clusteringParameters = ClusteringParameters(self) self.dimRedParameters = DimensionalityReductionParameters(self) self.classifierParameters = ClassifierParameters(self) self.regressionParameters = RegressionParameters(self) self.densityEstimationParameters = DensityEstimationParameters(self) self.probabilityDensityViewer = ProbabilityDensityViewer(self) self.licenseDialog = LicenseDialog(self) self.aboutDialog = AboutDialog(self, self.licenseDialog) self.infoDialog = InfoDialog(self) self.operationStack = OperationStack(self) self.createSamplesDockWidget = CreateSamplesProperties(self) self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.createSamplesDockWidget) self.statusbar = QtWidgets.QStatusBar() self.setStatusBar(self.statusbar) self.featurespace = FeatureSpace(self, self.statusbar, self.createSamplesDockWidget) self.setCentralWidget(self.featurespace) self.classifier = None self.regressor = None self.densityEstimator = None featureSpaceNewAction = QtWidgets.QAction('&New', self) featureSpaceNewAction.setShortcut('Ctrl+N') featureSpaceNewAction.setStatusTip('Create empty feature space') featureSpaceNewAction.triggered.connect(self.newFeatureSpace) featureSpaceOpenAction = QtWidgets.QAction('&Open...', self) featureSpaceOpenAction.setShortcut('Ctrl+O') featureSpaceOpenAction.setStatusTip('Load a feature space') featureSpaceOpenAction.triggered.connect(self.openFeatureSpace) featureSpaceSaveAction = QtWidgets.QAction('&Save', self) featureSpaceSaveAction.setShortcut('Ctrl+S') featureSpaceSaveAction.setStatusTip('Save the feature space') featureSpaceSaveAction.triggered.connect(self.saveFeatureSpace) featureSpaceSaveAsAction = QtWidgets.QAction('Save &as...', self) featureSpaceSaveAsAction.setStatusTip( 'Save the feature space to a new file') featureSpaceSaveAsAction.triggered.connect(self.saveAsFeatureSpace) featureSpaceImportAction = QtWidgets.QAction('&Import samples...', self) featureSpaceImportAction.setStatusTip( 'Read feature vectors from an ASCII file') featureSpaceImportAction.triggered.connect(self.importFeatureSpace) featureSpaceExportAction = QtWidgets.QAction('&Export samples...', self) featureSpaceExportAction.setStatusTip( 'Write the feature vectors to an ASCII file') featureSpaceExportAction.triggered.connect(self.exportFeatureSpace) featureSpaceSaveImageAction = QtWidgets.QAction( 'Export as image...', self) featureSpaceSaveImageAction.setStatusTip( 'Export the feature space as image') featureSpaceSaveImageAction.triggered.connect( self.exportFeatureSpaceAsImage) self.__featureSpaceHideSamplesAction = QtWidgets.QAction( 'Hide samples', self) self.__featureSpaceHideSamplesAction.setStatusTip('Hide all samples') self.__featureSpaceHideSamplesAction.setShortcut('F8') self.__featureSpaceHideSamplesAction.triggered.connect( self.hideSamples) self.__featureSpaceHideSamplesAction.setCheckable(True) self.__featureSpaceHideSamplesAction.setChecked(False) exitAction = QtWidgets.QAction('&Quit', self) exitAction.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Q) exitAction.setStatusTip('Exit the Python Classification Toolbox') exitAction.triggered.connect(self.close) menubar = self.menuBar() menubar.setNativeMenuBar(False) featureSpaceMenu = menubar.addMenu('&Feature Space') featureSpaceMenu.addAction(featureSpaceNewAction) featureSpaceMenu.addAction(featureSpaceOpenAction) featureSpaceMenu.addAction(featureSpaceSaveAction) featureSpaceMenu.addAction(featureSpaceSaveAsAction) featureSpaceMenu.addSeparator() featureSpaceMenu.addAction(featureSpaceImportAction) featureSpaceMenu.addAction(featureSpaceExportAction) featureSpaceMenu.addAction(featureSpaceSaveImageAction) featureSpaceMenu.addSeparator() featureSpaceMenu.addAction(self.__featureSpaceHideSamplesAction) featureSpaceMenu.addSeparator() featureSpaceMenu.addAction(exitAction) clusteringKMeansAction = QtWidgets.QAction('k-Means Clustering...', self) clusteringKMeansAction.setStatusTip('k-Means Clustering') clusteringKMeansAction.triggered.connect( lambda: self.clusterWithParameters(Clustering.kMeans)) clusteringGMMAction = QtWidgets.QAction('Gaussian Mixture Model...', self) clusteringGMMAction.setStatusTip('Gaussian Mixture Model') clusteringGMMAction.triggered.connect( lambda: self.clusterWithParameters(Clustering.GMM)) clusteringParametersAction = QtWidgets.QAction('Parameters...', self) clusteringParametersAction.setStatusTip( 'Edit the parameters of the clustering algorithms') clusteringParametersAction.triggered.connect( self.editClusteringParameters) clusteringMenu = menubar.addMenu('C&lustering') clusteringMenu.addAction(clusteringKMeansAction) clusteringMenu.addAction(clusteringGMMAction) clusteringMenu.addSeparator() clusteringMenu.addAction(clusteringParametersAction) dimRedPCAAction = QtWidgets.QAction('Principal Component Analysis...', self) dimRedPCAAction.setStatusTip('Principal Component Analysis (PCA)') dimRedPCAAction.triggered.connect( lambda: self.reduceDimensionalityWithParameters( DimensionalityReduction.PCA)) dimRedMenu = menubar.addMenu('&Dimensionality Reduction') dimRedMenu.addAction(dimRedPCAAction) classificationLogRegAction = QtWidgets.QAction( 'Linear Logistic Regression...', self) classificationLogRegAction.setStatusTip( 'Linear Logistic Regression classifier') classificationLogRegAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.LogReg)) classificationNormAction = QtWidgets.QAction('Norm classifier...', self) classificationNormAction.setStatusTip( 'Classification based on the distance to the class centers') classificationNormAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.Norm)) classificationNaiveBayesAction = QtWidgets.QAction('Naive Bayes', self) classificationNaiveBayesAction.setStatusTip('Naive Bayes classifier') classificationNaiveBayesAction.triggered.connect( lambda: self.classify(Classifier.NaiveBayes)) classificationGaussianAction = QtWidgets.QAction( 'Gaussian classifier', self) classificationGaussianAction.setStatusTip('Gaussian classifier') classificationGaussianAction.triggered.connect( lambda: self.classify(Classifier.Gauss)) classificationGMMAction = QtWidgets.QAction('GMM classifier...', self) classificationGMMAction.setStatusTip( 'Gaussian Mixture Model classifier') classificationGMMAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.GMM)) classificationKNNAction = QtWidgets.QAction('kNN...', self) classificationKNNAction.setStatusTip('k Nearest Neighbor classifier') classificationKNNAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.kNN)) classificationLinRegAction = QtWidgets.QAction('Linear Regression...', self) classificationLinRegAction.setStatusTip('Linear Regression classifier') classificationLinRegAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.LinReg)) classificationPerceptronAction = QtWidgets.QAction( 'Rosenblatt\'s Perceptron...', self) classificationPerceptronAction.setStatusTip('Rosenblatt\'s Perceptron') classificationPerceptronAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.Perceptron)) classificationMLPAction = QtWidgets.QAction('Multilayer Perceptron...', self) classificationMLPAction.setStatusTip('Multilayer Perceptron') classificationMLPAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.MLP)) try: # requires sklearn >= 0.18.dev0 neural_network.MLPClassifier() except: classificationMLPAction.setEnabled(False) classificationSVMAction = QtWidgets.QAction('SVM...', self) classificationSVMAction.setStatusTip('Support Vector Machine') classificationSVMAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.SVM)) classificationDecisionTreeAction = QtWidgets.QAction( 'Decision Tree...', self) classificationDecisionTreeAction.setStatusTip( 'Decision Tree classifier') classificationDecisionTreeAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.DecisionTree)) classificationRandomForestAction = QtWidgets.QAction( 'Random Forest...', self) classificationRandomForestAction.setStatusTip( 'Random Forest classifier') classificationRandomForestAction.triggered.connect( lambda: self.classifyWithParameters(Classifier.RandomForest)) classificationParametersAction = QtWidgets.QAction( 'Parameters...', self) classificationParametersAction.setStatusTip( 'Edit the parameters of the classification algorithms') classificationParametersAction.triggered.connect( self.editClassificationParameters) classificationNoneAction = QtWidgets.QAction('None', self) classificationNoneAction.setStatusTip('Delete classification results') classificationNoneAction.triggered.connect(self.unsetClassifier) classificationMenu = menubar.addMenu('&Classification') classificationMenu.addAction(classificationLogRegAction) classificationMenu.addAction(classificationNormAction) classificationMenu.addAction(classificationNaiveBayesAction) classificationMenu.addAction(classificationGaussianAction) classificationMenu.addAction(classificationGMMAction) classificationMenu.addAction(classificationKNNAction) classificationMenu.addAction(classificationLinRegAction) classificationMenu.addAction(classificationPerceptronAction) classificationMenu.addAction(classificationMLPAction) classificationMenu.addAction(classificationSVMAction) classificationMenu.addAction(classificationDecisionTreeAction) classificationMenu.addAction(classificationRandomForestAction) classificationMenu.addSeparator() classificationMenu.addAction(classificationParametersAction) classificationMenu.addAction(classificationNoneAction) regressionLinRegAction = QtWidgets.QAction('Linear Regression...', self) regressionLinRegAction.setStatusTip('Linear Regression') regressionLinRegAction.triggered.connect( lambda: self.regressionWithParameters(Regression.LinearRegression)) regressionSVRAction = QtWidgets.QAction('Support Vector Regression...', self) regressionSVRAction.setStatusTip('Support Vector Regression (SVR)') regressionSVRAction.triggered.connect( lambda: self.regressionWithParameters(Regression.SVR)) regressionRegressionTreeAction = QtWidgets.QAction( 'Regression Tree...', self) regressionRegressionTreeAction.setStatusTip('Regression Tree') regressionRegressionTreeAction.triggered.connect( lambda: self.regressionWithParameters(Regression.RegressionTree)) regressionRegressionForestAction = QtWidgets.QAction( 'Regression Forest...', self) regressionRegressionForestAction.setStatusTip('Regression Forest') regressionRegressionForestAction.triggered.connect( lambda: self.regressionWithParameters(Regression.RegressionForest)) regressionParametersAction = QtWidgets.QAction('Parameters...', self) regressionParametersAction.setStatusTip( 'Edit the parameters of the regression algorithms') regressionParametersAction.triggered.connect( self.editRegressionParameters) regressionNoneAction = QtWidgets.QAction('None', self) regressionNoneAction.setStatusTip('Delete regression result') regressionNoneAction.triggered.connect(self.unsetRegressor) regressionMenu = menubar.addMenu('&Regression') regressionMenu.addAction(regressionLinRegAction) regressionMenu.addAction(regressionSVRAction) regressionMenu.addAction(regressionRegressionTreeAction) regressionMenu.addAction(regressionRegressionForestAction) regressionMenu.addSeparator() regressionMenu.addAction(regressionParametersAction) regressionMenu.addAction(regressionNoneAction) densityEstimationHistogramAction = QtWidgets.QAction( 'Histogram...', self) densityEstimationHistogramAction.setStatusTip('Histogram estimation') densityEstimationHistogramAction.triggered.connect( lambda: self.densityEstimationWithParameters(DensityEstimation. Histogram)) densityEstimationSphereAction = QtWidgets.QAction( 'Sphere Density Estimation...', self) densityEstimationSphereAction.setStatusTip('Sphere Density Estimation') densityEstimationSphereAction.triggered.connect( lambda: self.densityEstimationWithParameters( DensityEstimation.SphereDensityEstimation)) densityEstimationKernelAction = QtWidgets.QAction( 'Kernel Density Estimation...', self) densityEstimationKernelAction.setStatusTip('Kernel Density Estimation') densityEstimationKernelAction.triggered.connect( lambda: self.densityEstimationWithParameters( DensityEstimation.KernelDensityEstimation)) densityEstimationParametersAction = QtWidgets.QAction( 'Parameters...', self) densityEstimationParametersAction.setStatusTip( 'Edit the parameters of the density estimation algorithms') densityEstimationParametersAction.triggered.connect( self.editDensityEstimationParameters) densityEstimationNoneAction = QtWidgets.QAction('None', self) densityEstimationNoneAction.setStatusTip( 'Delete density estimation result') densityEstimationNoneAction.triggered.connect( self.unsetDensityEstimation) densityEstimationMenu = menubar.addMenu('Density &Estimation') densityEstimationMenu.addAction(densityEstimationHistogramAction) densityEstimationMenu.addAction(densityEstimationSphereAction) densityEstimationMenu.addAction(densityEstimationKernelAction) densityEstimationMenu.addSeparator() densityEstimationMenu.addAction(densityEstimationParametersAction) densityEstimationMenu.addAction(densityEstimationNoneAction) aboutAction = QtWidgets.QAction('About...', self) aboutAction.setStatusTip('About this software') aboutAction.triggered.connect(self.aboutDialog.exec_) licenseAction = QtWidgets.QAction('License...', self) licenseAction.setStatusTip('GNU General Public License') licenseAction.triggered.connect(self.licenseDialog.showLicense) infoAction = QtWidgets.QAction('Info...', self) infoAction.setStatusTip('Information about the Python distribution') infoAction.triggered.connect(self.infoDialog.exec_) helpMenu = menubar.addMenu('&Help') helpMenu.addAction(aboutAction) helpMenu.addAction(licenseAction) helpMenu.addAction(infoAction) # exitAction = QtGui.QAction(QtGui.QIcon('./img/exit.png'), 'Exit', self) # exitAction.setShortcut('Ctrl+Q') # exitAction.triggered.connect(QtGui.qApp.quit) # coordinateSystemAction = QtGui.QAction(QtGui.QIcon('./img/coord.png'), 'Move coordinate system', self) # coordinateSystemAction.triggered.connect(self.onMoveCoordinateSystem) # gaussCreateAction = QtGui.QAction(QtGui.QIcon('./img/create_gauss.png'), 'Create Gaussians', self) # gaussCreateAction.triggered.connect(self.onCreateGaussians) # gaussModifyAction = QtGui.QAction(QtGui.QIcon('./img/modify_gauss.png'), 'Modify Gaussians', self) # gaussModifyAction.triggered.connect(self.onModifyGaussians) self.moveCoordinateSystemButton = QtWidgets.QToolButton() self.moveCoordinateSystemButton.setIcon( QtGui.QIcon(resource_path('./img/coord.png'))) self.moveCoordinateSystemButton.setStatusTip( 'Move the coordinate system by dragging the mouse or zoom in or out using the mouse scroll wheel' ) self.moveCoordinateSystemButton.setCheckable(True) self.moveCoordinateSystemButton.setChecked(True) self.moveCoordinateSystemButton.clicked.connect( self.onMoveCoordinateSystem) self.createGaussButton = QtWidgets.QToolButton() self.createGaussButton.setIcon( QtGui.QIcon(resource_path('./img/create_gauss.png'))) self.createGaussButton.setStatusTip( 'Create samples drawn from a new Gaussian pdf by spanning the bounding box of the covariance matrix' ) self.createGaussButton.setCheckable(True) self.createGaussButton.clicked.connect(self.onCreateGaussians) self.modifyGaussButton = QtWidgets.QToolButton() self.modifyGaussButton.setIcon( QtGui.QIcon(resource_path('./img/modify_gauss.png'))) self.modifyGaussButton.setStatusTip( 'Modify existing Gaussian pdfs by left of right clicking on the center' ) self.modifyGaussButton.setCheckable(True) self.modifyGaussButton.clicked.connect(self.onModifyGaussians) self.createSamplesButton = QtWidgets.QToolButton() self.createSamplesButton.setIcon( QtGui.QIcon(resource_path('./img/samples.png'))) self.createSamplesButton.setStatusTip( 'Create and modify individual samples by spanning a rectangle that contains one or more samples' ) self.createSamplesButton.setCheckable(True) self.createSamplesButton.clicked.connect(self.onCreateSamples) self.toolbar = QtWidgets.QToolBar(self) self.toolbar.setIconSize(QtCore.QSize(48, 48)) self.addToolBar(QtCore.Qt.RightToolBarArea, self.toolbar) # self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) # self.toolbar.addAction(coordinateSystemAction) # self.toolbar.addAction(gaussCreateAction) # self.toolbar.addAction(gaussModifyAction) self.toolbar.addWidget(self.moveCoordinateSystemButton) self.toolbar.addWidget(self.createGaussButton) self.toolbar.addWidget(self.modifyGaussButton) self.toolbar.addWidget(self.createSamplesButton) QtGui.QShortcut(QtGui.QKeySequence("Ctrl+Z"), self, self.undo) QtGui.QShortcut(QtGui.QKeySequence("Ctrl+R"), self, self.redo) self.printLicenseMessage()
def showAboutDialog(self, e): aboutDialog = AboutDialog(self) aboutDialog.show()
def OnAbout(self, event): from AboutDialog import AboutDialog aboutdlg = AboutDialog(None, _L["about_title"]) aboutdlg.ShowModal()
def webViewBridgeSlot_about(self): aboutDialog = AboutDialog() aboutDialog.exec_()
def about(self): dialog = AboutDialog(self.AppContext.get_resource('About.txt'), version=self.version) dialog.exec_()
def OnMenuHelp(self, event): dlg = AboutDialog(self, "About") dlg.CenterOnScreen() dlg.ShowModal() dlg.Destroy()
def __init__(self): super(self.__class__, self).__init__() self.setupUi(self) self.scale_spacing = 0.1 # in meters self.viewDataType = "thickness" self.scans2dLoaded = False self.scans3dLoaded = False self.refSelectionMode = False self.toolMode = -1 self.setToolMode(ToolModes.MoveMode) self.reportTool = -1 self.setReportTool(ReportTools.L) self.statusBarMessage = "" self.statusLabel = QtGui.QLabel() self.statusLabel.setText(self.statusBarMessage) self.statusbar.addWidget(self.statusLabel) self.optionsDialog = OptionsDialog() self.evaluationDialog = EvaluationDialog() self.scanManager = ScanManager(self.scanViewer, self.graphicsView, self.graphicsView_2) self.generate3dDialog = Generate3dDialog() self.reportDialog = ReportDialog() self.testDialog = TestDialog() self.autoDetectDialog = AutoDetectDialog(self.optionsDialog) self.savePictureDialog = SavePictureDialog() self.aboutDialog = AboutDialog() self.connect(self.autoDetectDialog, SIGNAL('showElement(PyQt_PyObject)'), self.loadElement) self.reportDialog.connect(self.autoDetectDialog, SIGNAL('reportElement(PyQt_PyObject)'), self.reportDialog.setCurrentElement) self.toolBar.actionTriggered.connect(self.processAction) self.menubar.triggered.connect(self.processAction) self.connect(self.pushButton_thickness, SIGNAL('clicked()'), self.thicknessButtonClicked) self.connect(self.pushButton_distance, SIGNAL('clicked()'), self.distanceButtonClicked) self.connect(self.pushButton_3d, SIGNAL('clicked()'), self.openGenerete3dDialog) self.connect(self.pushButton_go, SIGNAL('clicked()'), self.loadScan) self.connect(self.optionsDialog, SIGNAL("accepted()"), self.optionsAccepted) self.optionsDialog.connect(self.evaluationDialog, SIGNAL('changeTreshold(PyQt_PyObject)'), self.optionsDialog.setTreshold) self.connect(self.scanViewer, SIGNAL('mousePositionChanged(PyQt_PyObject)'), self.mousePositionChanged) self.connect(self.scanViewer, SIGNAL('areaSelected(PyQt_PyObject)'), self.areaSelected) self.connect(self.scanViewer, SIGNAL('tempDragModeActivated()'), self.tempDragModeEnable) self.connect(self.scanViewer, SIGNAL('tempDragModeDeactivated()'), self.tempDragModeDisable) self.connect(self.scanViewer, SIGNAL('mouseClicked(PyQt_PyObject)'), self.reportElement) self.scanManager.connect(self.scanViewer, SIGNAL('changeScale()'), self.scanManager.changeScale) self.connect(self.scanManager, SIGNAL('scans2dLoaded()'), self.setScans2dLoaded) self.connect(self.scanManager, SIGNAL('scans3dLoaded()'), self.setScans3dLoaded) self.connect(self.evaluationDialog, SIGNAL('changeParams(PyQt_PyObject)'), self.openOptions) self.connect(self.evaluationDialog, SIGNAL('activateRefSelection()'), self.activateRefSelectionMode) self.connect(self.evaluationDialog, SIGNAL('deactivateRefSelection()'), self.deactivateRefSelectionMode) self.connect(self.evaluationDialog, SIGNAL('corrosionReportSignal(PyQt_PyObject)'), self.addCorrosionReport) self.connect(self.generate3dDialog, SIGNAL('generate3d(PyQt_PyObject)'), self.generate3d) self.verticalSlider.valueChanged.connect(self.rearrangeScan) self.scanViewer.horizontalScrollBar().sliderReleased.connect( self.scanManager.checkIfScanLimitsReached) self.scanManager.connect(self.scanViewer, SIGNAL('checkIfScanLimitsReached()'), self.scanManager.checkIfScanLimitsReached) self.graphicsView.setBackgroundColor([255, 255, 255, 255]) self.thicknessButtonClicked()
class MainApp(QtGui.QMainWindow, MainWindow.Ui_MainWindow): def __init__(self): super(self.__class__, self).__init__() self.setupUi(self) self.scale_spacing = 0.1 # in meters self.viewDataType = "thickness" self.scans2dLoaded = False self.scans3dLoaded = False self.refSelectionMode = False self.toolMode = -1 self.setToolMode(ToolModes.MoveMode) self.reportTool = -1 self.setReportTool(ReportTools.L) self.statusBarMessage = "" self.statusLabel = QtGui.QLabel() self.statusLabel.setText(self.statusBarMessage) self.statusbar.addWidget(self.statusLabel) self.optionsDialog = OptionsDialog() self.evaluationDialog = EvaluationDialog() self.scanManager = ScanManager(self.scanViewer, self.graphicsView, self.graphicsView_2) self.generate3dDialog = Generate3dDialog() self.reportDialog = ReportDialog() self.testDialog = TestDialog() self.autoDetectDialog = AutoDetectDialog(self.optionsDialog) self.savePictureDialog = SavePictureDialog() self.aboutDialog = AboutDialog() self.connect(self.autoDetectDialog, SIGNAL('showElement(PyQt_PyObject)'), self.loadElement) self.reportDialog.connect(self.autoDetectDialog, SIGNAL('reportElement(PyQt_PyObject)'), self.reportDialog.setCurrentElement) self.toolBar.actionTriggered.connect(self.processAction) self.menubar.triggered.connect(self.processAction) self.connect(self.pushButton_thickness, SIGNAL('clicked()'), self.thicknessButtonClicked) self.connect(self.pushButton_distance, SIGNAL('clicked()'), self.distanceButtonClicked) self.connect(self.pushButton_3d, SIGNAL('clicked()'), self.openGenerete3dDialog) self.connect(self.pushButton_go, SIGNAL('clicked()'), self.loadScan) self.connect(self.optionsDialog, SIGNAL("accepted()"), self.optionsAccepted) self.optionsDialog.connect(self.evaluationDialog, SIGNAL('changeTreshold(PyQt_PyObject)'), self.optionsDialog.setTreshold) self.connect(self.scanViewer, SIGNAL('mousePositionChanged(PyQt_PyObject)'), self.mousePositionChanged) self.connect(self.scanViewer, SIGNAL('areaSelected(PyQt_PyObject)'), self.areaSelected) self.connect(self.scanViewer, SIGNAL('tempDragModeActivated()'), self.tempDragModeEnable) self.connect(self.scanViewer, SIGNAL('tempDragModeDeactivated()'), self.tempDragModeDisable) self.connect(self.scanViewer, SIGNAL('mouseClicked(PyQt_PyObject)'), self.reportElement) self.scanManager.connect(self.scanViewer, SIGNAL('changeScale()'), self.scanManager.changeScale) self.connect(self.scanManager, SIGNAL('scans2dLoaded()'), self.setScans2dLoaded) self.connect(self.scanManager, SIGNAL('scans3dLoaded()'), self.setScans3dLoaded) self.connect(self.evaluationDialog, SIGNAL('changeParams(PyQt_PyObject)'), self.openOptions) self.connect(self.evaluationDialog, SIGNAL('activateRefSelection()'), self.activateRefSelectionMode) self.connect(self.evaluationDialog, SIGNAL('deactivateRefSelection()'), self.deactivateRefSelectionMode) self.connect(self.evaluationDialog, SIGNAL('corrosionReportSignal(PyQt_PyObject)'), self.addCorrosionReport) self.connect(self.generate3dDialog, SIGNAL('generate3d(PyQt_PyObject)'), self.generate3d) self.verticalSlider.valueChanged.connect(self.rearrangeScan) self.scanViewer.horizontalScrollBar().sliderReleased.connect( self.scanManager.checkIfScanLimitsReached) self.scanManager.connect(self.scanViewer, SIGNAL('checkIfScanLimitsReached()'), self.scanManager.checkIfScanLimitsReached) self.graphicsView.setBackgroundColor([255, 255, 255, 255]) self.thicknessButtonClicked() def processAction(self, q_action): if q_action == self.actionOptions: self.openOptions() elif q_action == self.actionMove: self.setToolMode(ToolModes.MoveMode) elif q_action == self.actionCorrosions: self.setToolMode(ToolModes.CorrosionMode) elif q_action == self.actionReportAdd: self.setToolMode(ToolModes.ReportMode) elif q_action == self.actionReport: self.reportDialog.show() elif q_action == self.actionAutoDetect: self.autoDetectDialog.show() self.setToolMode(ToolModes.AutoDetectMode) elif q_action == self.screenShoot2D: self.setToolMode(ToolModes.ScreenShot2DMode) elif q_action == self.screenShoot3D: image3DToSave = self.scanManager.get3DImageToSave() self.savePictureDialog.saveImg(image3DToSave) self.setToolMode(ToolModes.ScreenShot3DMode) elif q_action == self.actionL: self.setReportTool(ReportTools.L) elif q_action == self.actionK: self.setReportTool(ReportTools.K) elif q_action == self.actionSW: self.setReportTool(ReportTools.SW) elif q_action == self.actionSP: self.setReportTool(ReportTools.SP) elif q_action == self.actionAbout: self.aboutDialog.show() def tempDragModeEnable(self): self.actionMove.setChecked(True) self.actionCorrosions.setChecked(False) self.actionReportAdd.setChecked(False) self.actionAutoDetect.setChecked(False) self.screenShoot3D.setChecked(False) self.screenShoot2D.setChecked(False) def tempDragModeDisable(self): self.setToolMode(self.toolMode) def setToolMode(self, mode): self.actionMove.setChecked(False) self.actionCorrosions.setChecked(False) self.actionReportAdd.setChecked(False) self.actionAutoDetect.setChecked(False) self.screenShoot3D.setChecked(False) self.screenShoot2D.setChecked(False) if mode == ToolModes.MoveMode: self.scanViewer.setDragMode(QtGui.QGraphicsView.ScrollHandDrag) self.toolMode = mode self.actionMove.setChecked(True) self.expandReportTools(False) elif mode == ToolModes.CorrosionMode: self.toolMode = mode self.actionCorrosions.setChecked(True) self.expandReportTools(False) self.scanViewer.setDragMode(QtGui.QGraphicsView.RubberBandDrag) elif mode == ToolModes.ReportMode: self.toolMode = mode self.actionReportAdd.setChecked(True) self.expandReportTools(True) elif mode == ToolModes.AutoDetectMode: self.toolMode = mode self.scanViewer.setDragMode(QtGui.QGraphicsView.RubberBandDrag) self.actionAutoDetect.setChecked(True) self.expandReportTools(False) elif mode == ToolModes.RefSelectionMode: self.toolMode = mode self.expandReportTools(False) elif mode == ToolModes.ScreenShot2DMode: self.toolMode = mode self.scanViewer.setDragMode(QtGui.QGraphicsView.RubberBandDrag) self.screenShoot2D.setChecked(True) self.expandReportTools(False) elif mode == ToolModes.ScreenShot3DMode: self.toolMode = mode self.screenShoot3D.setChecked(True) self.expandReportTools(False) def expandReportTools(self, expand): self.actionSP.setVisible(expand) self.actionSW.setVisible(expand) self.actionL.setVisible(expand) self.actionK.setVisible(expand) def setReportTool(self, tool): self.reportTool = tool self.actionL.setChecked(False) self.actionSP.setChecked(False) self.actionSW.setChecked(False) self.actionK.setChecked(False) if tool == ReportTools.L: self.actionL.setChecked(True) self.scanViewer.setDragMode(QtGui.QGraphicsView.RubberBandDrag) elif tool == ReportTools.SP: self.actionSP.setChecked(True) self.scanViewer.setDragMode(QtGui.QGraphicsView.NoDrag) elif tool == ReportTools.SW: self.actionSW.setChecked(True) self.scanViewer.setDragMode(QtGui.QGraphicsView.NoDrag) elif tool == ReportTools.K: self.actionK.setChecked(True) self.scanViewer.setDragMode(QtGui.QGraphicsView.RubberBandDrag) def addCorrosionReport(self, data): x = data[0][0] y = data[0][1] w = data[0][2] h = data[0][3] data.append("imgPath") image2DToSave = self.scanManager.get2DImageToSave(x, y, w, h) [x, y, d] = self.scanManager.getXYD(x + w / 2, y + h / 2, no_ratio=True) data[0] = 'X: ' + "{:.3F}".format(x) + " m" + ', Y: ' + "{:2d}".format( y[0]) + ' h ' + "{:2d}".format(y[1]) + ' min '.__str__() self.reportDialog.show() self.reportDialog.activateWindow() #print "Wysłano raport", data self.reportDialog.setCurrentElement([ReportTools.K.value, data], image2DToSave) def setScans2dLoaded(self): self.scans2dLoaded = True self.pushButton_3d.setEnabled(True) self.colorLegend() def setScans3dLoaded(self): self.scans3dLoaded = True self.pushButton_3d.setEnabled(True) def activateRefSelectionMode(self): self.setRefSelectionMode(True) self.activateWindow() def deactivateRefSelectionMode(self): self.setRefSelectionMode(False) def setRefSelectionMode(self, bool): if bool: self.toolMode = ToolModes.RefSelectionMode else: self.setToolMode(ToolModes.CorrosionMode) self.thicknessButtonClicked() self.pushButton_3d.setEnabled(not bool) self.pushButton_go.setEnabled(not bool) self.textEdit_km.setEnabled(not bool) self.pushButton_distance.setEnabled(not bool) self.comboBox_3.setEnabled(not bool) self.actionOptions.setEnabled(not bool) self.actionMove.setEnabled(not bool) self.actionAutoDetect.setEnabled(not bool) self.actionReport.setEnabled(not bool) self.actionCorrosions.setEnabled(not bool) self.actionReportAdd.setEnabled(not bool) self.screenShoot3D.setEnabled(not bool) self.screenShoot2D.setEnabled(not bool) self.actionL.setEnabled(not bool) self.actionSP.setEnabled(not bool) self.actionSW.setEnabled(not bool) def thicknessButtonClicked(self): self.pushButton_thickness.setChecked(True) self.pushButton_distance.setChecked(False) self.scanManager.viewDataType = "thickness" try: self.rearrangeScan() self.colorLegend() except: #print "blad tickness button clicked" return def distanceButtonClicked(self): self.pushButton_distance.setChecked(True) self.pushButton_thickness.setChecked(False) self.scanManager.viewDataType = "distance" try: self.rearrangeScan() self.colorLegend() except: #print "blad diustance button clicked" return def optionsAccepted(self): self.setEvalDialogParams() def closeEvent(self, QCloseEvent): self.evaluationDialog.close() self.optionsDialog.close() self.aboutDialog.close() self.savePictureDialog.close() self.autoDetectDialog.close() self.generate3dDialog.close() self.reportDialog.close() self.testDialog.close() super(self.__class__, self).closeEvent(QCloseEvent) def setEvalDialogParams(self): d = self.optionsDialog.Diameter dx = self.optionsDialog.DeltaX t = self.optionsDialog.thickness smys = self.optionsDialog.smys smys_unit = self.optionsDialog.pressureUnitSMYS p = self.optionsDialog.operatingPressure p_unit = self.optionsDialog.pressureUnitP factor_T = self.optionsDialog.factorT factor_F = self.optionsDialog.factorF th = self.optionsDialog.corrosionTreshold self.evaluationDialog.setParameters(d, dx, t, smys, smys_unit, p, p_unit, factor_T, factor_F, th) def areaSelected(self, rect): x = rect[0] y = rect[1] w = rect[2] h = rect[3] thickness_data_array = self.scanManager.getThicknessData( y, y + h + 1, x, x + w + 1) if self.toolMode == ToolModes.RefSelectionMode: self.evaluationDialog.showRefDialog( thickness_data_array, self.scanManager.thicknessScanColoredRearranged[y:y + h + 1, x:x + w + 1, :], self.scanViewer.aspect_ratio) elif self.toolMode == ToolModes.CorrosionMode: self.evaluationDialog.show() self.setEvalDialogParams() self.evaluationDialog.setData( thickness_data_array, self.scanManager.thicknessScanColoredRearranged[y:y + h + 1, x:x + w + 1, :], self.scanViewer.aspect_ratio, x, y, w, h) self.evaluationDialog.activateWindow() elif self.toolMode == ToolModes.ReportMode: self.reportDialog.show() self.reportDialog.activateWindow() image2DToSave = self.scanManager.get2DImageToSave( x, y, w + 1, h + 1) [x, y, d] = self.scanManager.getXYD(x + w / 2, y + h / 2, no_ratio=True) if self.reportTool == ReportTools.L: self.reportDialog.setCurrentElement([ ReportTools.L.value, [ 'X: ' + "{:.3F}".format(x) + " m" + ', Y: ' + "{:2d}".format(y[0]) + ' h ' + "{:2d}".format(y[1]) + ' min '.__str__(), "{:.3F}".format(w * self.scanManager.deltaX) + " mm", "{:.3F}".format(h * self.scanManager.deltaX) + " mm", "opisik laminacji", "imgPath" ] ], image2DToSave) elif self.reportTool == ReportTools.SP: self.reportDialog.setCurrentElement([ ReportTools.SP.value, [ 'X: ' + "{:.3F}".format(x) + " m", "{:.3F}".format(w * self.scanManager.deltaX) + " mm", "{:.3F}".format(h * self.scanManager.deltaX) + " mm", "opisik spoiny poprzecznej", "imgPath" ] ], image2DToSave) elif self.reportTool == ReportTools.SW: self.reportDialog.setCurrentElement([ ReportTools.SW.value, [ 'X: ' + "{:.3F}".format(x) + " m" + ', Y: ' + "{:2d}".format(y[0]) + ' h ' + "{:2d}".format(y[1]) + ' min ', "{:.3F}".format(w * self.scanManager.deltaX) + " mm", "{:.3F}".format(h * self.scanManager.deltaX) + " mm", "opisik spoiny wzdluznej", "imgPath" ] ], image2DToSave) elif self.reportTool == ReportTools.K: self.reportDialog.setCurrentElement([ ReportTools.K.value, [ 'X: ' + "{:.3F}".format(x) + " m" + ', Y: ' + "{:2d}".format(y[0]) + ' h ' + "{:2d}".format(y[1]) + ' min '.__str__(), "{:.3F}".format(w * self.scanManager.deltaX) + " mm", "{:.3F}".format(h * self.scanManager.deltaX) + " mm", "-", "-", "-", "-", "-", "imgPath" ] ], image2DToSave) elif self.toolMode == ToolModes.AutoDetectMode: self.testDialog.show() self.testDialog.setData( self.scanManager.thicknessScanRearranged[y:y + h, x:x + w], self.scanViewer.aspect_ratio) elif self.toolMode == ToolModes.ScreenShot2DMode: image2DToSave = self.scanManager.get2DImageToSave( x, y, w + 1, h + 1) self.savePictureDialog.saveImg(image2DToSave) def reportElement(self, pos): print "MouseClicked: ", pos x = pos[0] y = pos[1] w = 100 h = self.scanManager.bt1 - self.scanManager.bt0 if self.toolMode == ToolModes.ReportMode: self.reportDialog.show() self.reportDialog.activateWindow() if self.reportTool == ReportTools.SP: w = 100 h = self.scanManager.bt1 - self.scanManager.bt0 image2DToSave = self.scanManager.get2DImageToSave( x - w / 2, 0, w, h) [x, y, d] = self.scanManager.getXYD(x, y, no_ratio=True) self.reportDialog.setCurrentElement([ ReportTools.SP.value, [ 'X: ' + "{:.3F}".format(x) + " m", "opisik spoiny poprzecznej", "imgPath" ] ], image2DToSave) elif self.reportTool == ReportTools.SW: w = 300 h = 50 image2DToSave = self.scanManager.get2DImageToSave( x - 10, y - h / 2, w, h) [x, y, d] = self.scanManager.getXYD(x, y, no_ratio=True) self.reportDialog.setCurrentElement([ ReportTools.SW.value, [ 'X: ' + "{:.3F}".format(x) + " m" + ', Y: ' + "{:2d}".format(y[0]) + ' h ' + "{:2d}".format(y[1]) + ' min ', "-", "opisik spoiny wzdluznej", "imgPath" ] ], image2DToSave) def mousePositionChanged(self, QMouseEvent): if self.scans2dLoaded: position = self.scanViewer.mapToScene(QMouseEvent.pos().x(), QMouseEvent.pos().y()) position = position / self.scanViewer.view_scale [x, y, d] = self.scanManager.getXYD(position.x(), position.y()) self.statusBarMessage = 'X: ' + "{:.3F}".format( x ) + " m" + ', Y: ' + "{:2d}".format(y[0]) + ' h ' + "{:2d}".format( y[1]) + ' min ' + 'Grubosc: ' + "{:.3F}".format(d) + ' mm' self.statusLabel.setText(self.statusBarMessage) self.statusbar.update() def enableOnlyPipeParameters(self, bool): bool = not bool self.optionsDialog.textEdit_url.setEnabled(bool) self.optionsDialog.spinBox_frame_length.setEnabled(bool) self.optionsDialog.spinBox_thick_b_start.setEnabled(bool) self.optionsDialog.spinBox_thick_b_end.setEnabled(bool) self.optionsDialog.spinBox_dist_b_start.setEnabled(bool) self.optionsDialog.spinBox_dist_b_end.setEnabled(bool) self.optionsDialog.textEdit_A.setEnabled(bool) self.optionsDialog.textEdit_B.setEnabled(bool) self.optionsDialog.textEdit_C.setEnabled(bool) self.optionsDialog.textEdit_D.setEnabled(bool) self.optionsDialog.textEdit_deltaX.setEnabled(bool) self.optionsDialog.textEdit_dist.setEnabled(bool) def openOptions(self, onlyPipeParameters=False): if onlyPipeParameters: self.enableOnlyPipeParameters(True) else: self.enableOnlyPipeParameters(False) self.optionsDialog.show() self.optionsDialog.activateWindow() def openGenerete3dDialog(self): if self.comboBox_3.currentIndex() == 0: multiplier = 0.001 elif self.comboBox_3.currentIndex() == 1: multiplier = 1 elif self.comboBox_3.currentIndex() == 2: multiplier = 1000 meters = float(self.textEdit_km.toPlainText().replace( ",", ".")) * multiplier x1 = meters - 0.5 x2 = meters + 0.5 if self.generate3dDialog.textEdit.toPlainText() == '': self.generate3dDialog.textEdit.setText(x1.__str__()) if self.generate3dDialog.textEdit_2.toPlainText() == '': self.generate3dDialog.textEdit_2.setText(x2.__str__()) self.generate3dDialog.show() def generate3d(self, data): self.pushButton_3d.setEnabled(False) x1 = data[0] x2 = data[1] smooth = data[2] shaded = data[3] w = data[4] self.scanManager.create3dScan(x1, x2, smooth, shaded, w) def rearrangeScan(self): val = float(self.verticalSlider.value()) min = float(self.verticalSlider.minimum()) max = float(self.verticalSlider.maximum()) val_ratio = float(val / (max - min)) self.scanManager.rearrangeScan(val_ratio) def loadElement(self, data): milimiters = data[0] self.loadScan(milimiters) def loadScan(self, milimiters_start=-1, milimiters_end=-1): self.scans2dLoaded = False self.scans3dLoaded = False self.generate3dDialog.textEdit.clear() self.generate3dDialog.textEdit_2.clear() scan_dir = unicode(self.optionsDialog.dataDir) a = self.optionsDialog.CoefficientA b = self.optionsDialog.CoefficientB c = self.optionsDialog.CoefficientC d = self.optionsDialog.CoefficientD delta_x = self.optionsDialog.DeltaX diameter = self.optionsDialog.Diameter nominal_thickness = self.optionsDialog.thickness nominal_distance = self.optionsDialog.nominalDistance bd0 = self.optionsDialog.distanceStartByte bd1 = self.optionsDialog.distanceEndByte bt0 = self.optionsDialog.thicknessStartByte bt1 = self.optionsDialog.thicknessEndByte frame_length = self.optionsDialog.frameLength #print milimiters_start, milimiters_end if milimiters_start == -1 and milimiters_end == -1: if self.comboBox_3.currentIndex() == 0: multiplier = 1 elif self.comboBox_3.currentIndex() == 1: multiplier = 1000 elif self.comboBox_3.currentIndex() == 2: multiplier = 1000000 milimeters = float(self.textEdit_km.toPlainText().replace( ",", ".")) * multiplier self.scanManager.loadScan(milimeters, scan_dir, a, b, c, d, delta_x, diameter, nominal_thickness, nominal_distance, bd0, bd1, bt0, bt1, frame_length) elif milimiters_start != -1 and milimiters_end == -1: milimeters = float(milimiters_start) self.scanManager.loadScan(milimeters, scan_dir, a, b, c, d, delta_x, diameter, nominal_thickness, nominal_distance, bd0, bd1, bt0, bt1, frame_length) else: self.scanManager.loadScanFromTo(milimiters_start, milimiters_end, scan_dir, a, b, c, d, delta_x, diameter, nominal_thickness, nominal_distance, bd0, bd1, bt0, bt1, frame_length) def colorLegend(self): scene = QtGui.QGraphicsScene() items = self.scanManager.getColorLegendItems(400) for item in items: scene.addItem(item) self.graphicsView_2.setScene(scene) self.graphicsView_2.setMinimumHeight(scene.sceneRect().height())
def slot_About(self): w = AboutDialog(self) w.show()
def aboutSlot(self): AboutDialog().exec()
def about_dlg(self): # TODO: add version info/changelist to about dialog aboutdlg = AboutDialog(root, title="About")
class MainWindow(object): def __init__(self, application): self._application = application builder = gtk.Builder() builder.add_from_file(os.path.join(self._application.cli_options.share_dir, UNIX_APPNAME, "ui", "ui.glade")) self._window = builder.get_object("main_window") self._window.add_accel_group(builder.get_object("main_accelgroup")) self._window.set_title(_(APPNAME)) self._window.set_size_request(self._application.config["UI/width"], self._application.config["UI/height"]) self._maximized = self._application.config["UI/maximized"] if self._maximized: self._window.maximize() self._webview = webkit.WebView() builder.get_object("webview_container").add(self._webview) self._webview.get_settings().set_property('enable-file-access-from-file-uris', 1) self._webview.get_settings().set_property('enable-default-context-menu', 0) self._webview.connect("script-alert", self._on_webview_script_alert) self._webview_load_finished = False self._webview_pending_commands = [] self._statusbar = builder.get_object("statusbar") self._load_main_window() self._window.connect("delete_event", self._on_window_delete_event) builder.get_object("quit_menu_item").connect("activate", self._on_quit_clicked) builder.get_object("open_book_menuitem").connect("activate", self._on_open_book_clicked) builder.get_object("save_book_menuitem").connect("activate", self._on_save_book_clicked) builder.get_object("close_book_menuitem").connect("activate", self._on_close_book_clicked) builder.get_object("about_menuitem").connect("activate", self._on_about_clicked) self._open_book_dialog = OpenBookDialog(self._application, self._window) self._about_dialog = AboutDialog(self._window) self._save_quit_dialog = SaveQuitDialog(self._window) self._image_browser_dialog = ImageBrowserDialog(self._application, self._window) self._mapped = False self._window.connect("size-allocate", self._on_size_allocate) self._window.connect("window-state-event", self._on_window_state_event) self._window.connect("map-event", self._on_map_event) def _on_map_event(self, window, event): self._mapped = True self._window.connect("size-allocate", self._on_size_allocate) self._window.connect("window-state-event", self._on_window_state_event) def _on_window_state_event(self, window, event): if self._mapped: self._maximized = (event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED != 0) def _on_size_allocate(self, window, rectangle): if self._mapped: if self._maximized: self._application.config["UI/maximized"] = True else: self._application.config["UI/maximized"] = False width, height = self._window.get_size() self._application.config["UI/width"] = width self._application.config["UI/height"] = height def _check_quit(self): if self._application.book and self._application.book.changed: resp = self._save_quit_dialog.run() if resp == gtk.RESPONSE_YES: self._application.book.save() elif resp != gtk.RESPONSE_NO: return True gtk.main_quit() return False def _on_window_delete_event(self, window, event): return self._check_quit() def _on_close_book_clicked(self, menuitem): if self._application.book: if self._application.book.changed: resp = self._save_quit_dialog.run() if resp == gtk.RESPONSE_YES: self._application.book.save() elif resp != gtk.RESPONSE_NO: return self._application.unload_book() self.send_command("set_doc_structure(null)") def _on_about_clicked(self, menuitem): self._about_dialog.run() def _on_quit_clicked(self, menuitem): self._check_quit() def _on_open_book_clicked(self, menuitem): filename = self._open_book_dialog.run() if filename: if self._application.book: self._on_close_book_clicked(menuitem) if self._application.book: return self._application.load_book(filename) def _on_save_book_clicked(self, menuitem): self._application.book.save() def show_all(self): self._window.show_all() def _do_send_command(self, command): self._webview.execute_script(command) def send_command(self, command): if self._webview_load_finished: self._do_send_command(command) else: self._webview_pending_commands.append(command) def _on_webview_script_alert(self, editor, frame, message): logging.debug("_on_webview_script_alert:%s" % ":".join(message.split(":")[:2])) if ":" in message: i = message.index(":") command = message[:i] params = message[i+1:] else: command = message params = "" if command == "reload_doc_structure": if self._application.book: self.send_command("set_doc_structure(%s)" % json.dumps(self._application.book.get_structure_tree())) elif command == "editor_ready": while len(self._webview_pending_commands): command = self._webview_pending_commands[0] del self._webview_pending_commands[0] self._do_send_command(command) self._webview_load_finished = True elif command == "load_doc_section": section_id = int(params) section = self._application.book.find_section_by_id(section_id) xml = section.get_xml_text() if section.edit_mode == "html": self.send_command("set_edit_data(%s)" % json.dumps({"section_id": section_id, "edit_mode": section.edit_mode, "html": str(section.get_html()), "xml": str(xml)})) else: self.send_command("set_edit_data(%s)" % json.dumps({"section_id": section_id, "edit_mode": section.edit_mode, "xml": str(xml)})) elif command == "set_section_contents": i = params.index(":") section_id = int(params[:i]) contents = params[i+1:] section = self._application.book.find_section_by_id(section_id) parsing_error = section.update_from_html(contents) if parsing_error: parsing_error_json = json.dumps(_("You have an error in your document. Please fix it before editing another section.")) else: parsing_error_json = json.dumps(None) self.send_command("set_parsing_error(%s)" % parsing_error_json) self.send_command("set_doc_structure(%s)" % json.dumps(self._application.book.get_structure_tree())) elif command == "set_section_source_contents": i = params.index(":") section_id = int(params[:i]) contents = params[i+1:] section = self._application.book.find_section_by_id(section_id) parsing_error = section.update_from_xml(contents) if parsing_error: parsing_error_json = json.dumps(_("You have an error in your document. Please fix it before editing another section.")) else: parsing_error_json = json.dumps(None) self.send_command("set_parsing_error(%s)" % parsing_error_json) self.send_command("set_doc_structure(%s)" % json.dumps(self._application.book.get_structure_tree())) elif command == "browse_image": i = params.index(":") field_name = params[:i] url = params[i+1:] if url: filename = urllib.url2pathname(url)[7:] else: filename = None new_filename = self._image_browser_dialog.run(filename) if new_filename: self.send_command("set_file_browser_filename(%s)" % json.dumps({"field_name": field_name, "url": urlparse.urljoin('file:', urllib.pathname2url(new_filename))})) elif command == "load_config": self._do_send_command("set_config(%s)" % json.dumps(self._application.config.serialize())) elif command == "translate": self.send_command("set_translation(%s)" % json.dumps({"mesg": params, "translation": _(params)})) else: return False return True def _load_main_window(self): filename = os.path.join(self._application.cli_options.share_dir, UNIX_APPNAME, "ui", "main_window.html") f = open(filename) data = f.read() f.close() while "_(" in data: i = data.index("_(") pcount = 1 j = i + 2 while pcount != 0: if data[j] == "(": pcount += 1 if data[j] == ")": pcount -= 1 j += 1 data = data[:i] + _(data[i+2:j-1]) + data[j:] self._webview.load_html_string(data, urlparse.urljoin('file:', urllib.pathname2url(filename))) def refresh_view_for_new_book(self, section_id = 0): self.send_command("refresh_view_for_new_book(%d)" % section_id) if self._application.book: self._window.set_title("%s - %s" % (_(APPNAME), self._application.book.filename)) else: self._window.set_title("%s" % _(APPNAME))
def show_about(): logging.info("Show About dialog") about_dialog = AboutDialog(about_dialog_glade, SAFE_EYES_VERSION) about_dialog.show()
def on_about(self): dialog = AboutDialog(self) dialog.exec_()
def on_about(self): """ 点击关于软件,弹出关于界面\n :return: """ self.about_dlg = AboutDialog(True)
def aboutdialog(self): aboutdialogWindow = AboutDialog() aboutdialogWindow.show() aboutdialogWindow.exec_()
def OnAbout(self, event): dialog = AboutDialog(self) dialog.ShowModal()
def about(self): dialog = AboutDialog() dialog.exec_()