invoke(setattr, self, 'enabled', False, delay=.2) if hasattr(self, 'close'): self.close() self.bg.on_click = close if __name__ == '__main__': app = Ursina() WindowPanel( title='Custom Window', content=( Text('leflaijfae\njofeoijfw'), Button(text='test', color=color.green), Space(height=1), Text('leflaijfae\njofeoijfw'), InputField() # ButtonGroup(('test', 'eslk', 'skffk')) )) # Text(dedent(''' # [ My Window [x]] # | Create your character # | # | InputField # | [[Male][Female][Other]] # | ButtonGroup(('male', 'female', 'other')) # | Option1: [t] Option2: [] # | # |[ Submit ] [ Clear ] # '''[1:]), font='VeraMono.ttf', origin=(0,0) # ) # WindowPanel(title='My Window', (
def __init__(self, **kwargs): super().__init__( parent=camera.ui ) self.bg = Panel(parent=self, z=.1, scale=(99,99), color=color.black33) self.input_field = InputField(height=1) def create(): amvol.create(self.input_field.text) self.create_button = Button(text='Create', color=color.yellow, scale_x=.5, on_click=create) self.name_prompt = WindowPanel( parent = self, title = 'Enter Project Name', content = ( self.input_field, self.create_button, ), z = -1, scale_y=.03, color = color.amvol_color, popup = True, enabled = False ) self.name_prompt.panel.color = color.panel_color def name_prompt_close(): for input_field in [c for c in self.name_prompt.content if isinstance(c, InputField)]: input_field.text = input_field.start_text self.name_prompt.close = name_prompt_close original_name_promt_scale = self.name_prompt.scale def ask_for_name(): self.name_prompt.scale = 0 self.name_prompt.enabled = True self.name_prompt.bg.enabled = True self.name_prompt.animate_scale(original_name_promt_scale, duration=.2) self.input_field.editing = True self.new_project_button = Button('New Project', parent=self, color=color.amvol_color, scale=(.3, .05), y=.05, on_click=ask_for_name) self.load_menu = FileBrowser(parent=self, path=Path('amvol_projects'), file_types=('.amvol'), enabled=False) def on_submit(selection): for b in [e for e in selection if e.path.is_file()]: amvol.load(b.path) self.load_menu.on_submit = on_submit def open_load_menu(): self.load_menu.enabled = True self.open_button = Button('Open', parent=self, color=color.yellow, scale=(.3, .035), y=-.001, on_click=open_load_menu) class OpenRecentButton(Button): def on_click(self): amvol.load(self.path) recent_files = open('recent_projects.txt').read().strip().split('\n') for i, f in enumerate(recent_files): OpenRecentButton( parent = self, text = Path(f).stem, hovered_color = color.orange, scale = (.4,.025), # text_origin = (-.5, 0), y = -i*.025 -.075, path = Path(f) ) for key, value in kwargs.items(): setattr(self, key ,value)
def close(self): self.bg.enabled = False self.animate_scale_y(0, duration=.1) invoke(setattr, self, 'enabled', False, delay=.2) if __name__ == '__main__': ''' WindowPanel is an easy way to create UI. It will automatically layout the content. ''' app = Ursina() WindowPanel( title='Custom Window', content=( Text('Name:'), InputField(name='name_field'), Text('Age:'), InputField(name='age_field'), Text('Phone Number:'), InputField(name='phone_number_field'), # Space(height=1), # Text('Send:'), Button(text='Submit', color=color.azure), Slider() # ButtonGroup(('test', 'eslk', 'skffk')) ), # popup=True ) # Text(dedent(''' # [ My Window [x]] # | Create your character
def close(self): self.bg.enabled = False self.animate_scale_y(0, duration=.1) invoke(setattr, self, 'enabled', False, delay=.2) if __name__ == '__main__': ''' WindowPanel is an easy way to create UI. It will automatically layout the content. ''' app = Ursina() WindowPanel( title='Custom Window', content=( Text('Name:'), InputField(name='name_field'), # Text('Age:'), # InputField(name='age_field'), # Text('Phone Number:'), # InputField(name='phone_number_field'), # Space(height=1), # Text('Send:'), Button(text='Submit', color=color.azure), Slider(), Slider(), # ButtonGroup(('test', 'eslk', 'skffk')) ), # popup=True ) # Text(dedent(''' # [ My Window [x]]
if hasattr(self, 'close'): self.close() self.bg.on_click = close if __name__ == '__main__': app = Ursina() WindowPanel( title='Custom Window', content=( Text('leflaijfae\njofeoijfw'), Button(text='test', color=color.green), Space(height=1), Text('leflaijfae\njofeoijfw'), InputField() # ButtonGroup(('test', 'eslk', 'skffk')) ) ) # Text(dedent(''' # [ My Window [x]] # | Create your character # | # | InputField # | [[Male][Female][Other]] # | ButtonGroup(('male', 'female', 'other')) # | Option1: [t] Option2: [] # | # |[ Submit ] [ Clear ] # '''[1:]), font='VeraMono.ttf', origin=(0,0) # )