Pycharm_snippets
# -*- coding:GB18030 -*-
from guis import ui
from guis.uimve import model
from guis.uimve import event
import test_event # 事件 event
# 1. 这里的设计可以解决数据先到, 然后在客户端缓存的问题
# 2. 解决一个数据中心对应多个界面的问题
g_data = None
def instance(bind_view_root = None):
global g_data
if not g_data:
g_data = $class$()
if bind_view_root:
g_data.add_view_root(bind_view_root)
return g_data
# from debug.test_mve import $class$ as model
# model.instance()
class $class$(model.Model):
"""
数据中心
"""
def __init__(self):
super($class$,self).__init__()
# ==============================属性例子=====================================
# @property
# def Age(self):
# return self._age
# @Age.setter
# def Age(self,v):
# if v!=self._age:
# self._age = v
# self.trigger_event(test_event.EVENT_AGE,self._age)
# ==============================属性例子=====================================
# -*- coding:GB18030 -*-
from guis import ui
from guis.uimve import view
from guis.uimve import event
import test_event #事件 event
import test_model # 数据 model
from guis import ui_common_v2 as v2
import tw2global
# ==================================================================
#
# ==================================================================
# ==================================================================
# 组件的前缀说明:
# btn: 按钮相关
# ckbtn: 复选框按钮
# crbtn: 单选框按钮
# lb: 文本相关
# rlb: 富文本相关
# clb: 可点击的文本
# cs: 可选区域
# cb: 画一个区域
# cli: 列表
# csr: 滑动条
# cimg: 图片
# ced: 文本输入框
# crl: 右对齐文本
# ==================================================================
# ==================================================================
# 打印函数调用堆栈
# import inspect
# print self,': ',inspect.stack()
# ==================================================================
g_dialog = None
def instance():
global g_dialog
if not g_dialog:
g_dialog = $class$()
return g_dialog
# from debug.test_mve import test_view as view
# view.instance().hide(0)
class $class$(view.View):
# 这个大小由使用的面板的的背景来决定, 这里设置的大小适合于a1的面板
CAP_RECT_WIDTH = 1098 # 可拖动区域的大小
CAP_RECT_HEIGHT = 131 # 可拖动区域的高度
def __init__(self, parent=ui.getAnchor(ui.subpanel_center)):
# parent,filename,pos,msg,style=0,cap=True,w=0,h=0
# 这里需要注意的是style参数(定义在ui.py文件中):
# 用 | 连接
# STYLE_NONE = 0
# 能否移动
# STYLE_CAN_MOVE = 1
# 固定窗口顺序
# STYLE_STABLE_ORDER = 2
# 检查是否移出屏幕边界
# STYLE_STICK_INSIDE = 4
super($class$, self).__init__(parent, v2.DIALOG_BG_STYLE_A1, v2.DIALOG_BG_STYLE_A1_POS, 0, style=1)
self.setCapRect(0, 0, self.CAP_RECT_WIDTH, self.CAP_RECT_HEIGHT)
self.closeBtn = self.create_close_button(bg_Style=ui.BG_STYLE_A1)
tw2global.rds.$class$ = self
self.data = None # 数据中心
@view.check_dialog_show(event_id=event.EVENT_UPDATE_DIALOG)
def layout(self):
pass
def hide(self, bhide):
super($class$, self).hide(bhide)
ui.regShowDialog(self, bhide, 1)
if not bhide:
# 注册数据中心
self.data = test_model.instance(self) # 注册 view
# 注册所有事件
for method_name in TestView.ALL_DYNAMIC_LIST:
func = getattr(self,method_name,None)
if func and hasattr(func,'__call__'):
func(call_type = "register")
else:
if self.data!=None:
self.data.release_all_event(self) # 取消注册所有事件
self.data = None
def message(self, msgid):
msg = msgid - ui.msg_button
if msg == 1 or msg == ui.msg_escape:
self.hide(True)