resources are in resource file and not shipped anymore in the distributable (file scripts/create_rc_file.cmd has to be called)
This commit is contained in:
parent
a6e6370fd6
commit
22ffcf9f05
15 changed files with 1403 additions and 219 deletions
|
@ -20,6 +20,8 @@ from PySide2.QtGui import QIcon, QColor, QPalette
|
|||
from PySide2.QtUiTools import QUiLoader
|
||||
|
||||
# local imports
|
||||
import icons_rc
|
||||
import clsTableWidget_icons_rc
|
||||
from utils import resource_path, convert_uom_to_length, convert_uom_to_mass
|
||||
|
||||
# local globals
|
||||
|
@ -30,15 +32,15 @@ DEFAULT_UOM_MASS = None
|
|||
|
||||
UI_DLG_UOM = "./ui/dlg_uom.ui"
|
||||
|
||||
ICON_CLEAR = SCRIPT_PATH + "./img/icons8-clear-symbol-16.png"
|
||||
ICON_COPY = SCRIPT_PATH + "./img/icons8-copy-16.png"
|
||||
ICON_ERASER = SCRIPT_PATH + "/img/icons8-eraser-16.png"
|
||||
ICON_INSERT = SCRIPT_PATH + "/img/icons8-insert-clip-16.png"
|
||||
ICON_APPEND = SCRIPT_PATH + "/img/icons8-append-clip-16.png"
|
||||
ICON_PASTE = SCRIPT_PATH + "/img/icons8-paste-16.png"
|
||||
ICON_CUT = SCRIPT_PATH + "/img/icons8-scissors-16.png"
|
||||
ICON_ADD_ROW = SCRIPT_PATH + "/img/icons8-add-row-16.png"
|
||||
ICON_DEL = SCRIPT_PATH + "/img/icons8-delete-16.png"
|
||||
# ICON_CLEAR = SCRIPT_PATH + "./img/icons8-clear-symbol-16.png"
|
||||
# ICON_COPY = SCRIPT_PATH + "./img/icons8-copy-16.png"
|
||||
# ICON_ERASER = SCRIPT_PATH + "/img/icons8-eraser-16.png"
|
||||
# ICON_INSERT = SCRIPT_PATH + "/img/icons8-insert-clip-16.png"
|
||||
# ICON_APPEND = SCRIPT_PATH + "/img/icons8-append-clip-16.png"
|
||||
# ICON_PASTE = SCRIPT_PATH + "/img/icons8-paste-16.png"
|
||||
# ICON_CUT = SCRIPT_PATH + "/img/icons8-scissors-16.png"
|
||||
# ICON_ADD_ROW = SCRIPT_PATH + "/img/icons8-add-row-16.png"
|
||||
# ICON_DEL = SCRIPT_PATH + "/img/icons8-delete-16.png"
|
||||
|
||||
# def resource_path(relative_path):
|
||||
# """ Get absolute path to resource, works for dev and for PyInstaller """
|
||||
|
@ -93,11 +95,11 @@ class TableWidget(QTableWidget):
|
|||
|
||||
def on_context_menu(self, position):
|
||||
menu = QMenu()
|
||||
item_cut = menu.addAction(QIcon(ICON_CUT), QCoreApplication.translate("TableWidget", "Cut") + "\tCtrl+X")
|
||||
item_copy = menu.addAction(QIcon(ICON_COPY), QCoreApplication.translate("TableWidget", "Copy") + "\tCtrl+C")
|
||||
item_paste = menu.addAction(QIcon(ICON_PASTE), QCoreApplication.translate("TableWidget", "Paste") + "\tCtrl+V")
|
||||
item_cut = menu.addAction(QIcon(u":ICONS/ICON_CUT"), QCoreApplication.translate("TableWidget", "Cut") + "\tCtrl+X")
|
||||
item_copy = menu.addAction(QIcon(u":ICONS/ICON_COPY"), QCoreApplication.translate("TableWidget", "Copy") + "\tCtrl+C")
|
||||
item_paste = menu.addAction(QIcon(u":ICONS/ICON_PASTE"), QCoreApplication.translate("TableWidget", "Paste") + "\tCtrl+V")
|
||||
menu.addSeparator()
|
||||
item_delete = menu.addAction(QIcon(ICON_ERASER), QCoreApplication.translate("TableWidget", "Delete") + "\tDel")
|
||||
item_delete = menu.addAction(QIcon(u":ICONS/ICON_ERASER"), QCoreApplication.translate("TableWidget", "Delete") + "\tDel")
|
||||
|
||||
ac = menu.exec_(self.mapToGlobal(position))
|
||||
|
||||
|
@ -112,15 +114,15 @@ class TableWidget(QTableWidget):
|
|||
|
||||
def on_rowheadercontext_menu(self, position):
|
||||
menu = QMenu()
|
||||
row_cut = menu.addAction(QIcon(ICON_CUT), QCoreApplication.translate("TableWidget", "Cut row"))
|
||||
row_copy = menu.addAction(QIcon(ICON_COPY), QCoreApplication.translate("TableWidget", "Copy row"))
|
||||
row_paste = menu.addAction(QIcon(ICON_PASTE), QCoreApplication.translate("TableWidget", "Paste row"))
|
||||
row_cut = menu.addAction(QIcon(u":ICONS/ICON_CUT"), QCoreApplication.translate("TableWidget", "Cut row"))
|
||||
row_copy = menu.addAction(QIcon(u":ICONS/ICON_COPY"), QCoreApplication.translate("TableWidget", "Copy row"))
|
||||
row_paste = menu.addAction(QIcon(u":ICONS/ICON_PASTE"), QCoreApplication.translate("TableWidget", "Paste row"))
|
||||
menu.addSeparator()
|
||||
row_insert_before = menu.addAction(QIcon(ICON_INSERT), QCoreApplication.translate("TableWidget", "Insert row before"))
|
||||
row_insert_after = menu.addAction(QIcon(ICON_APPEND), QCoreApplication.translate("TableWidget", "Insert row after"))
|
||||
row_insert_before = menu.addAction(QIcon(u":ICONS/ICON_INSERT"), QCoreApplication.translate("TableWidget", "Insert row before"))
|
||||
row_insert_after = menu.addAction(QIcon(u":ICONS/ICON_APPEND"), QCoreApplication.translate("TableWidget", "Insert row after"))
|
||||
menu.addSeparator()
|
||||
row_remove = menu.addAction(QIcon(ICON_DEL), QCoreApplication.translate("TableWidget", "Remove row"))
|
||||
row_delete_items = menu.addAction(QIcon(ICON_ERASER), QCoreApplication.translate("TableWidget", "Delete items"))
|
||||
row_remove = menu.addAction(QIcon(u":ICONS/ICON_DEL"), QCoreApplication.translate("TableWidget", "Remove row"))
|
||||
row_delete_items = menu.addAction(QIcon(u":ICONS/ICON_ERASER"), QCoreApplication.translate("TableWidget", "Delete items"))
|
||||
ac = menu.exec_(self.mapToGlobal(position))
|
||||
|
||||
row = self.vertHeader.logicalIndexAt(position)
|
||||
|
@ -220,6 +222,7 @@ class TableWidget(QTableWidget):
|
|||
ui_file.open(QFile.ReadOnly)
|
||||
self.dlg = loader.load(ui_file, self)
|
||||
ui_file.close()
|
||||
self.retranslateUi_dlg(self.dlg)
|
||||
|
||||
self.dlg.uom_type = uom_type
|
||||
if uom_type == "UOM_TYPE_MASS":
|
||||
|
@ -241,7 +244,7 @@ class TableWidget(QTableWidget):
|
|||
|
||||
self.dlg.cmbUOM.currentIndexChanged.connect(self.on_cmbUOM_itemChanged)
|
||||
|
||||
if self.dlg.exec() == QDialog.Accepted:
|
||||
if self.dlg.exec_() == QDialog.Accepted:
|
||||
if not item:
|
||||
item = QTableWidgetItem("Dummy")
|
||||
self.setItem(self.currentRow(), self.currentColumn(), item)
|
||||
|
@ -380,3 +383,8 @@ class TableWidget(QTableWidget):
|
|||
self.parent.is_modified = False # set parents modification flag (if present)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def retranslateUi_dlg(self, dlg):
|
||||
dlg.setWindowTitle(QCoreApplication.translate("TableWidget","UOM"))
|
||||
dlg.lblValue.setText(QCoreApplication.translate("TableWidget","Value") + ":")
|
||||
dlg.lblUOM.setText(QCoreApplication.translate("TableWidget","UOM") + ":")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue