本文整理汇总了Python中odict.OrderedDict.values方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedDict.values方法的具体用法?Python OrderedDict.values怎么用?Python OrderedDict.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类odict.OrderedDict
的用法示例。
在下文中一共展示了OrderedDict.values方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: separate_tables_by_time
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
def separate_tables_by_time(self, tables, time_col):
return [tables], [range(len(tables))]
time_to_tables = OrderedDict()
time_to_idx = OrderedDict()
for i, time in enumerate(time_col):
time_to_tables.setdefault(time, []).append(tables[i])
time_to_idx.setdefault(time, []).append(i)
return time_to_tables.values(), time_to_idx.values()
示例2: __init__
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
class Group:
def __init__(self, name):
self.name = name
self.wordDict = OrderedDict()
self.whitespace = ""
self.join = ""
self.default = ""
self.prefixes = []
self.suffixes = []
def __str__(self):
str = ""
str = str + "\nName: %s\n" % (self.name)
str = str + "Whitespace: %s\n" % (self.whitespace)
str = str + "Join: %s\n" % (self.join)
str = str + "Default: %s\n" % (self.default)
str = str + "Prefixes: %s\n" % (self.prefixes)
str = str + "Suffixes: %s\n" % (self.suffixes)
str = str + "Words:\n"
for key in self.wordDict.keys():
str = str + "%s %s\n" % (key, self.wordDict[key])
return str
def set_used_codeword(self, codeword):
self.wordDict[codeword].used = True
def count_used_codewords(self):
count = 0
for codeword in self.wordDict.values():
if codeword.used:
count += 1
return count
def get_used_codeword(self):
def make_iter(self=self):
for codeword in self.wordDict.values():
if codeword.used:
yield codeword
return make_iter()
def get_unused_codeword(self):
def make_iter(self=self):
for codeword in self.wordDict.values():
if not codeword.used:
yield codeword
return make_iter()
示例3: get_stats
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
def get_stats(self, dim, prefix=''):
"""Get various 1d statistics for the datatable.
"""
def add_stat(stats, key, val):
stats[prefix+key] = val
def get_stat(stats, key):
return stats[prefix+key]
#print dim
#print self.num_cells
#print self.data
p = self.get_points(dim)
s = OrderedDict()
add_stat(s, 'num_cells', self.num_cells)
add_stat(s, 'min', np.min(p))
add_stat(s, 'max', np.max(p))
add_stat(s, 'average', np.average(p))
add_stat(s, 'std', np.std(p))
add_stat(s, 'median', np.median(p))
add_stat(s, 'gaussian_fit',
self.gaussian_pdf_compare(
dim, 100,
get_stat(s, 'average'),
get_stat(s, 'std')))
keys = s.keys()
vals = np.array([s.values()])
ret = DataTable(vals, keys, name=self.sub_name('stats for %s' % dim))
ret.properties['original_table'] = self
return ret
示例4: MainMenu
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
class MainMenu(BetterMenu):
def __init__(self):
super(MainMenu, self).__init__("Snake")
self.screen = director.get_window_size()
ratio = self.screen[1] / self.screen[0]
self.select_sound = StaticSource(pyglet.resource.media('move.wav'))
self.font_title['font_name'] = 'Pipe Dream'
self.font_title['font_size'] = self.screen[0] / 18
self.font_title['color'] = (255, 255, 255, 255)
self.font_item['font_name'] = 'Pipe Dream',
self.font_item['color'] = (255, 255, 255, 255)
self.font_item['font_size'] = self.screen[1] / 16 * ratio
self.font_item_selected['font_name'] = 'Pipe Dream'
self.font_item_selected['color'] = (0, 0, 255, 255)
self.font_item_selected['font_size'] = self.screen[1] / 16 * ratio
self.menu_anchor_y = 'center'
self.menu_anchor_x = 'center'
self.items = OrderedDict()
#self.items['mode'] = MultipleMenuItem('Mode: ', self.on_mode, director.settings['modes'], director.settings['modes'].index(director.settings['mode']))
self.items['player'] = MultipleMenuItem('Player: ', self.on_player, director.settings['players'], director.settings['players'].index(director.settings['player']))
# self.items['tutorial'] = MenuItem('Tutorial', self.on_tutorial)
self.items['start'] = MenuItem('Start', self.on_start)
self.items['options'] = MenuItem('Options', self.on_options)
self.items['quit'] = MenuItem('Quit', self.on_quit)
self.create_menu(self.items.values(), zoom_in(), zoom_out())
def on_player(self, player):
director.settings['player'] = director.settings['players'][player]
def on_mode(self, mode):
director.settings['mode'] = director.settings['modes'][mode]
def on_tutorial(self):
director.push(SplitColsTransition(Scene(TutorialLayer())))
def on_options(self):
self.parent.switch_to(1)
def on_start(self):
filebase = "Snake_%s" % (getDateTimeStamp())
director.settings['filebase'] = filebase
director.scene.dispatch_event('start_task')
def on_quit(self):
reactor.callFromThread(reactor.stop)
示例5: Packet
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
class Packet():
fields = OrderedDict([
])
def __init__(self, **kw):
self.fields = OrderedDict(self.__class__.fields)
for k,v in kw.items():
if callable(v):
self.fields[k] = v(self.fields[k])
else:
self.fields[k] = v
def __str__(self):
return "".join(map(str, self.fields.values()))
示例6: MainMenu
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
class MainMenu(BetterMenu):
def __init__(self):
super(MainMenu, self).__init__("Whack A Mole")
self.screen = director.get_window_size()
ratio = self.screen[1] / self.screen[0]
self.font_title['font_size'] = self.screen[0] / 18
self.font_title['color'] = (255, 255, 255, 255)
self.font_item['color'] = (255, 255, 255, 255)
self.font_item['font_size'] = self.screen[1] / 16 * ratio
self.font_item_selected['color'] = (0, 0, 255, 255)
self.font_item_selected['font_size'] = self.screen[1] / 16 * ratio
self.menu_anchor_y = 'center'
self.menu_anchor_x = 'center'
self.items = OrderedDict()
self.items['start'] = MenuItem('Start', self.on_start)
self.items['options'] = MenuItem('Options', self.on_options)
self.items['quit'] = MenuItem('Quit', self.on_quit)
self.create_menu(self.items.values(), zoom_in(), zoom_out())
def on_options(self):
self.parent.switch_to(1)
def on_start(self):
filebase = "WhackAMole_%s" % (getDateTimeStamp())
director.settings['filebase'] = filebase
director.scene.dispatch_event('start_task')
def on_quit(self):
reactor.callFromThread(reactor.stop)
示例7: OptionsMenu
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
class OptionsMenu(BetterMenu):
def __init__(self):
super(OptionsMenu, self).__init__('Options')
self.screen = director.get_window_size()
ratio = self.screen[1] / self.screen[0]
self.font_title['font_size'] = self.screen[0] / 18
self.font_title['color'] = (255, 255, 255, 255)
self.font_item['color'] = (255, 255, 255, 255)
self.font_item['font_size'] = self.screen[1] / 16 * ratio
self.font_item_selected['color'] = (0, 0, 255, 255)
self.font_item_selected['font_size'] = self.screen[1] / 16 * ratio
self.items = OrderedDict()
self.speed_opts = ['SLOW','FAST']
self.level_opts = ['NONE','WEAK','MEDIUM','STRONG']
self.eye_opts = ['NONE','RIGHT','LEFT']
self.points_opts = ['2','5','9','13']
self.items['overlay'] = ToggleMenuItem('Debug Overlay:', self.on_overlay, director.settings['overlay'])
self.items['eyetracker'] = ToggleMenuItem('EyeTracker:', self.on_eyetracker, director.settings['eyetracker'])
self.items['eyetracker_ip'] = EntryMenuItem('EyeTracker IP:', self.on_eyetracker_ip, director.settings['eyetracker_ip'])
self.items['eyetracker_in_port'] = EntryMenuItem('EyeTracker In Port:', self.on_eyetracker_in_port, director.settings['eyetracker_in_port'])
self.items['eyetracker_out_port'] = EntryMenuItem('EyeTracker Out Port:', self.on_eyetracker_out_port, director.settings['eyetracker_out_port'])
self.items['calibration_points'] = MultipleMenuItem('Calibration Points:', self.on_cal_points, self.points_opts, self.points_opts.index(str(director.settings['calibration_points'])))
self.items['calibration_eye'] = MultipleMenuItem('Calibration Eye:', self.on_cal_eye, self.eye_opts, director.settings['calibration_eye'])
self.items['calibration_level'] = MultipleMenuItem('Calibration Check Level:', self.on_cal_level, self.level_opts, director.settings['calibration_level'])
self.items['calibration_speed'] = MultipleMenuItem('Calibration Speed:', self.on_cal_speed, self.speed_opts, director.settings['calibration_speed'])
self.items['calibration_auto'] = ToggleMenuItem('Calibration Auto-accept:', self.on_cal_auto, director.settings['calibration_auto'])
self.items['calibration_wait'] = ToggleMenuItem('Calibration Wait For Good:', self.on_cal_wait, director.settings['calibration_wait'])
self.items['calibration_random'] = ToggleMenuItem('Calibration Randomize:', self.on_cal_random, director.settings['calibration_random'])
self.create_menu(self.items.values(), zoom_in(), zoom_out())
def on_overlay(self, value):
director.settings['overlay'] = value
def on_eyetracker(self, value):
director.settings['eyetracker'] = value
def on_cal_points(self, value):
director.settings['calibration_points'] = int(self.points_opts[value])
def on_cal_eye(self, value):
director.settings['calibration_speed'] = value
def on_cal_level(self, value):
director.settings['calibration_speed'] = value
def on_cal_speed(self, value):
director.settings['calibration_speed'] = value
def on_cal_auto(self, value):
director.settings['calibration_auto'] = value
def on_cal_wait(self, value):
director.settings['calibration_wait'] = value
def on_cal_random(self, value):
director.settings['calibration_random'] = value
def on_enter(self):
super(OptionsMenu, self).on_enter()
self.orig_values = (director.settings['eyetracker_ip'],
director.settings['eyetracker_in_port'],
director.settings['eyetracker_out_port'])
def on_exit(self):
super(OptionsMenu, self).on_exit()
new_values = (director.settings['eyetracker_ip'],
director.settings['eyetracker_in_port'],
director.settings['eyetracker_out_port'])
if new_values != self.orig_values:
director.scene.dispatch_event("eyetracker_info_changed")
def on_eyetracker(self, value):
director.settings['eyetracker'] = value
def on_eyetracker_ip(self, ip):
director.settings['eyetracker_ip'] = ip
def on_eyetracker_in_port(self, port):
director.settings['eyetracker_in_port'] = port
def on_eyetracker_out_port(self, port):
director.settings['eyetracker_out_port'] = port
def on_quit(self):
self.parent.switch_to(0)
示例8: OptionsMenu
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
class OptionsMenu(BetterMenu):
def __init__(self):
super(OptionsMenu, self).__init__('Options')
self.screen = director.get_window_size()
ratio = self.screen[1] / self.screen[0]
self.select_sound = StaticSource(pyglet.resource.media('move.wav'))
self.font_title['font_name'] = 'Pipe Dream'
self.font_title['font_size'] = self.screen[0] / 18
self.font_title['color'] = (255, 255, 255, 255)
self.font_item['font_name'] = 'Pipe Dream',
self.font_item['color'] = (255, 255, 255, 255)
self.font_item['font_size'] = self.screen[1] / 16 * ratio
self.font_item_selected['font_name'] = 'Pipe Dream'
self.font_item_selected['color'] = (0, 0, 255, 255)
self.font_item_selected['font_size'] = self.screen[1] / 16 * ratio
self.items = OrderedDict()
self.items['seed'] = EntryMenuItem('Random Seed:', self.on_seed, director.settings['seed'])
self.items['fps'] = ToggleMenuItem('Show FPS:', self.on_show_fps, director.show_FPS)
self.items['fullscreen'] = ToggleMenuItem('Fullscreen:', self.on_fullscreen, director.window.fullscreen)
if eyetracking:
self.items['eyetracker'] = ToggleMenuItem("EyeTracker:", self.on_eyetracker, director.settings['eyetracker'])
self.items['eyetracker_ip'] = EntryMenuItem('EyeTracker IP:', self.on_eyetracker_ip, director.settings['eyetracker_ip'])
self.items['eyetracker_in_port'] = EntryMenuItem('EyeTracker In Port:', self.on_eyetracker_in_port, director.settings['eyetracker_in_port'])
self.items['eyetracker_out_port'] = EntryMenuItem('EyeTracker Out Port:', self.on_eyetracker_out_port, director.settings['eyetracker_out_port'])
self.set_eyetracker_extras(director.settings['eyetracker'])
self.create_menu(self.items.values(), zoom_in(), zoom_out())
def on_enter(self):
super(OptionsMenu, self).on_enter()
self.orig_values = (director.settings['eyetracker_ip'],
director.settings['eyetracker_in_port'],
director.settings['eyetracker_out_port'])
def on_exit(self):
super(OptionsMenu, self).on_exit()
new_values = (director.settings['eyetracker_ip'],
director.settings['eyetracker_in_port'],
director.settings['eyetracker_out_port'])
if new_values != self.orig_values:
director.scene.dispatch_event("eyetracker_info_changed")
def on_seed(self, value):
director.settings['seed'] = value
def on_show_fps(self, value):
director.show_FPS = value
def on_fullscreen(self, value):
screen = pyglet.window.get_platform().get_default_display().get_default_screen()
director.window.set_fullscreen(value, screen)
def on_experiment(self, value):
director.settings['experiment'] = value
if eyetracking:
def set_eyetracker_extras(self, value):
self.items['eyetracker_ip'].visible = value
self.items['eyetracker_in_port'].visible = value
self.items['eyetracker_out_port'].visible = value
def on_eyetracker(self, value):
director.settings['eyetracker'] = value
self.set_eyetracker_extras(value)
def on_eyetracker_ip(self, ip):
director.settings['eyetracker_ip'] = ip
def on_eyetracker_in_port(self, port):
director.settings['eyetracker_in_port'] = port
def on_eyetracker_out_port(self, port):
director.settings['eyetracker_out_port'] = port
def on_quit(self):
self.parent.switch_to(0)
示例9: ParticipantMenu
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
class ParticipantMenu(BetterMenu):
def __init__(self):
super(ParticipantMenu, self).__init__("Participant Information")
self.screen = director.get_window_size()
ratio = self.screen[1] / self.screen[0]
self.select_sound = StaticSource(pyglet.resource.media('move.wav'))
self.font_title['font_name'] = 'Pipe Dream'
self.font_title['font_size'] = self.screen[0] / 18
self.font_title['color'] = (255, 255, 255, 255)
self.font_item['font_name'] = 'Pipe Dream',
self.font_item['color'] = (255, 255, 255, 255)
self.font_item['font_size'] = self.screen[1] / 16 * ratio
self.font_item_selected['font_name'] = 'Pipe Dream'
self.font_item_selected['color'] = (0, 0, 255, 255)
self.font_item_selected['font_size'] = self.screen[1] / 16 * ratio
self.menu_anchor_y = 'center'
self.menu_anchor_x = 'center'
def on_enter(self):
super(ParticipantMenu, self).on_enter()
self.items = OrderedDict()
self.items['firstname'] = BetterEntryMenuItem('First Name:', self.on_info_change, "", validator=lambda x: x.isalpha())
self.items['lastname'] = BetterEntryMenuItem('Last Name:', self.on_info_change, "", validator=lambda x: x.isalpha())
self.items['rin'] = BetterEntryMenuItem('RIN:', self.on_info_change, "", max_length=9, validator=lambda x: unicode(x).isnumeric())
self.items['start'] = MenuItem('Start', self.on_start)
self.create_menu(self.items.values(), zoom_in(), zoom_out())
self.items['start'].visible = False
def on_exit(self):
super(ParticipantMenu, self).on_exit()
for c in self.get_children(): self.remove(c)
def on_info_change(self, *args, **kwargs):
firstname = ''.join(self.items['firstname']._value).strip()
lastname = ''.join(self.items['lastname']._value).strip()
rin = ''.join(self.items['rin']._value)
if len(firstname) > 0 and len(lastname) > 0 and len(rin) == 9:
self.items['start'].visible = True
else:
self.items['start'].visible = False
def on_start(self):
si = {}
si['first_name'] = ''.join(self.items['firstname']._value).strip()
si['last_name'] = ''.join(self.items['lastname']._value).strip()
si['rin'] = ''.join(self.items['rin']._value)
si['encrypted_rin'], si['cipher'] = rin2id(si['rin'])
si['timestamp'] = getDateTimeStamp()
director.settings['si'] = si
filebase = "WilliamsSearch_%s_%s" % (si['timestamp'], si['encrypted_rin'][:8])
director.settings['filebase'] = filebase
writeHistoryFile("data/%s.history" % filebase, si)
director.scene.dispatch_event('start_task')
def on_quit(self):
self.parent.switch_to(0)
示例10: view
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
def view(self, tables):
""" The view method of this module draws the control panel and the histograms.
We need at least one input to be able to draw something.
"""
if not tables:
return View(self, 'No tables to show.')
self.widgets.color.guess_or_remember(('histogram text', tables), ['name'])
self.widgets.text.guess_or_remember(('histogram colors', tables), ['name'])
self.widgets.shift.guess_or_remember(('histogram shift', tables), '0.2')
self.widgets.sort_inside.guess_or_remember(('histogram sort inside', tables), ['similarity'])
self.widgets.sort_outside.guess_or_remember(('histogram sort outside', tables), ['sort'])
self.widgets.trim.guess_or_remember(('histogram trim', tables), ['no'])
self.widgets.trim_thresh.guess_or_remember(('histogram trim thresh', tables), '0')
sort_inside_options = [('unsort', 'Keep original order'), ('similarity', 'Put similar curves together')]
sort_inside_options += [(x, 'Sort by %s' % x) for x in tables[0].tags.keys()]
# Create the control panel view. This will enable users to choose the dimensions.
control_panel_view = stack_lines(
self.widgets.dims.view('Dimension', self.widgets.apply, options_from_table(tables[0])),
self.widgets.text.view('Text by', self.widgets.apply, tables[0].tags.keys()),
self.widgets.color.view('Color by', self.widgets.apply, tables[0].tags.keys()),
self.widgets.shift.view('Shift for multiple curves', self.widgets.apply),
self.widgets.sort_inside.view('Curve sorting', self.widgets.apply,
sort_inside_options,
multiple=False),
self.widgets.sort_outside.view('Plot sorting', self.widgets.apply,
[('sort', 'Put plots with many differences first'), ('unsort', 'Keep original order')],
multiple=False),
self.widgets.trim.view('Trim plots', self.widgets.apply,
[('yes', 'Convert values lower than threshold to 0'), ('no', 'Don\'t trim')], multiple=False),
self.widgets.trim_thresh.view('Trim threshold', self.widgets.apply),
self.widgets.apply.view())
main_views = []
shift = self.widgets.shift.value_as_float()
plots_for_legend = OrderedDict()
colorer = axes.Colorer()
# Check that the user has already chosen dimensions. Otherwise, ask him
# to do so.
if self.widgets.dims.values.choices:
timer = MultiTimer(len(self.widgets.dims.values.choices))
for i, dim in enumerate(self.widgets.dims.values.choices):
try:
# Go over every dimension and create the histogram:
# First create a new figure:
fig = self.create_and_adjust_figure(tables)
ax = fig.add_subplot(111)
# Draw the histogram for every input
plots = []
sorted_tables = tables
sort_method = self.widgets.sort_inside.values.choices[0]
if sort_method == 'unsort':
sorted_tables = tables
elif sort_method == 'similarity':
thresh = None
if self.widgets.trim.get_choices()[0] == 'yes':
thresh = self.widgets.trim_thresh.value_as_float()
# get distances table:
distances = datatable.ks_distances(tables, dim, thresh)
# sort by distance
sorted_tables = greedy_distance_sort(distances, tables)
else:
# we need to sort by tags:
tag_for_sort = self.widgets.sort_inside.values.choices[0]
sorted_tables = sorted(tables, key=lambda table: table.tags[tag_for_sort])
for i, table in enumerate(sorted_tables):
color_tags = self.widgets.color.values.choices
color_key = tuple([table.tags[c] for c in color_tags])
min_x = None
if self.widgets.trim.get_choices()[0] =='yes':
min_x = self.widgets.trim_thresh.value_as_float()
plot = axes.kde1d(ax, table, dim,
color=colorer.get_color(color_key),
min_x=min_x,
shift=shift*i)
plots_for_legend[color_key] = plot
# Add ticks with table names:
if self.widgets.shift.value_as_float() > 0:
ax.set_yticks(np.arange(0, len(tables)*shift, shift))
ax.set_yticklabels([t.get_tags(self.widgets.text.values.choices) for t in sorted_tables], size='xx-small')
# set axes y range:
ax.set_ylim(bottom = -0.1, top=0.8+shift*(len(sorted_tables)-1))
# Make sure we don't create the same widget twice. We create a new widget
# for every dimension asked.
widget_key = self._normalize_id(dim)
if not widget_key in self.widgets:
self._add_widget(widget_key, Figure)
figure_widget = self.widgets[widget_key]
if len(tables) > 1:
from scipy.stats import ks_2samp
ks, p_ks = ks_2samp(tables[0].get_cols(dim)[0], tables[1].get_cols(dim)[0])
ks_view = View(self, 'ks: %.3f, p_ks: %.10f' % (ks, p_ks))
final_view = stack_lines(ks_view, figure_widget.view(fig))
else:
ks, p_ks = 0, 0
final_view = figure_widget.view(fig)
# Add the new widget's view
main_views.append((ks, p_ks, final_view))
#.........这里部分代码省略.........
示例11: OptionsMenu
# 需要导入模块: from odict import OrderedDict [as 别名]
# 或者: from odict.OrderedDict import values [as 别名]
class OptionsMenu(BetterMenu):
def __init__(self):
super(OptionsMenu, self).__init__('Options')
self.screen = director.get_window_size()
ratio = self.screen[1] / self.screen[0]
self.select_sound = StaticSource(pyglet.resource.media('move.wav'))
self.font_title['font_name'] = 'Pipe Dream'
self.font_title['font_size'] = self.screen[0] / 18
self.font_title['color'] = (255, 255, 255, 255)
self.font_item['font_name'] = 'Pipe Dream',
self.font_item['color'] = (255, 255, 255, 255)
self.font_item['font_size'] = self.screen[1] / 16 * ratio
self.font_item_selected['font_name'] = 'Pipe Dream'
self.font_item_selected['color'] = (0, 0, 255, 255)
self.font_item_selected['font_size'] = self.screen[1] / 16 * ratio
self.board_sizes = map(str,range(11, 51, 2))
self.speed_factors = map(lambda(x): "%.3f" % x, [x / 1000.0 for x in range(750, 1000, 1)] + [1.000])
self.items = OrderedDict()
self.items['fps'] = ToggleMenuItem('Show FPS:', self.on_show_fps, director.show_FPS)
self.items['fullscreen'] = ToggleMenuItem('Fullscreen:', self.on_fullscreen, director.window.fullscreen)
self.items['board_size'] = MultipleMenuItem('Board Size:', self.on_board_size, self.board_sizes, self.board_sizes.index(director.settings['board_size']))
self.items['speed_factor'] = MultipleMenuItem('Speed Factor:', self.on_speed_factor, self.speed_factors, self.speed_factors.index(director.settings['speed_factor']))
if eyetracking:
self.items['eyetracker'] = ToggleMenuItem("EyeTracker:", self.on_eyetracker, director.settings['eyetracker'])
self.items['eyetracker_ip'] = EntryMenuItem('EyeTracker IP:', self.on_eyetracker_ip, director.settings['eyetracker_ip'])
self.items['eyetracker_in_port'] = EntryMenuItem('EyeTracker In Port:', self.on_eyetracker_in_port, director.settings['eyetracker_in_port'])
self.items['eyetracker_out_port'] = EntryMenuItem('EyeTracker Out Port:', self.on_eyetracker_out_port, director.settings['eyetracker_out_port'])
self.items['fixation_overlay'] = ToggleMenuItem("Fixation Overlay:", self.on_fixation_overlay, director.settings['fixation_overlay'])
self.set_eyetracker_extras(director.settings['eyetracker'])
self.create_menu(self.items.values(), zoom_in(), zoom_out())
def on_enter(self):
super(OptionsMenu, self).on_enter()
self.orig_values = (director.settings['eyetracker_ip'],
director.settings['eyetracker_in_port'],
director.settings['eyetracker_out_port'])
def on_exit(self):
super(OptionsMenu, self).on_exit()
new_values = (director.settings['eyetracker_ip'],
director.settings['eyetracker_in_port'],
director.settings['eyetracker_out_port'])
if new_values != self.orig_values:
director.scene.dispatch_event("eyetracker_info_changed")
def on_board_size(self, value):
director.settings["board_size"] = value
def on_speed_factor(self, value):
director.settings["speed_factor"] = value
def on_show_fps(self, value):
director.show_FPS = value
def on_fullscreen(self, value):
screen = pyglet.window.get_platform().get_default_display().get_default_screen()
director.window.set_fullscreen(value, screen)
def on_experiment(self, value):
director.settings['experiment'] = value
if eyetracking:
def set_eyetracker_extras(self, value):
self.items['eyetracker_ip'].visible = value
self.items['eyetracker_in_port'].visible = value
self.items['eyetracker_out_port'].visible = value
self.items['fixation_overlay'].visible = value
def on_eyetracker(self, value):
director.settings['eyetracker'] = value
self.set_eyetracker_extras(value)
def on_eyetracker_ip(self, ip):
director.settings['eyetracker_ip'] = ip
def on_eyetracker_in_port(self, port):
director.settings['eyetracker_in_port'] = port
def on_eyetracker_out_port(self, port):
director.settings['eyetracker_out_port'] = port
def on_fixation_overlay(self, overlay):
director.settings['fixation_overlay'] = overlay
def on_quit(self):
self.parent.switch_to(0)