当前位置: 首页>>代码示例>>Python>>正文


Python Graph.canPlot方法代码示例

本文整理汇总了Python中Graph.canPlot方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.canPlot方法的具体用法?Python Graph.canPlot怎么用?Python Graph.canPlot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph.canPlot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Main_Panel

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import canPlot [as 别名]
class Main_Panel(wx.Panel): #This is where all widgets are going to be placed

	def __init__(self, parent):

		wx.Panel.__init__(self, parent)

		self.statusLabels = ["\tStatus_Box", "File: None", "Has_Data: False", "PlotType: Scatter", 
						     "xLabel: None", "yLabel: None", "xLimit: None", "yLimit: None"]
		self.parent = parent
		self.style = 'Scatter'
		self.x_axis_label = None
		self.y_axis_label = None
		self.x_axis_range = [0,1]
		self.y_axis_range = [0,1]

		self.graph = Graph(self)                      #Graph Object
		self.yLimit = Axis_Range(self, wx.HORIZONTAL) #Axis Object
		self.xLimit = Axis_Range(self, wx.VERTICAL)   #Axis Object
		self.Labels = Axis_Labels(self)               #Axis Object
		self.status = wx.ListBox(self, choices=self.statusLabels)
		self.plotType = wx.RadioBox(self, label='Graph Style', choices=['Scatter', 'Line', 'Bar'], style=wx.RA_SPECIFY_ROWS)

		self.plotType.Bind(wx.EVT_RADIOBOX, self.updateStyle)

		sizer = wx.BoxSizer(wx.VERTICAL)
		space = wx.BoxSizer(wx.VERTICAL)
		hbox1 = wx.BoxSizer(wx.HORIZONTAL)
		hbox2 = wx.BoxSizer(wx.HORIZONTAL)
		vbox = wx.BoxSizer(wx.HORIZONTAL)
		hbox1.Add(self.yLimit, proportion=1, flag=wx.EXPAND)
		hbox1.Add(self.graph.addObj(), proportion=14, flag=wx.EXPAND)
		sizer.Add(hbox1, proportion=6, flag=wx.EXPAND)
		hbox2.Add(space, proportion=1, flag=wx.EXPAND)
		hbox2.Add(self.xLimit, proportion=14, flag=wx.EXPAND)
		vbox.Add(self.status, proportion=1, flag=wx.EXPAND)
		vbox.Add(self.plotType, proportion=1, flag=wx.EXPAND)
		vbox.Add(self.Labels, proportion=2, flag=wx.EXPAND)
		sizer.Add(hbox2, proportion=1, flag=wx.EXPAND)
		sizer.Add(vbox, proportion=4, border=40, flag=wx.EXPAND|wx.LEFT|wx.RIGHT)
		self.SetSizer(sizer)

		self.Fit()

	def updateStyle(self, evt):
		self.style = evt.EventObject.GetStringSelection()
		self.updateGraphParameters()

	def updateGraphParameters(self):
		self.updateStatus("Plot", self.style)
		self.updateStatus("xLabel", str(self.x_axis_label))
		self.updateStatus("yLabel", str(self.y_axis_label))
		self.updateStatus("xLimit",str(self.xLimit.getRange()))
		self.updateStatus("yLimit",str(self.yLimit.getRange()))
		self.graph.setFile(self.getFile())
		self.graph.setPlotType(self.style)
		self.graph.setXlabel(self.x_axis_label)
		self.graph.setYlabel(self.y_axis_label)
		self.graph.setXrange(self.xLimit.getRange())
		self.graph.setYrange(self.yLimit.getRange())
		if self.graph.canPlot():
			self.graph.updatePlot()

	def updatePlot(self):
		pass

	def updateStatus(self, parameter, label):
		key = self.getKey()
		assert(parameter in key.keys()), "Parameter needs to be " + str(key.keys())
		self.status.SetString(self.status.FindString(key[parameter]), key[parameter].split(' ')[0] + ' ' + label)

	def getKey(self):
		return {"File":self.status.GetString(1),
				"Data":self.status.GetString(2), 
			    "Plot":self.status.GetString(3), 
		        "xLabel":self.status.GetString(4), 
			    "yLabel":self.status.GetString(5), 
			    "xLimit":self.status.GetString(6),
			    "yLimit": self.status.GetString(7)}

	def getFile(self):
		return self.parent.currentFile
开发者ID:jaredarchey,项目名称:Arduino-Data-Logger,代码行数:83,代码来源:Main_Panel.py


注:本文中的Graph.canPlot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。