1
1
import sys
2
+ import os
3
+ import inspect
2
4
from PyQt5 import QtWidgets , QtCore , QtGui
3
- import ctypes
4
5
from uptime import boottime
5
6
6
7
@@ -10,10 +11,22 @@ def __init__(self):
10
11
super (TardisDiff , self ).__init__ ()
11
12
self .diff = 0
12
13
self .clipboard = QtWidgets .QApplication .clipboard ()
14
+ # Set hotkeys
13
15
QtWidgets .QShortcut (QtGui .QKeySequence ("Ctrl+Shift+C" ), self ,
14
16
self .setClipboard )
17
+
18
+ # Get directory path
19
+ # From: http://stackoverflow.com/questions/3718657/how-to-properly-determine-current-script-directory-in-python/22881871#22881871
20
+ if getattr (sys , 'frozen' , False ): # py2exe, PyInstaller, cx_Freeze
21
+ script_path = os .path .abspath (sys .executable )
22
+ else :
23
+ script_path = inspect .getabsfile (TardisDiff )
24
+ script_path = os .path .realpath (script_path )
25
+ script_path = os .path .dirname (script_path )
26
+
15
27
# Google for a fancy tardis icon until I've made one
16
- self .setWindowIcon (QtGui .QIcon ('tardis.ico' ))
28
+ self .setWindowIcon (QtGui .QIcon (
29
+ os .path .join (script_path , 'tardis.ico' )))
17
30
self .initUI ()
18
31
19
32
def initUI (self ):
@@ -92,12 +105,7 @@ def getBootTimeAsQTime(self):
92
105
93
106
94
107
def main ():
95
- app = QtWidgets .QApplication (sys .argv )
96
- ed = TardisDiff ()
97
- sys .exit (app .exec_ ())
98
-
99
-
100
- if __name__ == '__main__' :
108
+ '''
101
109
myappid = 'net.xerael.tardisdiff'
102
110
if sys.platform == "win32":
103
111
"""
@@ -109,4 +117,11 @@ def main():
109
117
http://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7
110
118
"""
111
119
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
120
+ '''
121
+ app = QtWidgets .QApplication (sys .argv )
122
+ ed = TardisDiff ()
123
+ sys .exit (app .exec_ ())
124
+
125
+
126
+ if __name__ == '__main__' :
112
127
main ()
0 commit comments