def _get_image_fields(self): # Display a menu to choose images to edit images = [] items = self.theme[self.path].items() items.sort(lambda x, y: cmp(x[0], y[0])) for k, v in items: if isinstance(v, TextureGraphicElementTemplate): assert k.startswith('image') images.append(k) def edit_image(choice): self.do_edit_image(choice) def add_image(): self.do_add_new_image() return [ kytten.FoldingSection( "Images", kytten.VerticalLayout([ kytten.Menu(options=images, on_select=edit_image, align=kytten.HALIGN_LEFT), kytten.Button('Add Image', on_click=add_image) ])) ]
def _get_custom_components(self): # Handle all components without built-in handlers here components = [] items = self.theme[self.path].items() items.sort(lambda x, y: cmp(x[0], y[0])) for k, v in items: if isinstance(v, dict): components.append(k) def edit_component(choice): self.do_edit_component(choice) def on_add_click(): self.do_add_new_component() return [ kytten.FoldingSection( "Custom Components", kytten.VerticalLayout([ kytten.Menu(options=components, on_select=edit_component, align=kytten.HALIGN_LEFT), kytten.Button("Add Component", on_click=on_add_click) ])) ]
def create_scrollable_dialog(): def on_select(choice): print("Kytten is %s" % choice) def on_set(value): print("Kytten rating is %0.0f" % value) dialog = kytten.Dialog(kytten.Frame( kytten.Scrollable(kytten.VerticalLayout([ kytten.Label("Rate Kytten from 1 to 10:"), kytten.Slider(7.0, 1.0, 10.0, steps=9, on_set=on_set), kytten.Label("This slider is disabled:"), kytten.Slider( 1.0, 1.0, 10.0, steps=9, on_set=on_set, disabled=True), kytten.Label("Kytten is..."), kytten.Menu(options=[ "Awesome", "Cute", "-Disabled Option", "Excellent", "Fantastic", "Great", "Supercalifragilistiexpialidocious", "Terrific" ], align=kytten.HALIGN_LEFT, on_select=on_select), ], align=kytten.HALIGN_LEFT), width=200, height=150)), window=window, batch=batch, group=fg_group, anchor=kytten.ANCHOR_CENTER, theme=kytten.themes.felyne_light, on_escape=on_escape)
def on_show_state(self, window, manager): BaseState.on_show_state(self, window, manager) def on_theme_file_select(filename): if filename: self.select_theme_file(filename) else: self.popup_message("Please select a file") def on_theme_file_cancel(dialog): self.manager.pop() json_files = glob.glob(os.path.join(self.theme_dir, '*.json')) json_files = [os.path.basename(x) for x in json_files] self.dialog = kytten.Dialog(kytten.TitleFrame( "kytten Theme Editor", kytten.VerticalLayout([ kytten.Label("Please select a theme file"), kytten.Menu(options=['(New File)'] + json_files, on_select=on_theme_file_select) ]), ), window=window, anchor=kytten.ANCHOR_CENTER, theme=gTheme, on_escape=on_theme_file_cancel)
window.dispatch_event('on_update', dt) pyglet.clock.schedule(update) # Set up a background which changes when user hits left or right arrow # background = Background(batch=batch, group=bg_group) # window.push_handlers(background) # Set up a Dialog to choose test dialogs to show dialog = kytten.Dialog(kytten.TitleFrame( "Kytten Demo", kytten.VerticalLayout([ kytten.Label("Select dialog to show"), kytten.Menu(options=[ "Document", "Form", "Scrollable", "Folding", "Dropdown", "File Load", "File Save", "Directory Select" ], on_select=on_select), ]), ), window=window, batch=batch, group=fg_group, anchor=kytten.ANCHOR_TOP_LEFT, theme=kytten.themes.felyne_dark) window2 = kytten.Window( "Window", kytten.VerticalLayout([ kytten.Label( "I'm a window, the first widget to be added to felyne."),