这个模版,不是smarty的那种模版引擎 不是template。是一种面向对象设计模式方法。
使用的地方譬如,作品easerver中, ui部分用的是wxpython , 我现在想换成qt , 感觉模版在这种功能就能起到一些作用。
重点是,核心功能封装于主类,让子类去继承应用。(程序以php代码做演示)
/*
*系统服务类
*/
class server {
//获取的服务项目列表
protected $sl = array('apache'=>'httpd.exe','nginx'=>'nginx.exe','memcache'=>'memcached.exe');
protected $select = '服务key';
//获取服务列表
public function getlist()
{
return $this->sl;
}
//启动服务操作
public function start()
{
start $this->select;
}
//停止服务操作
public function stop()
{
stop $this->select;
}
//重起服务
public function reboot()
{
reboot $this->select;
}
//选择要操作的服务
public function setselect($name)
{
$this->select = $this->sl[$name];
}
}
//显示界面
class wxpython extends server{
public function __construct()
{
parent::__construct();
}
//窗体
public function window()
{
//生成一个表格,提供给用户选择服务
$this->table($this->getlist());
//生成一个启动按钮,他的点击时间为启动服务
$this->startbut->bind('onclick',$this->start()); //启动
$this->stopbut->bind('onclick',$this->stop()); //关闭
$this->rebootbut->bind('onclick',$this->reboot()); //重起
}
//行选择的时候
public function rowsonselect()
{
$this->setselect( $this->tableselect() );
}
}
这样看来, 如果我想换qt的操作界面,只需要把wxpython 换成pyqt的界面生成,一样是几个按钮,给他们指定事件就可以了。
或许指定的语法不一样,比如wxpython用 bind指定事件,qt库就不是。更换ui库不需要修改内核功能部分

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor
