Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Hour Calculator- GUI Recommendation
#1
I am looking for a bit of advice. Im new to python and working on an overtime calculator similar to the one located at this website: https://www.worklawyers.com/overtime-cal...alifornia/

Mine is slightly different in that i want to put two weeks of information into it and return the hours for both weeks. I have already completed the logic portion and have it working in the command line interface. I would like to create a graphic interface and only plan on running it on a local computer. My interface would consist of 14 input boxes for each days hours and 3 output boxes for straight time hours, over-time hours, and double time hours.
I am using pycharm pro and anaconda 3.

My question is what would you all recommend as far as a method for doing this? Im not looking for the code, just a recommendation on django, kivy, etc so that i have a place to start looking in earnest.
I have very basic skills as this point, so i would like to keep it simple.
Quote
#2
Maybe you can try Gooey which pitches itself as: 'Turn (almost) any Python 2 or 3 Console Program into a GUI application with one line'
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Life of Brian: Conjugate the verb, "to go" !
Quote
#3
(Sep-26-2019, 07:33 PM)Denni Wrote: Well if you decide to go with PyQt5 I can invite you to the Python/PyQt Discord message server where I tutor several other folks on coding drop a line to DenniO#8137

I havent been able to find you in discord. I did build up using PyQt and figured out how to do most everything but im having trouble tieing my large calculation to the output.

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'C:\Python\Hours.1\GUI.Hours.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!


from PyQt5 import QtCore, QtGui, QtWidgets
import HourBreakDown import *


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(594, 678)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.layoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.layoutWidget.setGeometry(QtCore.QRect(130, 140, 122, 429))
        self.layoutWidget.setObjectName("layoutWidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.lineEdit = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit.setObjectName("lineEdit")
        self.verticalLayout.addWidget(self.lineEdit)
        self.lineEdit_2 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.verticalLayout.addWidget(self.lineEdit_2)
        self.lineEdit_3 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.verticalLayout.addWidget(self.lineEdit_3)
        self.lineEdit_4 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.verticalLayout.addWidget(self.lineEdit_4)
        self.lineEdit_5 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.verticalLayout.addWidget(self.lineEdit_5)
        self.lineEdit_6 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.verticalLayout.addWidget(self.lineEdit_6)
        self.lineEdit_7 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.verticalLayout.addWidget(self.lineEdit_7)
        self.lineEdit_8 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_8.setObjectName("lineEdit_8")
        self.verticalLayout.addWidget(self.lineEdit_8)
        self.lineEdit_9 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_9.setObjectName("lineEdit_9")
        self.verticalLayout.addWidget(self.lineEdit_9)
        self.lineEdit_10 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_10.setObjectName("lineEdit_10")
        self.verticalLayout.addWidget(self.lineEdit_10)
        self.lineEdit_11 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_11.setObjectName("lineEdit_11")
        self.verticalLayout.addWidget(self.lineEdit_11)
        self.lineEdit_12 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_12.setObjectName("lineEdit_12")
        self.verticalLayout.addWidget(self.lineEdit_12)
        self.lineEdit_13 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_13.setObjectName("lineEdit_13")
        self.verticalLayout.addWidget(self.lineEdit_13)
        self.lineEdit_14 = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_14.setObjectName("lineEdit_14")
        self.verticalLayout.addWidget(self.lineEdit_14)
        self.layoutWidget1 = QtWidgets.QWidget(self.centralwidget)
        self.layoutWidget1.setGeometry(QtCore.QRect(8, 140, 111, 431))
        self.layoutWidget1.setObjectName("layoutWidget1")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.layoutWidget1)
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.Monday = QtWidgets.QLabel(self.layoutWidget1)
        self.Monday.setObjectName("Monday")
        self.verticalLayout_2.addWidget(self.Monday)
        self.Tuesday = QtWidgets.QLabel(self.layoutWidget1)
        self.Tuesday.setObjectName("Tuesday")
        self.verticalLayout_2.addWidget(self.Tuesday)
        self.Wednesday = QtWidgets.QLabel(self.layoutWidget1)
        self.Wednesday.setObjectName("Wednesday")
        self.verticalLayout_2.addWidget(self.Wednesday)
        self.Thursday = QtWidgets.QLabel(self.layoutWidget1)
        self.Thursday.setObjectName("Thursday")
        self.verticalLayout_2.addWidget(self.Thursday)
        self.Friday = QtWidgets.QLabel(self.layoutWidget1)
        self.Friday.setObjectName("Friday")
        self.verticalLayout_2.addWidget(self.Friday)
        self.Saturday = QtWidgets.QLabel(self.layoutWidget1)
        self.Saturday.setObjectName("Saturday")
        self.verticalLayout_2.addWidget(self.Saturday)
        self.Sunday = QtWidgets.QLabel(self.layoutWidget1)
        self.Sunday.setObjectName("Sunday")
        self.verticalLayout_2.addWidget(self.Sunday)
        self.Monday2 = QtWidgets.QLabel(self.layoutWidget1)
        self.Monday2.setObjectName("Monday2")
        self.verticalLayout_2.addWidget(self.Monday2)
        self.Tuesday2 = QtWidgets.QLabel(self.layoutWidget1)
        self.Tuesday2.setObjectName("Tuesday2")
        self.verticalLayout_2.addWidget(self.Tuesday2)
        self.Wednesday2 = QtWidgets.QLabel(self.layoutWidget1)
        self.Wednesday2.setObjectName("Wednesday2")
        self.verticalLayout_2.addWidget(self.Wednesday2)
        self.Thursday2 = QtWidgets.QLabel(self.layoutWidget1)
        self.Thursday2.setObjectName("Thursday2")
        self.verticalLayout_2.addWidget(self.Thursday2)
        self.Friday2 = QtWidgets.QLabel(self.layoutWidget1)
        self.Friday2.setObjectName("Friday2")
        self.verticalLayout_2.addWidget(self.Friday2)
        self.Saturday2 = QtWidgets.QLabel(self.layoutWidget1)
        self.Saturday2.setObjectName("Saturday2")
        self.verticalLayout_2.addWidget(self.Saturday2)
        self.Sunday2 = QtWidgets.QLabel(self.layoutWidget1)
        self.Sunday2.setObjectName("Sunday2")
        self.verticalLayout_2.addWidget(self.Sunday2)
        self.layoutWidget2 = QtWidgets.QWidget(self.centralwidget)
        self.layoutWidget2.setGeometry(QtCore.QRect(460, 260, 81, 151))
        self.layoutWidget2.setObjectName("layoutWidget2")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.layoutWidget2)
        self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.lcdNumber = QtWidgets.QLCDNumber(self.layoutWidget2)
        self.lcdNumber.setObjectName("lcdNumber")
        self.verticalLayout_3.addWidget(self.lcdNumber)
        self.lcdNumber_2 = QtWidgets.QLCDNumber(self.layoutWidget2)
        self.lcdNumber_2.setObjectName("lcdNumber_2")
        self.verticalLayout_3.addWidget(self.lcdNumber_2)
        self.lcdNumber_3 = QtWidgets.QLCDNumber(self.layoutWidget2)
        self.lcdNumber_3.setObjectName("lcdNumber_3")
        self.verticalLayout_3.addWidget(self.lcdNumber_3)
        self.layoutWidget3 = QtWidgets.QWidget(self.centralwidget)
        self.layoutWidget3.setGeometry(QtCore.QRect(358, 260, 91, 151))
        self.layoutWidget3.setObjectName("layoutWidget3")
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.layoutWidget3)
        self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.Straight_Time = QtWidgets.QLabel(self.layoutWidget3)
        self.Straight_Time.setObjectName("Straight_Time")
        self.verticalLayout_4.addWidget(self.Straight_Time)
        self.Overtime = QtWidgets.QLabel(self.layoutWidget3)
        self.Overtime.setObjectName("Overtime")
        self.verticalLayout_4.addWidget(self.Overtime)
        self.DoubleOvertime = QtWidgets.QLabel(self.layoutWidget3)
        self.DoubleOvertime.setObjectName("DoubleOvertime")
        self.verticalLayout_4.addWidget(self.DoubleOvertime)
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(350, 430, 191, 51))
        self.pushButton.setObjectName("pushButton")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 594, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        self.pushButton.clicked.connect(self.CalHour)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.Monday.setText(_translate("MainWindow", "Monday"))
        self.Tuesday.setText(_translate("MainWindow", "Tuesday"))
        self.Wednesday.setText(_translate("MainWindow", "Wednesday"))
        self.Thursday.setText(_translate("MainWindow", "Thursday"))
        self.Friday.setText(_translate("MainWindow", "Friday"))
        self.Saturday.setText(_translate("MainWindow", "Saturday"))
        self.Sunday.setText(_translate("MainWindow", "Sunday"))
        self.Monday2.setText(_translate("MainWindow", "Monday 2"))
        self.Tuesday2.setText(_translate("MainWindow", "Tuesday 2"))
        self.Wednesday2.setText(_translate("MainWindow", "Wednesday 2"))
        self.Thursday2.setText(_translate("MainWindow", "Thursday 2"))
        self.Friday2.setText(_translate("MainWindow", "Friday 2"))
        self.Saturday2.setText(_translate("MainWindow", "Saturday 2"))
        self.Sunday2.setText(_translate("MainWindow", "Sunday 2"))
        self.Straight_Time.setText(_translate("MainWindow", "Straight Time"))
        self.Overtime.setText(_translate("MainWindow", "Overtime"))
        self.DoubleOvertime.setText(_translate("MainWindow", "Double Overtime"))
        self.pushButton.setText(_translate("MainWindow", "Calculate"))

    def CalHour(self):
        Monday_1 = self.lineEdit.text()
        Tuesday_1 = self.lineEdit_2.text()
        Wednesday_1 = self.lineEdit_3.text()
        Thursday_1 = self.lineEdit_4.text()
        Friday_1 = self.lineEdit_5.text()
        Saturday_1 = self.lineEdit_6()
        Sunday_1 = self.lineEdit_7.text()
       #Convert Text to Number
        Mon1 = float(Monday_1)
        Tue1 = float(Tuesday_1)
        Wed1 = float(Wednesday_1)
        Thur1 = float(Thursday_1)
        Fri1 = float(Friday_1)
        Sat1 = float(Saturday_1)
        Sun1 = float(Sunday_1)
        # Daily Straight Time Calculation
        if 0 <= Mon1 <= 8:
            Mon_straight_time = Mon1
        else:
            Mon_straight_time = 8
        if 0 <= Tue1 <= 8:
            Tue_straight_time = Tue1
        else:
            Tue_straight_time = 8

        if 0 <= Wed1 <= 8:
            Wed_straight_time = Wed1
        else:
            Wed_straight_time = 8

        if 0 <= Thur1 <= 8:
            Thur_straight_time = Thur1
        else:
            Thur_straight_time = 8

        if 0 <= Fri1 <= 8:
            Fri_straight_time = Fri1
        else:
            Fri_straight_time = 8

        if 0 <= Sat1 <= 8:
            Sat_straight_time = Sat1
        else:
            Sat_straight_time = 8

        if 0 <= Sun1 <= 8:
            Sun_straight_time = Sun1
        else:
            Sun_straight_time = 8

        # Weekly Straight time calculation
        Weekly_straight_time = (Mon_straight_time + Tue_straight_time +
                                Wed_straight_time + Thur_straight_time +
                                Fri_straight_time + Sat_straight_time + Sun_straight_time)
        # Evaluate  Daily Overtime
        if 8 < Mon1 <= 12:
            Mon_overtime = Mon1 - 8
        elif 8 < Mon1 > 12:
            Mon_overtime = 4
        else:
            Mon_overtime = 0
        if 8 < Tue1 <= 12:
            Tue_overtime = Tue1 - 8
        elif 8 < Tue1 > 12:
            Tue_overtime = 4
        else:
            Tue_overtime = 0
        if 8 < Wed1 <= 12:
            Wed_overtime = Wed1 - 8
        elif 8 < Wed1 > 12:
            Wed_overtime = 4
        else:
            Wed_overtime = 0
        if 8 < Thur1 <= 12:
            Thur_overtime = Thur1 - 8
        elif 8 < Thur1 > 12:
            Thur_overtime = 4
        else:
            Thur_overtime = 0
        if 8 < Fri1 <= 12:
            Fri_overtime = Fri1 - 8
        elif 8 < Fri1 > 12:
            Fri_overtime = 4
        else:
            Fri_overtime = 0

        # Saturday Overtime and Double-time
        if Weekly_straight_time >= 40 and 12 >= Sat1 > 0:
            Sat_overtime = Sat1
            Sat_double_time = 0
        elif Weekly_straight_time >= 40 and 12 <= Sat1:
            Sat_overtime = 12
            Sat_double_time = Sat1 - 12
        # elif Weekly_straight_time < 40 and Sat1 > 0 and Sat1 + Weekly_straight_time <= 40:
        #   Sat1 + Weekly_straight_time
        elif Weekly_straight_time < 40 and Sat1 > 0 and Sat1 + Weekly_straight_time > 40 and Sat1 <= 12:
            Sat_overtime = ((Sat1 + Weekly_straight_time) - 40)
            # Weekly_straight_time = 40
        elif Weekly_straight_time < 40 and Sat1 > 0 and Sat1 + Weekly_straight_time > 40 and Sat1 > 12:
            Sat_overtime = ((Sat1 + Weekly_straight_time) - 40)
            # Weekly_straight_time = 40
            Sat_double_time = (Sat1 - 12)
        elif Weekly_straight_time < 40 and Sat1 > 0 and Sat1 + Weekly_straight_time <= 40 and Sat1 > 12:
            Sat_overtime = 4
            # Weekly_straight_time = 40
            Sat_double_time = (Sat1 - 12)
        elif Sat1 == 0:
            Sat_overtime = 0
            Sat_double_time = 0
        elif Sat1 < 12:
            Sat_double_time = 0
        else:
            Sat_overtime = 0

        # Add Total Overtime to this point Mon-Sat
        Mon_Sat_Overtime = Mon_overtime + Tue_overtime + Wed_overtime + Thur_overtime + Fri_overtime + Sat_overtime

        # Sunday Overtime
        if Weekly_straight_time >= 40 and 12 >= Sun1 > 0 and (
                Mon_overtime + Tue_overtime + Wed_overtime + Thur_overtime + Fri_overtime + Sat_overtime) < 40 and (
                Sun1 + (
                Mon_overtime + Tue_overtime + Wed_overtime + Thur_overtime + Fri_overtime + Sat_overtime)) <= 40:
            Sun_overtime = Sun1
            Sun_double_time = 0
        elif Weekly_straight_time >= 40 and 12 <= Sun1 > 0 and (
                Mon_overtime + Tue_overtime + Wed_overtime + Thur_overtime + Fri_overtime + Sat_overtime) < 40 and (
                Sun1 + (Mon_overtime + Tue_overtime + Wed_overtime + Thur_overtime + Fri_overtime + Sat_overtime)) > 40:
            Sun_double_time = ((Sun1 + Mon_Sat_Overtime) - 40)
            Overtime = 40
            Sun_overtime = Sun1
        elif Weekly_straight_time >= 40 and 12 <= Sun1 > 0 and (
                Mon_overtime + Tue_overtime + Wed_overtime + Thur_overtime + Fri_overtime + Sat_overtime) < 40 and (
                Sun1 + (Mon_overtime + Tue_overtime + Wed_overtime + Thur_overtime + Fri_overtime + Sat_overtime)) < 40:
            Sun_double_time = Sun1 - 12
            Sun_overtime = 12

        # elif Weekly_straight_time == 40 and 12 >= Sun1:
        #   Sun_overtime = Sun1
        # elif Weekly_straight_time == 40 and 12 < Sun1:
        #  Sun_overtime = 12
        # Sun_double_time = (Sun1 - 12)
        # elif Weekly_straight_time < 40 and Sun1 >0 and Sun1 + Weekly_straight_time <= 40:
        # Sun1 + Weekly_straight_time

        elif Weekly_straight_time < 40 and Sun1 > 0 and Sun1 + Weekly_straight_time > 40 and Sun1 <= 12:
            Sun_overtime = ((Sun1 + Weekly_straight_time) - 40)
            # Weekly_straight_time = 40
        elif Weekly_straight_time < 40 and Sun1 > 0 and Sun1 + Weekly_straight_time > 40 and Sun1 > 12:
            Sun1 = ((12 + Weekly_straight_time) - 40)
            # Weekly_straight_time = 40
            Sun_double_time = (Sat1 - 12)
        elif Weekly_straight_time < 40 and Sun1 > 0 and Sun1 + Weekly_straight_time <= 40 and Sun1 > 12:
            # Sun1 = ((12 + Weekly_straight_time) - 40)
            # Weekly_straight_time = 40
            Sun_double_time = (Sun1 - 12)
            Sun_overtime = 4
        elif Sun1 == 0:
            Sun_double_time = 0
            Sun_overtime = 0

        # Double Time Calculations
        if Mon1 > 12:
            Mon_double_time = Mon1 - 12
        elif Mon1 < 12:
            Mon_double_time = 0
        if Tue1 > 12:
            Tue_double_time = Tue1 - 12
        elif Tue1 < 12:
            Tue_double_time = 0
        if Wed1 > 12:
            Wed_double_time = Wed1 - 12
        elif Wed1 < 12:
            Wed_double_time = 0
        if Thur1 > 12:
            Thur_double_time = Thur1 - 12
        elif Thur1 < 12:
            Thur_double_time = 0
        if Fri1 > 12:
            Fri_double_time = Fri1 - 12
        elif Fri1 < 12:
            Fri_double_time = 0

        Weekly_double_time = (
                    Mon_double_time + Tue_double_time + Wed_double_time + Thur_double_time + Fri_double_time + Sat_double_time + Sun_double_time)
        Weekly_Overtime = (
                    Mon_overtime + Tue_overtime + Wed_overtime + Thur_overtime + Fri_overtime + Sat_overtime + Sun_overtime)
        if Weekly_straight_time <= 40:
            self.lcdNumber.display(Weekly_straight_time)
        else:
            self.lcdNumber.display("40")

        if Weekly_Overtime > 40:
            self.lcdNumber_2.display(Overtime)
        elif Weekly_Overtime <= 40:
            self.lcdNumber_2.display(Weekly_Overtime)
        #self.lcdNumber_3.dispaly(Weekly_double_time)




if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
Quote
#4
Quote:import HourBreakDown import *

that can not work

from HourBreakDown import *
or

import HourBreakDown
Quote
#5
@slighted03 not sure why you cannot find me others have -- did you use the full id DenniO#8137 the name, #, and number are all required when you do a friend request -- otherwise post your Discord complete Id and I will shoot you the friend request.

Next as a big word of warning you should stop using the Designer to create your GUI soon or later you are going to go through some major pain when you are trying to do something and cannot because you chose to use the Designer -- either that you are going to have to do unnecessary coding back-flips and somersaults to get something rather simple done. So far all 11 students have come to this realization some more painfully than others ;) -- as well as a few folks online that I shared with how to code a pyqt GUI from scratch the way its supposed to be created -- they also found it was even easier than using the Designer and as quick or quicker.

As for your Import issue it appears @Axel_Erfurt has you covered there :)
silly American kah-nig-hit
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] hour format geckoes 1 160 Jul-17-2019, 01:58 PM
Last Post: ichabod801

Forum Jump:


Users browsing this thread: 1 Guest(s)