@@ -125,7 +125,88 @@ def __init__(self, master, Title, icon, message):
125
125
126
126
def destroy (self ):
127
127
self .message_dialog_window .destroy ()
128
-
128
+
129
+ class about_dialog :
130
+
131
+ def __init__ (self , master , Title , icon , software_version , author ):
132
+
133
+ #Change to script's directory
134
+ abspath = os .path .abspath (__file__ )
135
+ dname = os .path .dirname (abspath )
136
+ os .chdir (dname )
137
+
138
+ os_name = platform .system () + ' ' + platform .release ()
139
+
140
+ #Load icons
141
+ if (platform .system () == 'Linux' ):
142
+ self .os_icon = PhotoImage (file = 'Icons/linux_large.png' )
143
+ elif (platform .system () == 'FreeBSD' ):
144
+ self .os_icon = PhotoImage (file = 'Icons/freebsd_large.png' )
145
+ else :
146
+ self .os_icon = PhotoImage (file = 'Icons/windows_large.png' )
147
+
148
+ python_version = 'python v' + platform .python_version ()
149
+ if (sys .maxsize > (2 ** 31 - 1 )):
150
+ python_version += ' (64 bit)'
151
+ else :
152
+ python_version += ' (32 bit)'
153
+
154
+ message = software_version + '\n ' + python_version + '\n ' + os_name + '\n ' + author
155
+
156
+ #Create a new dialog box window
157
+ self .about_dialog_window = Toplevel ()
158
+
159
+ #Make it non-resizeble, set title
160
+ self .about_dialog_window .resizable (False , False )
161
+ self .about_dialog_window .title (Title )
162
+
163
+ #Create frames
164
+ self .icon_frame = ttk .Frame (self .about_dialog_window )
165
+ self .icon_frame .pack (side = 'left' , fill = Y )
166
+ self .entry_frame = ttk .Frame (self .about_dialog_window )
167
+ self .entry_frame .pack (side = 'left' , fill = Y )
168
+ self .os_icon_frame = ttk .Frame (self .about_dialog_window )
169
+ self .os_icon_frame .pack (side = 'left' , fill = Y )
170
+
171
+ #Create the label showing main icon
172
+ ttk .Label (self .icon_frame , image = icon ).pack (padx = 3 , pady = 3 )
173
+
174
+ #Create the label
175
+ ttk .Label (self .entry_frame , text = message , anchor = 'w' ).pack (padx = 3 , fill = X , expand = True )
176
+
177
+ #Create the label showing os icon
178
+ ttk .Label (self .os_icon_frame , image = self .os_icon ).pack (padx = 3 , pady = 3 )
179
+
180
+ #Create buttons
181
+ self .rename_ok_button = ttk .Button (self .entry_frame , text = 'OK' , command = self .destroy )
182
+ self .rename_ok_button .pack (pady = 3 , padx = 3 )
183
+
184
+ #center the window
185
+ self .about_dialog_window .withdraw ()
186
+ self .about_dialog_window .update ()
187
+ x = master .winfo_rootx ()
188
+ y = master .winfo_rooty ()
189
+ main_height = master .winfo_height ()
190
+ main_width = master .winfo_width ()
191
+ window_height = self .about_dialog_window .winfo_reqheight ()
192
+ window_width = self .about_dialog_window .winfo_reqwidth ()
193
+ geom = '+%d+%d' % ((x + main_width // 2 - window_width // 2 ), (y + main_height // 2 - window_height // 2 ))
194
+ self .about_dialog_window .geometry (geom )
195
+ self .about_dialog_window .deiconify ()
196
+
197
+ #Prevent new task in taskbar
198
+ self .about_dialog_window .transient (master )
199
+
200
+ #Focus on the dialog box, freeze controll of main window
201
+ self .about_dialog_window .focus_force ()
202
+ while True :
203
+ try :
204
+ self .about_dialog_window .grab_set ()
205
+ break
206
+ except : continue
207
+
208
+ def destroy (self ):
209
+ self .about_dialog_window .destroy ()
129
210
130
211
class warning_dialog :
131
212
@@ -699,14 +780,16 @@ def __init__(self, master, Title, func_command, directory_mode = False):
699
780
if (platform .system () == 'Linux' or platform .system () == 'FreeBSD' ):
700
781
common_file_list = []
701
782
for home_folders in ['' , 'Desktop' , 'Documents' , 'Downloads' , 'Music' , 'Pictures' , 'Videos' ]:
702
- common_file_list .append (os .getcwd ()+ '/' + home_folders )
783
+ if (os .path .exists (os .getcwd ()+ '/' + home_folders )):
784
+ common_file_list .append (os .getcwd ()+ '/' + home_folders )
703
785
for drive in psutil .disk_partitions ():
704
786
common_file_list .append (drive .mountpoint )
705
787
self .directory_text ['values' ] = common_file_list
706
788
elif (platform .system () == 'Windows' ):
707
789
common_file_list = []
708
790
for home_folders in ['' , 'Desktop' , 'Documents' , 'Downloads' , 'Music' , 'Pictures' , 'Videos' ]:
709
- common_file_list .append (os .getcwd ()+ '\\ ' + home_folders )
791
+ if (os .path .exists (os .getcwd ()+ '/' + home_folders )):
792
+ common_file_list .append (os .getcwd ()+ '\\ ' + home_folders )
710
793
#See SO link: https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
711
794
drives = win32api .GetLogicalDriveStrings ()
712
795
drives = drives .split ('\000 ' )[:- 1 ]
@@ -904,7 +987,9 @@ def delta(event):
904
987
905
988
def mouse_select (self , event ):
906
989
#Check for directory mode
907
- if (self .directory_mode is True ): return
990
+ if (self .directory_mode is True and not isfile (self .file_list [self .current_file_index ])):
991
+ self .change_dir (event )
992
+ return
908
993
#Store start position for drag select
909
994
self .start_x = self .x_cell_pos
910
995
self .start_y = self .y_cell_pos
0 commit comments