Example #1
0
File: main.py Project: ruishi/tenk
    def add_time(self):
        hours = self.hours_input.text()
        try:
            hours = float(hours)

            skill_name = self.skill_cb.currentText()
            session_date = self.date_edit.date().toString("yyyy-M-dd")
            file_path = self.config["PATHS"]["sessions_filepath"]
            session_params = {
                "skill_name": skill_name,
                "session_date": session_date,
                "hours": hours,
                "file_path": file_path,
            }

            for note_category, text_edit in self.note_inputs.items():
                # adding notes is optional, so ignore textareas left blank
                note_text = text_edit.toPlainText()
                if note_text:
                    session_params[note_category.replace(":", "")] = note_text
            session = Session(**session_params)
            session.serialize_and_save()

            self.user.add_time(skill_name, hours)
            utils.save(self.user, self.config)
            self.add_time_win.hide()
            self.reset_add_time_win()
        except ValueError as e:
            message_box = QtGui.QMessageBox()
            message_box.setText(e)
            message_box.exec_()
Example #2
0
File: main.py Project: ruishi/tenk
def remove_skill(skill):
    user = utils.load_user(config=config)
    if user:
        user.remove_skill(skill)
        utils.save(user, config)
    else:
        print(no_data_msg)
Example #3
0
File: main.py Project: ruishi/tenk
def add_time(skill, time, date=None):
    user = utils.load_user(config=config)
    if user:
        user.add_time(skill, time)
        utils.save(user, config)
        params = {'skill_name': skill, 'hours': time,
                  'file_path': config['PATHS']['sessions_filepath']}
        if date:
            params['session_date'] = date
        session = Session(**params)
        session.serialize_and_save()
    else:
        print(no_data_msg)
Example #4
0
File: main.py Project: ruishi/tenk
 def add_skill(self):
     """Add skill to skillset using data from add_skill_win"""
     skill_name = self.skill_name_input.text()
     hours = self.init_hours_input.text()
     if not skill_name:
         message_box = QtGui.QMessageBox()
         message_box.setText("Please enter a skill name.")
         message_box.exec_()
     else:
         try:
             hours = float(hours)
             skill = self.user.add_skill(skill_name, hours)
             utils.save(self.user, self.config)
             self.add_skill_to_main_win(skill_name, skill.calc_level(), skill.calc_progress())
             self.setLayout(self.layout)
             self.add_skill_win.hide()
             self.reset_add_skill_win()
         except ValueError:
             message_box = QtGui.QMessageBox()
             message_box.setText("{} is not a valid number.".format(hours))
             message_box.exec_()
Example #5
0
File: main.py Project: ruishi/tenk
def add_skill(name, hours=0):
    user = utils.load_user(create=True, config=config)
    user.add_skill(name, hours)
    utils.save(user, config)