Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1156e23

Browse files
committed
Merge pull request #6061 from tacaswell/prf_qt_config_draw
PRF: change draw -> draw_idle
2 parents 306b546 + 3a2d8d2 commit 1156e23

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -747,13 +747,17 @@ def __init__(self, targetfig, parent):
747747

748748
self.defaults = {}
749749
for attr in ('left', 'bottom', 'right', 'top', 'wspace', 'hspace', ):
750-
self.defaults[attr] = getattr(self.targetfig.subplotpars, attr)
750+
val = getattr(self.targetfig.subplotpars, attr)
751+
self.defaults[attr] = val
751752
slider = getattr(self, 'slider' + attr)
753+
txt = getattr(self, attr + 'value')
752754
slider.setMinimum(0)
753755
slider.setMaximum(1000)
754756
slider.setSingleStep(5)
757+
# do this before hooking up the callbacks
758+
slider.setSliderPosition(int(val * 1000))
759+
txt.setText("%.2f" % val)
755760
slider.valueChanged.connect(getattr(self, 'func' + attr))
756-
757761
self._setSliderPositions()
758762

759763
def _setSliderPositions(self):
@@ -768,7 +772,7 @@ def funcleft(self, val):
768772
self.targetfig.subplots_adjust(left=val)
769773
self.leftvalue.setText("%.2f" % val)
770774
if self.drawon:
771-
self.targetfig.canvas.draw()
775+
self.targetfig.canvas.draw_idle()
772776

773777
def funcright(self, val):
774778
if val == self.sliderleft.value():
@@ -777,7 +781,7 @@ def funcright(self, val):
777781
self.targetfig.subplots_adjust(right=val)
778782
self.rightvalue.setText("%.2f" % val)
779783
if self.drawon:
780-
self.targetfig.canvas.draw()
784+
self.targetfig.canvas.draw_idle()
781785

782786
def funcbottom(self, val):
783787
if val == self.slidertop.value():
@@ -786,7 +790,7 @@ def funcbottom(self, val):
786790
self.targetfig.subplots_adjust(bottom=val)
787791
self.bottomvalue.setText("%.2f" % val)
788792
if self.drawon:
789-
self.targetfig.canvas.draw()
793+
self.targetfig.canvas.draw_idle()
790794

791795
def functop(self, val):
792796
if val == self.sliderbottom.value():
@@ -795,31 +799,31 @@ def functop(self, val):
795799
self.targetfig.subplots_adjust(top=val)
796800
self.topvalue.setText("%.2f" % val)
797801
if self.drawon:
798-
self.targetfig.canvas.draw()
802+
self.targetfig.canvas.draw_idle()
799803

800804
def funcwspace(self, val):
801805
val /= 1000.
802806
self.targetfig.subplots_adjust(wspace=val)
803807
self.wspacevalue.setText("%.2f" % val)
804808
if self.drawon:
805-
self.targetfig.canvas.draw()
809+
self.targetfig.canvas.draw_idle()
806810

807811
def funchspace(self, val):
808812
val /= 1000.
809813
self.targetfig.subplots_adjust(hspace=val)
810814
self.hspacevalue.setText("%.2f" % val)
811815
if self.drawon:
812-
self.targetfig.canvas.draw()
816+
self.targetfig.canvas.draw_idle()
813817

814818
def functight(self):
815819
self.targetfig.tight_layout()
816820
self._setSliderPositions()
817-
self.targetfig.canvas.draw()
821+
self.targetfig.canvas.draw_idle()
818822

819823
def reset(self):
820824
self.targetfig.subplots_adjust(**self.defaults)
821825
self._setSliderPositions()
822-
self.targetfig.canvas.draw()
826+
self.targetfig.canvas.draw_idle()
823827

824828

825829
def error_msg_qt(msg, parent=None):

0 commit comments

Comments
 (0)