-
Notifications
You must be signed in to change notification settings - Fork 1
/
download.py
64 lines (52 loc) · 2.17 KB
/
download.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import platform
import subprocess
import downloadWnd
from configs import Configs
from PyQt4 import QtGui
from PyQt4 import QtCore
from paths import AppPath
from wndparams import WndParams
class DownloadWnd(QtGui.QWidget):
"""
Class which connect Download Window interface
in python app
"""
def __init__(self, parent=None):
super(DownloadWnd, self).__init__()
self.ui = downloadWnd.Ui_DownloadWnd()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.pbClose, QtCore.SIGNAL("clicked()"), self.on_close)
QtCore.QObject.connect(self.ui.pbOpen, QtCore.SIGNAL("clicked()"), self.on_downloads)
WndParams().on_screen_center(self)
self.app_path = AppPath().main()
if platform.system() == "Linux":
self.ui.label.setPixmap(QtGui.QPixmap( "".join((self.app_path, "images/fon.jpg")) ))
self.ui.label_2.setPixmap(QtGui.QPixmap( "".join((self.app_path, "images/network_9488.png")) ))
self.ui.label_4.setPixmap(QtGui.QPixmap( "".join((self.app_path, "images/Downloads_Folder.png")) ))
self.ui.pbClose.setIcon(QtGui.QIcon( "".join((self.app_path, "images/exit.png")) ))
self.ui.pbOpen.setIcon(QtGui.QIcon( "".join((self.app_path, "images/downloads.png")) ))
def on_close(self):
self.hide()
self.ui.lwFiles.clear()
def on_downloads(self):
self.hide()
self.ui.lwFiles.clear()
cfg = Configs()
if not os.path.exists(cfg.downloads_path()):
QtGui.QMessageBox.warning(self, 'Ошибка', 'Нет загруженных файлов!', QtGui.QMessageBox.Yes)
return
if platform.system() == "Linux":
for mngr in cfg.file_managers():
if os.path.exists("".join(("/usr/bin/", mngr))):
subprocess.call("".join((mngr, " ", cfg.downloads_path())), shell=True)
break
else:
import win32api
win32api.ShellExecute(0, 'open', cfg.downloads_path(), '', '', 1)
def closeEvent(self, e):
e.ignore()
self.hide()
self.ui.lwFiles.clear()