(self, title='', text='', callback=None, catch='')
| 1840 | instance = None |
| 1841 | |
| 1842 | def __init__(self, title='', text='', callback=None, catch=''): |
| 1843 | self.titletext = title |
| 1844 | self.text = text |
| 1845 | self.starttext = text |
| 1846 | self.bgcolor = (255 * int(not cfg.BLACK_BACKGROUND), )*3 |
| 1847 | self.textcolor = (255 * int(cfg.BLACK_BACKGROUND), )*3 + (255, ) |
| 1848 | self.batch = pyglet.graphics.Batch() |
| 1849 | self.title = pyglet.text.Label(title, font_size=self.titlesize, |
| 1850 | bold=True, color=self.textcolor, batch=self.batch, |
| 1851 | x=width_center(), y=(window.height*9)/10, |
| 1852 | anchor_x='center', anchor_y='center') |
| 1853 | self.document = pyglet.text.document.UnformattedDocument() |
| 1854 | self.document.set_style(0, len(self.document.text), {'color': self.textcolor}) |
| 1855 | self.layout = pyglet.text.layout.IncrementalTextLayout(self.document, |
| 1856 | (from_width_center(-20) - len(title) * calc_fontsize(6)), (window.height*10)/11, batch=self.batch, dpi=calc_dpi()) |
| 1857 | self.layout.x = from_width_center(15) + len(title) * calc_fontsize(6) |
| 1858 | if not callback: callback = lambda x: x |
| 1859 | self.callback = callback |
| 1860 | self.caret = pyglet.text.caret.Caret(self.layout) |
| 1861 | window.push_handlers(self.caret) |
| 1862 | window.push_handlers(self.on_key_press, self.on_draw) |
| 1863 | self.document.text = text |
| 1864 | # workaround for a bug: the keypress that spawns TextInputScreen doesn't |
| 1865 | # get handled until after the caret handler has been pushed, which seems |
| 1866 | # to result in the keypress being interpreted as a text input, so we |
| 1867 | # catch that later |
| 1868 | self.catch = catch |
| 1869 | self.instance = self |
| 1870 | |
| 1871 | |
| 1872 | def on_draw(self): |
nothing calls this directly
no test coverage detected