# Released under the MIT License. See LICENSE for details.#"""Provides functionality for displaying QR codes."""from__future__importannotationsfromtypingimportoverrideimportbauiv1asbuifrombauiv1lib.popupimportPopupWindow
[docs]classQRCodeWindow(PopupWindow):"""Popup window that shows a QR code."""def__init__(self,origin_widget:bui.Widget,qr_tex:bui.Texture):position=origin_widget.get_screen_space_center()assertbui.app.classicisnotNoneuiscale=bui.app.ui_v1.uiscalescale=(2.3ifuiscaleisbui.UIScale.SMALLelse1.65ifuiscaleisbui.UIScale.MEDIUMelse1.23)self._transitioning_out=Falseself._width=450self._height=400bg_color=(0.5,0.4,0.6)super().__init__(position=position,size=(self._width,self._height),scale=scale,bg_color=bg_color,)self._cancel_button=bui.buttonwidget(parent=self.root_widget,position=(50,self._height-30),size=(50,50),scale=0.5,label='',color=bg_color,on_activate_call=self._on_cancel_press,autoselect=True,icon=bui.gettexture('crossOut'),iconscale=1.2,)bui.imagewidget(parent=self.root_widget,position=(self._width*0.5-150,self._height*0.5-150),size=(300,300),texture=qr_tex,)def_on_cancel_press(self)->None:self._transition_out()def_transition_out(self)->None:ifnotself._transitioning_out:self._transitioning_out=Truebui.containerwidget(edit=self.root_widget,transition='out_scale')