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 bauiv1lib.popup import PopupWindow 8import bauiv1 as bui 9 10 11class ResourceTypeInfoWindow(PopupWindow): 12 """Popup window providing info about resource types.""" 13 14 def __init__(self, origin_widget: bui.Widget): 15 assert bui.app.classic is not None 16 uiscale = bui.app.ui_v1.uiscale 17 scale = ( 18 2.3 19 if uiscale is bui.UIScale.SMALL 20 else 1.65 21 if uiscale is bui.UIScale.MEDIUM 22 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 def on_popup_cancel(self) -> None: 57 bui.getsound('swish').play() 58 self._transition_out()
12class ResourceTypeInfoWindow(PopupWindow): 13 """Popup window providing info about resource types.""" 14 15 def __init__(self, origin_widget: bui.Widget): 16 assert bui.app.classic is not None 17 uiscale = bui.app.ui_v1.uiscale 18 scale = ( 19 2.3 20 if uiscale is bui.UIScale.SMALL 21 else 1.65 22 if uiscale is bui.UIScale.MEDIUM 23 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 def on_popup_cancel(self) -> None: 58 bui.getsound('swish').play() 59 self._transition_out()
Popup window providing info about resource types.
ResourceTypeInfoWindow(origin_widget: _bauiv1.Widget)
15 def __init__(self, origin_widget: bui.Widget): 16 assert bui.app.classic is not None 17 uiscale = bui.app.ui_v1.uiscale 18 scale = ( 19 2.3 20 if uiscale is bui.UIScale.SMALL 21 else 1.65 22 if uiscale is bui.UIScale.MEDIUM 23 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 )
def
on_popup_cancel(self) -> None:
Called when the popup is canceled.
Cancels can occur due to clicking outside the window, hitting escape, etc.