Exemple #1
0
class SideMenuWidget(QWidget):
    def __init__(self):
        super(SideMenuWidget, self).__init__()
        self.layout = QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(12)
        self.setLayout(self.layout)

        # PROFILE
        self.layout.addWidget(Profile())

        # BUTTONS
        self.listview = ListView()
        self.listview.setFrameStyle(QFrame.NoFrame)
        self.listview.setFocusPolicy(Qt.NoFocus)
        self.listview.setModel(Model())
        self.listview.setItemDelegate(Delegate())
        self.layout.addWidget(self.listview)

        # LABELS
        self.labels = QWidget()
        self.labels.setFixedHeight(60)
        self.layout.addWidget(self.labels)

        _margins = 16  # left margin

        self.app_name = LinkLabel(self.labels, "color: rgba(0, 0, 0, 80%)",
                                  "color: rgba(0, 0, 0, 60%)")
        self.app_name.setText("sidemenu app")
        self.app_name.setFont(QFont("Roboto Light", 12))
        self.app_name.move(self.labels.x() + _margins, self.labels.y())

        self.app_ver = LinkLabel(self.labels, "color: rgba(0, 0, 0, 60%)",
                                 "color: rgba(0, 0, 0, 60%)")
        self.app_ver.setText("Версия 1.0.0")
        self.app_ver.setFont(QFont("Roboto Light", 11))
        self.app_ver.move(self.labels.x() + _margins,
                          self.labels.y() + _margins * 2)

        self.lbl = QLabel(self.labels)
        self.lbl.setText("-")
        self.lbl.setStyleSheet("color: rgba(0, 0, 0, 60%)")
        self.lbl.setFont(QFont("Roboto Light", 11))
        self.lbl.move(self.labels.x() + _margins * 7,
                      self.labels.y() + _margins * 2)

        self.app_about = LinkLabel(self.labels, "color: rgba(0, 0, 0, 60%)",
                                   "color: rgba(0, 0, 0, 60%)")
        self.app_about.setText("О программе")
        self.app_about.setFont(QFont("Roboto Light", 11))
        self.app_about.move(self.labels.x() + _margins * 8,
                            self.labels.y() + _margins * 2)

        self.setStyleSheet("background: white;")

    def paintEvent(self, event):
        opt = QStyleOption()
        opt.initFrom(self)
        p = QPainter(self)
        self.style().drawPrimitive(QStyle.PE_Widget, opt, p, self)
Exemple #2
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        layout = QtWidgets.QVBoxLayout(self)
        label1 = QLabel('입력', self)
        label1.setAlignment(Qt.AlignVCenter)
        label1.move(200, 30)

        label2 = QLabel('결과', self)
        label2.setAlignment(Qt.AlignVCenter)
        label2.move(710, 30)

        self.text_box1 = QTextEdit(self)
        self.text_box1.resize(350, 350)
        self.text_box1.move(50, 60)

        self.text_box2 = QTextBrowser(self)
        self.text_box2.append('')
        self.text_box2.setGeometry(550, 60, 350, 350) 

        self.ok_base64 = QPushButton("OK", self)	
        self.ok_base64.setGeometry(50, 420, 850, 45) 
        self.ok_base64.clicked.connect(self.base64_conversion)

        self.back = QPushButton(self)
        self.back.setStyleSheet(
            '''
            QPushButton{image:url(./img/back_img.png); border:0px;}
            QPushButton:hover{image:url(./img/back_img_ev_1.png); border:0px;}
            ''') 
        self.back.setGeometry(0, 0, 50, 50) 
        self.back.clicked.connect(self.change_stack1)
Exemple #3
0
class Ex(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        vbox = QVBoxLayout()

        btn = QPushButton('Dialog', self)
        btn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        btn.move(20, 20)
        vbox.addWidget(btn)

        btn.clicked.connect(self.show_dialog)

        self.lbl = QLabel('Knowledge only matters', self)
        self.lbl.move(130, 20)

        vbox.addWidget(self.lbl)
        self.setLayout(vbox)

        self.setGeometry(300, 300, 250, 250)
        self.setWindowTitle("Font dialog")

    def show_dialog(self):
        ok, font = QFontDialog.getFont(self)
        if ok:
            self.lbl.setFont(font)
    def displayLabels(self):
        """Display text and images using qlabels
        catch err if file doesn't exist
        """
        txt = QLabel(self)
        txt.setText('Hello Yoda')
        txt.move(105, 15)

        img = '../../img/snippet.png'
        try:
            with open(img):
                code_img = QLabel(self)
                pixmap = QPixmap(img)
                code_img.setPixmap(pixmap)
                code_img.move(25, 40)
        except FileNotFoundError:
            print("Image file not found!!")
Exemple #5
0
class Profile(QWidget):
    def __init__(self, height=None):
        super(Profile, self).__init__()
        if height is None:
            self.setFixedHeight(150)
        else:
            self.setFixedHeight(height)
        self.paintAvatar()

    def paintAvatar(self):
        # DRAW PROFILE IMAGE
        image = QPixmap()
        image.load("res/img/icons/user.png")
        image = image.scaled(54, 54, Qt.IgnoreAspectRatio,
                             Qt.SmoothTransformation)

        _margin = 16
        _margin_text = 24

        self.avatar = QLabel(self)
        self.avatar.setCursor(Qt.PointingHandCursor)
        self.avatar.setAttribute(Qt.WA_TranslucentBackground)
        self.avatar.setPixmap(image)
        self.avatar.move(self.rect().x() + _margin, self.rect().y() + _margin)

        self.username = QLabel(self)
        self.username.setStyleSheet("color: white;")
        self.username.setFont(QFont("Roboto Light", 14))
        self.username.setCursor(Qt.PointingHandCursor)
        self.username.setAttribute(Qt.WA_TranslucentBackground)
        self.username.setText("dryerem19")
        self.username.move(self.rect().x() + _margin_text, self.height() - 50)

    def paintEvent(self, event):
        super(Profile, self).paintEvent(event)

        # DRAW BACKGROUND IMAGE
        p = QPainter(self)
        p.setRenderHint(QPainter.Antialiasing)

        image = QPixmap()
        image.load("res/img/back.jpg")
        image = image.scaled(self.width(), self.height(), Qt.IgnoreAspectRatio,
                             Qt.SmoothTransformation)
        p.drawPixmap(self.rect(), image)
Exemple #6
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        self.back = QPushButton(self)
        self.back.setStyleSheet(
            '''
            QPushButton{image:url(./img/back_img.png); border:0px;}
            QPushButton:hover{image:url(./img/back_img_ev_1.png); border:0px;}
            ''')
        self.back.setGeometry(0, 0, 50, 50) 
        self.back.clicked.connect(self.change_stack1)

        label1 = QLabel(' 중요한 이미지는 변환하지마세요 BASE64는 보안으로 매우 약합니다 간단한 텍스트 용도으로 사용하기 때문에 이미지 \n 변환은 권장하지 않습니다', self)
        label1.move(125, 180)

        self.files = QPushButton("파일 선택", self)	
        self.files.setGeometry(50, 100, 850, 50) 
        self.files.clicked.connect(self.pushButtonClicked)

        self.files_encoding = QPushButton("OK", self)	
        self.files_encoding.setGeometry(800, 450, 100, 30) 
        self.files_encoding.clicked.connect(self.base64_files_encoding)
Exemple #7
0
    def init_ui(self):
        l1 = QLabel("Hello", self)
        l2 = QLabel("Hell", self)
        l3 = QLabel("Heaven", self)

        l1.move(15, 10)
        l2.move(35, 40)
        l3.move(55, 70)

        self.setGeometry(300, 300, 250, 250)
        self.setWindowTitle("Absolute layout")
Exemple #8
0
    def initUI(self):
        lbl1 = QLabel('欢迎', self)
        lbl1.move(15, 10)

        lbl2 = QLabel('学习', self)
        lbl2.move(35, 40)

        lbl3 = QLabel('PySide6 !', self)
        lbl3.move(55, 70)

        self.setGeometry(300, 300, 320, 120)
        self.setWindowTitle('绝对位置布局例子')
Exemple #9
0
class RenderData(QWidget):
    def __init__(self, db_name_from_visualize):
        super().__init__()
        self.db_name_from_visual_btn = db_name_from_visualize
        self.type_of_display = QLabel(
            "Please choose how you'd like to display the data", self)
        self.type_of_display.move(20, 20)
        self.type_of_display.setStyleSheet("border: 1px solid black;")
        self.type_of_display.setFont(QFont("Calibre", 12))

        self.which_data = QLabel(
            "Please select which data you'd like to display", self)
        self.which_data.move(430, 20)
        self.which_data.setStyleSheet("border: 1px solid black")
        self.which_data.setFont(QFont("Calibre", 12))

        # LIST BOXES
        display_list = QListWidget(self)
        self.list_control = display_list
        display_list.resize(770, 440)
        display_list.move(10, 200)

        # CHECK BOXES
        self.color_coded_checkbox = QCheckBox("Color coded text in a list",
                                              self)
        self.color_coded_checkbox.move(100, 60)
        self.color_coded_checkbox.clicked.connect(
            self.swap_color_coded_checkbox)

        self.render_map_checkbox = QCheckBox("Render a Map", self)
        self.render_map_checkbox.move(100, 90)
        self.render_map_checkbox.toggle()
        self.render_map_checkbox.clicked.connect(self.swap_render_map_checkbox)

        self.analysis_type1_checkbox = QCheckBox(
            "Compare the number of college graduates in a state \n(for the most recent "
            "year) with number of jobs in that \nstate that likely expect a college "
            "education.", self)
        self.analysis_type1_checkbox.setGeometry(430, 20, 300, 100)
        self.analysis_type1_checkbox.clicked.connect(
            self.swap_num_grads_checkbox)

        self.analysis_type2_checkbox = QCheckBox(
            "Compare the 3 year graduate cohort declining balance \npercentage to "
            "the 25% salary in the state.", self)
        self.analysis_type2_checkbox.setGeometry(430, 70, 400, 100)
        self.analysis_type2_checkbox.toggle()
        self.analysis_type2_checkbox.clicked.connect(
            self.swap_3_yr_cohort_checkbox)

        # PUSH BUTTONS
        self.render_data_button = QPushButton("VISUALIZE", self)
        self.render_data_button.setGeometry(10, 150, 770, 40)
        self.render_data_button.clicked.connect(self.display_visualization)

        self.sort_ascending_button = QPushButton("Sort Ascending", self)
        self.sort_ascending_button.setGeometry(10, 650, 120, 30)
        self.sort_ascending_button.clicked.connect(self.sort_ascending)

        self.sort_descending_button = QPushButton("Sort Descending", self)
        self.sort_descending_button.setGeometry(130, 650, 120, 30)
        self.sort_descending_button.clicked.connect(self.sort_descending)

        self.close_visual_window_button = QPushButton("CLOSE", self)
        self.close_visual_window_button.setGeometry(660, 650, 120, 30)
        self.close_visual_window_button.clicked.connect(lambda: self.close())

        self.setWindowTitle(
            "Data Visualization for Project 1 - Sprint 4 - Ryan O'Connor - COMP490 - T/R"
        )
        self.setGeometry(100, 100, 800, 700)
        self.setFixedSize(800, 700)
        self.center()

    def display_visualization(self):
        conn, cursor = open_db(self.db_name_from_visual_btn)
        cursor.execute(
            'SELECT school_state, student_size_2018 FROM school_export')
        table = cursor.fetchall()

        self.list_control.clear()

        num_grads_in_state = {
            "AK": 0,
            "AL": 0,
            "AR": 0,
            "AS": 0,
            "AZ": 0,
            "CA": 0,
            "CO": 0,
            "CT": 0,
            "DC": 0,
            "DE": 0,
            "FL": 0,
            "FM": 0,
            "GA": 0,
            "GU": 0,
            "HI": 0,
            "IA": 0,
            "ID": 0,
            "IL": 0,
            "IN": 0,
            "KS": 0,
            "KY": 0,
            "LA": 0,
            "MA": 0,
            "MD": 0,
            "ME": 0,
            "MH": 0,
            "MI": 0,
            "MN": 0,
            "MO": 0,
            "MP": 0,
            "MS": 0,
            "MT": 0,
            "NC": 0,
            "ND": 0,
            "NE": 0,
            "NH": 0,
            "NJ": 0,
            "NM": 0,
            "NV": 0,
            "NY": 0,
            "OH": 0,
            "OK": 0,
            "OR": 0,
            "PA": 0,
            "PR": 0,
            "PW": 0,
            "RI": 0,
            "SC": 0,
            "SD": 0,
            "TN": 0,
            "TX": 0,
            "UT": 0,
            "VA": 0,
            "VI": 0,
            "VT": 0,
            "WA": 0,
            "WI": 0,
            "WV": 0,
            "WY": 0
        }

        for idx, row in enumerate(table):
            if row[1] is None:
                continue
            else:
                state_abbr_from_table = row[0]
                student_size_2018 = row[1]
                state_total = num_grads_in_state[state_abbr_from_table]
                num_grads_in_state[
                    state_abbr_from_table] = state_total + student_size_2018

        # Dividing by 4 years here - to simplify the size of a senior graduating class
        for student_total_2018 in num_grads_in_state:
            num_grads_in_state[student_total_2018] = num_grads_in_state[
                student_total_2018] / 4

        # DATA ANALYSIS - PART 1B
        num_jobs_in_state = {
            "AK": 0,
            "AL": 0,
            "AR": 0,
            "AS": 0,
            "AZ": 0,
            "CA": 0,
            "CO": 0,
            "CT": 0,
            "DC": 0,
            "DE": 0,
            "FL": 0,
            "FM": 0,
            "GA": 0,
            "GU": 0,
            "HI": 0,
            "IA": 0,
            "ID": 0,
            "IL": 0,
            "IN": 0,
            "KS": 0,
            "KY": 0,
            "LA": 0,
            "MA": 0,
            "MD": 0,
            "ME": 0,
            "MH": 0,
            "MI": 0,
            "MN": 0,
            "MO": 0,
            "MP": 0,
            "MS": 0,
            "MT": 0,
            "NC": 0,
            "ND": 0,
            "NE": 0,
            "NH": 0,
            "NJ": 0,
            "NM": 0,
            "NV": 0,
            "NY": 0,
            "OH": 0,
            "OK": 0,
            "OR": 0,
            "PA": 0,
            "PR": 0,
            "PW": 0,
            "RI": 0,
            "SC": 0,
            "SD": 0,
            "TN": 0,
            "TX": 0,
            "UT": 0,
            "VA": 0,
            "VI": 0,
            "VT": 0,
            "WA": 0,
            "WI": 0,
            "WV": 0,
            "WY": 0
        }

        cursor.execute(
            'SELECT area_title, occ_code, tot_emp FROM jobdata_by_state')
        table = cursor.fetchall()

        for idx, row in enumerate(table):
            check_occ_code = row[1]
            check_occ_code = int(check_occ_code[:2])

            if 30 <= check_occ_code <= 49:
                continue
            else:
                state_from_school_export = str(row[0])
                abbr_state = abbreviate_state(state_from_school_export)
                tot_emp_jobs_in_state = int(row[2])
                tot_emp = num_jobs_in_state[abbr_state]
                num_jobs_in_state[abbr_state] = tot_emp + tot_emp_jobs_in_state

        compare_total_jobs_to_grads = {
            k: (num_jobs_in_state[k] / num_grads_in_state[k])
            for k in num_jobs_in_state
        }

        display_data = open("display_map_data.csv", "w+")
        display_data.writelines("state,data\n")

        for key in compare_total_jobs_to_grads:
            total_jobs_rounded = (round(compare_total_jobs_to_grads[key], 2))

            if total_jobs_rounded == 0:
                display_data.writelines(f"{key}, {total_jobs_rounded}\n")
            else:
                display_data.writelines(f"{key}, {total_jobs_rounded}\n")

        display_data.close()

        # DATA ANALYSIS PART 2A
        repayment_2016_dict = {
            "AK": 0,
            "AL": 0,
            "AR": 0,
            "AS": 0,
            "AZ": 0,
            "CA": 0,
            "CO": 0,
            "CT": 0,
            "DC": 0,
            "DE": 0,
            "FL": 0,
            "FM": 0,
            "GA": 0,
            "GU": 0,
            "HI": 0,
            "IA": 0,
            "ID": 0,
            "IL": 0,
            "IN": 0,
            "KS": 0,
            "KY": 0,
            "LA": 0,
            "MA": 0,
            "MD": 0,
            "ME": 0,
            "MH": 0,
            "MI": 0,
            "MN": 0,
            "MO": 0,
            "MP": 0,
            "MS": 0,
            "MT": 0,
            "NC": 0,
            "ND": 0,
            "NE": 0,
            "NH": 0,
            "NJ": 0,
            "NM": 0,
            "NV": 0,
            "NY": 0,
            "OH": 0,
            "OK": 0,
            "OR": 0,
            "PA": 0,
            "PR": 0,
            "PW": 0,
            "RI": 0,
            "SC": 0,
            "SD": 0,
            "TN": 0,
            "TX": 0,
            "UT": 0,
            "VA": 0,
            "VI": 0,
            "VT": 0,
            "WA": 0,
            "WI": 0,
            "WV": 0,
            "WY": 0
        }

        cursor.execute(
            'SELECT school_state, repayment_repayment_cohort_3_year_declining_balance_2016 FROM school_export'
        )
        table = cursor.fetchall()

        for idx, row in enumerate(table):
            if row[1] is None:
                continue
            else:
                state_from_school_export = str(row[0])
                repayment_2016_data = row[1]
                repayment_2016_data_tot_sum = repayment_2016_dict[
                    state_from_school_export]
                repayment_2016_dict[
                    state_from_school_export] = repayment_2016_data + repayment_2016_data_tot_sum

        for key in repayment_2016_dict:
            if repayment_2016_dict[key] == 0:
                repayment_2016_dict[
                    key] = 0.0001  # States with 0 data get this due to dividing by 0

        # DATA ANALYSIS - PART 2B
        a_pc25_dict = {
            "AK": 0,
            "AL": 0,
            "AR": 0,
            "AS": 0,
            "AZ": 0,
            "CA": 0,
            "CO": 0,
            "CT": 0,
            "DC": 0,
            "DE": 0,
            "FL": 0,
            "FM": 0,
            "GA": 0,
            "GU": 0,
            "HI": 0,
            "IA": 0,
            "ID": 0,
            "IL": 0,
            "IN": 0,
            "KS": 0,
            "KY": 0,
            "LA": 0,
            "MA": 0,
            "MD": 0,
            "ME": 0,
            "MH": 0,
            "MI": 0,
            "MN": 0,
            "MO": 0,
            "MP": 0,
            "MS": 0,
            "MT": 0,
            "NC": 0,
            "ND": 0,
            "NE": 0,
            "NH": 0,
            "NJ": 0,
            "NM": 0,
            "NV": 0,
            "NY": 0,
            "OH": 0,
            "OK": 0,
            "OR": 0,
            "PA": 0,
            "PR": 0,
            "PW": 0,
            "RI": 0,
            "SC": 0,
            "SD": 0,
            "TN": 0,
            "TX": 0,
            "UT": 0,
            "VA": 0,
            "VI": 0,
            "VT": 0,
            "WA": 0,
            "WI": 0,
            "WV": 0,
            "WY": 0
        }

        cursor.execute('SELECT area_title, a_pct25 FROM jobdata_by_state')
        table = cursor.fetchall()

        for idx, row in enumerate(table):
            a_pct25_from_job_date_by_state = str(row[0])
            abbr_state = abbreviate_state(a_pct25_from_job_date_by_state)
            current_a_pct25 = row[1]
            tot_ann_pct25_dict = a_pc25_dict[abbr_state]
            a_pc25_dict[abbr_state] = current_a_pct25 + tot_ann_pct25_dict

        compare_a_pct25_to_2016_repayment = {
            k: (a_pc25_dict[k] / repayment_2016_dict[k])
            for k in a_pc25_dict
        }

        display_data = open("display_map_data2.csv", "w+")
        display_data.writelines("state,data\n")

        for key in compare_a_pct25_to_2016_repayment:
            if key in ("GU", "VI"
                       ):  # Omitting Guam & Virgin Islands due to skewing data
                continue
            else:
                tot_apc25_2016_repay_rounded = (round(
                    compare_a_pct25_to_2016_repayment[key], 2))
                display_data.writelines(
                    f"{key}, {tot_apc25_2016_repay_rounded}\n")

        display_data.close()

        if self.analysis_type1_checkbox.isChecked():
            type_of_analysis = "1"
        else:
            type_of_analysis = "2"

        if self.render_map_checkbox.isChecked():
            DisplayMap.display_map(type_of_analysis)

        else:
            if type_of_analysis == "1":
                for key in compare_total_jobs_to_grads:
                    total_jobs_rounded = (round(
                        compare_total_jobs_to_grads[key], 2))

                    if total_jobs_rounded == 0:
                        display_text = f"State: {key}\t Total jobs: {num_jobs_in_state[key]}\t\t Total college grads: " \
                                       f"{num_grads_in_state[key]}\t\t {total_jobs_rounded} jobs available " \
                                       f"per graduating student"
                    else:
                        display_text = f"State: {key}\t Total jobs: {num_jobs_in_state[key]}\t Total college grads: " \
                                       f"{num_grads_in_state[key]}\t\t {total_jobs_rounded} jobs available " \
                                       f"per graduating student"

                    list_item = QListWidgetItem(display_text,
                                                listview=self.list_control)
                    list_item.setForeground(Qt.darkRed)

            else:
                for key in compare_a_pct25_to_2016_repayment:
                    apc25_to_2016_repay_rounded = (round(
                        compare_a_pct25_to_2016_repayment[key], 2))
                    repay_2016_rounded = (round(repayment_2016_dict[key], 2))

                    if apc25_to_2016_repay_rounded == 0:
                        display_text = f"State: {key}\t 3 year graduate cohort declining balance percent: " \
                                       f"{repayment_2016_dict[key]}\t 25% salary: {a_pc25_dict[key]}\t\t Result: " \
                                       f"{apc25_to_2016_repay_rounded}"
                    else:
                        display_text = f"State: {key}\t 3 year graduate cohort declining balance percent: " \
                                       f"{repay_2016_rounded}\t 25% salary: {a_pc25_dict[key]}\t Result: " \
                                       f"{apc25_to_2016_repay_rounded}"

                    list_item = QListWidgetItem(display_text,
                                                listview=self.list_control)
                    list_item.setForeground(Qt.darkBlue)

        close_db(conn)

    def sort_ascending(self):
        self.list_control.sortItems(Qt.AscendingOrder)

    def sort_descending(self):
        self.list_control.sortItems(Qt.DescendingOrder)

    def swap_color_coded_checkbox(self):
        status = self.color_coded_checkbox.isChecked()

        if status:
            self.render_map_checkbox.setChecked(False)
        else:
            self.render_map_checkbox.setChecked(True)

    def swap_render_map_checkbox(self):
        status = self.render_map_checkbox.isChecked()

        if status:
            self.color_coded_checkbox.setChecked(False)
        else:
            self.color_coded_checkbox.setChecked(True)

    def swap_num_grads_checkbox(self):
        status = self.analysis_type1_checkbox.isChecked()

        if status:
            self.analysis_type2_checkbox.setChecked(False)
        else:
            self.analysis_type2_checkbox.setChecked(True)

    def swap_3_yr_cohort_checkbox(self):
        status = self.analysis_type2_checkbox.isChecked()

        if status:
            self.analysis_type1_checkbox.setChecked(False)
        else:
            self.analysis_type1_checkbox.setChecked(True)

    def center(self):
        screen_center = QScreen.availableGeometry(
            QApplication.primaryScreen()).center()
        self_geometry = self.frameGeometry()
        self_geometry.moveCenter(screen_center)
        self.move(self_geometry.topLeft())
class JobsWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.quit_button = QPushButton("Quit", self)
        self.update_button = QPushButton("Update Data", self)
        self.enter_data = QPushButton("Enter Data", self)
        self.data_button = QPushButton("Run Data Visualization", self)
        self.back_button = QPushButton("Back", self)
        self.text_visualization_button = QPushButton("Text Visualization", self)
        self.map_visualization = QPushButton("Map Visualization", self)
        self.order_selector_text = QComboBox(self)
        self.data_selector_map = QComboBox(self)
        self.data_visualization_label = QLabel("Welcome to data visualization!", self)
        self.welcome_label = QLabel("Welcome to Jobs data Visualization.", self)
        self.list_control = None
        self.update_label_01 = QLabel("", self)
        self.update_label_02 = QLabel("", self)
        self.update_label_03 = QLabel("", self)
        self.update_label_04 = QLabel("", self)
        self.update_label_05 = QLabel("", self)
        self.update_label_06 = QLabel("", self)
        self.update_label_07 = QLabel("", self)
        self.update_label_08 = QLabel("", self)
        self.excel_label = QLabel("Excel Spreadsheet:", self)
        self.update_information = QLabel(
            "If you would like to update a single entry please select the table and enter all of its information.\n"
            "If you would like to import from a spreadsheet type it into the box on the right and select the table.\n"
            "When you are ready with which ever function press Enter Data.\n"
            "For any data you want to append make sure the id is None.\n"
            "Also only work from one method at a time and make sure he other is empty.", self)
        self.table_selection = QComboBox(self)
        self.update_box_01 = QLineEdit(self)
        self.update_box_02 = QLineEdit(self)
        self.update_box_03 = QLineEdit(self)
        self.update_box_04 = QLineEdit(self)
        self.update_box_05 = QLineEdit(self)
        self.update_box_06 = QLineEdit(self)
        self.update_box_07 = QLineEdit(self)
        self.update_box_08 = QLineEdit(self)
        self.update_excel_selection = QLineEdit(self)
        self.list_control = None
        self.setup_window()

    def setup_window(self):
        self.setWindowTitle("Jobs Window")
        display_list = QListWidget(self)
        self.list_control = display_list
        display_list.resize(500, 350)
        self.setGeometry(50, 50, 500, 500)
        self.quit_button.clicked.connect(QApplication.instance().quit)
        self.quit_button.resize(self.quit_button.sizeHint())
        self.quit_button.move(415, 450)
        self.update_button.clicked.connect(self.update_data)
        self.update_button.move(200, 200)
        self.data_button.clicked.connect(self.run_data_visualization)
        self.data_button.move(175, 250)
        self.back_button.clicked.connect(self.go_back)
        self.back_button.move(25, 450)
        self.data_visualization_label.move(20, 400)
        self.text_visualization_button.move(400 - self.text_visualization_button.width(), 600)
        self.order_selector_text.move(self.text_visualization_button.x(),
                                      self.text_visualization_button.y()+self.text_visualization_button.height()+10)
        self.text_visualization_button.clicked.connect(self.text_visualization)
        self.map_visualization.move(self.text_visualization_button.x() + self.text_visualization_button.width(),
                                    self.text_visualization_button.y())
        self.data_selector_map.move(self.map_visualization.x(),
                                    self.map_visualization.y()+self.map_visualization.height()+10)
        self.map_visualization.clicked.connect(self.run_map_visualization)
        self.welcome_label.move(150, 150)
        self.update_box_01.move(150, 30)
        self.update_box_02.move(150, 60)
        self.update_box_03.move(150, 90)
        self.update_box_04.move(150, 120)
        self.update_box_05.move(150, 150)
        self.update_box_06.move(150, 180)
        self.update_box_07.move(150, 210)
        self.update_box_08.move(150, 240)
        self.excel_label.move(340, 70)
        self.update_excel_selection.move(340, 90)
        self.update_information.move(25, 325)
        self.update_label_01.setGeometry(5, 30, 145, 20)
        self.update_label_02.setGeometry(5, 60, 145, 20)
        self.update_label_03.setGeometry(5, 90, 145, 20)
        self.update_label_04.setGeometry(5, 120, 145, 20)
        self.update_label_05.setGeometry(5, 150, 145, 20)
        self.update_label_06.setGeometry(5, 180, 145, 20)
        self.update_label_07.setGeometry(5, 210, 145, 20)
        self.update_label_08.setGeometry(5, 240, 145, 20)
        self.table_selection.setGeometry(10, 10, 145, 20)
        self.enter_data.move(10, 260)
        self.enter_data.clicked.connect(self.import_data)
        self.table_selection.addItem("---")
        self.table_selection.addItem("Schools")
        self.table_selection.addItem("Jobs")
        self.order_selector_text.addItem("---")
        self.order_selector_text.addItem("ASC")
        self.order_selector_text.addItem("DESC")
        self.data_selector_map.addItem("---")
        self.data_selector_map.addItem("Employment to Graduates")
        self.data_selector_map.addItem("Average Salary to Average Declining Balance Percent")
        self.table_selection.currentIndexChanged.connect(self.update_selection)
        self.hidden_at_start()

        self.show()

    def hidden_at_start(self):
        self.hide_update_boxes()
        self.list_control.hide()
        self.update_information.hide()
        self.map_visualization.hide()
        self.text_visualization_button.hide()
        self.data_visualization_label.hide()
        self.back_button.hide()
        self.table_selection.hide()
        self.enter_data.hide()
        self.update_excel_selection.hide()
        self.excel_label.hide()
        self.data_selector_map.hide()
        self.order_selector_text.hide()

    def hide_update_boxes(self):
        self.update_box_01.hide()
        self.update_box_02.hide()
        self.update_box_03.hide()
        self.update_box_04.hide()
        self.update_box_05.hide()
        self.update_box_06.hide()
        self.update_box_07.hide()
        self.update_box_08.hide()
        self.update_label_01.setText("")
        self.update_label_02.setText("")
        self.update_label_03.setText("")
        self.update_label_04.setText("")
        self.update_label_05.setText("")
        self.update_label_06.setText("")
        self.update_label_07.setText("")
        self.update_label_08.setText("")

    def update_data(self):
        self.update_button.hide()
        self.data_button.hide()
        self.back_button.show()
        self.welcome_label.hide()
        self.table_selection.show()
        self.enter_data.show()
        self.update_information.show()
        self.update_excel_selection.show()
        self.excel_label.show()

    def update_selection(self):
        self.hide_update_boxes()
        if self.table_selection.currentText() == "Jobs":
            self.update_box_01.show()
            self.update_label_01.setText("jobs_id")
            self.update_box_02.show()
            self.update_label_02.setText("state_name")
            self.update_box_03.show()
            self.update_label_03.setText("occupation_code")
            self.update_box_04.show()
            self.update_label_04.setText("tittle")
            self.update_box_05.show()
            self.update_label_05.setText("employment")
            self.update_box_06.show()
            self.update_label_06.setText("salary_25th_percentile")
        elif self.table_selection.currentText() == "Schools":
            self.update_box_01.show()
            self.update_label_01.setText("school_id")
            self.update_box_02.show()
            self.update_label_02.setText("name")
            self.update_box_03.show()
            self.update_label_03.setText("state_abrev")
            self.update_box_04.show()
            self.update_label_04.setText("size_2017")
            self.update_box_05.show()
            self.update_label_05.setText("size_2018")
            self.update_box_06.show()
            self.update_label_06.setText("earnings")
            self.update_box_07.show()
            self.update_label_07.setText("repayment_overall")
            self.update_box_08.show()
            self.update_label_08.setText("repayment_cohort")

    def import_data(self):
        if self.update_excel_selection.text() == "":
            if self.table_selection.currentText() == "Jobs":
                information_to_update = [self.update_box_01.text(), self.update_box_02.text(),
                                         self.update_box_03.text(), self.update_box_04.text(),
                                         self.update_box_05.text(), self.update_box_06.text()]
                jobs.update_data_from_list(information_to_update, "Jobs", "jobs_db.sqlite")
            elif self.table_selection.currentText() == "Schools":
                information_to_update = [self.update_box_01.text(), self.update_box_02.text(),
                                         self.update_box_03.text(), self.update_box_04.text(),
                                         self.update_box_05.text(), self.update_box_06.text(),
                                         self.update_box_07.text(), self.update_box_08.text()]
                jobs.update_data_from_list(information_to_update, "Schools", "jobs_db.sqlite")
        else:
            if self.table_selection.currentText() == "Jobs":
                jobs.update_data_from_excel(self.update_excel_selection.text(), "Jobs", "jobs_db.sqlite")
            elif self.table_selection.currentText() == "Schools":
                jobs.update_data_from_excel(self.update_excel_selection.text(), "Jobs", "jobs_db.sqlite")

    def run_data_visualization(self):
        self.update_button.hide()
        self.data_button.hide()
        self.data_visualization_label.show()
        self.back_button.show()
        self.setGeometry(50, 50, 800, 800)
        self.back_button.move(25, 750)
        self.quit_button.move(715, 750)
        self.welcome_label.hide()
        self.map_visualization.show()
        self.text_visualization_button.show()
        self.data_selector_map.show()
        self.order_selector_text.show()

    def go_back(self):
        self.back_button.hide()
        self.update_button.show()
        self.data_button.show()
        self.data_visualization_label.hide()
        self.setGeometry(50, 50, 500, 500)
        self.back_button.move(25, 450)
        self.quit_button.move(415, 450)
        self.welcome_label.show()
        self.hidden_at_start()

    def text_visualization(self):
        self.list_control.clear()
        conn, cursor = jobs.open_db("jobs_db.sqlite")
        if self.order_selector_text.currentText() == "ASC":
            data_visualization_per_state = jobs.query_run('''SELECT state_abrev, state_name, ''' + '''
            total(jobs.employment) as employment,
            total(school.size_2018/4),
            round(avg(school.repayment_cohort),3) as repayment_cohort,
            round(avg(jobs.salary_25th_percentile)) as averge_entry_salary
            FROM school
            JOIN states using(state_abrev)
            JOIN jobs using(state_name)
            GROUP BY state_name
            ORDER BY employment ASC;''', cursor)
        elif self.order_selector_text.currentText() == "DESC":
            data_visualization_per_state = jobs.query_run('''SELECT state_abrev, state_name, ''' + '''
                        total(jobs.employment) as employment,
                        total(school.size_2018/4),
                        round(avg(school.repayment_cohort),3) as repayment_cohort,
                        round(avg(jobs.salary_25th_percentile)) as averge_entry_salary
                        FROM school
                        JOIN states using(state_abrev)
                        JOIN jobs using(state_name)
                        GROUP BY state_name
                        ORDER BY employment DESC;''', cursor)
        else:
            data_visualization_per_state = jobs.query_run('''SELECT state_abrev, state_name, ''' + '''
                                    total(jobs.employment) as employment,
                                    total(school.size_2018/4),
                                    round(avg(school.repayment_cohort),3) as repayment_cohort,
                                    round(avg(jobs.salary_25th_percentile)) as averge_entry_salary
                                    FROM school
                                    JOIN states using(state_abrev)
                                    JOIN jobs using(state_name)
                                    GROUP BY state_name
                                    ;''', cursor)
        QListWidgetItem("State", listview=self.list_control)
        for state in data_visualization_per_state:
            state_display_data = f"{state[0]}, {state[1]}"
            grad_employ_data = f"Employment/Graduates: {state[2]/state[3]}"
            repayment_data = f"Average Entry Salary/Average Declining Balance Percent: {state[5]/state[4]}"
            state_item = QListWidgetItem(state_display_data, listview=self.list_control)
            grad_item = QListWidgetItem(grad_employ_data, listview=self.list_control)
            repayment_item = QListWidgetItem(repayment_data, listview=self.list_control)
            grad_item.setForeground(Qt.darkGreen)
            repayment_item.setForeground(Qt.blue)
            state_item.setForeground(Qt.white)
            state_item.setBackground(Qt.black)
        self.list_control.show()
        jobs.close_db(conn)

    def run_map_visualization(self):
        conn, cursor = jobs.open_db("jobs_db.sqlite")
        data_visualization_per_state = jobs.query_run('''SELECT state_abrev, state_name, ''' + '''
                total(jobs.employment) as employment,
                total(school.size_2018/4),
                round(avg(school.repayment_cohort),3) as repayment_cohort,
                round(avg(jobs.salary_25th_percentile)) as averge_entry_salary
                FROM school
                JOIN states using(state_abrev)
                JOIN jobs using(state_name)
                GROUP BY state_name
                ;''', cursor)
        state_abrev = []
        state_grads = []
        state_repayment = []

        for state in data_visualization_per_state:
            state_abrev.append(state[0])
            state_grads.append(state[2]/state[3])
            state_repayment.append(state[5]/state[4])

        if self.data_selector_map.currentText() == "Graduates to Employment":
            us_map = px.Figure(data=px.Choropleth(locations=state_abrev, z=state_grads,
                                                  locationmode='USA-states', colorbar_title="Employment/Graduates"
                                                  ))
            us_map.update_layout(geo_scope='usa', title_text='Employment VS Graduates By State')
            us_map.show()
        elif self.data_selector_map.currentText() == "Average Declining Balance Percent":
            us_map = px.Figure(data=px.Choropleth(locations=state_abrev, z=state_repayment,
                                                  locationmode='USA-states', colorbar_title="Salary/Average Percent"
                                                  ))
            us_map.update_layout(geo_scope='usa', title_text='Average Salary VS Average '
                                                             'Percent of People with Declining Loans')
            us_map.show()
        else:
            us_map = px.Figure(data=px.Choropleth(locations=state_abrev, z=state_grads,
                                                  locationmode='USA-states', colorbar_title="Graduates"
                                                  ))
            us_map.update_layout(geo_scope='usa', title_text='Graduates By State')
            us_map.show()
        jobs.close_db(conn)
        self.list_control.hide()