Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified requirements-linux.txt
Binary file not shown.
Binary file modified requirements-unix.txt
Binary file not shown.
Binary file modified requirements-windows.txt
Binary file not shown.
181 changes: 181 additions & 0 deletions src/qtWin.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>462</width>
<height>367</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QPushButton" name="addCourse">
<property name="geometry">
<rect>
<x>360</x>
<y>20</y>
<width>81</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Add Course</string>
</property>
</widget>
<widget class="QScrollArea" name="courseList">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>441</width>
<height>181</height>
</rect>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>439</width>
<height>179</height>
</rect>
</property>
</widget>
</widget>
<widget class="QLabel" name="scrollLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Tracking Courses:</string>
</property>
</widget>
<widget class="QPushButton" name="startTracking">
<property name="geometry">
<rect>
<x>10</x>
<y>330</y>
<width>231</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Start Tracking (Will notify when slots open)</string>
</property>
</widget>
<widget class="QComboBox" name="term">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>81</width>
<height>21</height>
</rect>
</property>
<item>
<property name="text">
<string>fall</string>
</property>
</item>
<item>
<property name="text">
<string>winter</string>
</property>
</item>
<item>
<property name="text">
<string>spring</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>60</x>
<y>10</y>
<width>121</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Season/Term</string>
</property>
</widget>
<widget class="QLineEdit" name="CRN">
<property name="geometry">
<rect>
<x>230</x>
<y>30</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>270</x>
<y>10</y>
<width>47</width>
<height>13</height>
</rect>
</property>
<property name="text">
<string>CRN</string>
</property>
</widget>
<widget class="QPushButton" name="setTerm">
<property name="geometry">
<rect>
<x>100</x>
<y>30</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Set Term</string>
</property>
</widget>
<widget class="QLabel" name="curTerm">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>101</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Current Term: none</string>
</property>
</widget>
<widget class="QPushButton" name="delCourse">
<property name="geometry">
<rect>
<x>270</x>
<y>330</y>
<width>171</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Remove Selected Courses</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
126 changes: 126 additions & 0 deletions src/winMain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# from multiprocessing.connection import wait
from PyQt5.QtWidgets import *
from PyQt5 import uic
from courses import *
# import threading
# import multiprocessing
from datetime import datetime

courses = {}
# openCourse = []
# waitlistCourse = []
fullList = []
fullDict = {}

# TODO: MAKE THING SO THEY CAN REMOVE CRNs

class Ui(QDialog):
def __init__(self):
super(Ui, self).__init__() # Call the inherited classes __init__ method
uic.loadUi('src\qtWin.ui', self) # Load the .ui file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would probably need to make a second file for unix/linux because file pathing is handled differently between windows and unix/linux

Copy link
Owner

@JIceberg JIceberg Aug 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be a second file. You can use Python pathlib which should handle the different path systems internally. I believe you can replace this with

uic.loadUi(Path('src/qtWin.ui'), self)

That should be handled correctly regardless of OS.


# find QScrollArea (list where courses added to)
self.courseList = self.findChild(QScrollArea, 'courseList')
self.courseList.setWidget(QListWidget())

# binding button to method
self.addBtn = self.findChild(QPushButton, 'addCourse')
self.addBtn.clicked.connect(self.newCourse)

# binding term button to method
self.termBtn = self.findChild(QPushButton, 'setTerm')
self.termBtn.clicked.connect(self.tSet)

# binding button to close window method, starts tracking courses
self.track = self.findChild(QPushButton, 'startTracking')
self.track.clicked.connect(self.close)

self.dCourse = self.findChild(QPushButton, "delCourse")
self.dCourse.clicked.connect(self.rmvCourse)

self.term = ""

self.show() # Show the GUI

def newCourse(self):
if self.term == "":
# check if user confirmed/set a term to search for CRNs during
alrt = QMessageBox()
alrt.setWindowTitle("Error")
alrt.setText(f"Term not set (choose from dropdown and click \"Set Term\")")
x = alrt.exec_()

else:
crn = self.findChild(QLineEdit, 'CRN').text()

try:
# create Course item and add to list to be tracked
crs = Course(crn, self.term)
# add to dictionary for fast removal if necessary
fullDict[crn] = crs

# add item to list in QScrollArea
self.courseList.widget().addItem(crs.name)
except IndexError:
# means something wacky happened and oscar didn't have course
alrt = QMessageBox()
alrt.setWindowTitle("Error")
alrt.setText(f"CRN {crn} not found")
x = alrt.exec_()

def tSet(self):
# grab the term from dropdown
sem = self.findChild(QComboBox, 'term').currentText()
now = datetime.now()

# use parsing definitely not ctrl-c ctrl-v from tracking.py to change fall/spring/summer to a oscar acceptable format
if sem.lower() == 'spring':
self.term = f'{now.year + 1}' + '02' if now.month > 4 else f'{now.year}' + '02'
else:
self.term = f'{now.year}' + '05' if sem.lower() == 'summer' else f'{now.year}' + '08'

# changing label to reflect term
self.findChild(QLabel, 'curTerm').setText(f"Current Term: {sem}")

# small popup to confirm term set
# gets annoying after a while though
# alrt = QMessageBox()
# alrt.setWindowTitle("Term Set!")
# alrt.setText(f"Term set to {self.term} ({sem})")
# x = alrt.exec_()

def rmvCourse(self):
# track all selected indices in QScrollArea
selected = self.courseList.widget().selectedIndexes()
# for each selection, grab data, remove CRN from fullDict (won't track) and remove from QScrollArea
for ind in selected:
inf = ind.data()
crn = inf.split(" - ")[1]
fullDict.pop(crn)
self.courseList.widget().takeItem(ind.row())


# generic driver code
app = QApplication([])
win = Ui()
win.setWindowTitle("Grouch UI")
app.exec_()
app.exit()

# openCList = CourseList(openCourse)
# openWList = CourseList(waitlistCourse)

# multiprocessing.Process(target=openCList.run_available_courses).start()
# multiprocessing.Process(target=openWList.run_waitlist_notifiers).start()
# threading.Thread(target=openCList.run_available_courses).start()
# threading.Thread(target=openWList.run_waitlist_notifiers).start()

# print("woooooo")

# fullList = openCourse + waitlistCourse

# create CourseList of courses and run notifiers
# future goal: use multithreading or something to concurrently run waitlist and open course trackers (wasn't able to initially get working)
# so you can track waitlists of some sections (i.e. lab blocks) while checking openings of others (i.e. general lecture blocks)
fullList = [fullDict[x] for x in fullDict.keys()]
CourseList(fullList).run_notifiers()