0
点赞
收藏
分享

微信扫一扫

采用Remi纯Python写前端页面,范例2

灯火南山 2022-02-03 阅读 46

官网:https://remi.readthedocs.io/en/latest/

""" This example shows the possibility to stop the server by App.close() method.
With multiple_clients, the server will stop as soon as all the clients
will disconnect.
"""

import remi.gui as gui
from remi import start, App


class MyApp(App):
def main(self, name='world'):
# margin 0px auto allows to center the app to the screen
wid = gui.VBox(width=300, height=200, margin='0px auto')

bt = gui.Button('Close App', width=200, height=30)
bt.style['margin'] = 'auto 50px'
bt.style['background-color'] = 'red'

bt.onclick.do(self.on_button_pressed)

wid.append(bt)
return wid

# listener function
def on_button_pressed(self, _):
self.close() # closes the application

def on_close(self):
""" Overloading App.on_close event allows to perform some
activities before app termination.
"""
print("I'm going to be closed.")
super(MyApp, self).on_close()


if __name__ == "__main__":
start(MyApp)

执行效果:

采用Remi纯Python写前端页面,范例2_官网


举报

相关推荐

0 条评论