Advertisement
rugrln

Python script with PyQT GUI and Plot.ly plotting module

Aug 14th, 2014
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.45 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Form implementation generated from reading ui file 'simple_test.ui'
  4. #
  5. # Created: Wed Aug 06 19:09:43 2014
  6. #      by: PyQt4 UI code generator 4.11.1
  7. #
  8. # WARNING! All changes made in this file will be lost!
  9.  
  10. from PyQt4 import QtCore, QtGui
  11.  
  12. try:
  13.     _fromUtf8 = QtCore.QString.fromUtf8
  14. except AttributeError:
  15.     def _fromUtf8(s):
  16.         return s
  17.  
  18. try:
  19.     _encoding = QtGui.QApplication.UnicodeUTF8
  20.     def _translate(context, text, disambig):
  21.         return QtGui.QApplication.translate(context, text, disambig, _encoding)
  22. except AttributeError:
  23.     def _translate(context, text, disambig):
  24.         return QtGui.QApplication.translate(context, text, disambig)
  25.  
  26. class Ui_Dialog(object):
  27.     def setupUi(self, Dialog):
  28.         Dialog.setObjectName(_fromUtf8("Dialog"))
  29.         Dialog.resize(453, 455)
  30.         icon = QtGui.QIcon()
  31.         icon.addPixmap(QtGui.QPixmap(_fromUtf8("../../Users/Ismail/Pictures/Icons/python_icn.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  32.         Dialog.setWindowIcon(icon)
  33.         self.verticalLayout_2 = QtGui.QVBoxLayout(Dialog)
  34.         self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
  35.         self.verticalLayout = QtGui.QVBoxLayout()
  36.         self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
  37.         self.verticalLayout_3 = QtGui.QVBoxLayout()
  38.         self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
  39.         self.label = QtGui.QLabel(Dialog)
  40.         self.label.setObjectName(_fromUtf8("label"))
  41.         self.verticalLayout_3.addWidget(self.label)
  42.         self.verticalLayout.addLayout(self.verticalLayout_3)
  43.         self.label_2 = QtGui.QLabel(Dialog)
  44.         self.label_2.setObjectName(_fromUtf8("label_2"))
  45.         self.verticalLayout.addWidget(self.label_2)
  46.         self.verticalLayout_4 = QtGui.QVBoxLayout()
  47.         self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
  48.         self.runScript_btn = QtGui.QPushButton(Dialog)
  49.         self.runScript_btn.setObjectName(_fromUtf8("runScript_btn"))
  50.         self.verticalLayout_4.addWidget(self.runScript_btn)
  51.         self.verticalLayout.addLayout(self.verticalLayout_4)
  52.         self.verticalLayout_2.addLayout(self.verticalLayout)
  53.  
  54.         self.retranslateUi(Dialog)
  55.         QtCore.QMetaObject.connectSlotsByName(Dialog)
  56.  
  57.     def retranslateUi(self, Dialog):
  58.         Dialog.setWindowTitle(_translate("Dialog", "Python GUI", None))
  59.         self.label.setText(_translate("Dialog", "This is a test using Qt Designer to develop a GUI for a Python script.", None))
  60.         self.label_2.setText(_translate("Dialog", "This program will run a Python script.", None))
  61.         self.runScript_btn.setText(_translate("Dialog", "Run script", None))
  62.         self.runScript_btn.clicked.connect(self.runScript)
  63.  
  64.     def runScript(self):
  65.         import plotly.plotly as py
  66.         from plotly.graph_objs import Figure, Data, Layout, Scatter
  67.          
  68.         py.sign_in('USERNAME', 'API')
  69.         xresults = [1,2,3,4,5,6,7,8,9,10]
  70.         yresults = [10,3,5,7,9,12,15,25,30,2]
  71.         trace1 = Scatter(x=xresults, y=yresults)
  72.         my_data = Data([trace1])
  73.         my_layout = Layout(title = "Random graph")
  74.         my_fig = Figure(data=my_data, layout=my_layout)
  75.         py.plot(my_fig)
  76.  
  77. if __name__ == "__main__":
  78.     import sys
  79.     app = QtGui.QApplication(sys.argv)
  80.     Dialog = QtGui.QDialog()
  81.     ui = Ui_Dialog()
  82.     ui.setupUi(Dialog)
  83.     Dialog.show()
  84.     sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement