Hello, First of all, sorry about my lack of knowledge, and thank you, any kind of advice will be welcome. I've just started to learn about PyQt4 and avogadro, few weeks ago.
I am facing some problems that I haven't could solve by myself. I am working in the implementation of a python tool to provide different plots from avogadro results using PyQt4, giving a graphical interface for an user who will be able to choose between different options or customizations. To do that, I started learning PyQt4 with some easy tutorials. Now I would like to run one of them, which I tried independent from avogadro, through avogadro. I thought that I could use the Extension option, thus I followed the examples from the main website. I achieved that avogadro recognises my extension script in python and also appears as a new option in the main tool bar. The problems that I am facing are basically two (for now), even one of them I think that I fixed in a rude way. ____________________________________ The first problem, even it is not the most important problem (I guess), it is related with the imported files to the main script. I used the QTdesigner to generate "design.ui" file, then I converted it into design.py file to import it from my main python script application in an easier way. When I tried to do it in the extension it wasn't been imported, although I've put the file to be imported in the same folder. Is there a path problem (when I use "import design"), or is not possible to do it within avogadro's python Extension? ____________________________________ The second problem, and the most important, appears after the apparent solution of the first problem. To solve the previous problem, I copied the design code inside the main extension python file, and then I defined the main function used in the example to be called by the performinngaction function inside the Extension class, as it is shown in the following piece of code: """"""""" [...] def main(self): app = QApplication(sys.argv) # A new instance of QApplication form = ExampleApp() # We set the form to be our ExampleApp (design) form.show() # Show the form app.exec_() # and execute the app def performAction(self, action): self.emit(SIGNAL("message(const QString&)"), "performing action...") # return the undo command (ownership will be handled automatically) # return the undo command (ownership will be handled automatically) return self.main() """"""""" My example of a GUI application (ExampleApp() from: class ExampleApp(QMainWindow, Ui_MainWindow): ) is really simple: a window with a list space and two buttons, one of them to close the GUI. The problem appears when I click the action button in the menu of Avogadro, the perfomingaction function is called, but the sys.argv is not recognized: """"""""" performing action... Traceback (most recent call last): File "/***/****/.avogadro/extensionScripts/main2.py", line 120, in performAction return self.main() File "/***/****/.avogadro/extensionScripts/main2.py", line 111, in main app = QApplication(sys.argv) # A new instance of QApplication AttributeError: 'module' object has no attribute 'argv' """"""""" Finally, making some tests, when I imported matplotlib, the argv seems to be initialized, and when I click the button in the bar tool of the avogadro, the avogadro finishes... (and I don't know if it is because the program crashed or because the button with the option quit() inside the code) Sorry for the length of the e-mail. And thank you again. Best regards, R. Ruperez ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140 _______________________________________________ Avogadro-Discuss mailing list Avogadro-Discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/avogadro-discuss