a = Analysis(['main_window.py'],
pathex=['/home/msaghaei/PycharmProjects/minimpy2'],
binaries=[],
- datas=[],
+ datas=[('db/database.sql', 'db'), ('images/*', 'images'), ('locales/*', 'locales'), ('fa_IR.ts', '.'),
+ ('minimisation_*.txt', '.'), ('start_*.html', '.'), ('locale_sources.ts', '.')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
from os import path
from ui_about_minimisation import Ui_AboutMinimisationDialog
+from utils import resource_path
class AboutMinimisationDialog(qtw.QDialog):
self.ui = Ui_AboutMinimisationDialog()
self.ui.setupUi(self)
lang = parent.settings.value('language', 'en_US', type=str)
- filename = 'minimisation_{}.txt'.format(lang)
+ filename = resource_path('minimisation_{}.txt'.format(lang))
if not path.exists(filename):
- filename = 'minimisation_en_US.txt'
+ filename = resource_path('minimisation_en_US.txt')
if not path.exists(filename):
return
text = open(filename, encoding='utf8').read()
from PySide2 import QtWidgets as qtw
from config_dialog import Ui_ConfigDialog
+from utils import resource_path
class Config(qtw.QDialog):
self.parent = parent
self.ui = Ui_ConfigDialog()
self.ui.setupUi(self)
- lines = open('locales/languages.lst', encoding='utf8').readlines()
+ lines = open(resource_path('locales/languages.lst'), encoding='utf8').readlines()
self.lang_codes = []
cur_lang = self.parent.settings.value('language', 'en_US', type=str)
cur_index = 0
-from PySide2 import QtSql as qts
+from PySide2 import QtSql as qts, QtWidgets
from PySide2 import QtWidgets as qtw
from PySide2 import QtCore as qtc
import sys
import os
+from os import path
# noinspection PyTypeChecker
+from utils import resource_path
+
+
class Database(qtc.QObject):
__instance = None
'open db: ' + self.db.lastError().text()
)
sys.exit(1)
- all_sqls = open('db/database.sql', encoding='utf8').read().split(';')
+ all_sqls = open(resource_path('db/database.sql'), encoding='utf8').read().split(';')
for sql in all_sqls:
query = qts.QSqlQuery(self.db)
query.prepare(sql)
raise Exception("This class is a singleton!")
self.mainWindow = mainWindow
self.db = qts.QSqlDatabase.addDatabase('QSQLITE')
- self.db.setDatabaseName('db/minimizer.db')
- if not os.path.exists('db/minimizer.db'):
+ db_path = mainWindow.settings.value('db_path', None, type=str)
+ if db_path is None or not path.exists(db_path):
+ db_path = QtWidgets.QFileDialog.getExistingDirectory(mainWindow, 'Select a folder to store your data', '.', QtWidgets.QFileDialog.ShowDirsOnly)
+ if db_path is None or len(db_path.strip()) == 0:
+ exit(1)
+ mainWindow.settings.setValue('db_path', db_path)
+ if not path.exists(db_path):
+ os.mkdir(db_path)
+ self.db.setDatabaseName('{}/minimizer.db'.format(db_path))
+ if not os.path.exists('{}/minimizer.db'.format(db_path)):
self.create_db()
else:
if not self.db.open():
<message>
<location filename="main_window.py" line="37"/>
<source>Type of subject identifier. It can be Numeric, Alpha or Alphanumeric.
+Once a subject is enrolled, you can not change identifier type
</source>
<translation>نوع شناسه نمایش داده شده برای سوژه ها. گزینه های موجود عددی، حرفی و یا حرفی عددی می باشند.\nهنگامی که اولین سوژه وارده مطالعه شد، دیگر نمی توان نوع شناسه را تغییر دارد
</translation>
from PySide2 import QtCore as qtc
from PySide2 import QtGui as qtg
+from utils import resource_path
+
class FreqTable:
def __init__(self, parent, ui, trial_id):
return
preload = self.extract_counts()
if self.valid_counts(preload):
- pixmap = qtg.QPixmap("images/tick_mark.png")
+ pixmap = qtg.QPixmap(resource_path("images/tick_mark.png"))
self.database.clear_preload(self.trial_id)
self.database.save_preload(self.trial_id, preload)
else:
- pixmap = qtg.QPixmap("images/error.png")
+ pixmap = qtg.QPixmap(resource_path("images/error.png"))
self.valid_preload_image.setPixmap(pixmap)
def add_to_preload(self):
from trial import *
import sys
from tendo import singleton
+from utils import resource_path
+
# noinspection PyTypeChecker
class MainWindow(qtw.QMainWindow):
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
lang = settings.value('language', 'en_US', type=str)
- filename = 'start_{}.html'.format(lang)
+ if lang != 'en_US':
+ self.setLayoutDirection(qtc.Qt.RightToLeft)
+ filename = resource_path('start_{}.html'.format(lang))
start_str = open(filename, encoding='utf8').read()
self.ui.textEdit.setHtml(start_str)
- self.ui.actionNew.setIcon(qtg.QIcon('images/add.png'))
- self.ui.actionDelete.setIcon(qtg.QIcon('images/delete.png'))
- self.ui.actionLevels.setIcon(qtg.QIcon('images/levels.png'))
- self.ui.actionSave.setIcon(qtg.QIcon('images/save.png'))
- self.ui.actionHelp.setIcon(qtg.QIcon('images/help.png'))
- self.ui.actionQuit.setIcon(qtg.QIcon('images/exit.png'))
- self.ui.actionConfig.setIcon(qtg.QIcon('images/config.png'))
- self.ui.actionAbout_MinimPy2.setIcon(qtg.QIcon('images/about.png'))
+ self.ui.actionNew.setIcon(qtg.QIcon(resource_path('images/add.png')))
+ self.ui.actionDelete.setIcon(qtg.QIcon(resource_path('images/delete.png')))
+ self.ui.actionLevels.setIcon(qtg.QIcon(resource_path('images/levels.png')))
+ self.ui.actionSave.setIcon(qtg.QIcon(resource_path('images/save.png')))
+ self.ui.actionHelp.setIcon(qtg.QIcon(resource_path('images/help.png')))
+ self.ui.actionQuit.setIcon(qtg.QIcon(resource_path('images/exit.png')))
+ self.ui.actionConfig.setIcon(qtg.QIcon(resource_path('images/config.png')))
+ self.ui.actionAbout_MinimPy2.setIcon(qtg.QIcon(resource_path('images/about.png')))
self.database = Database.get_instance(self)
self.trial = None
self.ui.editPreloadCheckBox.toggled.connect(self.on_edit_preload)
self.ui.convertPreloadButton.clicked.connect(self.on_convert_preload)
- self.ui.factorTableWidget.cellDoubleClicked.connect(self.factor_coloumn_dblclicked)
- self.ui.subjectTableWidget.cellDoubleClicked.connect(self.subject_coloumn_dblclicked)
+ self.ui.factorTableWidget.cellDoubleClicked.connect(self.factor_column_dblclicked)
+ self.ui.subjectTableWidget.cellDoubleClicked.connect(self.subject_column_dblclicked)
self.ui.trialIdentifierLengthSpinBox.valueChanged.connect(self.on_identifier_length)
self.ui.trialBaseProbabilitySlider.valueChanged.connect(self.on_base_prob_change)
self.ui.showAtStartCheckBox.setChecked(True)
self.ui.showAtStartCheckBox.toggled.connect(self.toggle_show_at_start)
+ def on_identifier_length(self, value):
+ self.trial.identifier_length = value
+ self.update_sample_size_label()
+
def toggle_show_at_start(self, check):
self.settings.setValue('show_tutorial_at_start', not check)
def on_base_prob_change(self, value):
self.ui.baseProbLabel.setText('{:4.2f}'.format(value / 100.0))
- def on_identifier_length(self, value):
+ def on_idenqdialogbuttonboxtifier_length(self, value):
self.trial.identifier_length = value
self.update_sample_size_label()
return
self.update_subjects_progress()
- def subject_coloumn_dblclicked(self, row, col):
+ def subject_column_dblclicked(self, row, col):
button = qtw.QMessageBox.question(self, self.tr("Warning"),
self.tr('''Are you sure you want to edit subject at row "{}" ?\n
Editing subject may invalidate your research and the result of minimisation''').format(row),
self.add_factor_row(factor)
self.ui.factorTableWidget.blockSignals(False)
- def factor_coloumn_dblclicked(self, row, col):
+ def factor_column_dblclicked(self, row, col):
if col != 2:
return
self.factor_levels()
app = qtw.QApplication(sys.argv)
except RuntimeError:
app = qtc.QCoreApplication.instance()
- app.setWindowIcon(qtg.QIcon('images/logo.png'))
+ app.setWindowIcon(qtg.QIcon(resource_path('images/logo.png')))
settings = qtc.QSettings('net.saghaei', 'minimpy2')
lang = settings.value('language', 'en_US', type=str)
if lang != 'en_US':
translator = qtc.QTranslator()
- translator.load('locales/{}'.format(lang))
+ translator.load(resource_path('locales/{}'.format(lang)))
app.installTranslator(translator)
mw = MainWindow(settings)
app.mainWindow = mw
class RunTest:
def __init__(self, sequence, v1, v2):
+ #sequence = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1]
self.sequence = sequence
self.v1, self.v2 = v1, v2
--- /dev/null
+ایرادات
+MinimPy2
+تغییر عنوان بلافاصله نشان داده نمی شود
+
+تعداد سوژه های وارد شده در Progressbar بروزرسانی نمیشود
+
+فیلترها در صفحه سوژه ها بصورت منو باشد
+
+تولید لیست رندومیزه
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>7</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<rect>
<x>0</x>
<y>0</y>
- <width>760</width>
- <height>422</height>
+ <width>98</width>
+ <height>28</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0">
--- /dev/null
+import sys
+import os
+
+
+def resource_path(relative_path):
+ """ Get absolute path to resource, works for dev and for PyInstaller """
+ try:
+ # PyInstaller creates a temp folder and stores path in _MEIPASS
+ base_path = sys._MEIPASS
+ except Exception:
+ base_path = os.path.abspath(".")
+ return os.path.join(base_path, relative_path)