本文整理汇总了Python中matplotlibwidget.MatplotlibWidget.setFocus方法的典型用法代码示例。如果您正苦于以下问题:Python MatplotlibWidget.setFocus方法的具体用法?Python MatplotlibWidget.setFocus怎么用?Python MatplotlibWidget.setFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlibwidget.MatplotlibWidget
的用法示例。
在下文中一共展示了MatplotlibWidget.setFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Ui_MainWindow
# 需要导入模块: from matplotlibwidget import MatplotlibWidget [as 别名]
# 或者: from matplotlibwidget.MatplotlibWidget import setFocus [as 别名]
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.mplwidget = MatplotlibWidget(self.centralwidget)
self.mplwidget.setGeometry(QtCore.QRect(170, 150, 400, 300))
self.mplwidget.setObjectName("mplwidget")
self.mplwidget.setFocus()
self.mplwidget.axes.plot(x,y)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(170, 60, 75, 23))
self.pushButton.setObjectName("pushButton")
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), self.plot)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def plot(self):
global y
global x
x = [2,3,4]
y = [2,2,1]
self.replot()
def replot(self):
Ui_MainWindow()
ui.setupUi(MainWindow)
示例2: Ui_MainWindow
# 需要导入模块: from matplotlibwidget import MatplotlibWidget [as 别名]
# 或者: from matplotlibwidget.MatplotlibWidget import setFocus [as 别名]
class Ui_MainWindow(object):
x = np.linspace(-10,10,500)
y = np.sin(x)
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(800, 600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.mplw = MatplotlibWidget(self.centralwidget)
self.mplw.setGeometry(QtCore.QRect(189, 40, 511, 421))
self.mplw.setObjectName(_fromUtf8("mplw"))
self.mplw.setFocus()
#self.mplw.axes.plot(self.x,self.y)
self.comboBox = QtGui.QComboBox(self.centralwidget)
self.comboBox.setGeometry(QtCore.QRect(50, 50, 69, 22))
self.comboBox.setObjectName(_fromUtf8("comboBox"))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(50, 110, 75, 23))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QObject.connect(self.comboBox, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), self.msgTest)
QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.draw)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.comboBox.setItemText(0, _translate("MainWindow", "Sin(x)", None))
self.comboBox.setItemText(1, _translate("MainWindow", "Cos(x)", None))
self.pushButton.setText(_translate("MainWindow", "Draw!", None))
def msgTest(self):
print('Current index:',self.comboBox.currentIndex())
def draw(self):
self.mplw.setFocus()
self.mplw.axes.plot(self.x,self.y)
def selectGraph(self):
if (self.comboBox.currentIndex() == 0):
self.y = np.sin(self.x)
if (self.comboBox.currentIndex() == 1):
self.y = np.cos(self.x)