Skip to content

Commit

Permalink
new code with maps
Browse files Browse the repository at this point in the history
  • Loading branch information
ARS-CSGCL-DT committed May 10, 2023
1 parent 1458605 commit 262f0ca
Show file tree
Hide file tree
Showing 26 changed files with 1,433 additions and 1,238 deletions.
Binary file modified CLASSIMDirectoryStructure.zip
Binary file not shown.
6 changes: 4 additions & 2 deletions Classim/CLASSIM.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ block_cipher = None
options =[]
added_files= [
('.\\images\\*.png','images'),
('.\\images\\*.ico','images')
('.\\images\\*.ico','images'),
(os.environ['Conda_prefix'] + '\\Lib\\site-packages\\pyqtlet','pyqtlet')
]

a = Analysis(['classim.py'],
pathex=["/%userprofile%/AppData/Local/conda/conda/envs/Classim22/Library/bin"],
pathex=[os.environ['Conda_prefix'] + '\\Library\\bin'],
binaries=[],
datas=added_files,
hiddenimports=[],
Expand Down
4 changes: 2 additions & 2 deletions Classim/Classim.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os
from TabbedDialog.Tabs import Tabs_Widget
from DatabaseSys.Databasesupport import *
from PyQt5.QtWidgets import QApplication, QMainWindow, QFrame
from PyQt5.Qt import QHBoxLayout
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QApplication

'''
Starting point for the application. It calls tabs.py (to calls all the other tabs of Welcome, Site, Soil, Cultivar, Weather,
Expand Down
8 changes: 3 additions & 5 deletions Classim/CustomTool/UI.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import re
import os

from PyQt5 import QtSql, QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox

def messageUser(errMessage):
Expand All @@ -10,13 +6,14 @@ def messageUser(errMessage):
Input:
errMessage = message that explains error message to user
Output:
returns False
'''
msg = QMessageBox()
msg.setIcon(QMessageBox.Critical)
msg.setText(errMessage)
msg.setWindowTitle("Error")
msg.exec_()
return True
return False


def messageUserInfo(errMessage):
Expand All @@ -25,6 +22,7 @@ def messageUserInfo(errMessage):
Input:
errMessage = message that explains error message to user
Output:
returns True
'''
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
Expand Down
9 changes: 3 additions & 6 deletions Classim/CustomTool/createManRepWindow.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import sqlite3
import os
import pandas as pd

from PyQt5 import QtSql, QtCore, QtWidgets, QtGui
from PyQt5.QtWidgets import QTreeWidgetItem, QTextEdit, QWidget, QLabel, QHBoxLayout, QListWidget, QTableWidget, QVBoxLayout, \
QHeaderView, QSpacerItem, QSizePolicy, QTableWidgetItem, QLineEdit
from PyQt5 import QtCore
from PyQt5.QtWidgets import QWidget, QLabel, QTableWidget, QVBoxLayout, QHeaderView, QTableWidgetItem, QLineEdit
from PyQt5.QtCore import Qt
from DatabaseSys.Databasesupport import *
from pprint import pprint

gusername = os.environ['username'] #windows. What about linux
gparent_dir = 'C:\\Users\\'+gusername +'\\Documents'
dbDir = os.path.join(gparent_dir,'classim_v3')
dbDir = os.path.join(gparent_dir,'classim')

class createManRepWindow(QWidget):
"""
Expand Down
21 changes: 1 addition & 20 deletions Classim/CustomTool/custom1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
from contextlib import contextmanager
from TabbedDialog import *
from DatabaseSys.Databasesupport import *
from PyQt5.QtCore import Qt, QModelIndex, QVariant, QAbstractItemModel, QIODevice
from PyQt5.QtWidgets import QComboBox, QGridLayout, QGroupBox, QLabel, QWidget, QListWidget, QListWidgetItem, QTableWidget, \
QTableWidgetItem, QPushButton, QRadioButton, QCheckBox
from PyQt5.QtCore import Qt, QModelIndex, QVariant, QAbstractItemModel

# add all the custom listbox, signal and slot cases here
username=os.environ['username']
Expand Down Expand Up @@ -173,7 +171,6 @@ def remove_child_at_row(self,row):
"""
Removes the child object from the children list
"""
#print("Remove node")
if row <0 or row >= len(self.fields):
return False
child = self.fields.pop(row)
Expand Down Expand Up @@ -205,7 +202,6 @@ def flags(self,index):
Probably here we can further fine tune to do just the nodes with leaves.
"""
defaultFlags = QAbstractItemModel.flags(self,index)
#print("tree flags entered",index.isValid())

if not index.isValid():
# works return QtCore.Qt.ItemIsEnabled | defaultFlags
Expand Down Expand Up @@ -277,7 +273,6 @@ def mimeData(self, index):

if generation_count ==3:
temp_str =temp_str2
#print("temp_str=", temp_str)
mimeData = QtCore.QMimeData()
mimeData.setText(temp_str)
return mimeData
Expand All @@ -294,28 +289,23 @@ def insertRow(self,row,parentIndex):


def insertRows(self,row,count, parentIndex):
#print("Insert Rows")
#print("parents.len=",len(parentIndex.internalPointer()))
self.beginInsertRows(parentIndex,row,(row +(count-1)))
parentItem = parentIndex.internalPointer().insertChildAtIndex(row)
# should we add something like parentItem.insertChild()
self.endInsertRows()
#print("parents.len=",len(parentIndex.internalPointer()))
return True


def removeRow(self,row,parentIndex):
parentNode = parentIndex
if not parentIndex.isValid():
#parent can be invalid when it is a root node (root parent returns an empty QModelIndex)
#print("Debug: parentIndex not valid.")
parentNode = self.root
self.removeRows(row,1,parentNode)
return True


def load2(self,databasename,tablename,nesting,separator,loader=2):
#print("inside TreeOfTabelModel, load")
assert nesting >0
self.nesting = nesting
self.root = BranchNode("")
Expand Down Expand Up @@ -390,26 +380,22 @@ def addExperimentTreatment(self,therlist,thecropname,callReset=True,loader=2):
for i in range(len(therlist)):
key = thecropname
root = self.root
oldroot =root
branch = None
branch = root.childWithKey(key)
if branch is not None:
root = branch
branch = BranchNode(therlist[i])
root.insertChild(branch)
oldroot = root
root = branch
else:
branch = BranchNode(therlist[i])
root.insertChild(branch)
oldroot = root
root = branch

# now work on populating this new branch
new_branches = read_treatmentDB(key,root.name)
#print("new_branches = ", new_branches)
theader5 = ["1","2","3","4","5","6","7","8","9"]
temp_leaves = ["Operations","B"]
### adding here to see if it will enable the empty tree display
self.columns = max(self.columns, len(theader5))
assert branch is not None
Expand Down Expand Up @@ -489,7 +475,6 @@ def data(self, index, role):

def headerData(self,section, orientation, role):
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
#print("headerData: section=",section," headers=",self.headers)
return (QVariant(self.headers[section])) if section < len(self.headers) else QVariant()
return QVariant()

Expand All @@ -514,10 +499,8 @@ def parent(self, child):
if parent is None:
return QModelIndex()
if type(parent) != BranchNode:
#print("Debug: inside treeoftablemodel childname,node.name has no attribute name")
return QModelIndex()

#print("Debug: inside treeoftablemodel parent:, type=",type(parent), parent.name," node.name=",node.name)
grandparent = parent.parent
if grandparent is None:
return QModelIndex()
Expand All @@ -529,10 +512,8 @@ def getDepth(self, index):
#root has rdepth value of 1
rdepth = 1
tnode = self.nodeFromIndex(index).parent
#print("debug:getDepth, name=",self.nodeFromIndex(index).name)
## works in some cases while tnode is not self.root: # None:
while tnode.parent is not None:
rdepth = rdepth+1
#print("debug:getDepth, tnode name1=",tnode.name)
tnode = tnode.parent
return rdepth
Loading

0 comments on commit 262f0ca

Please sign in to comment.