(self, options, values=None, actions={}, names={}, title='',
footnote = _('Esc: cancel Space: modify option Enter: apply'),
choose_once=False, default=0)
| 1943 | |
| 1944 | |
| 1945 | def __init__(self, options, values=None, actions={}, names={}, title='', |
| 1946 | footnote = _('Esc: cancel Space: modify option Enter: apply'), |
| 1947 | choose_once=False, default=0): |
| 1948 | self.bgcolor = (255 * int(not cfg.BLACK_BACKGROUND), )*3 |
| 1949 | self.textcolor = (255 * int(cfg.BLACK_BACKGROUND), )*3 + (255,) |
| 1950 | self.markercolors = (0,0,255,0,255,0,255,0,0)#(255 * int(cfg.BLACK_BACKGROUND), )*3*3 |
| 1951 | self.pagesize = min(len(options), (window.height*6/10) / (self.choicesize*3/2)) |
| 1952 | if type(options) == dict: |
| 1953 | vals = options |
| 1954 | self.options = list(options) |
| 1955 | else: |
| 1956 | vals = dict([[op, None] for op in options]) |
| 1957 | self.options = options |
| 1958 | self.values = values or vals # use values if there's anything in it |
| 1959 | self.actions = actions |
| 1960 | for op in self.options: |
| 1961 | if not op in names.keys(): |
| 1962 | names[op] = op |
| 1963 | self.names = names |
| 1964 | self.choose_once = choose_once |
| 1965 | self.disppos = 0 # which item in options is the first on the screen |
| 1966 | self.selpos = default # may be offscreen? |
| 1967 | self.batch = pyglet.graphics.Batch() |
| 1968 | |
| 1969 | self.title = pyglet.text.Label(title, font_size=self.titlesize, |
| 1970 | bold=True, color=self.textcolor, batch=self.batch, |
| 1971 | x=width_center(), y=(window.height*9)/10, |
| 1972 | anchor_x='center', anchor_y='center') |
| 1973 | self.footnote = pyglet.text.Label(footnote, font_size=self.footnotesize, |
| 1974 | bold=True, color=self.textcolor, batch=self.batch, |
| 1975 | x=width_center(), y=from_bottom_edge(35), |
| 1976 | anchor_x='center', anchor_y='center') |
| 1977 | |
| 1978 | self.labels = [pyglet.text.Label('', font_size=self.choicesize, |
| 1979 | bold=True, color=self.textcolor, batch=self.batch, |
| 1980 | x=window.width/8, y=(window.height*8)/10 - i*(self.choicesize*3/2), |
| 1981 | anchor_x='left', anchor_y='center', font_name=self.fontlist) |
| 1982 | for i in range(self.pagesize)] |
| 1983 | |
| 1984 | if have_shapes: |
| 1985 | self.marker = pyglet.shapes.Polygon((0,0), (0,0), (0,0), color=[1] * 3, batch=self.batch) |
| 1986 | else: |
| 1987 | self.marker = self.batch.add(3, pyglet.gl.GL_POLYGON, None, ('v2i', (0,)*6,), |
| 1988 | ('c3B', self.markercolors)) |
| 1989 | |
| 1990 | self.update_labels() |
| 1991 | |
| 1992 | window.push_handlers(self.on_key_press, self.on_text, |
| 1993 | self.on_text_motion, self.on_draw) |
| 1994 | |
| 1995 | # keep a reference to the current instance as pyglet>=1.4 Window.push_handlers |
| 1996 | # only keep weak references to handlers so Menu subclasses will be deleted |
| 1997 | self.instance = self |
| 1998 | |
| 1999 | def textify(self, x): |
| 2000 | if type(x) == bool: |
nothing calls this directly
no test coverage detected