-
Notifications
You must be signed in to change notification settings - Fork 14
Grouch UI #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aaravg04
wants to merge
5
commits into
JIceberg:main
Choose a base branch
from
aaravg04:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Grouch UI #13
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dc60c17
window working. multiuthreading isnt :(
aaravg04 378dd16
removed broken multithreading, now tracks correctly (i think)
aaravg04 3663009
popup+cont if crn not found instead of crashing
aaravg04 e27b121
cleaned up code, added remove course capability, can now set term
aaravg04 1b3d2dd
added qtpy to requirements, stopped importing useless libraries
aaravg04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
| # 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() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
pathlibwhich should handle the different path systems internally. I believe you can replace this withThat should be handled correctly regardless of OS.