@@ -15,6 +15,8 @@ class MainWindow(QtWidgets.QMainWindow):
1515
1616 def __init__ (self ):
1717 super (MainWindow , self ).__init__ ()
18+ icon = os .path .join (os .getcwd (), 'preferences-desktop-wallpaper-symbolic.svg' )
19+ self .setWindowIcon (QtGui .QIcon (icon ))
1820 self .wallpaper_path = None
1921 self .full_file_path = None
2022 self .label_2_text = ''
@@ -55,15 +57,15 @@ def __init__(self):
5557 self .checkBox = QtWidgets .QCheckBox (self .centralwidget )
5658 self .checkBox .setObjectName ("checkBox" )
5759 self .horizontalLayout .addWidget (self .checkBox )
58- spacerItem = QtWidgets .QSpacerItem (16 , 16 , QtWidgets .QSizePolicy .MinimumExpanding , QtWidgets .QSizePolicy .Expanding )
59- self .horizontalLayout .addItem (spacerItem )
60+ spacer_item = QtWidgets .QSpacerItem (16 , 16 , QtWidgets .QSizePolicy .MinimumExpanding , QtWidgets .QSizePolicy .Expanding )
61+ self .horizontalLayout .addItem (spacer_item )
6062 self .label_2 = QtWidgets .QLabel (self .centralwidget )
6163 self .label_2 .setEnabled (True )
6264 self .label_2 .setObjectName ("label_2" )
6365 self .label_2 .hide ()
6466 self .horizontalLayout .addWidget (self .label_2 , 0 , QtCore .Qt .AlignLeft )
65- spacerItem1 = QtWidgets .QSpacerItem (16 , 16 , QtWidgets .QSizePolicy .MinimumExpanding , QtWidgets .QSizePolicy .Expanding )
66- self .horizontalLayout .addItem (spacerItem1 )
67+ spacer_item1 = QtWidgets .QSpacerItem (16 , 16 , QtWidgets .QSizePolicy .MinimumExpanding , QtWidgets .QSizePolicy .Expanding )
68+ self .horizontalLayout .addItem (spacer_item1 )
6769 self .SortButton = QtWidgets .QPushButton (self .centralwidget )
6870 self .SortButton .setObjectName ("SortButton" )
6971 self .horizontalLayout .addWidget (self .SortButton )
@@ -72,39 +74,37 @@ def __init__(self):
7274 self .statusbar = QtWidgets .QStatusBar (self )
7375 self .statusbar .setObjectName ("statusbar" )
7476 self .setStatusBar (self .statusbar )
75- self .retranslateUi ()
77+ self .retranslate_ui ()
7678 self .openDirectoryBtn .clicked .connect (self .get_directory )
7779 self .SortButton .clicked .connect (self .sort )
78- print (self .full_file_path )
7980 QtCore .QMetaObject .connectSlotsByName (self )
80-
81+ self . center_on_screen ()
8182 self .show ()
8283
84+ def center_on_screen (self ):
85+ resolution = QtWidgets .QDesktopWidget ().screenGeometry ()
86+ self .move (int ((resolution .width () / 2 ) - (self .frameSize ().width () / 2 )), int ((resolution .height () / 2 ) - (self .frameSize ().height () / 2 )))
87+
8388 def get_directory (self ):
8489 file = str (QtWidgets .QFileDialog .getExistingDirectory (self , 'Select Directory to Sort' ))
85- print (file )
8690 self .label_2_text = "Path Set: {}" .format (file )
8791 self .label_2 .show ()
88- self .retranslateUi ()
92+ self .retranslate_ui ()
8993 self .full_file_path = os .path .abspath (file )
9094
9195 def set_wallpaper_path (self ):
92- msgBox = QtWidgets .QMessageBox .question (self ,'Set Output Path' , "Would you like to use default Path at : \n {} \n Or Set Custom ?" .format (self .wallpaper_path ), QtWidgets .QMessageBox .Yes | QtWidgets .QMessageBox .No )
96+ msgBox = QtWidgets .QMessageBox .question (self ,'Set Output Path' , "Default output path is : \n {} \n would you like to set custom ?" .format (self .wallpaper_path ), QtWidgets .QMessageBox .Yes | QtWidgets .QMessageBox .No )
9397
94- if msgBox == QtWidgets .QMessageBox .Yes :
98+ if msgBox == QtWidgets .QMessageBox .No :
9599 pass
96- elif msgBox == QtWidgets .QMessageBox .No :
100+ elif msgBox == QtWidgets .QMessageBox .Yes :
97101 file = str (QtWidgets .QFileDialog .getExistingDirectory (self , 'Select Wallpaper Sort Folder' ))
98- print (file )
99102 if os .path .isdir (file ):
100103 self .wallpaper_path = os .path .abspath (file )
101104 else :
102105 pass
103106
104-
105107 def sort (self ):
106- print (self .full_file_path )
107- print (self .checkBox .isChecked ())
108108 search_subfolders = self .checkBox .isChecked ()
109109
110110 # sort subfolders and folders
@@ -116,7 +116,7 @@ def sort(self):
116116 self .progressBar .show ()
117117 self .set_wallpaper_path ()
118118 self .label_2_text = "Beginning Sort..."
119- self .retranslateUi ()
119+ self .retranslate_ui ()
120120 QtCore .QCoreApplication .processEvents ()
121121
122122 try :
@@ -147,19 +147,19 @@ def sort(self):
147147 continue
148148 self .label_2_text = "{} out of {} Images Sorted" .format (total_image_count , total_images )
149149 self .label_2 .show ()
150- self .retranslateUi ()
150+ self .retranslate_ui ()
151151 QtCore .QCoreApplication .processEvents ()
152152 self .label_2 .hide ()
153153 if image_count > 0 :
154154 self .label_2_text = '{} Images sorted to: {}' .format (image_count , self .wallpaper_path )
155155 self .label_2 .setAlignment (QtCore .Qt .AlignLeft | QtCore .Qt .AlignVCenter )
156156 self .label_2 .show ()
157- self .retranslateUi ()
157+ self .retranslate_ui ()
158158 QtCore .QCoreApplication .processEvents ()
159159 else :
160160 self .label_2_text = "No Images Found"
161161 self .label_2 .show ()
162- self .retranslateUi ()
162+ self .retranslate_ui ()
163163 QtCore .QCoreApplication .processEvents ()
164164 self .progressBar .hide ()
165165 self .SortButton .show ()
@@ -168,10 +168,10 @@ def sort(self):
168168 else :
169169 self .label_2_text = "No Directory Selected"
170170 self .label_2 .show ()
171- self .retranslateUi ()
171+ self .retranslate_ui ()
172172 QtCore .QCoreApplication .processEvents ()
173173
174- def retranslateUi (self ):
174+ def retranslate_ui (self ):
175175 _translate = QtCore .QCoreApplication .translate
176176 self .setWindowTitle (_translate ("MainWindow" , "WallPaperSorT" ))
177177 self .openDirectoryBtn .setText (_translate ("MainWindow" , "Open Directory" ))
@@ -205,7 +205,6 @@ def search_folder(folder, search_subfolders):
205205
206206
207207if __name__ == '__main__' :
208- faulthandler .enable ()
209208 app = QtWidgets .QApplication (sys .argv )
210209 gui = MainWindow ()
211210 sys .exit (app .exec_ ())
0 commit comments