Commit 72a85f00 authored by Daalen, Tim van's avatar Daalen, Tim van
Browse files

icon round two and nowloading images again

parent c944c84a
......@@ -8,8 +8,8 @@
# run again. Do not edit this file unless you know what you are doing.
from os.path import dirname, realpath
from sys import argv
from os.path import dirname, join, pardir, realpath
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
......@@ -78,7 +78,10 @@ class Ui_tabBrowser(object):
self.homeButton = QtWidgets.QPushButton(tabBrowser)
self.homeButton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(dirname(realpath(argv[0])) + "/icons/home.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
if getattr(sys, 'frozen', True):
icon.addPixmap(QtGui.QPixmap(join(dirname(realpath(sys.argv[0])), pardir) + "/icons/home.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
else:
icon.addPixmap(QtGui.QPixmap(dirname(realpath(sys.argv[0])) + "/icons/home.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.homeButton.setIcon(icon)
self.homeButton.setObjectName("homeButton")
self.gridLayout.addWidget(self.homeButton, 0, 2, 1, 1)
......
......@@ -8,8 +8,8 @@
# run again. Do not edit this file unless you know what you are doing.
from os.path import dirname, realpath
from sys import argv
from os.path import dirname, join, pardir, realpath
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
......@@ -94,7 +94,10 @@ class Ui_tabTicketAccess(object):
self.homeButton = QtWidgets.QPushButton(tabTicketAccess)
self.homeButton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(dirname(realpath(argv[0])) + "/icons/home.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
if getattr(sys, 'frozen', True):
icon.addPixmap(QtGui.QPixmap(join(dirname(realpath(sys.argv[0])), pardir) + "/icons/home.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
else:
icon.addPixmap(QtGui.QPixmap(dirname(realpath(sys.argv[0])) + "/icons/home.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.homeButton.setIcon(icon)
self.homeButton.setObjectName("homeButton")
self.horizontalLayout_5.addWidget(self.homeButton)
......@@ -131,7 +134,10 @@ class Ui_tabTicketAccess(object):
self.downloadButton = QtWidgets.QPushButton(tabTicketAccess)
self.downloadButton.setText("")
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(dirname(realpath(argv[0])) + "/icons/arrow-right.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
if getattr(sys, 'frozen', True):
icon1.addPixmap(QtGui.QPixmap(join(dirname(realpath(sys.argv[0])), pardir) + "/icons/arrow-right.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
else:
icon1.addPixmap(QtGui.QPixmap(dirname(realpath(sys.argv[0])) + "/icons/arrow-right.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.downloadButton.setIcon(icon1)
self.downloadButton.setIconSize(QtCore.QSize(30, 30))
self.downloadButton.setObjectName("downloadButton")
......
......@@ -8,8 +8,8 @@
# run again. Do not edit this file unless you know what you are doing.
from os.path import dirname, realpath
from sys import argv
from os.path import dirname, join, pardir, realpath
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
......@@ -133,7 +133,10 @@ class Ui_tabUpDownload(object):
self.UploadButton.setMinimumSize(QtCore.QSize(100, 0))
self.UploadButton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(dirname(realpath(argv[0])) + "/icons/arrow-right.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
if getattr(sys, 'frozen', True):
icon.addPixmap(QtGui.QPixmap(join(dirname(realpath(sys.argv[0])), pardir) + "/icons/arrow-right.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
else:
icon.addPixmap(QtGui.QPixmap(dirname(realpath(sys.argv[0])) + "/icons/arrow-right.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.UploadButton.setIcon(icon)
self.UploadButton.setIconSize(QtCore.QSize(50, 50))
self.UploadButton.setObjectName("UploadButton")
......@@ -147,7 +150,10 @@ class Ui_tabUpDownload(object):
self.DownloadButton.setMinimumSize(QtCore.QSize(100, 0))
self.DownloadButton.setText("")
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(dirname(realpath(argv[0])) + "/icons/arrow-left.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
if getattr(sys, 'frozen', True):
icon1.addPixmap(QtGui.QPixmap(join(dirname(realpath(sys.argv[0])), pardir) + "/icons/arrow-left.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
else:
icon1.addPixmap(QtGui.QPixmap(dirname(realpath(sys.argv[0])) + "/icons/arrow-left.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DownloadButton.setIcon(icon1)
self.DownloadButton.setIconSize(QtCore.QSize(50, 50))
self.DownloadButton.setObjectName("DownloadButton")
......
......@@ -34,6 +34,7 @@ def ui_to_py(ui_folder, python):
run_cmd(f"""{python} -m PyQt5.uic.pyuic -x {ui_file} -o {filename +".py"}""")
# Find and replace the pixelmap references... They are hardcoded
# Also have to go up one directory for the executable, its ugly!
with open(filename +".py", 'r') as file:
lines = file.readlines()
modified_lines = {}
......@@ -42,14 +43,22 @@ def ui_to_py(ui_folder, python):
abs_fchar = line.find("\"")
abs_lchar = line.find(".", abs_fchar) + 2
new_line = line[0:abs_fchar] + "dirname(realpath(argv[0])) + \"" + line[abs_lchar:]
modified_lines[linenum] = new_line
new_line = line[0:abs_fchar] + "dirname(realpath(sys.argv[0])) + \"" + line[abs_lchar:]
exeline = line[0:abs_fchar] + "join(dirname(realpath(sys.argv[0])), pardir) + \"" + line[abs_lchar:]
modified_lines[linenum] = (new_line, exeline)
if len(modified_lines) > 0:
lineofset = 0
spacing = " " #distance of one tab
for linenum, text in modified_lines.items():
lines[(linenum)] = text
lines.insert(10, "from sys import argv\n")
lines.insert(10, "from os.path import dirname, realpath\n")
lines[(linenum + lineofset)] = spacing + text[0]
lines.insert(linenum + lineofset, f"{spacing}else:\n")
lines.insert(linenum + lineofset, spacing + text[1])
lines.insert(linenum + lineofset, f"{spacing}if getattr(sys, 'frozen', True):\n")
lineofset = lineofset + 3
lines.insert(10, "import sys\n")
lines.insert(10, "from os.path import dirname, join, pardir, realpath\n")
with open(filename +".py", 'w') as file:
file.writelines(lines)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment