Skip to content

Commit 2629d4a

Browse files
committedAug 28, 2018
Added FreeBSD support and improved dialog windows
1 parent 83506ca commit 2629d4a

15 files changed

+143
-18
lines changed
 
6.96 KB
Loading
675 Bytes
Loading
3.94 KB
Loading
6.96 KB
Loading

‎Icons/freebsd_large.png

6.96 KB
Loading

‎Icons/linux_large.png

549 Bytes
Loading

‎Icons/windows_large.png

310 Bytes
Loading

‎TkDND/libtkdnd2.8_FreeBSD.so

41.5 KB
Binary file not shown.

‎TkDND/pkgIndex.tcl

+16-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@
44

55
switch [tk windowingsystem] {
66
x11 {
7-
package ifneeded tkdnd 2.8 \
8-
"source \{$dir/tkdnd.tcl\} ; \
9-
tkdnd::initialise \{$dir\} libtkdnd2.8.so tkdnd"
7+
switch [lindex $::tcl_platform(os) 0] {
8+
Linux {
9+
package ifneeded tkdnd 2.8 \
10+
"source \{$dir/tkdnd.tcl\} ; \
11+
tkdnd::initialise \{$dir\} libtkdnd2.8.so tkdnd"
12+
}
13+
FreeBSD {
14+
package ifneeded tkdnd 2.8 \
15+
"source \{$dir/tkdnd.tcl\} ; \
16+
tkdnd::initialise \{$dir\} libtkdnd2.8_FreeBSD.so tkdnd"
17+
}
18+
default {
19+
error "unknown x11 platform"
20+
}
21+
}
1022
}
1123
win32 -
1224
windows {
@@ -17,4 +29,4 @@ switch [tk windowingsystem] {
1729
default {
1830
error "unknown Tk windowing system"
1931
}
20-
}
32+
}

‎TkDND64/libtkdnd2.8_FreeBSD.so

50.7 KB
Binary file not shown.

‎TkDND64/pkgIndex.tcl

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@
44

55
switch [tk windowingsystem] {
66
x11 {
7-
package ifneeded tkdnd 2.8 \
8-
"source \{$dir/tkdnd.tcl\} ; \
9-
tkdnd::initialise \{$dir\} libtkdnd2.8.so tkdnd"
7+
switch [lindex $::tcl_platform(os) 0] {
8+
Linux {
9+
package ifneeded tkdnd 2.8 \
10+
"source \{$dir/tkdnd.tcl\} ; \
11+
tkdnd::initialise \{$dir\} libtkdnd2.8.so tkdnd"
12+
}
13+
FreeBSD {
14+
package ifneeded tkdnd 2.8 \
15+
"source \{$dir/tkdnd.tcl\} ; \
16+
tkdnd::initialise \{$dir\} libtkdnd2.8_FreeBSD.so tkdnd"
17+
}
18+
default {
19+
error "unknown x11 platform"
20+
}
21+
}
1022
}
1123
win32 -
1224
windows {

‎TkDND_wrapper.py

+1
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,4 @@ def parse_uri_list(self, uri_list):
100100
else:
101101
file_list.append(item)
102102
return file_list
103+

‎install_dependencies.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,28 @@
4848
print('Installing pypiwin32...')
4949
os.system(python_path + ' -m pip install pypiwin32==219')
5050
input('Press enter to continue...')
51-
5251
#if Linux
53-
if(platform.system() == 'Linux'):
52+
elif(platform.system() == 'Linux'):
5453
print('Platform: Linux')
5554
print('Upgrading pip...')
5655
os.system('python3 -m pip install --upgrade pip')
5756
print('Installing pramiko...')
5857
os.system('python3 -m pip install paramiko')
59-
os.system('python3 -m pip install psutil')
6058
print('Installing psutil...')
59+
os.system('python3 -m pip install psutil')
6160
input('Press enter to continue...')
61+
#if FreeBSD
62+
elif(platform.system() == 'FreeBSD'):
63+
if(os.geteuid() != 0):
64+
print('You need to have root privileges to run this script.')
65+
input('Press enter to continue...')
66+
print('Platform: FreeBSD')
67+
print('Upgrading pip...')
68+
os.system('python3.6 -m pip install --upgrade pip')
69+
print('Installing tkinter...')
70+
os.system('pkg install py36-tkinter-3.6.5_6')
71+
print('Installing pramiko...')
72+
os.system('python3.6 -m pip install paramiko')
73+
print('Installing psutil...')
74+
os.system('python3.6 -m pip install psutil')
75+
input('Press enter to continue...')

‎whipFTP.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __init__(self, master):
9696

9797
#Set window title and size
9898
master.wm_title('whipFTP')
99-
master.minsize(width = 860, height = 560)
99+
master.minsize(width = 930, height = 600)
100100

101101
#Variable for holding the font
102102
self.default_font = font.nametofont("TkDefaultFont")
@@ -303,7 +303,8 @@ def bind_events(self):
303303
self.cut_button.bind('<Motion>', lambda event, arg = 'Cut.': self.update_status(event, arg))
304304
self.copy_button.bind('<Motion>', lambda event, arg = 'Copy.': self.update_status(event, arg))
305305
self.paste_button.bind('<Motion>', lambda event, arg = 'Paste.': self.update_status(event, arg))
306-
self.search_button.bind('<Motion>', lambda event, arg = 'Find.': self.update_status(event, arg))
306+
self.search_button.bind('<Motion>', lambda event, arg = 'Find.': self.update_status(event, arg))
307+
self.goto_button.bind('<Motion>', lambda event, arg = 'Goto.': self.update_status(event, arg))
307308
self.up_button.bind('<Motion>', lambda event, arg = 'Go to parent directory.': self.update_status(event, arg))
308309
self.info_button.bind('<Motion>', lambda event, arg = 'About/Info.': self.update_status(event, arg))
309310

@@ -377,7 +378,7 @@ def update_file_list(self):
377378
self.disable_toolbar()
378379
#Set search to false
379380
self.search_performed = False
380-
self.update_status(message = 'Retrieving file list, Hidden files: {}.'.format(self.ftpController.hidden_files))
381+
self.update_status(message = 'Retrieving file list, Hidden files: {}, Please wait...'.format(self.ftpController.hidden_files))
381382
self.lock_status_bar()
382383
del self.file_list[:]
383384
del self.detailed_file_list[:]
@@ -1120,7 +1121,7 @@ def progress(self, file_name, status):
11201121

11211122

11221123
def info(self):
1123-
self.info_window = Filedialogs.message_dialog(self.master, 'About', self.whipFTP_icon, 'whipFTP v4.3, Written by:\nVishnu Shankar')
1124+
self.info_window = Filedialogs.about_dialog(self.master, 'About', self.whipFTP_icon, 'whipFTP v5.0', '© Vishnu Shankar')
11241125

11251126

11261127

‎whipFTP_FileDialogs.py

+89-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,88 @@ def __init__(self, master, Title, icon, message):
125125

126126
def destroy(self):
127127
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()
129210

130211
class warning_dialog:
131212

@@ -699,14 +780,16 @@ def __init__(self, master, Title, func_command, directory_mode = False):
699780
if(platform.system() == 'Linux' or platform.system() == 'FreeBSD'):
700781
common_file_list = []
701782
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)
703785
for drive in psutil.disk_partitions():
704786
common_file_list.append(drive.mountpoint)
705787
self.directory_text['values'] = common_file_list
706788
elif(platform.system() == 'Windows'):
707789
common_file_list = []
708790
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)
710793
#See SO link: https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
711794
drives = win32api.GetLogicalDriveStrings()
712795
drives = drives.split('\000')[:-1]
@@ -904,7 +987,9 @@ def delta(event):
904987

905988
def mouse_select(self, event):
906989
#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
908993
#Store start position for drag select
909994
self.start_x = self.x_cell_pos
910995
self.start_y = self.y_cell_pos

0 commit comments

Comments
 (0)
Please sign in to comment.