Skip to content

Commit

Permalink
Fixed logistic interactive for PyQt5 type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyhyman committed Feb 8, 2023
1 parent 5375798 commit 426085e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
Binary file modified .DS_Store
Binary file not shown.
28 changes: 8 additions & 20 deletions logistic_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,6 @@ def __init__(self, variable='', parent=None):
self.l4.addWidget(self.ipop)
self.ipop.setValue(50)



self.verticalLayout.addLayout(self.l4)

self.resize(self.sizeHint())
Expand Down Expand Up @@ -530,8 +528,8 @@ def setValues(self, kind=''):
self.rateval = linear_interp(self.rate_box.value(),
0, 3.99, 0, 3.99, lim=1, dec=2)
self.rate.blockSignals(True)
self.rate.setValue( linear_interp(self.rateval,
0, 3.99, 0, 99, lim=1, dec=2) )
self.rate.setValue( int(linear_interp(self.rateval,
0, 3.99, 0, 99, lim=1, dec=2)) )
self.rate.blockSignals(False)

elif kind == 'ipop_slider':
Expand All @@ -540,16 +538,16 @@ def setValues(self, kind=''):


self.ipop_box.blockSignals(True)
self.ipop_box.setValue(self.ipopval)
self.ipop_box.setValue(float(self.ipopval))
self.ipop_box.blockSignals(False)


elif kind == 'ipop_box':
self.ipopval = self.ipop_box.value()

self.ipop.blockSignals(True)
self.ipop.setValue( linear_interp(self.ipopval,
0, 1, 0, 100, lim=1) )
self.ipop.setValue( int(linear_interp(self.ipopval,
0, 1, 0, 100, lim=1)) )
self.ipop.blockSignals(False)


Expand All @@ -575,7 +573,7 @@ def __init__(self, app, parent=None):
self.controls.setValues()
self.horizontalLayout.addWidget(self.controls)

self.win = pg.GraphicsWindow()
self.win = pg.GraphicsLayoutWidget()

self.setWindowTitle("Logistic Map 🤯")
self.horizontalLayout.addWidget(self.win)
Expand Down Expand Up @@ -658,7 +656,7 @@ def update_plot(self):

self.f = 0
self.fmax = 100
self.timer.start(self.animspeed)
self.timer.start(int(self.animspeed))

self.redraw_plots()

Expand All @@ -669,7 +667,7 @@ def update_plot(self):
self.animspeed = max(1, self.animspeed)
self.animspeed = 1000/self.animspeed

self.timer.start(self.animspeed)
self.timer.start(int(self.animspeed))

elif not self.animate and self.f == 0:

Expand Down Expand Up @@ -729,17 +727,7 @@ def animate_plot(self):

if self.f >= self.fmax:
self.timer.stop()
"""
def resizeEvent(self, event):

self.blockSignals(True)
w = event.size().width()
h = event.size().width() * 1/2.35
self.resize(w,h)
self.blockSignals(False)
"""

if __name__ == '__main__':
app = QApplication(sys.argv)
Expand Down

0 comments on commit 426085e

Please sign in to comment.