-- coding: UTF-8 --
import sys, fitz
from reportlab.lib.pagesizes import portrait
from reportlab.pdfgen import canvas
from PIL import Image as ima
import os
#import jm
from pypinyin import lazy_pinyin
import traceback, base64
from PyQt5.QtWidgets import QMessageBox
import sys, traceback
from PyQt5.QtWidgets import QApplication, QMainWindow, QFileDialog, QAction
from PyQt5 import QtCore, QtGui, QtWidgets
import os, sys
#插入记录到文本框
self.textEdit_jpg_pdf.append(‘jpg转换PDF完成’)
if QMessageBox.information(None, ‘提示’, “转换完成,是否打开文件夹进行查看”,
QMessageBox.Yes | QMessageBox.No) == 16384:#给出确定与否的弹窗,是的话则下一步
os.startfile(path_bc)#打开文件
self.textEdit_excel_book.append(‘出错了%s\n’ % traceback.format_exc())#设置报错文本
#错误弹跳窗
QMessageBox.information(None, ‘提示’, “申请书和审批表的路径只能选择一个”)
#获取单行文本框的值
path_shp = self.lineEdit_dwg_shp.text()
#获取多行文本框的值
text = self.textEdit_point.toPlainText()
##进度条
jd_pl = 100 / len(list)
jd = 100 / len(list)
jd = jd + jd_pl
self.progressBar_point.setProperty(“value”, jd)
QApplication.processEvents()
QMessageBox.information(None, ‘提示’, ‘出错了%s\n’ % traceback.format_exc())
#获取选择框的值
layer_zd_zj = self.comboBox_4_dwg_shp.currentText()
self.comboBox_dwg_shp.addItem(“”)
self.comboBox_dwg_shp.setItemText(i, name)#给选择框添加选项
#获取日期框的值
zm = self.zm.text()
def jpg_pdf_main(self):
def askdirectory_word_pdf_xz():
“”“”“”
_translate = QtCore.QCoreApplication.translate
folder = QFileDialog.getExistingDirectory()
self.lineEdit_jpg_pdf.setText(_translate(“Form”, folder))文章来源:https://www.toymoban.com/news/detail-420322.html
def askdirectory_word_pdf_bc():
""""""
_translate = QtCore.QCoreApplication.translate
folder = QFileDialog.getExistingDirectory()
self.lineEdit_jpg_pdf_2.setText(_translate("Form", folder))
def askdirectory():
_translate = QtCore.QCoreApplication.translate
folder = QFileDialog.getOpenFileName(caption='选择CAD文件', filter='Txt files(*.dwg)')
# print(folder[0])
self.lineEdit_sk_dwg.setText(_translate("Form", folder[0]))
def jpg_pdf():
path_word = self.lineEdit_jpg_pdf.text()
path_bc = self.lineEdit_jpg_pdf_2.text()
if self.radioButton_jpg_pdf.isChecked() == True:#判断radioButton_jpg_pdf选择是否为真
file_name1(path_word, path_bc, self)
elif self.radioButton_jpg_pdf_2.isChecked() == True:
file_name2(path_word, path_bc, self)
elif self.radioButton_jpg_pdf_3.isChecked() == True:
file_name3(path_word, path_bc, self)
########隐藏控件或显示控件
self.frame.setVisible(False)
self.frame_2.setVisible(False)
###########布局放大
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
def ye1():
self.frame.setVisible(True)
self.frame_2.setVisible(False)
# progressBar = self.progressBar_2
self.gridLayout.addWidget(self.frame, 0, 0, 1, 1)
# self.gridLayout.addWidget(progressBar, 1, 0, 1, 1)
MainWindow.setStyleSheet("")
self.action1.triggered.connect(ye1)
self.pushButton_jpg_pdf.clicked.connect(jpg_pdf)
self.toolButton_jpg_pdf.clicked.connect(askdirectory_word_pdf_xz)
self.toolButton_jpg_pdf_2.clicked.connect(askdirectory_word_pdf_bc)
self.menu.aboutToHide.connect(ye_sk)
self.pushButton.setEnabled(False)#设置禁用按钮
#添加右键事件
self.toolButton.setContextMenuPolicy(Qt.CustomContextMenu)
self.toolButton.customContextMenuRequested.connect(yess1) # mouseDoubleClickEvent
self.comboBox_arcgis_sctj.currentIndexChanged.connect(ye_create_zd) # 下拉输出条件触发
if name == ‘main’:
import jm
app = QApplication(sys.argv)
MainWindow = QMainWindow() # QMainWindow模块名
self = jm.Ui_MainWindow()
self.setupUi(MainWindow)
# 给界面添加图标
icon = QtGui.QIcon()
path = os.path.join(os.getcwd(), resource_path(os.path.join(“temp”, “gzjc.ico”)))
icon.addPixmap(QtGui.QPixmap(path), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)文章来源地址https://www.toymoban.com/news/detail-420322.html
jpg_pdf_main(self)
MainWindow.show()
sys.exit(app.exec_())
到了这里,关于python pyqt5部分控件操作,包括弹窗等的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!