Skip to content

Commit

Permalink
2.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
riceshowerX committed Jul 31, 2024
1 parent 0b04fdf commit 0dd849f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
6 changes: 2 additions & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 11 additions & 24 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
# main.py
import os
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.properties import StringProperty, NumericProperty
from kivy.clock import Clock
from kivy.uix.popup import Popup
from kivy.uix.filechooser import FileChooserListView
from kivy.uix.label import Label
from kivy.uix.button import Button
from core import ImageProcessor, Config
from kivy.uix.boxlayout import BoxLayout

# 获取当前脚本的目录
current_dir = os.path.dirname(os.path.abspath(__file__))
from snapforge.core.image_processor import ImageProcessor
from snapforge.core.config import Config
from snapforge.ui.main_window import MainWindow

# 使用正确的路径加载 .kv 文件
kv_path = os.path.join(current_dir, "kivy_ui", "main_window.kv")
# 加载 KV 文件
kv_path = os.path.join(os.path.dirname(__file__), 'ui', 'kv', 'main_window.kv')
Builder.load_file(kv_path)


class MainWindow(BoxLayout):
source_directory = StringProperty(None)
target_directory = StringProperty(None)
source_file = StringProperty(None)
progress_value = NumericProperty(0)

def __init__(self, **kwargs):
super(MainWindow, self).__init__(**kwargs)
self.config = Config()
self.image_processor = ImageProcessor(self.config)


class SnapForgeApp(App):
def build(self):
self.config = Config()
self.image_processor = ImageProcessor(self.config)
self.root = MainWindow()
Clock.schedule_once(self.bind_buttons)
return self.root
Expand Down Expand Up @@ -82,7 +70,7 @@ def rename_files(self, instance):

self.root.progress_value = 0
try:
renamed_count = self.root.image_processor.batch_rename_files(
renamed_count = self.image_processor.batch_rename_files(
self.root.source_file,
self.root.target_directory,
prefix,
Expand All @@ -105,7 +93,7 @@ def convert_files(self, instance):

self.root.progress_value = 0
try:
converted_count = self.root.image_processor.batch_convert_images(
converted_count = self.image_processor.batch_convert_images(
self.root.source_file,
self.root.target_directory,
target_format,
Expand All @@ -130,7 +118,7 @@ def compress_files(self, instance):

self.root.progress_value = 0
try:
compressed_count = self.root.image_processor.batch_compress_images(
compressed_count = self.image_processor.batch_compress_images(
self.root.source_file,
self.root.target_directory,
quality,
Expand All @@ -156,6 +144,5 @@ def show_error_message(self, message):
button.bind(on_press=popup.dismiss)
popup.open()


if __name__ == "__main__":
SnapForgeApp().run()

0 comments on commit 0dd849f

Please sign in to comment.