finally I can solve the problem by using this following 
tutorial: https://nikolak.com/pyqt-qt-designer-getting-started/

Pada Kamis, 24 Mei 2018 00.35.45 UTC+7, Jan Sebastian menulis:
>
> so, I try to follow the example from: 
> https://groups.google.com/forum/#!msg/pyqtgraph/kGHogKpcZC0/OgVijQEPEgAJ;context-place=forum/pyqtgraph
>  
> and https://gist.github.com/friendzis/4e98ebe2cf29c0c2c232 to change my 
> axis x format into time  and this is the example of my code:
>
> from PyQt4 import QtCore,QtGui,uic
> from PyQt4.QtCore import QTime, QTimer
> import sys
> import time
> from pyqtgraph import ViewBox, PlotWidget, PlotItem
> #import pyqtgraph as pg
> from pyqtgraph.Qt import QtCore, QtGui
>
> from collections import deque
> from customthread import customthread 
>
> class TimeAxisItem(pg.AxisItem):
>     def __init__(self, *args, **kwargs):
>         super().__init__(*args, **kwargs)
>
>     def tickStrings(self, values, scale, spacing):
>         a = 'a'
>         # PySide's QTime() initialiser fails miserably and dismisses 
> args/kwargs
>         return [QTime().addMSecs(value).toString('mm:ss') for value in 
> values]
>
>
> qtCreatorFile = "mejaGetar2.ui"
>
>
> Ui_MainWindow,QtBaseClass = uic.loadUiType(qtCreatorFile)
>
> class MyApp(QtGui.QTabWidget,Ui_MainWindow):
>     akselerasi = 0
>     #threads = []
>     #threads2 = []
>     curve = None
>     curve2 = None
>     dataGraph = deque(maxlen=20)
>     x1 = []
>     y1 = []
>     aa = False
>     aa2 = False
>     def __init__(self):
>
>         QtGui.QTabWidget.__init__(self)
>         Ui_MainWindow.__init__(self)
>         self.setupUi(self)
>         self.akselerasi.setMinimum(0)
>         self.akselerasi.setMaximum(30)
>         self.akselerasi.setValue(0)
>         self.akselerasi.valueChanged.connect(self.valueAkselerasi)
>         self.akselerasi.sliderReleased.connect(self.getThread)
>
>         self.threadDinamis = customthread ()
>         self.threadDinamis.dataThread.connect(self.runningDynamic)
>         MyApp.curve = self.graph1.plot(pen=(255,0,0))
>         self.graph1.setRange(xRange=None, yRange=[-1, 1 ])
>         self.graph1.setLabel('bottom', 'time', 's')
>         self.graph1.PlotWidget(axisItems={'bottom': 
> TimeAxisItem(orientation='bottom')})
>         self.graph1.showGrid(x=True, y=True)
>         self.graph1.setMouseEnabled(x=False, y=False)
>         
>
>         self.l1.setText(str(self.akselerasi.value()))
>
>         
>         
>     def getThread(self):
>         
>         if self.sender() == self.akselerasi:
>             MyApp.akselerasii = int(self.akselerasi.value())
>
>         if MyApp.akselerasii > 0:
>             if MyApp.aa == True:
>                 print("second")
>                 minRange = int(self.akselerasi.value()) * -1
>                 self.graph1.setRange(xRange=None, yRange=[minRange, 
> int(self.akselerasi.value()) ])
>                 self.threadDinamis.trigrer(MyApp.akselerasii)
>                 
>             else:
>                 minRange = int(self.akselerasi.value()) * -1
>                 self.graph1.setRange(xRange=None, yRange=[minRange, 
> int(self.akselerasi.value()) ])
>                 MyApp.aa = True
>                 
>                 print("first")
>                 self.threadDinamis.trigrer(MyApp.akselerasii)
>                 self.threadDinamis.start()
>         else:
>             self.threadDinamis.stop()
>             #self.graph1.clear()
>             MyApp.aa = False
>             MyApp.dataGraph.clear()
>             #MyApp.dataGraph = deque(maxlen=20)
>             MyApp.x1 = []
>             MyApp.y1 = []
>
>     def runningDynamic(self,generateData):
>         #print(generateData['x'])
>         MyApp.dataGraph.append({'x': generateData['x'], 'y': 
> generateData['y']})
>         MyApp.x1 = [item['x'] for item in MyApp.dataGraph]
>         MyApp.y1 = [item['y'] for item in MyApp.dataGraph]
>         MyApp.curve.setData(x=MyApp.x1, y=MyApp.y1)
>
>     def valueAkselerasi(self):
>         value = self.akselerasi.value()
>         self.l1.setText(str(value))     
>
>
> if __name__ == "__main__":
>     app = QtGui.QApplication(sys.argv)
>     window = MyApp()
>     window.show()
>     sys.exit(app.exec_())
>
> but, I got an error in self.graph1.PlotWidget(axisItems={'bottom': 
> TimeAxisItem(orientation='bottom')}) . the error says:
>
> Traceback (most recent call last):
>   File "D:\this\is\my\python\directory\app.py", line 153, in <module>
>     window = MyApp()
>   File "D:\this\is\my\python\directory\app.py", line 49, in __init__
>     self.graph1.PlotWidget(axisItems={'bottom': 
> TimeAxisItem(orientation='bottom')})
>   File "C:\Python36\lib\site-packages\pyqtgraph\widgets\PlotWidget.py", 
> line 79, in __getattr__
>     raise NameError(attr)
> NameError: PlotWidget
> so, I don't realy understand wath the error mean and how to fix it, thank 
> you 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/c9626e23-aa0f-4520-9765-1f50b71c981e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to