コード例 #1
0
ファイル: schedule_ui.py プロジェクト: arut-ji/task-ledger
    def itemClicked(self, index):
        task: Task = self.model.itemFromIndex(index).data()
        self.selected_task = task
        checked = self.model.itemFromIndex(index).checkState()
        if not checked:
            self.dialog = dialog.Display_dialog()
            self.dialog.setupUi(self.dialog, task.topic)
            self.dialog.show()

            self.start_date = QDate.fromString(
                task.start_at.strftime("%d/%m/%Y"), 'dd/MM/yyyy')
            self.end_date = QDate.fromString(task.end_at.strftime("%d/%m/%Y"),
                                             'dd/MM/yyyy')
            self.start_time = QTime.fromString(
                task.start_at.strftime("%H:%M:%S"), 'hh:mm:ss')
            self.end_time = QTime.fromString(task.end_at.strftime("%H:%M:%S"),
                                             'hh:mm:ss')
            self.topic = task.topic
            self.location = task.location
            self.desc = task.description

            self.dialog.title.setText(self.topic)
            self.dialog.location.setText(self.location)
            self.dialog.from_dateEdit.setDate(self.start_date)
            self.dialog.to_dateEdit.setDate(self.end_date)
            self.dialog.textEdit_desc.setText(self.desc)
            self.dialog.timeEdit.setTime(self.start_time)
            self.dialog.to_timeEdit.setTime(self.end_time)
            self.dialog.edit_btn.clicked.connect(self.edit_dialog)

        else:
            details = task.get_detail()
            details['status'] = True
            self.system.update_task(task.id, details)
コード例 #2
0
    def __init__(self):
        super(MainTime, self).__init__()

        self.raiz = Ui_Elementos()
        self.raiz.setupUi(self)

        # extraer variable str *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        variabletime = self.raiz.timef1.time().toString("hh:mm AP")
        print(variabletime)

        # establecer hora *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        self.raiz.timef1.setTime(QTime.fromString("12:32 PM", "hh:mm AP"))

        # mandar hora por evento *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        self.raiz.timef1.timeChanged.connect(
            lambda time: print(time.toString("hh:mm AP")))

        # hora maximo y minimo *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        'self.raiz.timef1.setMinimumTime(QTime.fromString("06:00 PM", "hh:mm AP"))'
        'self.raiz.timef1.setMaximumTime(QTime.fromString("10:30 PM", "hh:mm AP"))'

        # establecr hora maxima (hora actual) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        'self.raiz.timef1.setMaximumTime(QTime.currentTime())'

        # establecer rango de hora *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        """
        hora_minima = QTime.fromString("12:00 PM", "hh:mm AP")
        hora_maxima = QTime.fromString("12:50 PM", "hh:mm AP")
        self.raiz.timef1.setTimeRange(hora_minima, hora_maxima)
        """

        # obtener hora por boton *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        self.raiz.btnf1.clicked.connect(
            lambda: print(self.raiz.timef1.time().toString("hh:mm AP")))
コード例 #3
0
 def from_string(self, text, original_value):
     if isinstance(original_value, QColor):
         match = self.color_exp.match(text)
         return QColor(min(int(match.captured(1)), 255),
                       min(int(match.captured(2)), 255),
                       min(int(match.captured(3)), 255),
                       min(int(match.captured(4)), 255))
     if isinstance(original_value, QDate):
         value = QDate.fromString(text, Qt.ISODate)
         return value if value.isValid() else None
     if isinstance(original_value, QDateTime):
         value = QDateTime.fromString(text, Qt.ISODate)
         return value if value.isValid() else None
     if isinstance(original_value, QTime):
         value = QTime.fromString(text, Qt.ISODate)
         return value if value.isValid() else None
     if isinstance(original_value, QPoint):
         match = self.point_exp.match(text)
         return QPoint(int(match.captured(1)),
                       int(match.captured(2)))
     if isinstance(original_value, QRect):
         match = self.rect_exp.match(text)
         return QRect(int(match.captured(1)),
                      int(match.captured(2)),
                      int(match.captured(3)),
                      int(match.captured(4)))
     if isinstance(original_value, QSize):
         match = self.size_exp.match(text)
         return QSize(int(match.captured(1)),
                      int(match.captured(2)))
     if isinstance(original_value, list):
         return text.split(',')
     return type(original_value)(text)
コード例 #4
0
    def setPage(self):

        self.elapsedTimer.start()
        self.timer.timeout.connect(self.updateTime)
        self.timer.start(500)
        self.userData = self.reader.getCurrentData()
        self.userTime = QTime.fromString(self.userData["time_used"],
                                         "hh:mm:ss")
        self.ui.UsedTime.setText(self.userTime.toString("hh:mm:ss"))
        self.ui.UserName.setText(self.userData["name"] + " 님")
コード例 #5
0
ファイル: clock_widget.py プロジェクト: mholtrop/Qt_clock
    def setup_from_json(self, json):
        """Set settings from the json dictionary passed."""

        if "BedTime" in json:
            new_bedtime = QTime.fromString(json["BedTime"], "hh:mm:ss")
            if not new_bedtime.isValid():
                new_bedtime = QTime.fromString(json["BedTime"], "hh:mm")

            if new_bedtime.isValid():
                self.bedtime = new_bedtime
                self.timeEdit.setTime(self.bedtime)
            else:
                print("Could not set bedtime to {}".format(str(new_bedtime)))

        if "GracePeriod" in json:
            self.bedtime_grace_period = int(json["GracePeriod"])
            self.grace_period.setValue(self.bedtime_grace_period)

        if "Brightness" in json:
            self.LCD_brightness = int(json["Brightness"])
            self.Brightness.setValue(self.LCD_brightness)
コード例 #6
0
    def __init__(self):
        super(MainDatime, self).__init__()
        
        self.raiz = Ui_Elementos()
        self.raiz.setupUi(self)

        # extraer variable str *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        variablefecha = self.raiz.datimeg1.date().toString("dd/MM/yyyy") # fecha
        variablehora = self.raiz.datimeg1.time().toString("hh:mm AP") # hora
        print('variablefecha:',variablefecha,' variablehora:',variablehora)

        # establecer fecha y hora *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        self.raiz.datimeg1.setDate(QDate.fromString( "08/12/2020", "dd/MM/yyyy" )) # fecha
        self.raiz.datimeg1.setTime(QTime.fromString( "10:31 AM", "hh:mm AP" )) # hora

        # establecer fecha/hora minima *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        'self.raiz.datimeg1.setMinimumDate(QDate.fromString("08/11/2020", "dd/MM/yyyy" ))'
        'self.raiz.datimeg1.setMinimumTime(QTime.fromString("06:00 PM", "hh:mm AP"))'

        # establecr fecha/hora maxima *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        'self.raiz.datimeg1.setMaximumDate(QDate.fromString("20/12/2020", "dd/MM/yyyy" ))'
        'self.raiz.datimeg1.setMaximumTime(QTime.fromString("10:30 PM", "hh:mm AP"))'

        # establecr fecha/maxima maxima (fecha/hora actual) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        'self.raiz.datimeg1.setMaximumDate(QDate.currentDate())'
        'self.raiz.datimeg1.setMaximumTime(QTime.currentTime())'

        # establecer rango de ... *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

        # hora
        '''
        hora_minima = QTime.fromString("12:00 PM", "hh:mm AP")
        hora_maxima = QTime.fromString("12:50 PM", "hh:mm AP")
        self.raiz.datimeg1.setTimeRange(hora_minima, hora_maxima)
        '''

        # fecha
        '''
        fecha_minima = QDate.fromString("05/11/2020", "dd/MM/yyyy" )
        fecha_maxima = QDate.fromString("15/12/2020", "dd/MM/yyyy" )
        self.raiz.datimeg1.setDateRange(fecha_minima, fecha_maxima)
        '''

        # evento de cambio de... *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        self.raiz.datimeg1.dateChanged.connect(lambda date: print(date.toString("dd/MM/yyyy"))) # fecha
        self.raiz.datimeg1.timeChanged.connect(lambda time: print(time.toString("hh:mm AP"))) # hora
        self.raiz.datimeg1.dateTimeChanged.connect(lambda datetime: print(datetime.toString("dd/MM/yyyy hh:mm AP"))) # fecha-hora

        # obtener valor de... *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
        self.raiz.btng1.clicked.connect(lambda : print(self.raiz.datimeg1.date().toString("dd/MM/yyyy"))) # fecha
        self.raiz.btng2.clicked.connect(lambda : print(self.raiz.datimeg1.time().toString("hh:mm AP"))) # hora
        self.raiz.btng3.clicked.connect(lambda : print(self.raiz.datimeg1.dateTime().toString("dd/MM/yyyy hh:mm AP"))) # fecha-hora
コード例 #7
0
 def __init__(self, name, time, link):
     self.rowlayout = QHBoxLayout()
     self.timebox = QTimeEdit(QTime.fromString(time))
     self.timebox.setDisplayFormat("HH:mm")
     self.coursename = QLineEdit(name)
     self.linkbox = QLineEdit(link)
     self.openbutton = QPushButton(text="Go")
     self.openbutton.clicked.connect(self.go_to_link)
     self.linkbox.setMinimumSize(QSize(300, 24))
     self.rowlayout.addWidget(self.coursename)
     self.rowlayout.addWidget(self.timebox)
     self.rowlayout.addWidget(self.linkbox)
     self.rowlayout.addWidget(self.openbutton)
     self.hlayout = QVBoxLayout()
     self.hlayout.addLayout(self.rowlayout)
     self.dow = DaysOfWeekSelector()
     self.hlayout.addLayout(self.dow.hlayout)
     self.hlayout.setSizeConstraint(QLayout.SetFixedSize)