Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some useless dependencies, adjust some widget style (just a min… #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dist
build
.conda
.idea
jpg_to_pdf/images
jpg_to_pdf/output
release
Expand Down
Binary file added src/drawing/__pycache__/drawing.cpython-310.pyc
Binary file not shown.
Binary file not shown.
37 changes: 20 additions & 17 deletions src/jpg_to_pdf/jpgToPdf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QPushButton, QVBoxLayout, QFileDialog, QProgressBar
from PyQt5.QtCore import Qt, pyqtSlot, QThread, pyqtSignal, QTimer, QCoreApplication
from PyQt5.QtGui import QPixmap
from PyQt5.QtCore import pyqtSlot, QThread, pyqtSignal, QCoreApplication
from PIL import Image
from reportlab.pdfgen import canvas
import os

class ImageToPDFConverter(QWidget):
class ImageToPDFConverter(QWidget):
def __init__(self):
super().__init__()

Expand All @@ -14,8 +13,7 @@ def __init__(self):
self.progress_bar = QProgressBar()
self.pdf_path_label = QLabel()

self.worker = None # Initialize worker instance

self.worker = None
self.init_ui()

def init_ui(self):
Expand All @@ -25,19 +23,31 @@ def init_ui(self):
layout.addWidget(self.folder_path)

browse_button = QPushButton("浏览", clicked=self.browse)
browse_button.setFixedSize(480, 50)
layout.addWidget(browse_button)

convert_button = QPushButton("一键转换", clicked=self.convert_to_pdf)
convert_button.setFixedSize(480, 50)
layout.addWidget(convert_button)

layout.addWidget(QLabel("转换进度:"))
layout.addWidget(self.progress_bar)
layout.addWidget(self.pdf_path_label)
layout.addWidget(self.message_label)

window_width = 2900
window_height = 600
button_width = browse_button.sizeHint().width()
button_height = browse_button.sizeHint().height()

self.setLayout(layout)
self.setWindowTitle("Image to PDF Converter")
self.setGeometry(100, 100, 520, 260) # 设置窗口大小

self.setGeometry(
(window_width - button_width) // 2,
(window_height - button_height) // 2,
button_width,
button_height,
)
@pyqtSlot()
def browse(self):
folder_selected = QFileDialog.getExistingDirectory(self, "选择文件夹")
Expand All @@ -48,7 +58,7 @@ def convert_to_pdf(self):
folder_path = self.folder_path.text()

if not folder_path:
self.show_message("未选择文件夹退出。")
self.show_message("未选择文件夹退出。")
return

output_pdf_path = "output"
Expand All @@ -61,7 +71,7 @@ def convert_to_pdf(self):

@pyqtSlot(str)
def show_message(self, message):
self.message_label.setStyleSheet("") # Reset to default
self.message_label.setStyleSheet("")
self.message_label.setText(message)
self.message_label.repaint()

Expand All @@ -78,14 +88,7 @@ def show_conversion_result(self, result):
@pyqtSlot(int)
def update_progress_bar(self, value):
self.progress_bar.setValue(value)
QCoreApplication.processEvents() # Allow the GUI to update

# @pyqtSlot()
# def return_to_original(self):
# # 在这里执行返回时的操作
# self.close()
# # 返回原来的界面
# app.main()
QCoreApplication.processEvents()

class ImageToPDFWorker(QThread):
finished = pyqtSignal(str)
Expand Down
Binary file added src/output/output.pdf
Binary file not shown.
Binary file not shown.
Binary file added src/sign_in/__pycache__/signIn.cpython-310.pyc
Binary file not shown.