#!/usr/bin/python3
# -*- coding: utf-8 -*- """
ZetCode PyQt5 tutorial This program creates a quit
button. When we press the button,
the application terminates. Author: Jan Bodnar
Website: zetcode.com
Last edited: January 2018
""" import sys from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QWidget, QPushButton, QApplication, QToolTip, QLabel, QLineEdit, QGridLayout
import pandas as pd
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import *
from PyQt5.QtCore import * class Example(QWidget): def __init__(self):
super().__init__() self.initUI() def hitbtn(self): try:
character2 = "++"
character1 = "|" self.step = 0
self.i = 0
self.pbar.setValue(self.step)
self.tipscontent.setText('正在匹配数据...')
ENCODE = 'utf-8' self.step = self.step + 1
self.pbar.setValue(self.step) patient_detail_data = pd.read_excel(self.patient_detail.text(), encoding=ENCODE)
charge_data = pd.read_excel(self.charge.text(), encoding=ENCODE)
charge_data['line'] = '' charge_data_count = len(charge_data)
patient_detail_data_count = len(patient_detail_data)
# print(charge_data_count)
# print(patient_detail_data_count)
# charge_data_count = 1600
step_length = (patient_detail_data_count * 2 + charge_data_count) / 85 self.step = self.step + 4
self.pbar.setValue(self.step) def change_ProgressBar():
self.i = self.i + 1
# print(self.i)
if self.i >= step_length:
# print("-------+++--",self.i)
self.step = self.step + 1
self.pbar.setValue(self.step)
self.i = 0 def change_charge_str(data_row):
change_ProgressBar() data_row = data_row.astype('str')
line = data_row['f_dcmzid'] + character1 return line # charge_data["line"] = charge_data.apply(lambda data_row: change_str(data_row))
charge_data["line"] = charge_data.apply(lambda data_row: change_charge_str(data_row),
axis=1) # axis=1表示对每一行做相同的操作 charge_data.drop('f_id', axis=1, inplace=True) setdict = {}
for row in charge_data.index:
change_ProgressBar() data_row = charge_data.loc[row]
f_brmzid = str(data_row["f_brmzid"])
line = data_row["line"] if f_brmzid in setdict:
svalue = setdict[f_brmzid]
svalue = svalue + character2 + line setdict[f_brmzid] = svalue
else:
setdict[f_brmzid] = line patient_detail_data[''] = ''
patient_detail_data[''] = '' def change_patient_str(the_id):
change_ProgressBar() the_id = str(the_id)
if the_id in setdict:
svalue = setdict[the_id]
return svalue def change_str3(charge):
change_ProgressBar() charge = str(charge)
if charge.__contains__(character1):
return charge.count(character2) + 1 patient_detail_data[""] = patient_detail_data[''].apply(lambda x: change_patient_str(x))
patient_detail_data[''] = patient_detail_data[''].apply(lambda x, i=0: change_str3(x)) try:
path = self.patient_detail.text()
rindex = path.rfind('/')
path = str(path)[:rindex]
path = path + '/合并表.xlsx' except Exception as e:
print(e)
self.tipscontent.setText(e)
path = '合并表.xlsx' self.tipscontent.setText('正在生成合并表...')
patient_detail_data.to_excel(path, index=False) self.step = 100
self.pbar.setValue(self.step)
self.tipscontent.setText('生成合并表成功') except Exception as e:
print(e)
self.tipscontent.setText("发生错误:" + str(e)) def initUI(self):
conmbinebtn = QPushButton('合并', self)
conmbinebtn.clicked.connect(self.hitbtn)
conmbinebtn.resize(conmbinebtn.sizeHint())
# conmbinebtn.move(500, 50)
QToolTip.setFont(QFont('SansSerif', 12))
# self.setToolTip('This is a <b>QWidget</b> widget')
self.setGeometry(300, 300, 650, 450)
self.setWindowTitle('定制小合并') self.pbar = QProgressBar(self)
self.step = 0 self.tips = QLabel('提示')
self.tipscontent = QLabel('') title = QLabel('详细表')
author = QLabel('费表')
self.patient_detail = QLineEdit()
self.charge = QLineEdit()
grid = QGridLayout()
grid.setSpacing(10) grid.addWidget(title, 1, 0)
grid.addWidget(self.patient_detail, 1, 1)
grid.addWidget(author, 2, 0)
grid.addWidget(self.charge, 2, 1) self.pushButton = QPushButton('打开', self)
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.openfile)
grid.addWidget(self.pushButton, 1, 2) self.pushButton2 = QPushButton('打开', self)
self.pushButton2.setObjectName("pushButton")
self.pushButton2.clicked.connect(self.openfile2)
grid.addWidget(self.pushButton2, 2, 2) grid.addWidget(self.tips, 4, 0)
grid.addWidget(self.tipscontent, 4, 1)
grid.addWidget(conmbinebtn, 4, 2)
grid.addWidget(self.pbar, 3, 1)
self.setLayout(grid)
self.show() def openfile(self):
openfile_name = QFileDialog.getOpenFileName(self, '选择文件', '', 'Excel files(*.xlsx , *.xls)')
add = openfile_name[0]
self.patient_detail.setText(add) def openfile2(self):
openfile_name = QFileDialog.getOpenFileName(self, '选择文件', '', 'Excel files(*.xlsx , *.xls)')
add = openfile_name[0]
self.charge.setText(add) if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_()) # pyinstaller -w custom_combine.py --hidden-import=pandas._libs.tslibs.timedeltas
这是个可以是在 win 下生成exe目录,后面hidden是为了解决打包支持pandas的问题 # try:
# self.tipscontent.setText('正在匹配数据...')
# ENCODE = 'utf-8'
# patient_detail_data = pd.read_excel(self.patient_detail.text(), encoding=ENCODE)
# charge_data = pd.read_excel(self.charge.text(), encoding=ENCODE)
#
# # patient_detail_data.merge(charge_data, left_on='lkey', right_on='rkey', how='outer')
# # result = pd.concat([patient_detail_data, charge_data], axis=1, join='right')
# # result = pd.merge(patient_detail_data, charge_data,how='right',left_on=['门诊号'], right_on=['f_brmzid'])
# result = pd.merge(patient_detail_data, charge_data,how='outer',left_on=['门诊号'], right_on=['f_brmzid'])
#
# try:
# path = self.patient_detail.text()
# rindex = path.rfind('/')
# path = str(path)[:rindex]
# path = path + '/合并表2.xlsx'
#
# except Exception as e:
# print(e)
# self.tipscontent.setText(e)
# path = '合并表2.xlsx'
#
# self.tipscontent.setText('正在生成合并表...')
# result.to_excel(path)
# self.tipscontent.setText('生成合并表成功')
# except Exception as e:
# print(e)
# self.tipscontent.setText("发生错误:" + str(e))

pyqt5 做的小程序,可以用来UI做个小demo的更多相关文章

  1. 微信小程序来了,小程序都能做些什么

    2017年的微信大动作就是微信小程序了,到底小程序都能做些什么?这是很多人关注的热点,小程序开发对企业又有什么帮助呢?下面让厦门微信小程序开发公司来为你就分析下.       微信小程序与APP的关系 ...

  2. 基于spring-boot的社区社交微信小程序,适合做脚手架、二次开发

    基于spring-boot的社区社交微信小程序,适合做脚手架.二次开发 代码地址如下:http://www.demodashi.com/demo/13867.html 1 概述 笔者做的一个后端基于s ...

  3. 微信小程序 springboot nginx 做图片存储 上传 浏览

    微信小程序前端-springboot后端-nginx图片存储 前言 本人小白一名,这是第一次学习微信小程序,特此做个记录. 首先准备nginx做图片存储 选择一个地址存放图片 #我的地址 [root@ ...

  4. uni-app开发微信小程序引入UI组件库(Vant-weapp)步骤

    uni-app开发微信小程序引入UI组件库(Vant-weapp)步骤 这里以vant-weapp为例 uni-app官方文档介绍引入组件的方法 1. 新建相关目录 根目录下创建 wxcomponen ...

  5. 微信小程序之提高应用速度小技巧

    作者:vicyao, 腾讯web前端开发 高级工程师商业转载请联系腾讯WeTest获得授权,非商业转载请注明出处. 原文链接:http://wetest.qq.com/lab/view/294.htm ...

  6. 微信小程序怎样提高应用速度小技巧

    作者:vicyao, 腾讯web前端开发 高级工程师商业转载请联系腾讯WeTest获得授权,非商业转载请注明出处. 原文链接:http://wetest.qq.com/lab/view/294.htm ...

  7. 微信小程序全选,微信小程序checkbox,微信小程序购物车

    微信小程序,这里实现微信小程序checkbox,有需要此功能的朋友可以参考下. 摘要: 加减商品数量,汇总价格,全选与全不选 设计思路: 一.从网络上传入以下Json数据格式的数组  1.标题titl ...

  8. 微信小程序之微信登陆 —— 微信小程序教程系列(20)

    简介: 微信登陆,在新建一个微信小程序Hello World项目的时候,就可以看到项目中出现了我们的微信头像,其实这个Hello World项目,就有一个简化版的微信登陆.只不过是,还没有写入到咱们自 ...

  9. 微信小程序开发——前端如何区分小程序运行环境

    前言: 之前用vue做h5项目,对于接口请求,都是根据前端访问域名来判断运行环境,然后自动适配对应的服务器地址的.这样的好处就是在开发.测试及发布上线全程都不需要手动去改接口请求地址,只要提前配置好就 ...

  10. 小程序内嵌H5——判断小程序环境的坑

    现在各种小程序风靡,这边H5的需求还没有搞定,产品又要求做小程序版本,做可以,关键是618前上线,我-- whatever,618要做推广,日期订了,剩下的就只能是排期,定方案,尽可能完成. 最后和产 ...

随机推荐

  1. Likecloud-吃、吃、吃(洛谷 1508)

    题目背景 问世间,青春期为何物? 答曰:“甲亢,甲亢,再甲亢:挨饿,挨饿,再挨饿!” 题目描述 正处在某一特定时期之中的李大水牛由于消化系统比较发达,最近一直处在饥饿的状态中.某日上课,正当他饿得头昏 ...

  2. F - True Liars 带权并查集

    After having drifted about in a small boat for a couple of days, Akira Crusoe Maeda was finally cast ...

  3. 怎样用Android Studio打多包名APK

    问题:项目中不同的分发渠道可能须要打包多种APK(相同的代码),包名可能是不一样的,假设一个一个改动包名又一次编apk是非常麻烦,能够參考下列步骤在Android Studio上操纵Gradle来打包 ...

  4. 在CentOS VPS上源代码安装高版本号git

    背景:个别软件在国内下载非常慢,在vps下载就非常快. 可是下载好后的文件通过scp弄出来的时候又非常慢,所以想通过在vps里安装git,通过gitlab或oschina来进行中转.但遗憾的是,上传到 ...

  5. CentOS出错You don&#39;t have permission to access on this server

    检查http.conf发现没错之后.查找资料后发现时selinux的问题,所以须要关闭这个服务: 1 vi /etc/sysconfig/selinux 2 SELINUX=enforcing 改为 ...

  6. JS中split使用方法和数组中元素的删除

    JS中split使用方法和数组中元素的删除 JS中split使用方法 <script language="javascript"> function spli(){ d ...

  7. 关于FrameBuffer【转】

    本文转载自:http://blog.csdn.net/ganxingming/article/details/764482 一.FrameBuffer的原理 FrameBuffer 是出现在 2.2. ...

  8. SQL Source Control for teams

    You'll use SQL Source Control differently depending on which development model you're using: 不同的模式有不 ...

  9. C# winform listBox中的项上下移动(转)

    C# winform listBox中的项上下移动 分类: C# winform2009-06-24 12:37 876人阅读 评论(0) 收藏 举报 winformc#object //上移节点   ...

  10. Java中jspf文件的作用

    转自:https://blog.csdn.net/xzmeasy/article/details/75103431 为什么要用jspf文件 写jsp页面时,是不是:css和js引用特别多,而且有些页面 ...