コード例 #1
0
 def __init__(self):
   super().__init__()
   self.setStyleSheet("""
   QWidget{
     color:#c7c7c7;
     font-weight: bold;
   }
   QPushButton{
     background-color: rgba(0, 0, 0, 0);
     border: 1px solid;
     font-size: 18px;
     font-weight: bold;
     border-color: #808080;
     min-height: 28px;
     white-space:nowrap;
     text-align: left;
     padding-left: 5%;
     font-family: Montserrat;
   }
   QPushButton:hover:!pressed{
     border: 2px solid;
     border-color: #747474;
   }
   QPushButton:pressed{
     border: 2px solid;
     background-color: #323232;
     border-color: #6C6C6C;
   }""")
   self.db_wrapper = DatabaseWrapper()
   self.table_name = "Workouts"
   self.db_wrapper.create_local_table(self.table_name)
   if self.db_wrapper.local_table_is_empty(self.table_name): self.db_wrapper.insert_default_values(self.table_name)
   self.fetched_my_workouts = json.loads(self.db_wrapper.fetch_local_column(self.table_name, "my_workouts"))
   self.create_panel()
コード例 #2
0
 def __init__(self, parent):
     super().__init__(parent)
     self.db_wrapper = DatabaseWrapper()
     self.create_panel()
     self.setMaximumWidth(201)
     self.setStyleSheet("""
                    QPushButton{
                      text-align: center;
                      background-color: #440D0F;
                      border-radius: 3px;
                      min-height: 23px;
                      min-width: 180px;
                      color: #c7c7c7;
                      font: 15px;
                      font-weight:500;
                      font-family:Montserrat;
                      padding-bottom: 3px;
                      }
                    QPushButton:hover:!pressed{
                      background-color: #5D1A1D
                    }
                    QPushButton:pressed{
                      background-color: #551812
                    }
                    """)
コード例 #3
0
 def __init__(self, email, password):
     super().__init__()
     self.setStyleSheet("""
 QWidget{
   background-position: center;
   color: #D9D9D9;
   font-family: Montserrat;
   font-size: 14px;
 }
 QPushButton{
   border-radius: 1px;
   background-color: #440D0F;
 }
 QPushButton:hover:!pressed{
   background-color: #5D1A1D
 }
 QPushButton:pressed{
   background-color: #551812
 }    
 QLineEdit{
   padding: 6px;
   background-color: rgb(33,33,33);
   border-radius: 2px;
 }
 QComboBox{
   border-radius: 4px;
   font-size: 18px;
   font-weight: bold;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
   min-height: 28px;
   background-color: #440D0F;
 }
 QComboBox:down-arrow{
   width: 0px;
   height: 0px;
   background: #d3d3d3; 
   opacity:0
 }
 QComboBox:drop-down{
   background-color: #440D0F;
   border: 0px;
   opacity:0;
   border-radius: 0px;
   width: 0px;
   height: 0px;
 }
 QComboBox:hover:!pressed{
   background-color: #5D1A1D;
 }
 QComboBox:pressed{
   background-color: #551812;
 }
 """)
     self.db_wrapper = DatabaseWrapper()
     self.email = email
     self.password = password
     self.create_panel()
コード例 #4
0
    def __init__(self, table_name, db_path="test.db"):
        self.test_user = {
            "email":
            "*****@*****.**",
            "password":
            hashlib.sha256("testpassword123".encode('UTF-8')).hexdigest(),
            "name":
            "Test",
            "age":
            "18",
            "gender":
            "male",
            "units":
            "metric",
            "weight":
            "100",
            "height":
            "190",
            "goal":
            "Weight gain",
            "goalparams":
            json.dumps(["Moderately active", 0.25]),
            "goalweight":
            "120"
        }

        self.test_password = "******"
        self.db_path = db_path
        self.table_name = table_name

        self.db_wrapper = DatabaseWrapper(self.db_path)
        self.sqlite_connection = self.db_wrapper.sqlite_connection
        self.sqlite_cursor = self.sqlite_connection.cursor()
        self.pg_connection = self.db_wrapper.pg_connection
        self.pg_cursor = self.pg_connection.cursor()
コード例 #5
0
 def __init__(self):
   super().__init__()
   self.db_wrapper = DatabaseWrapper()
   self.setStyleSheet("""
   QWidget{
     background-position: center;
     font-family: Montserrat;
     color: #D9D9D9;
     font-size: 14px;
   }
   QPushButton{
     border-radius: 1px;
     background-color: #440D0F;
   }
   QPushButton:hover:!pressed{
     background-color: #5D1A1D
   }
   QPushButton:pressed{
     background-color: #551812
   }    
   QLineEdit{
     padding: 6px;
     background-color: rgb(33,33,33);
     border-radius: 2px;
   }
   """)
   self.create_panel()
コード例 #6
0
 def __init__(self, parent, search_results):
     super().__init__(parent)
     self.query_number = 6
     self.search = search_results[1]
     self.search_results = search_results[0]
     self.create_panel()
     self.setStyleSheet("QLabel{color:white;}")
     self.db_wrapper = DatabaseWrapper()
コード例 #7
0
 def setUp(self):
   self.test_class = TestClass("big_lifts", "test.db")
   self.db_wrapper = DatabaseWrapper("test.db")
   
   self.table_name = "Compound Exercises"
   self.test_class.create_test_user()
   self.db_wrapper.create_local_table("Compound Exercises")
   self.db_wrapper.insert_default_values("Compound Exercises")
コード例 #8
0
    def __init__(self, to_edit, old_value, fitness_goal=None, date=None):
        super().__init__()
        assert to_edit in ("Current Weight", "Weight Goal", "Loss Per Week",
                           "Time Spent", "Distance Travelled")
        if to_edit == "Loss Per Week":
            assert fitness_goal != None
            self.fitness_goal = fitness_goal
        elif to_edit == "Current Weight":
            assert date != None
            self.date = date

        self.db_wrapper = DatabaseWrapper()
        self.table_name = "Weight Loss"
        self.to_edit = to_edit
        self.old_value = old_value
        self.current_date = datetime.today().strftime("%d/%m/%Y")
        self.setStyleSheet("""QWidget{
      background-color: #232120;
      color:#c7c7c7;
      font-weight: bold;
      font-family: Montserrat;
      font-size: 16px;
      }
    QPushButton{
      background-color: rgba(0, 0, 0, 0);
      border: 1px solid;
      font-size: 18px;
      font-weight: bold;
      border-color: #808080;
      min-height: 28px;
      white-space:nowrap;
      text-align: left;
      padding-left: 5%;
      font-family: Montserrat;
    }
    QPushButton:hover:!pressed{
      border: 2px solid;
      border-color: #747474;
    }
    QPushButton:pressed{
      border: 2px solid;
      background-color: #323232;
      border-color: #6C6C6C;
    }
    QLineEdit{
      padding: 6px;
      background-color: rgb(33,33,33);
      border: 1px solid;
      border-color: #cdcdcd;
    }""")
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
        self.setWindowModality(Qt.ApplicationModal)
        self.setWindowTitle("".join(["Edit ", self.to_edit]))
        self.layout = QVBoxLayout()
        self.layout.addLayout(self.create_layout())
        self.setLayout(self.layout)
コード例 #9
0
 def __init__(self, layout_name):
     super().__init__()
     self.main_panel = ExercisesAndWorkouts(
     ) if layout_name == "Exercises and Workouts" else WorkoutPlanner()
     if layout_name == "Exercises and Workouts" and DatabaseWrapper(
     ).connection_exists:
         self.main_panel.show_muscle_group_signal.connect(
             lambda muscle_group: self.show_muscle_group_layout(muscle_group
                                                                ))
     self.side_panel = SidePanel(self)
     self.side_panel.emit_layout_name.connect(
         lambda layout_name: self.emit_display_layout_signal(layout_name))
     self.create_grid()
コード例 #10
0
  def __init__(self, month, year, parent=None, width=5, height=4, dpi=100):
    figure = Figure(figsize=(width, height), dpi=dpi, tight_layout=True)
    FigureCanvas.__init__(self, figure)
    self.current_month = month
    self.current_year = year
    self.set_parent = parent
    self.db_wrapper = DatabaseWrapper()
    self.weight_history = json.loads(self.db_wrapper.fetch_local_column("Weight Loss", "weight_history"))

    self.axes = figure.subplots(nrows=1, ncols=1)
    self.create_figure()
    FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding)
    FigureCanvas.updateGeometry(self)
コード例 #11
0
ファイル: __main__.py プロジェクト: JuricaRT/fitness_tracker
    def __init__(self):
        super().__init__()
        self.setWindowIcon(QIcon(icon_path))
        QFontDatabase.addApplicationFont(
            os.path.join(os.path.dirname(__file__), "font",
                         "Montserrat-Regular.ttf"))
        QFontDatabase.addApplicationFont(
            os.path.join(os.path.dirname(__file__), "font",
                         "Ubuntu-Regular.ttf"))
        if getattr(sys, 'frozen', False):
            QFontDatabase.addApplicationFont(
                os.path.join(os.path.dirname(sys.executable), "font",
                             "Montserrat-Regular.ttf"))
            QFontDatabase.addApplicationFont(
                os.path.join(os.path.dirname(sys.executable), "font",
                             "Ubuntu-Regular.ttf"))

        self.db_wrapper = DatabaseWrapper()

        self.create_window()
        if self.db_wrapper.local_table_exists("Users"):
            if not self.db_wrapper.one_logged_in_user(): self.cw = Login()
            else: self.cw = BigLiftsNotes()
        else:
            self.cw = Login()
        self.cw.display_layout_signal.connect(
            lambda layout: self.display_layout(layout))
        self.layouts = {
            "Login": Login,
            "Signup": Signup,
            "Continue": SignupQuestions,
            "Profile": Profile,
            "Logout": Login,
            "Compound Exercises": BigLiftsNotes,
            "Workout Planner": WorkoutsNotes,
            "Exercises and Workouts": WorkoutsNotes,
            "Nutrition": NutritionNotes,
            "Weight Loss": WeightLossNotes,
            "1 Rep Max Calculator": OneRepMaxCalculator,
            "Body Fat Calculator": BodyFatCalculator,
            "Strength Estimator": StrengthEstimator,
            "Food Database": FoodDB
        }
        self.colorize_background()
        self.colorize_foreground()
        self.setup_borders()
        self.title_bar = TitleBar(self)
        self.setMouseTracking(True)
        #add funct that generates default config file if 'settings.ini' isn't found
        main_widget = self.setup_main_layout()
        self.setCentralWidget(main_widget)
コード例 #12
0
    def __init__(self):
        super().__init__()
        self.db_wrapper = DatabaseWrapper()
        self.table_name = "Weight Loss"
        self.setStyleSheet("""
    QWidget{
      background-color: #232120;
      font-weight: bold;
      color:#c7c7c7;
    }
    QPushButton{
      background-color: rgba(0, 0, 0, 0);
      border: 1px solid;
      font-size: 18px;
      font-weight: bold;
      border-color: #808080;
      min-height: 28px;
      white-space:nowrap;
      text-align: center;
      padding-left: 5%;
      font-family: Montserrat;
    }
    QPushButton:hover:!pressed{
      border: 2px solid;
      border-color: #747474;
    }
    QPushButton:pressed{
      border: 2px solid;
      background-color: #323232;
    }
    """)
        self.units = "kg" if self.db_wrapper.fetch_local_column(
            "Users", "units") == "metric" else "lb"
        self.cardio_history = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name,
                                               "cardio_history"))
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
        self.setWindowModality(Qt.ApplicationModal)
        self.setWindowTitle("Cardio History")

        widget = QWidget()
        self.layout = QGridLayout(widget)
        self.setWidget(widget)
        self.setWidgetResizable(True)

        self.entry_count = 0
        for date in self.cardio_history:
            for activity in self.cardio_history[date]:
                self.entry_count += len(self.cardio_history[date][activity])
        self.create_history(True, True)
コード例 #13
0
 def __init__(self, parent):
     super().__init__()
     self.db_wrapper = DatabaseWrapper()
     self.setStyleSheet("""
 QWidget{
   font-family: Montserrat;
   color:#c7c7c7;
   font-weight: bold;      
   font-size:12px;
 }
 QPushButton{
   background-color: rgba(0, 0, 0, 0);
   border: 1px solid;
   font-size: 18px;
   font-weight: bold;
   border-color: #808080;
   min-height: 28px;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
 }
 QPushButton:hover:!pressed{
   border: 2px solid;
   border-color: #747474;
 }
 QPushButton:pressed{
   border: 2px solid;
   background-color: #323232;
   border-color: #6C6C6C;
 }
 QLineEdit{
   padding: 6px;
   background-color: rgb(33,33,33);
   border-radius: 2px;
 }
 QTableWidget{
   background-color: rgb(33,33,33);  
   border: 1px solid;
   border-color: rgb(88, 88, 88);
   font-size: 14px;
 }
 QHeaderView:section{
   background-color: rgb(54,54,54);  
   border: 1px solid;
   border-color: rgb(88, 88, 88)
 }
 """)
     self.create_panel()
コード例 #14
0
 def __init__(self, lift_type, rm_history, year, parent=None, width=5, height=4, dpi=100):
   assert lift_type in ["Horizontal Press", "Floor Pull", "Squat", "Vertical Press"], "Invalid lift type: '%s'" % lift_type
   self.db_wrapper = DatabaseWrapper()
   self.lift_type = lift_type
   self.rm_history = rm_history
   self.year = year
   
   fig = Figure(figsize=(width, height), dpi=dpi, tight_layout=True)
   FigureCanvas.__init__(self, fig)
   
   self.axes = fig.subplots(nrows=1, ncols=1)
   self.create_figure()
   self.set_parent = parent
   FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding)
   FigureCanvas.updateGeometry(self)
コード例 #15
0
 def __init__(self):
     super().__init__()
     self.db_wrapper = DatabaseWrapper()
     self.table_name = "Nutrition"
     self.user_data = self.db_wrapper.fetch_local_user_info()
     self.user_weight = self.user_data["Weight"]
     self.goal_weight = self.user_data["Weight Goal"]
     goal_parameters = self.user_data["Goal Params"]
     self.goal = self.user_data["Goal"]
     self.activity_level = goal_parameters[0]
     self.weight_per_week = goal_parameters[1]
     self.age = self.user_data["Age"]
     self.gender = self.user_data["Gender"]
     self.height = self.user_data["Height"]
     self.setWindowTitle("Edit weight")
     self.create_layout()
コード例 #16
0
 def __init__(self, cardio_history, date, activity, index):
     super().__init__()
     self.db_wrapper = DatabaseWrapper()
     self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
     self.setWindowModality(Qt.ApplicationModal)
     self.table_name = "Weight Loss"
     self.cardio_history = cardio_history
     self.date = date
     self.activity = activity
     self.index = index
     self.entry = self.cardio_history[self.date][self.activity][self.index]
     self.setStyleSheet("""
 QWidget{
   background-color: #322d2d;
   font-weight: bold;
   color:#c7c7c7;
 }
 QPushButton{
   background-color: rgba(0, 0, 0, 0);
   border: 1px solid;
   font-size: 18px;
   font-weight: bold;
   border-color: #808080;
   min-height: 28px;
   white-space:nowrap;
   text-align: center;
   padding-left: 5%;
   font-family: Montserrat;
 }
 QPushButton:hover:!pressed{
   border: 2px solid;
   border-color: #747474;
 }
 QPushButton:pressed{
   border: 2px solid;
   background-color: #323232;
 }
 """)
     self.units = "kg" if self.db_wrapper.fetch_local_column(
         "Users", "units") == "metric" else "lb"
     self.cardio_history = json.loads(
         self.db_wrapper.fetch_local_column(self.table_name,
                                            "cardio_history"))
     self.setWindowModality(Qt.ApplicationModal)
     self.setWindowFlags(Qt.Tool)
     self.setWindowTitle("Edit Cardio History Entry")
     self.create_layout()
コード例 #17
0
 def __init__(self, age, gender, height, weight, activity_level, goal, weight_per_week):
   self.db_wrapper = DatabaseWrapper()
   self.units = self.db_wrapper.fetch_local_column("Users", "units")
   self.age = age
   self.gender = gender
   activity_factors = {"Maintain": 1, "Sedentary": 1.2, "Lightly active": 1.375,
                       "Moderately active": 1.550, "Very active": 1.725,
                       "Extra active": 1.9}
   self.activity_level = activity_factors[activity_level]
   if self.units == "imperial":
     self.height = imperial_to_metric_height(height["feet"], height["inches"])
     self.weight = pounds_to_kg(weight)
   else:
     self.height = height
     self.weight = weight
   self.goal = goal
   self.weight_per_week = weight_per_week
コード例 #18
0
    def __init__(self):
        super().__init__()
        self.setStyleSheet("""
    QWidget{
      color:#c7c7c7;
      font-weight: bold;
    }
    QPushButton{
      background-color: rgba(0, 0, 0, 0);
      border: 1px solid;
      font-size: 18px;
      font-weight: bold;
      border-color: #808080;
      min-height: 28px;
      white-space:nowrap;
      text-align: left;
      padding-left: 5%;
      font-family: Montserrat;
    }
    QPushButton:hover:!pressed{
      border: 2px solid;
      border-color: #747474;
    }
    QPushButton:pressed{
      border: 2px solid;
      background-color: #323232;
      border-color: #6C6C6C;
    }""")

        self.db_wrapper = DatabaseWrapper()
        self.table_name = "Workouts"
        self.db_wrapper.create_local_table(self.table_name)
        if self.db_wrapper.local_table_is_empty(self.table_name):
            self.db_wrapper.insert_default_values(self.table_name)
        self.fetched_workouts = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name, "workouts"))
        self.current_date = datetime.today().strftime("%d/%m/%Y")
        if not self.current_date in self.fetched_workouts:
            self.fetched_workouts[self.current_date] = {
                "Personal Notes": "",
                "Workout Name": "None"
            }
            self.db_wrapper.update_table_column(
                self.table_name, "workouts", json.dumps(self.fetched_workouts))
        self.create_panel()
コード例 #19
0
 def __init__(self, parent, edit_func):
     super().__init__()
     self.edit_func = edit_func
     self.this_parent = parent
     self.db_wrapper = DatabaseWrapper()
     self.setStyleSheet("""QWidget{
   background-color: #232120;
   color:#c7c7c7;
   font-weight: bold;
   font-family: Montserrat;
   font-size: 16px;
   }
 QPushButton{
   background-color: rgba(0, 0, 0, 0);
   border: 1px solid;
   font-size: 18px;
   font-weight: bold;
   border-color: #808080;
   min-height: 28px;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
 }
 QPushButton:hover:!pressed{
   border: 2px solid;
   border-color: #747474;
 }
 QPushButton:pressed{
   border: 2px solid;
   background-color: #323232;
   border-color: #6C6C6C;
 }
 QLineEdit{
   padding: 6px;
   background-color: rgb(33,33,33);
   border: 1px solid;
   border-color: #cdcdcd;
 }""")
     dialog_layout = QVBoxLayout()
     self.setWindowFlags(Qt.FramelessWindowHint)
     dialog_layout.addLayout(self.create_input_window())
     self.setLayout(dialog_layout)
コード例 #20
0
 def __init__(self, parent, edit_func, parameter):
     super().__init__()
     self.edit_func = edit_func
     self.this_parent = parent
     self.parameter = parameter  # goal or gender
     self.db_wrapper = DatabaseWrapper()
     self.setStyleSheet("""QWidget{
   background-color: #232120;
   color:#c7c7c7;
   font-weight: bold;
   font-family: Montserrat;
   font-size: 16px;
   }
 QPushButton{
   background-color: rgba(0, 0, 0, 0);
   border: 1px solid;
   font-size: 18px;
   font-weight: bold;
   border-color: #808080;
   min-height: 28px;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
 }
 QPushButton:hover:!pressed{
   border: 2px solid;
   border-color: #747474;
 }
 QPushButton:pressed{
   border: 2px solid;
   background-color: #323232;
   border-color: #6C6C6C;
 }""")
     dialog_layout = QVBoxLayout()
     self.setWindowFlags(Qt.FramelessWindowHint)
     self.setLayout(dialog_layout)
     if self.edit_func == "gender":
         layout = self.create_radio_button_gender()
     elif self.edit_func == "goal":
         layout = self.create_radio_button_goal()
     dialog_layout.addLayout(layout)
コード例 #21
0
 def __init__(self, workout_name=None, one_time=False, date=None):
   super().__init__()
   self.setStyleSheet("""
   QWidget{
     background-color: #232120;
     font-weight: bold;
     color:#c7c7c7;
   }
   QPushButton{
     background-color: rgba(0, 0, 0, 0);
     border: 1px solid;
     font-size: 18px;
     font-weight: bold;
     border-color: #808080;
     min-height: 28px;
     white-space:nowrap;
     text-align: center;
     padding-left: 5%;
     font-family: Montserrat;
   }
   QPushButton:hover:!pressed{
     border: 2px solid;
     border-color: #747474;
   }
   QPushButton:pressed{
     border: 2px solid;
     background-color: #323232;
   }
   """)
   self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
   self.setWindowModality(Qt.ApplicationModal)
   if workout_name != None:
     self.setWindowTitle("Edit Workout")
   else:
     self.setWindowTitle("Create a New Workout")
   self.db_wrapper = DatabaseWrapper()
   self.table_name = "Workouts"
   self.workout_name = workout_name
   self.one_time = one_time
   self.current_date = date
   self.fetched_my_workouts = json.loads(self.db_wrapper.fetch_local_column(self.table_name, "my_workouts"))
   self.create_panel()
コード例 #22
0
 def __init__(self):
     super().__init__()
     self.db_wrapper = DatabaseWrapper()
     self.table_name = "Compound Exercises"
     self.setStyleSheet("""
 QWidget{
   background-color: #232120;
   font-weight: bold;
   color:#c7c7c7;
 }
 QPushButton{
   background-color: rgba(0, 0, 0, 0);
   border: 1px solid;
   font-size: 18px;
   font-weight: bold;
   border-color: #808080;
   min-height: 28px;
   white-space:nowrap;
   text-align: center;
   padding-left: 5%;
   font-family: Montserrat;
 }
 QPushButton:hover:!pressed{
   border: 2px solid;
   border-color: #747474;
 }
 QPushButton:pressed{
   border: 2px solid;
   background-color: #323232;
 }
 """)
     self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
     self.setWindowModality(Qt.ApplicationModal)
     self.units = "kg" if self.db_wrapper.fetch_local_column(
         "Users", "units") == "metric" else "lb"
     self.preferred_lifts = json.loads(
         self.db_wrapper.fetch_local_column(self.table_name,
                                            "preferred_lifts"))
     self.setWindowTitle("Update Lifts For Reps")
     self.setLayout(self.create_panel())
     self.set_line_edit_values()
コード例 #23
0
ファイル: titlebar.py プロジェクト: JuricaRT/fitness_tracker
    def __init__(self, parent):
        super(TitleBar, self).__init__()
        self.parent = parent
        self.db_wrapper = DatabaseWrapper()
        self.layout = QHBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.title = QLabel("Fitness Tracker")
        try:
            self.username = self.db_wrapper.fetch_local_column("Users", "name")
        except:
            self.username = None
        if self.username == None:
            self.version = QLabel()
        else:
            self.version = QLabel("-" + self.username)

        self.setFixedHeight(25)

        self.gridlayout = QHBoxLayout()
        self.gridlayout.setContentsMargins(0, 0, 0, 0)

        slight_indent = QSpacerItem(4, 0, QSizePolicy.Minimum,
                                    QSizePolicy.Expanding)
        version_space = QSpacerItem(20, 0, QSizePolicy.Minimum,
                                    QSizePolicy.Expanding)

        title_font_size = 14
        title_font = QFont('Ubuntu', title_font_size)
        self.title.setFont(title_font)

        self.version.setFont(title_font)
        self.version.setStyleSheet("color: #A5A5A5;")

        icon_max_size_x = 32
        icon_max_size_y = 24

        self.close_icon = QIcon(icons["close"])
        self.close_button = QPushButton()
        self.close_button.clicked.connect(self.close_click)
        self.close_button.setIcon(self.close_icon)
        self.close_button.setMaximumSize(icon_max_size_x, icon_max_size_y)
        self.close_button.setStyleSheet(
            "QPushButton{ background-color: rgba(237, 17, 17, 0); }"
            "QPushButton:hover{ background-color: rgba(237, 17, 17, 75); }"
            "QPushButton:pressed{ background-color: rgba(255, 0, 0, 100); }")

        self.minimise_icon = QIcon(icons["min"])
        self.minimise_button = QPushButton()
        self.minimise_button.clicked.connect(self.min_click)
        self.minimise_button.setIcon(self.minimise_icon)
        self.minimise_button.setMaximumSize(icon_max_size_x, icon_max_size_y)
        self.minimise_button.setStyleSheet(
            "QPushButton{ background-color: rgba(255, 255, 255, 0); }"
            "QPushButton:hover{ background-color: rgba(255, 255, 255, 70); }"
            "QPushButton:pressed{ background-color: rgba(255, 255, 255, 40); }"
        )

        self.maximize_icon = QIcon(icons["max"])
        self.unmax_icon = QIcon(icons["small"])
        self.maximize_button = QPushButton()
        self.maximize_button.setIcon(self.maximize_icon)
        self.maximize_button.clicked.connect(self.max_click)
        self.maximize_button.setMaximumSize(icon_max_size_x, icon_max_size_y)
        self.maximize_button.setStyleSheet(
            "QPushButton{ background-color: rgba(255, 255, 255, 0); }"
            "QPushButton:hover{ background-color: rgba(255, 255, 255, 70); }"
            "QPushButton:pressed{ background-color: rgba(255, 255, 255, 40); }"
        )

        self.settings_icon = QIcon(icons["settings"])
        self.settings_button = QPushButton()
        self.settings_button.setIcon(self.settings_icon)
        self.settings_button.setMaximumSize(icon_max_size_x, icon_max_size_y)
        self.settings_button.setStyleSheet(
            "QPushButton{ background-color: rgba(255, 255, 255, 0); }"
            "QPushButton:hover{ background-color: rgba(255, 255, 255, 70); }"
            "QPushButton:pressed{ background-color: rgba(255, 255, 255, 40); }"
        )
        self.settings_button.clicked.connect(self.showSettings)

        self.settings_button.setObjectName("SettingsButton")

        self.layout.addItem(slight_indent)
        self.layout.addWidget(self.title)
        self.layout.addItem(version_space)
        self.layout.addWidget(self.version)

        if not self.db_wrapper.connection_exists:
            self.layout.addItem(
                QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding))
            connection_label = QLabel(
                "No internet connection. Changes will not be saved!")
            connection_label.setStyleSheet("color: red;")
            connection_label.setFont(title_font)
            self.layout.addWidget(connection_label)

        self.layout.addStretch(-1)

        self.gridlayout.addLayout(self.layout)
        self.gridlayout.addStretch(1)
        self.gridlayout.setSpacing(0)
        self.gridlayout.addWidget(self.settings_button)
        self.gridlayout.addWidget(self.minimise_button)
        self.gridlayout.addWidget(self.maximize_button)
        self.gridlayout.addWidget(self.close_button)
        self.setLayout(self.gridlayout)

        self.start = QPoint(0, 0)
        self.pressing = False
        self.maximized = False
コード例 #24
0
 def __init__(self, parent):
     super().__init__(parent)
     self.db_wrapper = DatabaseWrapper()
     self.user_data = self.db_wrapper.fetch_local_user_info()
     self.setStyleSheet("""QWidget{
   color:#c7c7c7;
   font-weight: bold;
   font-family: Montserrat;
   font-size: 16px;
   }
 QPushButton{
   background-color: rgba(0, 0, 0, 0);
   border: 1px solid;
   font-size: 18px;
   font-weight: bold;
   border-color: #808080;
   min-height: 28px;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
 }
 QPushButton:hover:!pressed{
   border: 2px solid;
   border-color: #747474;
 }
 QPushButton:pressed{
   border: 2px solid;
   background-color: #323232;
   border-color: #6C6C6C;
 }
 QComboBox{
   border-radius: 4px;
   font-size: 18px;
   font-weight: bold;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
   min-height: 28px;
   background-color: #440D0F;
 }
 QComboBox:down-arrow{
   width: 0px;
   height: 0px;
   background: #d3d3d3; 
   opacity:0
 }
 QComboBox:drop-down{
   background-color: #440D0F;
   border: 0px;
   opacity:0;
   border-radius: 0px;
   width: 0px;
   height: 0px;
 }
 QComboBox:hover:!pressed{
   background-color: #5D1A1D;
 }
 QComboBox:pressed{
   background-color: #551812;
 }""")
     self.create_panel()
コード例 #25
0
    def __init__(self, parent):
        super().__init__(parent)
        self.db_wrapper = DatabaseWrapper()
        self.table_name = "Compound Exercises"
        self.setStyleSheet("""
    QWidget{
      color:#c7c7c7;
      font-weight: bold;
    }
    QPushButton{
      background-color: rgba(0, 0, 0, 0);
      border: 1px solid;
      font-size: 18px;
      font-weight: bold;
      border-color: #808080;
      min-height: 28px;
      white-space:nowrap;
      text-align: left;
      padding-left: 5%;
      font-family: Montserrat;
    }
    QPushButton:hover:!pressed{
      border: 2px solid;
      border-color: #747474;
    }
    QPushButton:pressed{
      border: 2px solid;
      background-color: #323232;
      border-color: #6C6C6C;
    }
    QComboBox{
      border-radius: 4px;
      font-size: 18px;
      font-weight: bold;
      white-space:nowrap;
      text-align: left;
      padding-left: 5%;
      font-family: Montserrat;
      min-height: 28px;
      background-color: #440D0F;
    }
    QComboBox:down-arrow{
      width: 0px;
      height: 0px;
      background: #d3d3d3; 
      opacity:0
    }
    QComboBox:drop-down{
      background-color: #440D0F;
      border: 0px;
      opacity:0;
      border-radius: 0px;
      width: 0px;
      height: 0px;
    }
    QComboBox:hover:!pressed{
      background-color: #5D1A1D;
    }
    QComboBox:pressed{
      background-color: #551812;
    }
    """)
        self.current_year = str(datetime.now().year)
        self.db_wrapper.create_local_table(self.table_name)
        if self.db_wrapper.local_table_is_empty(self.table_name):
            self.db_wrapper.insert_default_values(self.table_name)

        self.units = "kg" if self.db_wrapper.fetch_local_column(
            "Users", "units") == "metric" else "lb"
        big_lifts_units = "kg" if self.db_wrapper.fetch_local_column(
            self.table_name, "units") == "metric" else "lb"

        one_rep_maxes = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name,
                                               "one_rep_maxes"))
        lifts_for_reps = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name,
                                               "lifts_for_reps"))
        self.rm_history = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name, "rm_history"))

        if not self.current_year in self.rm_history:
            self.add_year_to_rm_history(self.current_year)
            self.rm_history = json.loads(
                self.db_wrapper.fetch_local_column(self.table_name,
                                                   "rm_history"))

        if self.units != big_lifts_units:
            units_name = "metric" if self.units == "kg" else "imperial"
            self.db_wrapper.update_table_column(self.table_name, "units",
                                                units_name)
            if units_name == "metric":
                for exercise, weight in one_rep_maxes.items():
                    one_rep_maxes[exercise] = str(pounds_to_kg(weight))
                for exercise, reps_and_weight in lifts_for_reps.items():
                    lifts_for_reps[exercise] = [
                        reps_and_weight[0],
                        str(pounds_to_kg(reps_and_weight[1]))
                    ]

            elif units_name == "imperial":
                for exercise, weight in one_rep_maxes.items():
                    one_rep_maxes[exercise] = str(kg_to_pounds(weight))
                for exercise, reps_and_weight in lifts_for_reps.items():
                    lifts_for_reps[exercise] = [
                        reps_and_weight[0],
                        str(kg_to_pounds(reps_and_weight[1]))
                    ]

            for year in self.rm_history:
                for month in self.rm_history[year]:
                    for exercise_type in list(self.rm_history[year][month]):
                        for exercise in list(
                                self.rm_history[year][month][exercise_type]):
                            for i, weight in enumerate(
                                    self.rm_history[year][month][exercise_type]
                                [exercise]):
                                if units_name == "imperial":
                                    self.rm_history[year][month][
                                        exercise_type][exercise][i] = str(
                                            kg_to_pounds(weight))
                                elif units_name == "metric":
                                    self.rm_history[year][month][
                                        exercise_type][exercise][i] = str(
                                            pounds_to_kg(weight))

            self.db_wrapper.update_table_column(self.table_name,
                                                "one_rep_maxes", one_rep_maxes)
            self.db_wrapper.update_table_column(self.table_name,
                                                "lifts_for_reps",
                                                lifts_for_reps)
            self.convert_lift_history_weight(self.units)

        self.one_RM = [[lift, " ".join([weight, self.units])]
                       for lift, weight in one_rep_maxes.items()]
        self.lifts_reps = [[lift, " ".join(["x".join(weight), self.units])]
                           for lift, weight in lifts_for_reps.items()]

        self.lift_history_window = LiftHistory()
        self.lift_history_window.setGeometry(100, 200, 300, 300)

        self.plists_window = PreferredLifts()
        self.plists_window.change_lifts_signal.connect(
            self.changed_preferred_lifts)

        self.update_1RM_window = Update1RMWindow()
        self.update_1RM_window.change_1RM_lifts_signal.connect(
            self.changed_1RM_lifts)
        self.update_1RM_window.history_signal.connect(
            lambda signal: self.lift_history_window.create_history(signal))
        self.update_1RM_window.update_graph_signal.connect(
            lambda signal: self.refresh_graph(signal))

        self.lifts_for_reps = UpdateLiftsForRepsWindow()
        self.lifts_for_reps.change_lifts_for_reps_signal.connect(
            self.changed_lifts_for_reps)
        self.lifts_for_reps.history_signal.connect(
            lambda signal: self.lift_history_window.create_history(signal))

        self.preferred_lifts = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name,
                                               "preferred_lifts"))
        self.one_rep_maxes = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name,
                                               "one_rep_maxes"))
        self.create_panel()
コード例 #26
0
 def __init__(self):
     super().__init__()
     self.db_wrapper = DatabaseWrapper()
     self.table_name = "Compound Exercises"
     self.setStyleSheet("""
 QWidget{
   background-color: #232120;
   font-weight: bold;
   color:#c7c7c7;      
 }
 QPushButton{
   background-color: rgba(0, 0, 0, 0);
   border: 1px solid;
   font-size: 18px;
   font-weight: bold;
   border-color: #808080;
   min-height: 28px;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
 }
 QPushButton:hover:!pressed{
   border: 2px solid;
   border-color: #747474;
 }
 QPushButton:pressed{
   border: 2px solid;
   background-color: #323232;
   border-color: #6C6C6C;
 }
 QComboBox{
   border-radius: 4px;
   font-size: 18px;
   font-weight: bold;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
   min-height: 28px;
   background-color: #440D0F;
 }
 QComboBox:down-arrow{
   width: 0px;
   height: 0px;
   background: #d3d3d3; 
   opacity:0
 }
 QComboBox:drop-down{
   background-color: #440D0F;
   border: 0px;
   opacity:0;
   border-radius: 0px;
   width: 0px;
   height: 0px;
 }
 QComboBox:hover:!pressed{
   background-color: #5D1A1D;
 }
 QComboBox:pressed{
   background-color: #551812;
 }
 """)
     self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool)
     self.setWindowModality(Qt.ApplicationModal)
     self.setWindowTitle("Edit Preferred Lifts")
     self.preferred_lifts = json.loads(
         self.db_wrapper.fetch_local_column(self.table_name,
                                            "preferred_lifts"))
     self.setLayout(self.create_panel())
     self.set_preferred_lifts()
コード例 #27
0
    def __init__(self, parent):
        super().__init__(parent)
        self.db_wrapper = DatabaseWrapper()
        self.table_name = "Weight Loss"
        self.setStyleSheet("""
    QWidget{
      color:#c7c7c7;
      font-weight: bold;
    }
    QPushButton{
      background-color: rgba(0, 0, 0, 0);
      border: 1px solid;
      font-size: 18px;
      font-weight: bold;
      border-color: #808080;
      min-height: 28px;
      white-space:nowrap;
      text-align: left;
      padding-left: 5%;
      font-family: Montserrat;
    }
    QPushButton:hover:!pressed{
      border: 2px solid;
      border-color: #747474;
    }
    QPushButton:pressed{
      border: 2px solid;
      background-color: #323232;
      border-color: #6C6C6C;
    }
    QComboBox{
      border-radius: 4px;
      font-size: 18px;
      font-weight: bold;
      white-space:nowrap;
      text-align: left;
      padding-left: 5%;
      font-family: Montserrat;
      min-height: 28px;
      background-color: #440D0F;
    }
    QComboBox:down-arrow{
      width: 0px;
      height: 0px;
      background: #d3d3d3; 
      opacity:0
    }
    QComboBox:drop-down{
      background-color: #440D0F;
      border: 0px;
      opacity:0;
      border-radius: 0px;
      width: 0px;
      height: 0px;
    }
    QComboBox:hover:!pressed{
      background-color: #5D1A1D;
    }
    QComboBox:pressed{
      background-color: #551812;
    }
    """)

        self.db_wrapper.create_local_table(self.table_name)
        self.db_wrapper.create_local_table("Nutrition")

        if self.db_wrapper.local_table_is_empty("Nutrition"):
            self.db_wrapper.insert_default_values("Nutrition")

        if self.db_wrapper.local_table_is_empty(self.table_name):
            self.db_wrapper.insert_default_values(self.table_name)

        self.fetch_user_data()
        self.date = datetime.today().strftime("%d/%m/%Y")
        self.current_year = datetime.today().year
        self.calorie_goal = self.db_wrapper.fetch_local_column(
            "Nutrition", "calorie_goal")

        self.units = "kg" if self.db_wrapper.fetch_local_column(
            "Users", "units") == "metric" else "lb"
        weight_loss_units = "kg" if self.db_wrapper.fetch_local_column(
            self.table_name, "units") == "metric" else "lb"
        self.weight_history = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name,
                                               "weight_history"))

        if self.units != weight_loss_units:
            units_name = "metric" if self.units == "kg" else "imperial"
            self.db_wrapper.update_table_column(self.table_name, "units",
                                                units_name)
            if units_name == "metric":
                for date in self.weight_history:
                    self.weight_history[date] = str(
                        pounds_to_kg(self.weight_history[date]))

            elif units_name == "imperial":
                for date in self.weight_history:
                    self.weight_history[date] = str(
                        kg_to_pounds(self.weight_history[date]))

            self.db_wrapper.update_table_column(
                self.table_name, "weight_history",
                json.dumps(self.weight_history))

        self.preferred_activity = self.db_wrapper.fetch_local_column(
            self.table_name, "preferred_activity")
        self.cardio_history = json.loads(
            self.db_wrapper.fetch_local_column(self.table_name,
                                               "cardio_history"))
        if not self.date in self.cardio_history:
            self.add_date_to_cardio_history()
        if not self.date in self.weight_history:
            self.add_date_to_weight_history()

        self.init_cardio_labels()
        self.create_panel()
コード例 #28
0
 def __init__(self, parent):
     super().__init__(parent)
     self.db_wrapper = DatabaseWrapper()
     self.units = self.db_wrapper.fetch_local_column("Users", "units")
     self.setStyleSheet("""
 QWidget{
   font-family: Montserrat;
   color:#c7c7c7;
   font-weight: bold;
 }
 QPushButton{
   background-color: rgba(0, 0, 0, 0);
   border: 1px solid;
   font-size: 18px;
   font-weight: bold;
   border-color: #808080;
   min-height: 28px;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
 }
 QPushButton:hover:!pressed{
   border: 2px solid;
   border-color: #747474;
 }
 QPushButton:pressed{
   border: 2px solid;
   background-color: #323232;
   border-color: #6C6C6C;
 }
 QLineEdit{
   padding: 6px;
   background-color: rgb(33,33,33);
   border-radius: 2px;
 }
 QTableWidget{
   background-color: rgb(33,33,33);  
   border: 1px solid;
   border-color: rgb(88, 88, 88);
   font-size: 14px;
 }
 QComboBox{
   border-radius: 4px;
   font-size: 18px;
   font-weight: bold;
   white-space:nowrap;
   text-align: left;
   padding-left: 5%;
   font-family: Montserrat;
   min-height: 28px;
   background-color: #440D0F;
 }
 QComboBox:down-arrow{
   width: 0px;
   height: 0px;
   background: #d3d3d3; 
   opacity:0
 }
 QComboBox:drop-down{
   background-color: #440D0F;
   border: 0px;
   opacity:0;
   border-radius: 0px;
   width: 0px;
   height: 0px;
 }
 QComboBox:hover:!pressed{
   background-color: #5D1A1D;
 }
 QComboBox:pressed{
   background-color: #551812;
 }
 QHeaderView:section{
   background-color: rgb(54,54,54);  
   border: 1px solid;
   border-color: rgb(88, 88, 88)
 }""")
     self.units = "kg" if self.units == "metric" else "lb"
     self.CreatePanel()
コード例 #29
0
 def setUp(self):
     self.test_class = TestClass("users", "test.db")
     self.db_wrapper = DatabaseWrapper("test.db")
     self.test_class.create_test_user()