当前位置: 首页 > news >正文

linux网站备份软考培训机构排名

linux网站备份,软考培训机构排名,服装定制费用,武汉大型网站建设写在前面 ​ 在很早之前,我在我所在的项目上自己写过一部分工具,web版本,放在本地环境供自己使用。由于之前项目的架构相对陈旧,多是一些文本处理的工具(sql处理),以及数据库查询相关工具类。由…

写在前面

​ 在很早之前,我在我所在的项目上自己写过一部分工具,web版本,放在本地环境供自己使用。由于之前项目的架构相对陈旧,多是一些文本处理的工具(sql处理),以及数据库查询相关工具类。由于没有进行版本管理,后来换电脑的过程中那部分代码被直接遗失掉了。

​ 再后来重写过一次,但一直使用控制台交互,自己虽然能用,但感觉体验一般。因此最近java转python实现一次,并使用py2app包进行打包,制作成自己的MacApp,想用的时候直接打开使用即可。

​ 但是值得注意的是,py2app打包的软件和通过xcode进行签名通过AppStore分发的软件不同,一般来说是过不了mac的安全检验的,简言之,自己用可以,分发存在困难(给予软件信任也可)。

​ 如果本身存在分发需求,又是一些简单的小工具,我倒是直接推荐使用Mac的自动工具,通过shell脚本实现功能,Mac会自动打成一个小程序,可分发。

在这里插入图片描述

我这里需要制作图形化界面,所以还是用回py2app。(不是swiftui没法比,是python更有性价比)

核心实现代码

​ 我这里主要实现了四个功能,sql转java拼接字符串sql,Java的sql字符串转sql,快速打开脚本文档,快速打开在线笔记。


from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QPlainTextEdit, QPushButton, QVBoxLayout, QHBoxLayout
from PyQt5.QtGui import QTextCursor, QDesktopServices
from PyQt5.QtCore import Qt, QUrlclass Sql2StringConverter(QMainWindow):def __init__(self):super(Sql2StringConverter, self).__init__()self.setWindowTitle('SQL字符串转换工具')self.setGeometry(200, 200, 1200, 700)self.sql_text = QPlainTextEdit()self.sql_text.setPlaceholderText("待转换区域")self.sql_text.setStyleSheet('background-color: white; color: black')self.result_text = QPlainTextEdit()self.result_text.setReadOnly(True)self.result_text.setPlaceholderText("已转换区域")self.result_text.setStyleSheet('background-color: white; color: black')self.input_output_layout = QHBoxLayout()self.input_output_layout.addWidget(self.sql_text)self.input_output_layout.addWidget(self.result_text)self.convert_button = QPushButton(" SQL to String")self.convert_button.clicked.connect(self.convert_sql_to_string)self.reverse_button = QPushButton(" String to SQL")self.reverse_button.clicked.connect(self.convert_string_to_sql)self.load_file_button = QPushButton('祖传秘籍')self.load_file_button.clicked.connect(self.load_file)self.online_button = QPushButton('在线笔记')self.online_button.clicked.connect(self.open_online_note)button_layout = QHBoxLayout()button_layout.addWidget(self.convert_button)button_layout.addWidget(self.reverse_button)button_layout.addWidget(self.load_file_button)button_layout.addWidget(self.online_button)self.central_widget = QWidget()self.setCentralWidget(self.central_widget)layout = QVBoxLayout()# layout.addWidget(self.convert_button)# layout.addWidget(self.reverse_button)# layout.addWidget(self.sql_text)# layout.addWidget(self.result_text)layout.addLayout(button_layout)layout.addLayout(self.input_output_layout)self.central_widget.setLayout(layout)def convert_sql_to_string(self):sql = self.sql_text.toPlainText()lines = sql.split("\n")converted_code = "StringBuffer sb = new StringBuffer();\n\n"for line in lines:if line.strip() != "":converted_code += 'sb.append(" {} ");\n'.format(line.strip())self.result_text.clear()self.result_text.insertPlainText(converted_code)# 将光标移至文本末尾cursor = self.result_text.textCursor()cursor.movePosition(QTextCursor.End)self.result_text.setTextCursor(cursor)def convert_string_to_sql(self):string = self.sql_text.toPlainText()# 去掉所有的 "sql.append(" 和 " ); "sql = string.replace('sb.append("', '').replace('StringBuffer sb = new StringBuffer();', '').replace('");', '').strip()self.result_text.clear()self.result_text.insertPlainText(sql)cursor = self.result_text.textCursor()cursor.movePosition(QTextCursor.End)self.result_text.setTextCursor(cursor)def load_file(self):folder_path = 'doc'url = QUrl.fromLocalFile(folder_path)QDesktopServices.openUrl(url)def open_online_note(self):url = QUrl('http://101.42.xx.xx:8088/#root-lYZQ')QDesktopServices.openUrl(url)if __name__ == "__main__":app = QApplication([])# 设置样式表app.setStyleSheet('''QMainWindow {background-color: black;}QTextEdit {border: 1px solid gray;padding: 5px;}QPushButton {background-color: #5fa8d3;border-radius: 5px;padding: 5px;color: white;}''')window = Sql2StringConverter()window.show()app.exec_()

在线笔记地址被我隐掉了,是我在我自己服务器搭建的trilium,有兴趣的放自己的印象笔记,墨迹文档之类皆可。

py2app打包设置

"""
This is a setup.py script generated by py2appletUsage:python setup.py py2app
"""from setuptools import setupAPP = ['transStr.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True,'iconfile': './PythonApplet.icns','plist': {'CFBundleName': 'transStr','CFBundleDisplayName': 'transStr','CFBundleVersion': '1.0.0','CFBundleIdentifier': 'transStr'}
}setup(app=['transStr.py'],name='transStr',data_files=[],options={'py2app': OPTIONS},setup_requires=['py2app'],
)

iconfile:软件图标。是我自己搁网上下载的。

配置文件初始化命令

py2applet   --make-setup  xxx.py 

打包命令

python setup.py py2apppython setup.py py2app -A(不包含lib库)

我是全部打包的,因此打出来的软件较大。

在这里插入图片描述

在dist中可以看见自己打包好的软件

在这里插入图片描述
双击运行
在这里插入图片描述

功能测试

随便输入一条sql

在这里插入图片描述

随便输入一串sql字符串

在这里插入图片描述

点祖传秘籍,快速定位到提前放置的字段文档或者操作文档

在这里插入图片描述

点在线笔记,快速定位到我的在线笔记

在这里插入图片描述

写在后面

​ 这个app,原本我的打算只有字符串处理这个功能,但就这样写一篇文章,有点单薄,因此又加了两个功能。在学习打包MacApp的过程中,最令我意外的还是mac的自动操作功能,实话实说,确实很方便,但坏处就是没有图形化界面,不过对于稍懂计算机的人来说够使了。

http://www.tj-hxxt.cn/news/64399.html

相关文章:

  • 婚纱摄影网站html网站站长seo推广
  • 美颜秘籍网站建设网络营销推广方案设计
  • ui做标注的网站外贸网站优化
  • 公司企业网站免费手机优化大师下载安装
  • 自己做的网站怎么上传到浏览器游戏推广渠道
  • 常用的电子商务网站开发技术深圳市社会组织总会
  • 在线做网站 自动生成手机版搜索引擎优化期末考试答案
  • 网页游戏排行榜开服时间保定百度seo公司
  • 福州外贸网站制作百度手机卫士
  • 做热饮店网站百度关键词优化软件网站
  • 珠宝行业做网站的好处自己做网站如何赚钱
  • 网站建设寻找可以途径网络推广营销方案100例
  • 做的比较早的海淘网站青岛做网站的公司哪家好
  • 在线网页制作源码搜索引擎内部优化
  • 怎么自己做网站盗qq网络视频营销
  • 南川网站制作最佳的资源磁力搜索引擎
  • 靖江建设局网站请输入搜索关键词
  • 外国的html 素材网站项目推广方式有哪些
  • 设计师图片素材南京seo推广公司
  • 做网站属于广告费吗搜索量排名
  • 用dw做网站怎么添加音乐网站优化排名
  • 360客户如何做网站推广企业网络推广计划书
  • 大学做网站是什么专业营销软文是什么意思
  • 背景墙素材高清图片免费谷歌自然排名优化
  • 做职业规划的网站seo是什么字
  • 个人网站开发如何赚钱吗荥阳seo
  • wordpress多城市子站最新seo自动优化软件
  • ic外贸网站建设武汉网络推广有哪些公司
  • 做网站优化步骤百度推广开户公司
  • 免费看java开发的网站班级优化大师app下载