Skip to content

Commit 1b64d1b

Browse files
committed
Icon is now loaded using an absolute path.
Also removed the setting of the AppUserModelID since it caused problems with the windows 7 "pin this program to taskbar" function. Icons seem to still work though.
1 parent d65721f commit 1b64d1b

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

TardisDiff.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
2+
import os
3+
import inspect
24
from PyQt5 import QtWidgets, QtCore, QtGui
3-
import ctypes
45
from uptime import boottime
56

67

@@ -10,10 +11,22 @@ def __init__(self):
1011
super(TardisDiff, self).__init__()
1112
self.diff = 0
1213
self.clipboard = QtWidgets.QApplication.clipboard()
14+
# Set hotkeys
1315
QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+Shift+C"), self,
1416
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+
1527
# 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')))
1730
self.initUI()
1831

1932
def initUI(self):
@@ -92,12 +105,7 @@ def getBootTimeAsQTime(self):
92105

93106

94107
def main():
95-
app = QtWidgets.QApplication(sys.argv)
96-
ed = TardisDiff()
97-
sys.exit(app.exec_())
98-
99-
100-
if __name__ == '__main__':
108+
'''
101109
myappid = 'net.xerael.tardisdiff'
102110
if sys.platform == "win32":
103111
"""
@@ -109,4 +117,11 @@ def main():
109117
http://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7
110118
"""
111119
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__':
112127
main()

0 commit comments

Comments
 (0)