Download pool/shard004/Python/0035909_ui_menu.py from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard004/Python/0035909_ui_menu.py
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard004/Python/0035909_ui_menu.py
-
curl -L -o 0035909_ui_menu.py https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard004/Python/0035909_ui_menu.py
1.54 kB
| # Menu classes | |
| from browser import html, document | |
| class Menu(html.DIV): | |
| def __init__(self): | |
| html.DIV.__init__(self,style=dict(paddingBottom='5px')) | |
| class BarItem: | |
| def __init__(self, parent, label): | |
| self.item = html.DIV(label,style=dict(float='left', | |
| padding='5px 7px 5px 7px', | |
| borderWidth='1px', borderStyle='solid', borderColor='#FFF') | |
| ) | |
| self.item.bind('click', self.open) | |
| parent <= self.item | |
| self.children = [] | |
| def open(self, ev): | |
| self.menu = html.DIV(style=dict(position='absolute', | |
| left=self.item.left, | |
| top=self.item.top+self.item.height, | |
| zIndex=99,padding='5px',backgroundColor='#FFF', | |
| borderStyle='solid', borderWidth='1px', borderColor="#777")) | |
| for child in self.children: | |
| self.menu <= child | |
| self.item.style.borderColor = '#777' | |
| document <= self.menu | |
| ev.stopPropagation() | |
| def close(self): | |
| self.item.style.borderColor = '#FFF' | |
| document.remove(self.menu) | |
| class MenuListItem: | |
| def __init__(self, parent, label, action=None): | |
| item = html.DIV(label, style=dict(padding='10px')) | |
| item.bind('mouseover', over_menu) | |
| item.bind('mouseout', out_menu) | |
| if action is not None: | |
| item.bind('click', action) | |
| parent.children.append(item) | |
| def over_menu(ev): | |
| ev.target.style.backgroundColor='#DDD' | |
| def out_menu(ev): | |
| ev.target.style.backgroundColor='#FFF' | |