本文整理汇总了Python中timeline.Timeline.add_event方法的典型用法代码示例。如果您正苦于以下问题:Python Timeline.add_event方法的具体用法?Python Timeline.add_event怎么用?Python Timeline.add_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timeline.Timeline
的用法示例。
在下文中一共展示了Timeline.add_event方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExperimentSettings
# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import add_event [as 别名]
#.........这里部分代码省略.........
return self.timeline
def does_tag_exists(self, tag_prefix, instnace=None):
for tag in self.global_settings:
if ((tag_prefix is None or tag.startswith(tag_prefix)) and (instnace is None or get_tag_instance(tag) == instnace)):
return True
else:
return False
def is_supp_protocol_filled(self, tag_prefix, instance=None):
'''tag_prefix is always type|event e.g. AddProcess|Wash
'''
for tag in self.global_settings:
if ((tag_prefix is None or tag.startswith(tag_prefix)) and (instance is None or get_tag_instance(tag) == instance)):
if (self.get_field(tag_prefix+'|ProtocolName|%s'%instance) is None) or (self.get_field(tag_prefix+'|Step1|%s'%instance) == ['', '', '']):
return False
else:
return True
def update_timeline(self, welltag):
'''Updates the experiment metadata timeline event associated with the
action and wells in welltag (eg: 'ExpNum|AddProcess|Spin|Wells|1|1')
'''
platewell_ids = self.get_field(welltag, [])
if platewell_ids == []:
self.timeline.delete_event(welltag)
else:
event = self.timeline.get_event(welltag)
if event is not None:
event.set_well_ids(platewell_ids)
else:
self.timeline.add_event(welltag, platewell_ids)
def save_to_file(self, file):
f = open(file, 'w')
for field, value in sorted(self.global_settings.items()):
f.write('%s = %s\n'%(field, repr(value)))
f.close()
def save_settings(self, file, protocol):
'''
saves settings in text file. the settings may include instrument settings, supp protocol, stock flask
Format: attr = value where value may be text, int, list, etc.
'''
instance = get_tag_attribute(protocol)
tag_stump = get_tag_stump(protocol, 2)
setting_type = get_tag_event(protocol)
f = open(file,'w')
f.write(setting_type+'\n')
attributes = self.get_attribute_list_by_instance(tag_stump, instance)
for attr in attributes:
info = self.get_field(tag_stump+'|%s|%s' %(attr, instance))
print info
f.write('%s = %s\n'%(attr, repr(info)))
f.close()
def save_supp_protocol_file(self, file, protocol):
instance = get_tag_attribute(protocol)
tag_stump = get_tag_stump(protocol, 2)
f = open(file,'w')
attributes = self.get_attribute_list_by_instance(tag_stump, instance)
示例2: ExperimentSettings
# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import add_event [as 别名]
#.........这里部分代码省略.........
return self.timeline
def does_tag_exists(self, tag_prefix, instnace=None):
for tag in self.global_settings:
if ((tag_prefix is None or tag.startswith(tag_prefix)) and (instnace is None or get_tag_instance(tag) == instnace)):
return True
else:
return False
def is_supp_protocol_filled(self, tag_prefix, instance=None):
'''tag_prefix is always type|event e.g. AddProcess|Wash
'''
for tag in self.global_settings:
if ((tag_prefix is None or tag.startswith(tag_prefix)) and (instance is None or get_tag_instance(tag) == instance)):
if (self.get_field(tag_prefix+'|ProtocolName|%s'%instance) is None) or (self.get_field(tag_prefix+'|Step1|%s'%instance) == ['', '', '']):
return False
else:
return True
def update_timeline(self, welltag):
'''Updates the experiment metadata timeline event associated with the
action and wells in welltag (eg: 'ExpNum|AddProcess|Spin|Wells|1|1')
'''
platewell_ids = self.get_field(welltag, [])
if platewell_ids == []:
self.timeline.delete_event(welltag)
else:
event = self.timeline.get_event(welltag)
if event is not None:
event.set_well_ids(platewell_ids)
else:
self.timeline.add_event(welltag, platewell_ids)
def save_file_dialogue(self):
exp_date = self.get_field('Overview|Project|ExptDate')
exp_num = self.get_field('Overview|Project|ExptNum')
exp_title = self.get_field('Overview|Project|Title')
if self.save_file_path:
self.save_to_file()
#import ntpath
#filename = os.path.splitext(ntpath.basename(self.save_file_path))[0]
else:
filename = 'new_experiment.txt'
if None not in [exp_date, exp_num, exp_title]:
day, month, year = exp_date.split('/')
filename = '%s%s%s_%s_%s.txt'%(year, month, day , exp_num, exp_title)
dlg = wx.FileDialog(None, message='Saving experimental protocol...',
defaultDir=os.getcwd(), defaultFile=filename,
wildcard='.txt',
style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
if dlg.ShowModal() == wx.ID_OK:
self.save_file_path = dlg.GetPath()
self.save_to_file()
def save_as_file_dialogue(self):
exp_date = self.get_field('Overview|Project|ExptDate')
exp_num = self.get_field('Overview|Project|ExptNum')
exp_title = self.get_field('Overview|Project|Title')
if self.save_file_path:
import ntpath
filename = os.path.splitext(ntpath.basename(self.save_file_path))[0]
else:
filename = 'new_experiment.txt'
if None not in [exp_date, exp_num, exp_title]: