bauiv1lib.resourcetypeinfo
Provides a window which shows info about resource types.
1# Released under the MIT License. See LICENSE for details. 2# 3"""Provides a window which shows info about resource types.""" 4 5from __future__ import annotations 6 7from typing import override 8 9from bauiv1lib.popup import PopupWindow 10import bauiv1 as bui 11 12 13class ResourceTypeInfoWindow(PopupWindow): 14 """Popup window providing info about resource types.""" 15 16 def __init__(self, origin_widget: bui.Widget): 17 assert bui.app.classic is not None 18 uiscale = bui.app.ui_v1.uiscale 19 scale = ( 20 2.3 21 if uiscale is bui.UIScale.SMALL 22 else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23 23 ) 24 self._transitioning_out = False 25 self._width = 570 26 self._height = 350 27 bg_color = (0.5, 0.4, 0.6) 28 super().__init__( 29 size=(self._width, self._height), 30 toolbar_visibility='inherit', 31 scale=scale, 32 bg_color=bg_color, 33 position=origin_widget.get_screen_space_center(), 34 ) 35 self._cancel_button = bui.buttonwidget( 36 parent=self.root_widget, 37 position=(50, self._height - 30), 38 size=(50, 50), 39 scale=0.5, 40 label='', 41 color=bg_color, 42 on_activate_call=self._on_cancel_press, 43 autoselect=True, 44 icon=bui.gettexture('crossOut'), 45 iconscale=1.2, 46 ) 47 48 def _on_cancel_press(self) -> None: 49 self._transition_out() 50 51 def _transition_out(self) -> None: 52 if not self._transitioning_out: 53 self._transitioning_out = True 54 bui.containerwidget(edit=self.root_widget, transition='out_scale') 55 56 @override 57 def on_popup_cancel(self) -> None: 58 bui.getsound('swish').play() 59 self._transition_out()
14class ResourceTypeInfoWindow(PopupWindow): 15 """Popup window providing info about resource types.""" 16 17 def __init__(self, origin_widget: bui.Widget): 18 assert bui.app.classic is not None 19 uiscale = bui.app.ui_v1.uiscale 20 scale = ( 21 2.3 22 if uiscale is bui.UIScale.SMALL 23 else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23 24 ) 25 self._transitioning_out = False 26 self._width = 570 27 self._height = 350 28 bg_color = (0.5, 0.4, 0.6) 29 super().__init__( 30 size=(self._width, self._height), 31 toolbar_visibility='inherit', 32 scale=scale, 33 bg_color=bg_color, 34 position=origin_widget.get_screen_space_center(), 35 ) 36 self._cancel_button = bui.buttonwidget( 37 parent=self.root_widget, 38 position=(50, self._height - 30), 39 size=(50, 50), 40 scale=0.5, 41 label='', 42 color=bg_color, 43 on_activate_call=self._on_cancel_press, 44 autoselect=True, 45 icon=bui.gettexture('crossOut'), 46 iconscale=1.2, 47 ) 48 49 def _on_cancel_press(self) -> None: 50 self._transition_out() 51 52 def _transition_out(self) -> None: 53 if not self._transitioning_out: 54 self._transitioning_out = True 55 bui.containerwidget(edit=self.root_widget, transition='out_scale') 56 57 @override 58 def on_popup_cancel(self) -> None: 59 bui.getsound('swish').play() 60 self._transition_out()
Popup window providing info about resource types.
ResourceTypeInfoWindow(origin_widget: _bauiv1.Widget)
17 def __init__(self, origin_widget: bui.Widget): 18 assert bui.app.classic is not None 19 uiscale = bui.app.ui_v1.uiscale 20 scale = ( 21 2.3 22 if uiscale is bui.UIScale.SMALL 23 else 1.65 if uiscale is bui.UIScale.MEDIUM else 1.23 24 ) 25 self._transitioning_out = False 26 self._width = 570 27 self._height = 350 28 bg_color = (0.5, 0.4, 0.6) 29 super().__init__( 30 size=(self._width, self._height), 31 toolbar_visibility='inherit', 32 scale=scale, 33 bg_color=bg_color, 34 position=origin_widget.get_screen_space_center(), 35 ) 36 self._cancel_button = bui.buttonwidget( 37 parent=self.root_widget, 38 position=(50, self._height - 30), 39 size=(50, 50), 40 scale=0.5, 41 label='', 42 color=bg_color, 43 on_activate_call=self._on_cancel_press, 44 autoselect=True, 45 icon=bui.gettexture('crossOut'), 46 iconscale=1.2, 47 )
@override
def
on_popup_cancel(self) -> None:
57 @override 58 def on_popup_cancel(self) -> None: 59 bui.getsound('swish').play() 60 self._transition_out()
Called when the popup is canceled.
Cancels can occur due to clicking outside the window, hitting escape, etc.