Esempio n. 1
0
    def __init__(self):
        super().__init__()
        # 윈도우 설정
        self.setGeometry(300, 100, 1200, 800)  # x, y, w, h
        self.setWindowTitle('Canlendar Widget')

        # CalendarWidget 위젯 화면에 표시
        self.cal = QCalendarWidget(self)
        self.cal.setGeometry(120, 50, 970, 300)
        self.cal.setGridVisible(True)
        self.cal.selectionChanged.connect(self.calendar_change)

        # min max 기간 설정
        #self.cal.setMinimumDate(QDate(2020, 8, 25))
        #self.cal.setMaximumDate(QDate(2020, 8, 27))

        # Calendar 에서 선택한 값 표시할 QLabel
        self.calendar_label = QLabel(self)
        self.calendar_label.setGeometry(120, 370, 970, 30)
        self.calendar_label.setStyleSheet('background-color:#D3D3D3')

        self.b = QPlainTextEdit(self)
        self.b.insertPlainText("일기를 작성해요주세용.\n")
        self.b.setGeometry(120, 420, 970, 200)

        self.setupUI()
    def __init__(
        self, projectconfigwindow_classobject
    ):  #Multiple inheritance, see documentation on super().__init__()
        super(CalendarDialog, self).__init__()
        self.start_calendar = projectconfigwindow_classobject.start_date_calendar
        self.end_calendar = projectconfigwindow_classobject.end_date_calendar
        self.date_picked = ''
        self.setWindowTitle('Date Picker')
        self.setFixedSize(400, 300)
        mainlayout = QVBoxLayout()
        exitlayout = QHBoxLayout()

        self.my_calendar = QCalendarWidget(self)
        self.my_calendar.setGridVisible(True)
        if self.end_calendar == True:
            self.my_calendar.setMinimumDate(
                QDate(projectconfigwindow_classobject.minimumdate[2],
                      projectconfigwindow_classobject.minimumdate[0],
                      projectconfigwindow_classobject.minimumdate[1]))
        self.my_calendar.clicked[QDate].connect(self.show_date)

        self.date_label = QLabel(self)
        date = self.my_calendar.selectedDate()
        self.date_label.setText(date.toString())
        confirmbutt = QPushButton('Confirm Date')
        confirmbutt.clicked.connect(self.on_confirm_button_clicked)

        exitlayout.addWidget(self.date_label)
        exitlayout.addWidget(confirmbutt)

        mainlayout.addWidget(self.my_calendar)
        mainlayout.addLayout(exitlayout)
        self.setLayout(mainlayout)
Esempio n. 3
0
 def paintCell(self, painter, rect, date):
     print('painting')
     QCalendarWidget.paintCell(self, painter, rect, date)
     
     
     if date.day() % 5 == 0: # example condition based on date
         painter.drawText(rect.bottomLeft(), "test")
Esempio n. 4
0
class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.vbox = QVBoxLayout(self)

        self.cal = QCalendarWidget(self)
        self.cal.setGridVisible(True)
        self.cal.clicked[QDate].connect(self.showDate)

        self.vbox.addWidget(self.cal)

        self.lbl = QLabel(self)
        date = self.cal.selectedDate()
        self.lbl.setText(date.toString())

        self.vbox.addWidget(self.lbl)

        self.setLayout(self.vbox)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.show()

    def showDate(self, date):
        self.lbl.setText(date.toString())
Esempio n. 5
0
    def __init__(self):
        super(Date, self).__init__()
        self.calendar = QCalendarWidget(self)
        self.calendar.setMinimumDate(QDate(1946, 2, 14))  # 2
        self.calendar.setMaximumDate(QDate(6666, 6, 6))  # 3
        # self.calendar.setDateRange(QDate(1946, 2, 14), QDate(6666, 6, 6))
        # self.calendar.setFirstDayOfWeek(Qt.Monday)                            # 4
        # self.calendar.setSelectedDate(QDate(1946, 2, 14))                     # 5
        self.calendar.setGridVisible(True)  # 6
        self.calendar.clicked.connect(self.show_emotion_func)  # 6

        print(self.calendar.minimumDate())  # 7
        print(self.calendar.maximumDate())
        print(self.calendar.selectedDate())

        self.label = QLabel(self)  # 8
        self.label.setAlignment(Qt.AlignCenter)

        weekday = self.calendar.selectedDate().toString('ddd')  # 9
        self.label.setText(EMOTION[weekday])

        self.v_layout = QVBoxLayout()
        self.v_layout.addWidget(self.calendar)
        self.v_layout.addWidget(self.label)

        self.setLayout(self.v_layout)
        self.setWindowTitle('QCalendarWidget')
Esempio n. 6
0
    def paintCell(self, painter, rect, date):
        #calling original paintCell to draw the actual calendar
        QCalendarWidget.paintCell(self, painter, rect, date)

        #highlight a particular date
        if date in self.dateList:
            painter.fillRect(rect, self.color)
    def __init__(self, parent=None):
        super(VistaListaPrenotazioni, self).__init__(parent)

        self.g_layout = QGridLayout()

        self.label_prenotazioni_by_data = QLabel("\nSeleziona una data, poi premi  'Vai'  per vedere gli arrivi alla data selezionata: \n")
        self.label_prenotazioni_by_data.setStyleSheet("font: 200 14pt \"Papyrus\";\n""color: rgb(0, 0, 0);\n"
                                                    "background-color: rgb(178, 225, 255);\n"
                                                    "selection-color: rgb(170, 255, 0);")
        self.g_layout.addWidget(self.label_prenotazioni_by_data, 0, 0)

        self.calendario = QCalendarWidget()
        self.calendario.setGridVisible(True)
        self.calendario.setVerticalHeaderFormat(QCalendarWidget.NoVerticalHeader)
        self.calendario.setMinimumDate(QDate(2021, 6, 1))
        self.calendario.setMaximumDate(QDate(2021, 9, 15))

        self.g_layout.addWidget(self.calendario, 1, 0)

        self.h_layout = QHBoxLayout()

        self.create_button("Mostra tutte", self.go_lista_prenotazioni, "background-color:#FFD800;")
        self.create_button("Vai", self.go_lista_prenotazioni_by_data, "background-color:#00FF00;")

        self.g_layout.addLayout(self.h_layout, 2, 0)

        self.setLayout(self.g_layout)
        self.resize(700, 600)
        self.setWindowTitle("Lista Prenotazioni")
Esempio n. 8
0
    def initUI(self):
        self.cal = QCalendarWidget()
        self.cal.setGridVisible(True)  # 격자표시 설정
        self.cal.setDateRange(QDate(2020, 1, 1), QDate.currentDate())
        self.cal.clicked[QDate].connect(self.PastDate)

        self.label1 = QLabel(self)
        self.date = self.cal.selectedDate()
        self.label1.setText(self.date.toString())

        self.label2 = QLabel(self)
        previousBtn = QPushButton('이전 달')
        previousBtn.clicked.connect(self.preMonth)
        nextBtn = QPushButton('다음 달')
        nextBtn.clicked.connect(self.nextMonth)

        vbox = QVBoxLayout()
        vbox.addWidget(self.cal)
        vbox.addWidget(self.label1)
        vbox.addWidget(self.label2)
        vbox.addWidget(previousBtn)
        vbox.addWidget(nextBtn)

        self.setLayout(vbox)

        self.setWindowTitle('QCalendarWidget')
        self.setGeometry(300, 300, 500, 400)
        self.show()
Esempio n. 9
0
    def initUI(self):
        vbox = QVBoxLayout(self)
        # 创建一个横向布局
        cal = QCalendarWidget(self)
        # 创建一个QCalendarWidget
        cal.setGridVisible(True)
        # 设置网格可见
        # 从窗口组件中选定一个日期,会发射一个QCore.QDate信号
        cal.clicked[QDate].connect(
            self.showDate)  # clicked[QDate]说明点击信号发出,会带有一个QDate参数, 就要求槽函数也要有形参
        # 选择一个日期时, QDate的点击信号就触发了,
        # 把这个信号和我们自己定义的showDate()方法关联起来
        # 并且传入一个QDate类型的参数(即当前选中的日期)
        vbox.addWidget(cal)

        # 自动在底部标签栏显示当前日期的信息
        self.lbl = QLabel(self)
        # 设置日历的最小日期
        # self.cal.setMinimumDate(QDate(1980,1,1))
        # cal.setSelectedDate(QDate(1980,1,1)) 设置选取的日期
        date = cal.selectedDate()
        # 使用selectedDate()方法获取选中的日期, 默认当前日期
        self.lbl.setText(date.toString())
        # 然后把日期对象转成字符串, 在标签栏里面显示出来

        vbox.addWidget(self.lbl)
        # 布局中加入标签控件
        self.setLayout(vbox)
        # 设置布局
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.show()
Esempio n. 10
0
    def initUI(self):
        self.setWindowTitle('进度条示例')
        self.setWindowIcon(QIcon('./res/apaki.ico'))
        self.setGeometry(400, 300, 400, 300)

        self.pbar = QProgressBar(self)
        self.btn = QPushButton("开始下载", self)
        self.btn.clicked.connect(self.doAction)

        self.timer = QBasicTimer()
        self.step = 0

        # -------------------------------------------------
        cal = QCalendarWidget(self)
        cal.clicked[QDate].connect(self.showData)

        date = cal.selectedDate()
        self.label = QLabel(self)
        self.label.setText(date.toString())

        grid = QGridLayout(self)
        grid.addWidget(self.pbar, 0, 1)
        grid.addWidget(self.btn, 0, 0)
        grid.addWidget(self.label, 2, 0, 1, 2)
        grid.addWidget(cal, 3, 0, 1, 2)
        self.setLayout(grid)
Esempio n. 11
0
    def initUI(self):

        vbox = QVBoxLayout(self)

        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.clicked[QDate].connect(self.showDate)

        vbox.addWidget(cal)

        self.lbl = QLabel(self)
        date = cal.selectedDate()
        self.lbl.setText(date.toString())
        #lbl contains the date of the selected day
        vbox.addWidget(self.lbl)

        self.setLayout(vbox)
        reminderbutton = QPushButton("Check For Reminder", self)
        reminderbutton.move(120, 990)
        reminderbutton.resize(175, 25)
        addbutton = QPushButton("Add Reminder", self)
        addbutton.move(300, 990)
        addbutton.resize(175, 25)
        temporary = LabelAndButtonWork()
        self.lbls = self.lbl.text()
        reminderbutton.clicked.connect(lambda: temporary.CheckForReminder(
            temporary.GetWordsForLabel(self.lbls)))
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.show()
Esempio n. 12
0
 def __init__(self, parent, filter_widget):
     super().__init__(parent=parent)
     self.parent=parent
     self.filter_widget=filter_widget
     self.global_layout=QHBoxLayout()
     self.setLayout(self.global_layout)
     self.item1=QComboBox()
     for column in Filter.columns:
         self.item1.addItem(column)
     self.global_layout.addWidget(self.item1)
     self.item2=QComboBox()
     for operation in ['<','<=','=','>','>=']:
         self.item2.addItem(operation)
     self.global_layout.addWidget(self.item2)
     self.item3=QLineEdit()
     self.global_layout.addWidget(self.item3)
     self.calendar=QCalendarWidget()
     self.global_layout.addWidget(self.calendar)
     self.calendar.hide()
     self.remove_button=QToolButton()
     folder=os.path.split(inspect.getfile(Curve))[0]
     self.remove_button.setIcon(QtGui.QIcon(os.path.join(folder,'minus.png')))
     self.global_layout.addWidget(self.remove_button)
     self.remove_button.clicked.connect(self.remove)
     self.activate_box = QCheckBox('activate')
     
     self.global_layout.addWidget(self.activate_box)
     self.item1.currentTextChanged.connect(self.columnchanged)
Esempio n. 13
0
    def createCalendar(self):
        """
        Set up calendar, others widgets and layouts for main window. 
        """
        self.calendar = QCalendarWidget()
        self.calendar.setGridVisible(True)
        self.calendar.setMinimumDate(QDate(1900, 1, 1))
        self.calendar.setMaximumDate(QDate(2200, 1, 1))

        # Connect to newDateSelection slot when currently selected date is changed
        self.calendar.selectionChanged.connect(self.newDateSelection)

        current = QDate.currentDate().toString(Qt.DefaultLocaleLongDate)
        self.current_label = QLabel(current)
        self.current_label.setObjectName("DateSelected")

        # Create current, minimum and maximum QDateEdit widgets
        min_date_label = QLabel("Minimum Date:")
        self.min_date_edit = QDateEdit()
        self.min_date_edit.setDisplayFormat("MMM d yyyy")
        self.min_date_edit.setDateRange(self.calendar.minimumDate(),
                                        self.calendar.maximumDate())
        self.min_date_edit.setDate(self.calendar.minimumDate())
        self.min_date_edit.dateChanged.connect(self.minDatedChanged)

        current_date_label = QLabel("Current Date:")
        self.current_date_edit = QDateEdit()
        self.current_date_edit.setDisplayFormat("MMM d yyyy")
        self.current_date_edit.setDate(self.calendar.selectedDate())
        self.current_date_edit.setDateRange(self.calendar.minimumDate(),
                                            self.calendar.maximumDate())
        self.current_date_edit.dateChanged.connect(self.selectionDateChanged)

        max_date_label = QLabel("Maximum Date:")
        self.max_date_edit = QDateEdit()
        self.max_date_edit.setDisplayFormat("MMM d yyyy")
        self.max_date_edit.setDateRange(self.calendar.minimumDate(),
                                        self.calendar.maximumDate())
        self.max_date_edit.setDate(self.calendar.maximumDate())
        self.max_date_edit.dateChanged.connect(self.maxDatedChanged)

        # Add widgets to group box and add to grid layout
        dates_gb = QGroupBox("Set Dates")
        dates_grid = QGridLayout()
        dates_grid.addWidget(self.current_label, 0, 0, 1, 2, Qt.AlignAbsolute)
        dates_grid.addWidget(min_date_label, 1, 0)
        dates_grid.addWidget(self.min_date_edit, 1, 1)
        dates_grid.addWidget(current_date_label, 2, 0)
        dates_grid.addWidget(self.current_date_edit, 2, 1)
        dates_grid.addWidget(max_date_label, 3, 0)
        dates_grid.addWidget(self.max_date_edit, 3, 1)
        dates_gb.setLayout(dates_grid)

        # Create and set main window's layout
        main_h_box = QHBoxLayout()
        main_h_box.addWidget(self.calendar)
        main_h_box.addWidget(dates_gb)

        self.setLayout(main_h_box)
Esempio n. 14
0
 def createPreviewGroupBox(self):
     self.previewGroupBox = QGroupBox("Calendar")
     self.calendar = QCalendarWidget()
     self.calendar.setMaximumDate(QDate(3000, 1, 1))
     self.calendar.setGridVisible(True)
     self.previewLayout = QGridLayout()
     self.previewLayout.addWidget(self.calendar, 0, 0)
     self.previewGroupBox.setLayout(self.previewLayout)
Esempio n. 15
0
 def cal(self):
     self.c = QCalendarWidget(self)
     self.grid_layout.addWidget(self.c, 1, 0, 3, 4)
     self.c.setMinimumDate(QDate.currentDate())
     if QDate.currentDate().dayOfWeek() == 5:
         self.c.setMaximumDate(QDate.currentDate().addDays(16))
     else:
         self.c.setMaximumDate(QDate.currentDate().addDays(14))
Esempio n. 16
0
 def calendar(self):
     self.cal=QCalendarWidget()
     self.cal.setGridVisible(True)
     self.cal.setGeometry(300,300,450,200)
     self.cal.setWindowIcon(QIcon(self.settings_panel))
     self.cal.setWindowTitle('Calendar')
     self.cal.show()
     self.cal.clicked[QDate].connect(self.show_date)
Esempio n. 17
0
    def delivery_calender(self):
        self.calender = QCalendarWidget()
        self.calender.setMinimumDate(QDate(1900, 1, 1))
        self.calender.setMaximumDate(QDate(2999, 12, 31))
        self.calender.setGridVisible(True)
        self.calender.clicked.connect(self.updatedate)

        self.calender.show()
Esempio n. 18
0
 def init_calendar(self):
     try:
         self.date = QDate()
         self.calendar = QCalendarWidget(self)
         self.calendar.adjustSize()
         self.calendar.setMinimumDate(self.date.currentDate())
     except Exception as err:
         print(err)
Esempio n. 19
0
 def calendar(self):
     self.cal=QCalendarWidget()
     self.cal.setGridVisible(True)#Видимая сетка на календаре
     self.cal.setGeometry(300,300,450,200)
     self.cal.setWindowIcon(QIcon(self.settings_panel))
     self.cal.setWindowTitle('Calendar')
     self.cal.show()
     self.cal.clicked[QDate].connect(self.show_date)#При нажатии на дату передает сигнал заданной функции
Esempio n. 20
0
    def __init__(self, user_id: str):
        super().__init__()

        self.user_id = user_id

        grid = QGridLayout()
        self.setLayout(grid)

        self.calendar = QCalendarWidget()
        self.calendar.selectionChanged.connect(self.new_date)
        grid.addWidget(self.calendar)

        self.events = []

        current_date = self.calendar.selectedDate()
        self.date_label = QLabel(
            datetime.datetime(current_date.year(), current_date.month(),
                              current_date.day()).strftime("%a, %d %b %Y"))
        grid.addWidget(self.date_label)

        timings = QWidget()
        timings_grid = QGridLayout()
        timings.setLayout(timings_grid)

        self.create_btn_lst: List[QPushButton] = []
        self.details_label_lst: List[QLabel] = []
        for hour in range(6, 24):  # Adding Widgets for Each Timing
            label = QLabel(f"{hour}:00")
            timings_grid.addWidget(label, (hour - 6) % 9, (hour - 6) // 9 * 3)

            create_event_btn = QPushButton()
            create_event_btn.setToolTip("Click to Create Event!")
            create_event_btn.clicked.connect(
                partial(self.get_details, time=hour))
            self.create_btn_lst.append(create_event_btn)
            timings_grid.addWidget(create_event_btn, (hour - 6) % 9,
                                   (hour - 6) // 9 * 3 + 1)

            details_label = QLabel()
            self.details_label_lst.append(details_label)
            timings_grid.addWidget(details_label, (hour - 6) % 9,
                                   (hour - 6) // 9 * 3 + 2)

        grid.addWidget(timings)

        save_btn = QPushButton("Save and Upload to Database")
        save_btn.clicked.connect(self.upload_to_firebase)
        grid.addWidget(save_btn)

        # Download the Schedule from Firebase
        try:
            storage.child(f"schedules/{self.user_id}.pickle").download(
                "", f"temp.pickle")
            self.events = pickle.load(open("temp.pickle", "rb"))
            self.reload()

        except FileNotFoundError:
            print("File Not Found in Firebase!")
Esempio n. 21
0
 def __init__(self, task):
     self.task = task
     super().__init__(flags=Qt.WindowTitleHint | Qt.WindowCloseButtonHint
                      | Qt.WindowMinimizeButtonHint
                      | Qt.WindowMaximizeButtonHint)
     size_policy = QSizePolicy()
     size_policy.setHorizontalPolicy(QSizePolicy.MinimumExpanding)
     size_policy.setHorizontalStretch(255)
     self.setSizePolicy(size_policy)
     self.setMinimumSize(120, 36)
     self.setCursor(Qt.OpenHandCursor)
     task_layout = QVBoxLayout()
     task_layout.setContentsMargins(25, 6, 6, 6)
     first_line = QHBoxLayout()
     self.name_widget = QLabel()
     self.name_widget.setText(self.task.text)
     first_line.addWidget(self.name_widget,
                          stretch=255,
                          alignment=Qt.AlignLeading)
     self.edit_name = QLineEdit()
     self.edit_name.setText(self.task.text)
     self.edit_name.textChanged.connect(self.setTaskText)
     self.edit_name.returnPressed.connect(self.leaveEditMode)
     first_line.addWidget(self.edit_name)
     self.edit_button = QPushButton()
     self.edit_button.setFlat(True)
     self.edit_button.setIcon(QIcon("Icon/Edit.png"))
     self.edit_button.clicked.connect(self.enterEditMode)
     first_line.addWidget(self.edit_button, alignment=Qt.AlignRight)
     self.leave_edit_mode_button = QPushButton()
     self.leave_edit_mode_button.setFlat(True)
     self.leave_edit_mode_button.setIcon(QIcon("Icon/Collapse.png"))
     self.leave_edit_mode_button.clicked.connect(self.leaveEditMode)
     first_line.addWidget(self.leave_edit_mode_button,
                          alignment=Qt.AlignRight)
     del_button = QPushButton()
     del_button.setFlat(True)
     #del_button.setIcon(QCommonStyle().standardIcon(QStyle.SP_TrashIcon))
     del_button.setIcon(QIcon("Icon/Trash.png"))
     del_button.clicked.connect(self.delete_task)
     first_line.addWidget(del_button, alignment=Qt.AlignRight)
     task_layout.addLayout(first_line)
     second_line = QHBoxLayout()
     self.due_date_box = QGroupBox("Due Date")
     due_date_box_layout = QVBoxLayout()
     self.due_date_calendar = QCalendarWidget()
     if self.task.due_date:
         self.due_date_calendar.setSelectedDate(self.task.due_date)
     self.due_date_calendar.selectionChanged.connect(self.setDueDate)
     due_date_box_layout.addWidget(self.due_date_calendar)
     self.due_date_time = TimeSelector(self.task.get_due_date_time())
     self.due_date_time.time_changed.connect(self.setDueDateTime)
     due_date_box_layout.addWidget(self.due_date_time)
     self.due_date_box.setLayout(due_date_box_layout)
     second_line.addWidget(self.due_date_box, alignment=Qt.AlignLeft)
     task_layout.addLayout(second_line)
     self.setLayout(task_layout)
     self.setEditMode(False)
Esempio n. 22
0
	def __init__(self, r, c):
		super().__init__(r, c)
		self.FileOpenProcess = False
		self.ChangeDateProcess = False
		self.initUI()
		self.ProjectName = ""
		self.ProjectManager = ""
		self.Start = ""
		self.cal = QCalendarWidget(self)
Esempio n. 23
0
    def __init__(self, parent=None):
        super().__init__(parent)

        # initialize variables and download / parse the data file
        self.data = {}
        self.last_date = QDate().currentDate()
        self.currencies = []
        self.period = []
        self.download_unzip()

        # initialize widgets
        self.from_currency_label = QLabel("From currency:")
        self.from_currency = QComboBox()
        self.from_currency.addItems(self.currencies)
        self.to_currency_label = QLabel("To currency:")
        self.to_currency = QComboBox()
        self.to_currency.addItems(self.currencies)
        self.from_amount_label = QLabel("Amount to convert:")
        self.from_amount = QDoubleSpinBox()
        self.from_amount.setRange(0.01, 100000000.00)
        self.from_amount.setValue(1.00)
        self.to_amount_label = QLabel(
            "Result of conversion based on most recent rates: ")
        self.to_amount = QLabel("%.02f" % 1.00)
        self.from_date = QCalendarWidget()
        self.to_date = QCalendarWidget()
        self.rates_plot = pg.PlotWidget()
        self.legend = self.rates_plot.addLegend()

        # set widgets into layout
        grid = QGridLayout()
        grid.addWidget(self.from_currency_label, 0, 0)
        grid.addWidget(self.from_currency, 0, 1)
        grid.addWidget(self.to_currency_label, 0, 2)
        grid.addWidget(self.to_currency, 0, 3)
        grid.addWidget(self.from_amount_label, 1, 0)
        grid.addWidget(self.from_amount, 1, 1)
        grid.addWidget(self.to_amount_label, 1, 2)
        grid.addWidget(self.to_amount, 1, 3)
        grid.addWidget(self.from_date, 2, 0, 1, 2)
        grid.addWidget(self.to_date, 2, 2, 1, 2)
        grid.addWidget(self.rates_plot, 4, 0, 1, 4)
        self.setLayout(grid)
        self.setWindowTitle(
            "Currency Converter - Assignment 1 - Dommerc - 2982021")

        # refresh data
        today = QDate.currentDate()
        self.from_date.setSelectedDate(today.addDays(-10))
        self.update_ui()

        # set event when input change (refresh ui)
        self.from_currency.currentIndexChanged.connect(self.update_ui)
        self.to_currency.currentIndexChanged.connect(self.update_ui)
        self.from_amount.valueChanged.connect(self.update_ui)
        self.from_date.selectionChanged.connect(self.update_ui)
        self.to_date.selectionChanged.connect(self.update_ui)
Esempio n. 24
0
 def to_calender(self):
     self.to_calender = QCalendarWidget()
     self.to_calender.setMinimumDate(QDate(1900,1,1))
     self.to_calender.setMaximumDate(QDate(2999,12,31))
     self.to_calender.setGridVisible(True)
     self.to_calender.clicked.connect(self.to_updatedate)
     self.to_calender.setWindowModality(Qt.ApplicationModal)
     self.to_calender.setWindowTitle("To Date")
     self.to_calender.show()
Esempio n. 25
0
 def Calender(self):
     """日历"""
     self.groupBox2 = QGroupBox("日历", alignment=Qt.AlignCenter)
     vbox = QVBoxLayout()
     self.calender = QCalendarWidget()
     self.calender.selectionChanged.connect(self.onSelectionChanged)
     self.calender.setGridVisible(True)
     vbox.addWidget(self.calender)
     self.groupBox2.setLayout(vbox)
 def paintCell(self, painter, rect, date):
     if date in self.checkins:
         colour = QColor(255, 0, 0, 50)
         painter.fillRect(rect, colour)
         painter.drawText(rect.center(), str(date.day()))
         painter.drawText(rect.bottomLeft(),
                          self.methods[self.checkins.index(date)])
     else:
         QCalendarWidget.paintCell(self, painter, rect, date)
Esempio n. 27
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        QMainWindow.__init__(self)

        self.currentData = {}
        self.indx = 0
        self.indxPlotTable = {
            0: 'Emojis',
            1: 'Words',
            2: 'Messages by user',
            3: 'Media messages by user'
        }
        self.currentFile = ""

        self.title = 'Whatsapp Statisic Application'

        self.mindataToDisplay = date(1900, 1, 1)
        self.currentMinData = date(1900, 1, 1)

        self.maxdataToDisplay = date(2100, 12, 31)
        self.currentMaxData = date(2100, 12, 31)

        self.setWindowTitle(self.title)
        self.setGeometry(30, 30, 1280, 1024)
        self.statusBar().showMessage('Ready')

        self.initMenubar()
        self.initToolBar()
        self.plotWidget = WidgetPlot(self)

        widget = QWidget(self)
        self.setCentralWidget(widget)
        vlay = QVBoxLayout(widget)

        self.nameLabel = QLabel('Min Date', self)
        self.nameLabel2 = QLabel('Max Date', self)

        self.nameLabel.setFont(QFont('Arial', 20))
        self.nameLabel2.setFont(QFont('Arial', 20))

        self.pyCal = QCalendarWidget()
        self.pyCal.setGridVisible(True)
        self.pyCal.clicked[QDate].connect(self.sendMinDate)

        self.pyCal2 = QCalendarWidget()
        self.pyCal2.setGridVisible(True)
        self.pyCal2.clicked[QDate].connect(self.sendMaxDate)

        grid = QGridLayout()
        grid.addWidget(self.nameLabel, 0, 0, Qt.AlignCenter)
        grid.addWidget(self.nameLabel2, 0, 1, Qt.AlignCenter)
        grid.addWidget(self.pyCal, 1, 0)
        grid.addWidget(self.pyCal2, 1, 1)

        vlay.addLayout(grid)
        vlay.addWidget(self.plotWidget)
Esempio n. 28
0
class Form(FramelessWindow):
    # 继承QRibbonWindow
    def __init__(self):
        super(Form, self).__init__()
        self.resize(800, 600)
        self.init_ui()

    def init_ui(self):
        ribbon_toolbar = QRibbonToolBar(self)
        # 标题栏
        ribbon_toolbar.title = '这是一个标题'
        ribbon_toolbar.add_widget(icon='image/left.ico', left=True)
        ribbon_toolbar.add_widget(icon='image/right.ico', left=False)
        # 菜单栏
        menu = ribbon_toolbar.add_menu('开始')
        # 工具组
        group = ribbon_toolbar.add_group('剪切板', menu)
        # 工具组右下角按钮
        corner = group.corner
        corner.clicked.connect(lambda: print('test'))
        # 工具组添加widget
        label = QLabel()
        label.setPixmap(QPixmap('image/cut.png'))
        group.add_widget(label)
        group = ribbon_toolbar.add_group('字体', menu)
        label = QLabel()
        label.setPixmap(QPixmap('image/font.png'))
        group.add_widget(label)
        # -------------------------------------------
        menu = ribbon_toolbar.add_menu('插入')
        group = ribbon_toolbar.add_group('剪切板11', menu)
        group = ribbon_toolbar.add_group('字体11', menu)
        menu = ribbon_toolbar.add_menu('设计')
        menu = ribbon_toolbar.add_menu('布局管理')

        self.setWindowIcon(QIcon('image/left.ico'))
        self.addToolBar(ribbon_toolbar)

        self.centralwidget = QWidget(self)
        gridLayout = QGridLayout(self.centralwidget)
        gridLayout.setContentsMargins(self.margin, self.margin, self.margin,
                                      self.margin)
        self.calendarWidget = QCalendarWidget(self.centralwidget)
        self.calendarWidget.setMouseTracking(True)
        gridLayout.addWidget(self.calendarWidget, 0, 0, 1, 1)
        self.setCentralWidget(self.centralwidget)
        self.centralwidget.setMouseTracking(True)
        dockewidget = QDockWidget(self)
        dockewidget.setMouseTracking(True)
        self.addDockWidget(Qt.LeftDockWidgetArea, dockewidget)
        statusbar = QStatusBar(self)
        statusbar.setMouseTracking(True)
        self.setStatusBar(statusbar)

        ribbon_toolbar.installEventFilter(self)
        self.calendarWidget.installEventFilter(self)
Esempio n. 29
0
 def paintCell(self, painter, rect, date):
     painter.setRenderHint(QPainter.Antialiasing, True)
     if (date.day() == 1) or (date.day() == 15):
         #painter.save()
         painter.drawRect(rect)
         painter.setPen(Qt.blue)
         painter.drawText(QRectF(rect), Qt.TextSingleLine|Qt.AlignCenter, str(date.day()))
         painter.restore()
     else:
         QCalendarWidget.paintCell(self, painter, rect, date)
Esempio n. 30
0
 def createFormGroupBox(self):
     self.formGroupBox = QGroupBox("Form layout")
     layout = QFormLayout()
     layout.addRow(QLabel("RFC no.:"), QLineEdit())
     # layout.addRow(QLabel("Line 2, long text:"), QComboBox())
     layout.addRow(QLabel("Start Time:"), QSpinBox())
     layout.addRow(QLabel("End Time:"), QSpinBox())
     layout.addRow(QLabel("Start Date:"), QCalendarWidget(self))
     layout.addRow(QLabel("End Date:"), QCalendarWidget(self))
     self.formGroupBox.setLayout(layout)
Esempio n. 31
0
    def __init__(self):
        QWidget.__init__(self)

        # Set Time One Group
        self.time_one_calendar = QCalendarWidget()
        self.time_one_country_combobox = QComboBox()
        self.time_one_vbox = QVBoxLayout()
        self.time_one_groupbox = QGroupBox("Time One")
        self.time_one_bottom_hbox = QHBoxLayout()
        self.time_one_time_edit = QTimeEdit()
        self.time_one_default_button = QPushButton()
        self.time_one_default_button.setIcon(QIcon("%s/gnome-set-time.png" % icon_path))
        self.time_one_default_button.setMaximumSize(50, 50)
        self.time_one_bottom_hbox.addWidget(self.time_one_time_edit)
        self.time_one_bottom_hbox.addWidget(self.time_one_default_button)
        self.time_one_vbox.addWidget(self.time_one_country_combobox)
        self.time_one_vbox.addWidget(self.time_one_calendar)
        self.time_one_vbox.addLayout(self.time_one_bottom_hbox)
        self.time_one_groupbox.setLayout(self.time_one_vbox)

        # Set Time Two Group
        self.time_two_groupbox = QGroupBox("Time Two")
        self.time_two_calendar = QCalendarWidget()
        self.time_two_vbox = QVBoxLayout()
        self.time_two_country_combobox = QComboBox()
        self.time_two_bottom_hbox = QHBoxLayout()
        self.time_two_time_edit = QTimeEdit()
        self.time_two_default_button = QPushButton()
        self.time_two_default_button.setIcon(QIcon("%s/gnome-set-time.png" % icon_path))
        self.time_two_default_button.setMaximumSize(50, 50)
        self.time_two_bottom_hbox.addWidget(self.time_two_time_edit)
        self.time_two_bottom_hbox.addWidget(self.time_two_default_button)
        self.time_two_vbox.addWidget(self.time_two_country_combobox)
        self.time_two_vbox.addWidget(self.time_two_calendar)
        self.time_two_vbox.addLayout(self.time_two_bottom_hbox)
        self.time_two_groupbox.setLayout(self.time_two_vbox)

        # Set main layout
        self.main_layout = QHBoxLayout()
        self.main_layout.addWidget(self.time_one_groupbox)
        self.main_layout.addWidget(self.time_two_groupbox)
        self.setLayout(self.main_layout)

        # Wire-up your widgets!
        self.time_one_connect()
        self.time_two_connect()
        self.time_one_default_button.clicked.connect(self.set_local_time_one)
        self.time_two_default_button.clicked.connect(self.set_local_time_two)

        # Set the local time for time one
        self.set_local_country()
        self.set_local_time_one()

        # Finally, convert the second time based on the first
        self.convert_timeone_to_timetwo()
Esempio n. 32
0
 def select_date(self, button):
     d = WindowModalDialog(self, _("Select date"))
     d.setMinimumSize(600, 150)
     d.date = None
     vbox = QVBoxLayout()
     def on_date(date):
         d.date = date
     cal = QCalendarWidget()
     cal.setGridVisible(True)
     cal.clicked[QDate].connect(on_date)
     vbox.addWidget(cal)
     vbox.addLayout(Buttons(OkButton(d), CancelButton(d)))
     d.setLayout(vbox)
     if d.exec_():
         if d.date is None:
             return None
         date = d.date.toPyDate()
         button.setText(self.format_date(date))
         return datetime.datetime(date.year, date.month, date.day)
Esempio n. 33
0
    def createPreviewGroupBox(self):
        self.previewGroupBox = QGroupBox("Preview")

        self.calendar = QCalendarWidget()
        self.calendar.setMinimumDate(QDate(1900, 1, 1))
        self.calendar.setMaximumDate(QDate(3000, 1, 1))
        self.calendar.setGridVisible(True)
        self.calendar.currentPageChanged.connect(self.reformatCalendarPage)

        self.previewLayout = QGridLayout()
        self.previewLayout.addWidget(self.calendar, 0, 0, Qt.AlignCenter)
        self.previewGroupBox.setLayout(self.previewLayout)
    def initUI(self):

        self.layout = QHBoxLayout()

        self.groupboxCal = QGroupBox("Calendar")
        self.groupboxDataset = QGroupBox("Dataset")
        self.groupboxCal.setStyleSheet("QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}")
        self.groupboxDataset.setStyleSheet("QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}")
        self.layoutCal = QVBoxLayout()
        self.layoutDataset = QGridLayout()
        self.groupboxCal.setLayout(self.layoutCal)
        self.groupboxDataset.setLayout(self.layoutDataset)

        self.layout_but = QHBoxLayout()
        self.cal = QCalendarWidget(self)
        self.cal.setGridVisible(True)
        self.cal.clicked[QDate].connect(self.showDate)
        self.lbl = QLabel(self)
        date = self.cal.selectedDate()

        self.lbl.setText(date.toString())
        self.buttonSave = QPushButton("Save")
        self.buttonSave.clicked.connect(self.closeEvent)

        self.checkboxRealTime = QCheckBox("Real Time Data Monitoring")
        self.checkboxPastRuns = QCheckBox("Visualize Past Runs")
        self.spinboxDays = QSpinBox()
        self.spinboxDays.setRange(1, 100)
        self.spinboxDays.setValue(1)
        self.checkboxRealTime.stateChanged.connect(self.realTimeMode)
        self.checkboxPastRuns.stateChanged.connect(self.oldData)

        self.checkboxRealTime.setCheckState(2)

        self.layoutDataset.addWidget(self.checkboxRealTime, 0, 0, 2, 1)

        self.layoutDataset.addWidget(QLabel("Duration (Days)"), 2, 1, 1, 1)
        self.layoutDataset.addWidget(self.checkboxPastRuns, 3, 0, 1, 1)
        self.layoutDataset.addWidget(self.spinboxDays, 3, 1, 1, 1)

        self.layoutCal.addWidget(self.cal)
        self.layout_but.addWidget(self.lbl)
        self.layout_but.addWidget(self.buttonSave)
        self.layoutCal.addLayout(self.layout_but)

        self.layout.addWidget(self.groupboxCal)
        self.layout.addWidget(self.groupboxDataset)
        self.setLayout(self.layout)
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.setWindowModality(Qt.WindowModal)
        self.show()
    def __init__(self, dateplot):
        self.dateplot = dateplot
        QWidget.__init__(self)
        self.layout = QHBoxLayout()

        self.cal = QCalendarWidget(self)
        self.cal.setGridVisible(True)
        self.cal.clicked[QDate].connect(self.showDate)
        self.cal.activated.connect(self.hide)

        gbCalendar = QGroupBox('Calendar')
        gbDataset = QGroupBox('Dataset')
        gbCalendar.setStyleSheet('QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}')
        gbDataset.setStyleSheet('QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}')

        self.confAuto = QCheckBox('Configuration : Auto')
        self.checkboxRealTime = QCheckBox('Real-time')
        self.checkboxPastRuns = QCheckBox('Archived')
        self.spinboxDays = QSpinBox()
        self.spinboxDays.setRange(1, 100)
        self.spinboxDays.setValue(1)

        self.confAuto.setChecked(0)

        self.confAuto.stateChanged.connect(self.dateplot.loadConf)
        self.checkboxRealTime.stateChanged.connect(self.realtime)
        self.checkboxPastRuns.stateChanged.connect(self.archivedData)

        self.checkboxRealTime.setCheckState(2)
        layoutDataset = QGridLayout()
        layoutDataset.addWidget(self.confAuto, 0, 0, 2, 1)
        layoutDataset.addWidget(self.checkboxRealTime, 2, 0, 2, 1)
        layoutDataset.addWidget(QLabel('Duration (Days)'), 4, 1, 1, 1)
        layoutDataset.addWidget(self.checkboxPastRuns, 5, 0, 1, 1)
        layoutDataset.addWidget(self.spinboxDays, 5, 1, 1, 1)

        layoutCalendar = QVBoxLayout()
        layoutCalendar.addWidget(self.cal)

        gbCalendar.setLayout(layoutCalendar)
        gbDataset.setLayout(layoutDataset)

        self.layout.addWidget(gbCalendar)
        self.layout.addWidget(gbDataset)
        self.setLayout(self.layout)
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.setWindowModality(Qt.WindowModal)
Esempio n. 36
0
    def __init__(self, main, parent=None):
        super(SelectSession, self).__init__(parent)
        self.glob = main

        mainLayout = QVBoxLayout()

        self.cal = QCalendarWidget()
        self.export = QPushButton('CSV export')
        self.cal.setFirstDayOfWeek(QtCore.Qt.Monday)
        self.lst = QListWidget()
        self.lst.clicked.connect(self.goto)

        mainLayout.addWidget(self.cal)
        mainLayout.addWidget(self.lst)

        mainLayout.addWidget(self.export)

        self.export.clicked.connect(self.doExport)
        mainLayout.addStretch(2)
        self.setLayout(mainLayout)
    def initUI(self):      

        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(20, 20)
        cal.clicked[QDate].connect(self.showDate)
        
        self.lbl = QLabel(self)
        date = cal.selectedDate()
        self.lbl.setText(date.toString())
        self.lbl.move(130, 260)
        
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.show()
Esempio n. 38
0
    def initUI(self):
        # checkBox
        cb = QCheckBox('show title', self)
        cb.move(10, 10)
        cb.toggle()
        cb.stateChanged.connect(self.changeTitle)

        # 颜色混合
        self.col = QColor(0, 0, 0)
        redb = QPushButton('Red', self)
        redb.setCheckable(True)
        redb.move(10, 30)
        redb.clicked[bool].connect(self.setColor)

        grnb = QPushButton('Green', self)
        grnb.setCheckable(True)
        grnb.move(10, 60)
        grnb.clicked[bool].connect(self.setColor)

        blueb = QPushButton('Blue', self)
        blueb.setCheckable(True)
        blueb.move(10, 90)
        blueb.clicked[bool].connect(self.setColor)

        self.square = QFrame(self)
        self.square.setGeometry(150, 20, 50, 50)
        self.square.setStyleSheet("QWidget { background-color: %s}" %
                                  self.col.name())

        # slider 滚动条
        sld = QSlider(Qt.Horizontal, self)
        sld.setFocusPolicy(Qt.NoFocus)
        sld.setGeometry(10, 120, 100, 10)
        sld.valueChanged[int].connect(self.changeValue)

        self.label = QLabel(self)
        self.label.setPixmap(QPixmap('1.png'))
        self.label.setGeometry(150, 90, 80, 80)

        # 进度条ProgressBar
        self.pbar = QProgressBar(self)
        self.pbar.setGeometry(10, 170, 200, 20)
        self.btn = QPushButton('Start', self)
        self.btn.move(10, 200)
        self.btn.clicked.connect(self.doAction)

        self.timer = QBasicTimer()
        self.step = 0

        # Calendar 日历
        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(10, 230)
        cal.clicked[QDate].connect(self.showDate)
        self.lbl = QLabel(self)
        date = cal.selectedDate()
        self.lbl.setText(date.toString())
        self.lbl.move(80, 440)

        self.setGeometry(300, 200, 300, 500)
        self.setWindowTitle('Toggle')
        self.show()
class Calendar(QWidget):
    def __init__(self, parent):
        QWidget.__init__(self)
        self.parent = parent
        self.initUI()
        self.defaultDate()

    def initUI(self):

        self.layout = QHBoxLayout()

        self.groupboxCal = QGroupBox("Calendar")
        self.groupboxDataset = QGroupBox("Dataset")
        self.groupboxCal.setStyleSheet("QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}")
        self.groupboxDataset.setStyleSheet("QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}")
        self.layoutCal = QVBoxLayout()
        self.layoutDataset = QGridLayout()
        self.groupboxCal.setLayout(self.layoutCal)
        self.groupboxDataset.setLayout(self.layoutDataset)

        self.layout_but = QHBoxLayout()
        self.cal = QCalendarWidget(self)
        self.cal.setGridVisible(True)
        self.cal.clicked[QDate].connect(self.showDate)
        self.lbl = QLabel(self)
        date = self.cal.selectedDate()

        self.lbl.setText(date.toString())
        self.buttonSave = QPushButton("Save")
        self.buttonSave.clicked.connect(self.closeEvent)

        self.checkboxRealTime = QCheckBox("Real Time Data Monitoring")
        self.checkboxPastRuns = QCheckBox("Visualize Past Runs")
        self.spinboxDays = QSpinBox()
        self.spinboxDays.setRange(1, 100)
        self.spinboxDays.setValue(1)
        self.checkboxRealTime.stateChanged.connect(self.realTimeMode)
        self.checkboxPastRuns.stateChanged.connect(self.oldData)

        self.checkboxRealTime.setCheckState(2)

        self.layoutDataset.addWidget(self.checkboxRealTime, 0, 0, 2, 1)

        self.layoutDataset.addWidget(QLabel("Duration (Days)"), 2, 1, 1, 1)
        self.layoutDataset.addWidget(self.checkboxPastRuns, 3, 0, 1, 1)
        self.layoutDataset.addWidget(self.spinboxDays, 3, 1, 1, 1)

        self.layoutCal.addWidget(self.cal)
        self.layout_but.addWidget(self.lbl)
        self.layout_but.addWidget(self.buttonSave)
        self.layoutCal.addLayout(self.layout_but)

        self.layout.addWidget(self.groupboxCal)
        self.layout.addWidget(self.groupboxDataset)
        self.setLayout(self.layout)
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.setWindowModality(Qt.WindowModal)
        self.show()

    def defaultDate(self):
        mydate = datetime.datetime(datetime.datetime.today().year, datetime.datetime.today().month,
                                   datetime.datetime.today().day)
        self.mydatetime = mydate
        self.mydate_num = self.parent.db.convertTimetoAstro(mydate.strftime("%d/%m/%Y %H:%M:%S"))

    def getChosenDate(self):
        mydate = datetime.datetime.combine(self.cal.selectedDate().toPyDate(), datetime.datetime.min.time())
        self.mydatetime = mydate
        self.mydate_num = self.parent.db.convertTimetoAstro(mydate.strftime("%d/%m/%Y %H:%M:%S"))

    def showDate(self, date):

        self.lbl.setText(date.toString())

    def realTimeMode(self):

        if self.checkboxRealTime.isChecked():
            self.parent.dataset = "real_time"
            self.checkboxPastRuns.setCheckState(0)
        else:
            self.checkboxPastRuns.setCheckState(2)

    def oldData(self):
        if self.checkboxPastRuns.isChecked():
            self.parent.dataset = "past_run"
            self.checkboxRealTime.setCheckState(0)
        else:
            self.checkboxRealTime.setCheckState(2)

    def closeEvent(self, event):
        self.hide()
        self.getChosenDate()
        try:
            event.accept()
        except AttributeError:
            pass
Esempio n. 40
0
    def initUI(self):

        # checkbox
        cb = QCheckBox('show title', self)
        cb.move(20, 20)
        cb.toggle()
        cb.stateChanged.connect(self.changeTitle)

        # toggle button
        self.col = QColor(0, 0, 0)

        redb = QPushButton('red', self)
        redb.setCheckable(True)
        redb.move(20, 40)
        redb.clicked[bool].connect(self.setColor)

        greenb = QPushButton('green', self)
        greenb.setCheckable(True)
        greenb.move(20, 60)
        greenb.clicked[bool].connect(self.setColor)

        blueb = QPushButton('blue', self)
        blueb.setCheckable(True)
        blueb.move(20, 80)
        blueb.clicked[bool].connect(self.setColor)

        self.square = QFrame(self)
        self.square.setGeometry(150, 20, 100, 100)
        self.square.setStyleSheet('QWidget {background-color: %s}' %
            self.col.name())

        # slider
        sld = QSlider(Qt.Horizontal, self)
        sld.setFocusPolicy(Qt.NoFocus)
        sld.setGeometry(20, 160, 100, 20)
        sld.valueChanged[int].connect(self.changeValue)

        self.label = QLabel('0', self)
        self.label.setGeometry(140, 155, 80, 30)

        # progressbar
        self.pbar = QProgressBar(self)
        self.pbar.setGeometry(20, 200, 200, 25)

        self.btn = QPushButton('start', self)
        self.btn.move(20, 230)
        self.btn.clicked.connect(self.doAction)

        self.timer = QBasicTimer()
        self.step = 0

        # calendar
        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(20, 300)
        cal.clicked[QDate].connect(self.showDate)

        self.lbl = QLabel(self)
        date = cal.selectedDate()
        self.lbl.setText(date.toString())
        self.lbl.move(20, 280)

        self.setGeometry(300, 300, 400, 550)
        self.setWindowTitle('widgets')
        self.show()
Esempio n. 41
0
    def initUI(self):
        # checkbox
        cb = QCheckBox('Show title', self)
        cb.move(20, 160)
        cb.toggle()
        cb.stateChanged.connect(self.changeTitle)

        # toggle button
        self.col = QColor(0, 0, 0)
        redb = QPushButton('Red', self)
        redb.setCheckable(True)
        redb.move(10, 10)
        redb.clicked[bool].connect(self.setColor)
        redb = QPushButton('Green', self)
        redb.setCheckable(True)
        redb.move(10, 60)
        redb.clicked[bool].connect(self.setColor)
        blueb = QPushButton('Blue', self)
        blueb.setCheckable(True)
        blueb.move(10, 110)
        blueb.clicked[bool].connect(self.setColor)
        self.square = QFrame(self)
        self.square.setGeometry(150, 20, 100, 100)
        self.square.setStyleSheet("QWidget { background-color: %s }" %
                                  self.col.name())

        # slider
        sld = QSlider(Qt.Horizontal, self)
        sld.setFocusPolicy(Qt.NoFocus)
        sld.setGeometry(30, 210, 100, 30)
        sld.valueChanged[int].connect(self.changeValue)

        # pixmap
        self.label = QLabel(self)
        self.label.setPixmap(QPixmap('web.png'))
        self.label.setGeometry(160, 210, 80, 30)

        # process bar
        self.pbar = QProgressBar(self)
        self.pbar.setGeometry(30, 260, 200, 25)
        self.btn = QPushButton('Start', self)
        self.btn.move(40, 310)
        self.btn.clicked.connect(self.doAction)
        self.timer = QBasicTimer()
        self.step = 0

        # calendar
        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(300, 10)
        cal.clicked[QDate].connect(self.showDate)
        self.lbl = QLabel(self)
        date = cal.selectedDate()
        self.lbl.setText(date.toString())
        self.lbl.move(300, 260)

        # line edit
        self.lbl2 = QLabel(self)
        qle = QLineEdit(self)
        qle.move(300, 310)
        self.lbl2.move(480, 310)
        qle.textChanged[str].connect(self.onChanged)

        self.setGeometry(300, 300, 640, 480)
        self.setWindowTitle('QCheckBox')
        self.show()
Esempio n. 42
0
class MainWidget(QWidget):

    def __init__(self):
        QWidget.__init__(self)

        # Set Time One Group
        self.time_one_calendar = QCalendarWidget()
        self.time_one_country_combobox = QComboBox()
        self.time_one_vbox = QVBoxLayout()
        self.time_one_groupbox = QGroupBox("Time One")
        self.time_one_bottom_hbox = QHBoxLayout()
        self.time_one_time_edit = QTimeEdit()
        self.time_one_default_button = QPushButton()
        self.time_one_default_button.setIcon(QIcon("%s/gnome-set-time.png" % icon_path))
        self.time_one_default_button.setMaximumSize(50, 50)
        self.time_one_bottom_hbox.addWidget(self.time_one_time_edit)
        self.time_one_bottom_hbox.addWidget(self.time_one_default_button)
        self.time_one_vbox.addWidget(self.time_one_country_combobox)
        self.time_one_vbox.addWidget(self.time_one_calendar)
        self.time_one_vbox.addLayout(self.time_one_bottom_hbox)
        self.time_one_groupbox.setLayout(self.time_one_vbox)

        # Set Time Two Group
        self.time_two_groupbox = QGroupBox("Time Two")
        self.time_two_calendar = QCalendarWidget()
        self.time_two_vbox = QVBoxLayout()
        self.time_two_country_combobox = QComboBox()
        self.time_two_bottom_hbox = QHBoxLayout()
        self.time_two_time_edit = QTimeEdit()
        self.time_two_default_button = QPushButton()
        self.time_two_default_button.setIcon(QIcon("%s/gnome-set-time.png" % icon_path))
        self.time_two_default_button.setMaximumSize(50, 50)
        self.time_two_bottom_hbox.addWidget(self.time_two_time_edit)
        self.time_two_bottom_hbox.addWidget(self.time_two_default_button)
        self.time_two_vbox.addWidget(self.time_two_country_combobox)
        self.time_two_vbox.addWidget(self.time_two_calendar)
        self.time_two_vbox.addLayout(self.time_two_bottom_hbox)
        self.time_two_groupbox.setLayout(self.time_two_vbox)

        # Set main layout
        self.main_layout = QHBoxLayout()
        self.main_layout.addWidget(self.time_one_groupbox)
        self.main_layout.addWidget(self.time_two_groupbox)
        self.setLayout(self.main_layout)

        # Wire-up your widgets!
        self.time_one_connect()
        self.time_two_connect()
        self.time_one_default_button.clicked.connect(self.set_local_time_one)
        self.time_two_default_button.clicked.connect(self.set_local_time_two)

        # Set the local time for time one
        self.set_local_country()
        self.set_local_time_one()

        # Finally, convert the second time based on the first
        self.convert_timeone_to_timetwo()

    def set_local_country(self):
        global_timezone_list = timezone_info.get_global_timezone_list()
        local_tz_index = global_timezone_list.index(str(self.get_local_timezone()))
        self.time_one_country_combobox.addItems(global_timezone_list)
        self.time_one_country_combobox.setCurrentIndex(local_tz_index)
        self.time_two_country_combobox.addItems(global_timezone_list)

    # To-do: Current solution works for Debian systems. Need to find repo solution that
    # allows for something like "from tzlocal import get_localzone"
    @staticmethod
    def get_local_timezone():
        timezone_file = '/etc/timezone'
        try:
            file = open(timezone_file, 'r')
            system_timezone = file.read().rstrip()
        except IOError:
            print("Unable to open %s") & timezone_file
            system_timezone = 'UTC'

        return system_timezone

    @staticmethod
    def get_local_times():
        local_hour = datetime.datetime.now().strftime("%H")
        local_minute = datetime.datetime.now().strftime("%M")
        local_current_time = QTime(int(local_hour), int(local_minute), 0, 0)

        return local_current_time

    def set_local_time_one(self):

        # Set time for one time
        local_current_time = self.get_local_times()
        self.time_one_time_edit.setTime(local_current_time)

        # Set date for one calendar
        self.time_one_calendar.setSelectedDate(QDate.currentDate())

        # Convert the second time based on the first
        self.convert_timeone_to_timetwo()

    def set_local_time_two(self):

        # Set time for one time
        local_current_time = self.get_local_times()
        self.time_two_time_edit.setTime(local_current_time)

        # Set date for one calendar
        self.time_two_calendar.setSelectedDate(QDate.currentDate())

        # Convert the first time based on the second
        self.convert_timetwo_to_timeone()

    def time_one_connect(self):
        self.time_one_country_combobox.activated.connect(self.convert_timeone_to_timetwo)
        self.time_one_calendar.clicked.connect(self.convert_timeone_to_timetwo)
        self.time_one_calendar.currentPageChanged.connect(self.convert_timeone_to_timetwo)
        self.time_one_time_edit.timeChanged.connect(self.convert_timeone_to_timetwo)

    def time_two_connect(self):
        self.time_two_country_combobox.activated.connect(self.convert_timeone_to_timetwo)
        self.time_two_calendar.clicked.connect(self.convert_timetwo_to_timeone)
        self.time_two_calendar.currentPageChanged.connect(self.convert_timetwo_to_timeone)
        self.time_two_time_edit.timeChanged.connect(self.convert_timetwo_to_timeone)

    def time_one_disconnect(self):
        self.time_one_calendar.clicked.disconnect()
        self.time_one_country_combobox.activated.disconnect()
        self.time_one_time_edit.timeChanged.disconnect()

    def time_two_disconnect(self):
        self.time_two_calendar.clicked.disconnect()
        self.time_two_country_combobox.activated.disconnect()
        self.time_two_time_edit.timeChanged.disconnect()

    def clear_combo_boxes(self):
        self.time_one_country_combobox.clear()
        self.time_two_country_combobox.clear()

    def __amend_country_region(self):
        """
        Used to add the regional header before converting if a region outside of global is used.
        """

        current_region = timezone_info.get_city_region(self.time_one_country_combobox.currentText())
        time_one_country = self.time_one_country_combobox.currentText()
        time_two_country = self.time_two_country_combobox.currentText()

        if '/' not in time_one_country:
            time_one_country = current_region+'/'+self.time_one_country_combobox.currentText()
            time_two_country = current_region+'/'+self.time_two_country_combobox.currentText()

        return time_one_country, time_two_country

    def convert_timeone_to_timetwo(self):
        # Disconnect time two widgets,so that they do not run
        self.time_two_disconnect()

        time_one_country, time_two_country = self.__amend_country_region()

        date_time_one = datetime.datetime(self.time_one_calendar.yearShown(),
                                          self.time_one_calendar.monthShown(),
                                          self.time_one_calendar.selectedDate().day(),
                                          self.time_one_time_edit.time().hour(),
                                          self.time_one_time_edit.time().minute())

        first_tz = timezone(time_one_country)
        second_tz = timezone(time_two_country)

        first_dt = first_tz.localize(date_time_one)
        second_dt = first_dt.astimezone(second_tz)

        new_date_two = QDate(second_dt.year, second_dt.month, second_dt.day)
        self.time_two_calendar.setSelectedDate(new_date_two)

        new_time_two = QTime(int(second_dt.hour), int(second_dt.minute))
        self.time_two_time_edit.setTime(new_time_two)

        # Reconnect time one widgets.
        self.time_two_connect()

    def convert_timetwo_to_timeone(self):

        # Disconnect time one widgets,so that they do not run
        self.time_one_disconnect()

        time_one_country, time_two_country = self.__amend_country_region()

        date_time_two = datetime.datetime(self.time_two_calendar.yearShown(),
                                          self.time_two_calendar.monthShown(),
                                          self.time_two_calendar.selectedDate().day(),
                                          self.time_two_time_edit.time().hour(),
                                          self.time_two_time_edit.time().minute())

        first_tz = timezone(time_one_country)
        second_tz = timezone(time_two_country)

        second_dt = second_tz.localize(date_time_two)
        first_dt = second_dt.astimezone(first_tz)

        new_date_one = QDate(first_dt.year, first_dt.month, first_dt.day)
        self.time_one_calendar.setSelectedDate(new_date_one)

        new_time_one = QTime(int(first_dt.hour), int(first_dt.minute))
        self.time_one_time_edit.setTime(new_time_one)

        # Reconnect time one widgets
        self.time_one_connect()
    def ajoutRechercheBonDeTravail(self):
        # Recuperation des differents attributs
        self.bonDeTravailManager = BonTravailManager(pathBonTravailDatabase)
        try:
            fichierConf = open(pathFichierConf, 'r')  # try: ouvrir le fichier et le lire
            with fichierConf:
                self._conf = yaml.load(fichierConf)
        except IOError:  # attrape l'erreur IOError si elle se présente et renvoie
            print("Could not read file: ", pathFichierConf)  # définir ce qu'il faut faire pour corriger

        self.listeCategorieEquipement = list(self._conf['CategorieEquipement'])
        self.listeCategorieEquipement.sort()
        self.listeUnite = list(self._conf['Unite'])
        self.listeUnite.sort()
        self.listeEtatService = list(self._conf['EtatService'])
        self.listeEtatService.sort()

        #Mise a jour des differentes listes deroulantes
        self.comboBoxCategorieEquipement.clear()
        self.comboBoxCategorieEquipement.addItem("")
        self.comboBoxCategorieEquipement.addItems(self.listeCategorieEquipement)
        self.comboBoxEtat.clear()
        self.comboBoxEtat.addItem("")
        self.comboBoxEtat.addItems(self.listeEtatService)
        self.comboBoxUnite.clear()
        self.comboBoxUnite.addItem("")
        self.comboBoxUnite.addItems(self.listeUnite)

        fichierConf.close()

        self.signalRechercheBon = Communicate()
        self.signalRechercheBon.aucunResultat.connect(self.aucunResultat)
        self.signalRechercheBon.remplirTableau.connect(self.remplirTableau)
        self.signalRechercheBon.nouvelleRecherche.connect(self.nouvelleRecherche)

        #modification calendrier
        calendrierApres = QCalendarWidget()
        calendrierApres.setStyleSheet("background :#F5F5F5;\n color: black;")
        calendrierApres.setGridVisible(True)
        self.calendrierApres.setCalendarWidget(calendrierApres)
        calendrierApres.setVerticalHeaderFormat(QCalendarWidget.NoVerticalHeader)
        self.calendrierApres.setLocale(QLocale(QLocale.French, QLocale.France))
        calendrierAvant = QCalendarWidget()
        calendrierAvant.setStyleSheet("background :#F5F5F5;\n color: black;")
        calendrierAvant.setVerticalHeaderFormat(QCalendarWidget.NoVerticalHeader)
        calendrierAvant.setGridVisible(True)
        self.calendrierAvant.setCalendarWidget(calendrierAvant)
        self.calendrierAvant.setLocale(QLocale(QLocale.French, QLocale.France))

        self.calendrierAvant.setDate(QDate.currentDate())
        self.calendrierApres.setDate(QDate.currentDate())

        #Creation des differents colonnes pour le tableau de resultat
        self.listeCleDonnees = list(["IdEquipement", "NumeroBonTravail", "CategorieEquipement", "Modele", "Unite", "EtatBDT", "Date", "DescriptionSituation"])
        
        #liste contenant les bons résultant de la recherche
        self.listeResultat = list()
        #liste contenant les informations des bons a afficher
        self.listeDonnees = list()

        self.tableResultats.setColumnCount(len(self.listeCleDonnees))
        self.listeHeaders = ["Id de l'équipement", "Numero du bon de travail", "Catégorie d'équipement", "Modèle", "Unité", "État BDT", "Date", "Description de la situation"]
        self.tableResultats.setHorizontalHeaderLabels(self.listeHeaders)
        self.tableResultats.resizeColumnsToContents()
        self.tableResultats.setRowCount(0)
        self.dictionnaireRecherche = dict()

        #Connexion des differentes recherches pour la mise a jour automatique
        self.comboBoxCategorieEquipement.currentTextChanged.connect(self.rechercheCategorieEquipement)
        self.comboBoxEtat.currentTextChanged.connect(self.rechercheEtatDeService)
        self.comboBoxUnite.currentTextChanged.connect(self.rechercheUnite)
        self.calendrierAvant.dateChanged.connect(self.rechercheDateAvant)
        self.lineEditDescriptionSituation.returnPressed.connect(self.rechercheDescriptionSituation)
        self.calendrierApres.dateChanged.connect(self.rechercheDateApres)
        self.boutonNouvelleRecherche.clicked.connect(self.signalRechercheBon.nouvelleRecherche.emit)
        self.tableResultats.horizontalHeader().sectionClicked.connect(self.trier)
        self.boutonActualiser.clicked.connect(self.rechercherBonTravailThread)
        self.colonneClique = None
        self.nombreClique = 0
        # Empeche la modification de la table
        self.tableResultats.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers);
        self.tableResultats.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.tableResultats.cellDoubleClicked.connect(self.choisirBonDeTravail)
        self.bonDeTravailSelectionne = None
Esempio n. 44
0
File: gui.py Progetto: kharyuk/astro
    def __init__(self, parent):
        super(DateInputW, self).__init__()
        
        self.layout = QGridLayout()
        self.parent = parent
        
        self.title1 = QLabel(u'Начало:', self)
        self.title1.move(5, 5)
        self.cal1 = QCalendarWidget()
        self.cal1.setGridVisible(True)
        self.cal1.setDateEditEnabled(True)

        self.cal1.clicked.connect(self.setDateStart)
        self.cal1.setFixedSize(200, 160)
        ymd1 = [parent.day_start.year, parent.day_start.month, parent.day_start.day]
        qdate1 = QDate()
        qdate1.setDate(ymd1[0], ymd1[1], ymd1[2])
        self.cal1.setSelectedDate(qdate1)
        
        self.lbl1 = QLabel(self)
        self.lbl1.setText(parent.day_start.strftime('%d/%m/%Y'))
        self.lbl1.move(5, 25)
        
        self.title2 = QLabel(u'Конец:', self)
        self.title2.move(325, 5)
        self.cal2 = QCalendarWidget()
        self.cal2.setGridVisible(True)
        self.cal2.setDateEditEnabled(True)

        self.cal2.clicked.connect(self.setDateEnd)
        self.cal2.setFixedSize(200, 160)
        ymd2 = [parent.day_end.year, parent.day_end.month, parent.day_end.day]
        qdate2 = QDate()
        qdate2.setDate(ymd2[0], ymd2[1], ymd2[2])
        self.cal2.setSelectedDate(qdate2)
        
        self.lbl2 = QLabel(self)
        self.lbl2.setText(parent.day_end.strftime('%d/%m/%Y'))
        self.lbl2.move(325, 25)
        
        self.layout.addWidget(self.cal1, 1, 0)
        self.layout.addWidget(self.cal2, 1, 1)
        
        self.setAutoFillBackground(True)
        palette = self.palette()
        palette.setColor(self.backgroundRole(), QColor('white'))
        self.setPalette(palette)
        
        self.setFrameShape(_frameShape)
        self.setFrameShadow(_frameShadow)
        self.setLineWidth(_lineWidth)
        self.setMidLineWidth(_midLineWidth)
        
        #change NavBar background color
        child = self.cal1.children()[3]
        palette = child.palette()
        palette.setColor(child.backgroundRole(), QColor('silver'))
        child.setPalette(palette)
        
        child = self.cal2.children()[3]
        palette = child.palette()
        palette.setColor(child.backgroundRole(), QColor('silver'))
        child.setPalette(palette)
        
        # change cell color
        brush = self.cal1.paintCell
Esempio n. 45
0
class Window(QWidget):
    def __init__(self):
        super(Window, self).__init__()

        self.createPreviewGroupBox()
        self.createGeneralOptionsGroupBox()
        self.createDatesGroupBox()
        self.createTextFormatsGroupBox()

        layout = QGridLayout()
        layout.addWidget(self.previewGroupBox, 0, 0)
        layout.addWidget(self.generalOptionsGroupBox, 0, 1)
        layout.addWidget(self.datesGroupBox, 1, 0)
        layout.addWidget(self.textFormatsGroupBox, 1, 1)
        layout.setSizeConstraint(QLayout.SetFixedSize)
        self.setLayout(layout)

        self.previewLayout.setRowMinimumHeight(0,
                self.calendar.sizeHint().height())
        self.previewLayout.setColumnMinimumWidth(0,
                self.calendar.sizeHint().width())

        self.setWindowTitle("Calendar Widget")

    def localeChanged(self, index):
        self.calendar.setLocale(self.localeCombo.itemData(index))

    def firstDayChanged(self, index):
        self.calendar.setFirstDayOfWeek(
                Qt.DayOfWeek(self.firstDayCombo.itemData(index)))

    def selectionModeChanged(self, index):
        self.calendar.setSelectionMode(
                QCalendarWidget.SelectionMode(
                        self.selectionModeCombo.itemData(index)))

    def horizontalHeaderChanged(self, index):
        self.calendar.setHorizontalHeaderFormat(
                QCalendarWidget.HorizontalHeaderFormat(
                        self.horizontalHeaderCombo.itemData(index)))

    def verticalHeaderChanged(self, index):
        self.calendar.setVerticalHeaderFormat(
                QCalendarWidget.VerticalHeaderFormat(
                        self.verticalHeaderCombo.itemData(index)))

    def selectedDateChanged(self):
        self.currentDateEdit.setDate(self.calendar.selectedDate())

    def minimumDateChanged(self, date):
        self.calendar.setMinimumDate(date)
        self.maximumDateEdit.setDate(self.calendar.maximumDate())

    def maximumDateChanged(self, date):
        self.calendar.setMaximumDate(date)
        self.minimumDateEdit.setDate(self.calendar.minimumDate())

    def weekdayFormatChanged(self):
        format = QTextCharFormat()
        format.setForeground(
                Qt.GlobalColor(
                        self.weekdayColorCombo.itemData(
                                self.weekdayColorCombo.currentIndex())))

        self.calendar.setWeekdayTextFormat(Qt.Monday, format)
        self.calendar.setWeekdayTextFormat(Qt.Tuesday, format)
        self.calendar.setWeekdayTextFormat(Qt.Wednesday, format)
        self.calendar.setWeekdayTextFormat(Qt.Thursday, format)
        self.calendar.setWeekdayTextFormat(Qt.Friday, format)

    def weekendFormatChanged(self):
        format = QTextCharFormat()
        format.setForeground(
                Qt.GlobalColor(
                        self.weekendColorCombo.itemData(
                                self.weekendColorCombo.currentIndex())))

        self.calendar.setWeekdayTextFormat(Qt.Saturday, format)
        self.calendar.setWeekdayTextFormat(Qt.Sunday, format)

    def reformatHeaders(self):
        text = self.headerTextFormatCombo.currentText()
        format = QTextCharFormat()

        if text == "Bold":
            format.setFontWeight(QFont.Bold)
        elif text == "Italic":
            format.setFontItalic(True)
        elif text == "Green":
            format.setForeground(Qt.green)

        self.calendar.setHeaderTextFormat(format)

    def reformatCalendarPage(self):
        if self.firstFridayCheckBox.isChecked():
            firstFriday = QDate(self.calendar.yearShown(),
                    self.calendar.monthShown(), 1)

            while firstFriday.dayOfWeek() != Qt.Friday:
                firstFriday = firstFriday.addDays(1)

            firstFridayFormat = QTextCharFormat()
            firstFridayFormat.setForeground(Qt.blue)

            self.calendar.setDateTextFormat(firstFriday, firstFridayFormat)

        # May 1st in Red takes precedence.
        if self.mayFirstCheckBox.isChecked():
            mayFirst = QDate(self.calendar.yearShown(), 5, 1)

            mayFirstFormat = QTextCharFormat()
            mayFirstFormat.setForeground(Qt.red)

            self.calendar.setDateTextFormat(mayFirst, mayFirstFormat)

    def createPreviewGroupBox(self):
        self.previewGroupBox = QGroupBox("Preview")

        self.calendar = QCalendarWidget()
        self.calendar.setMinimumDate(QDate(1900, 1, 1))
        self.calendar.setMaximumDate(QDate(3000, 1, 1))
        self.calendar.setGridVisible(True)
        self.calendar.currentPageChanged.connect(self.reformatCalendarPage)

        self.previewLayout = QGridLayout()
        self.previewLayout.addWidget(self.calendar, 0, 0, Qt.AlignCenter)
        self.previewGroupBox.setLayout(self.previewLayout)
 
    def createGeneralOptionsGroupBox(self):
        self.generalOptionsGroupBox = QGroupBox("General Options")

        self.localeCombo = QComboBox()

        curLocaleIndex = -1
        index = 0

        this_language = self.locale().nativeLanguageName()
        this_country = self.locale().nativeCountryName()

        for locale in QLocale.matchingLocales(QLocale.AnyLanguage, QLocale.AnyScript, QLocale.AnyCountry):
            language = locale.nativeLanguageName()
            country = locale.nativeCountryName()

            if language == this_language and country == this_country:
                curLocaleIndex = index

            self.localeCombo.addItem('%s/%s' % (language, country), locale)
            index += 1

        if curLocaleIndex != -1:
            self.localeCombo.setCurrentIndex(curLocaleIndex)

        self.localeLabel = QLabel("&Locale")
        self.localeLabel.setBuddy(self.localeCombo)

        self.firstDayCombo = QComboBox()
        self.firstDayCombo.addItem("Sunday", Qt.Sunday)
        self.firstDayCombo.addItem("Monday", Qt.Monday)
        self.firstDayCombo.addItem("Tuesday", Qt.Tuesday)
        self.firstDayCombo.addItem("Wednesday", Qt.Wednesday)
        self.firstDayCombo.addItem("Thursday", Qt.Thursday)
        self.firstDayCombo.addItem("Friday", Qt.Friday)
        self.firstDayCombo.addItem("Saturday", Qt.Saturday)

        self.firstDayLabel = QLabel("Wee&k starts on:")
        self.firstDayLabel.setBuddy(self.firstDayCombo)

        self.selectionModeCombo = QComboBox()
        self.selectionModeCombo.addItem("Single selection",
                QCalendarWidget.SingleSelection)
        self.selectionModeCombo.addItem("None",
                QCalendarWidget.NoSelection)
        self.selectionModeLabel = QLabel("&Selection mode:")
        self.selectionModeLabel.setBuddy(self.selectionModeCombo)

        self.gridCheckBox = QCheckBox("&Grid")
        self.gridCheckBox.setChecked(self.calendar.isGridVisible())

        self.navigationCheckBox = QCheckBox("&Navigation bar")
        self.navigationCheckBox.setChecked(True)

        self.horizontalHeaderCombo = QComboBox()
        self.horizontalHeaderCombo.addItem("Single letter day names",
                QCalendarWidget.SingleLetterDayNames)
        self.horizontalHeaderCombo.addItem("Short day names",
                QCalendarWidget.ShortDayNames)
        self.horizontalHeaderCombo.addItem("Long day names",
                QCalendarWidget.LongDayNames)
        self.horizontalHeaderCombo.addItem("None",
                QCalendarWidget.NoHorizontalHeader)
        self.horizontalHeaderCombo.setCurrentIndex(1)

        self.horizontalHeaderLabel = QLabel("&Horizontal header:")
        self.horizontalHeaderLabel.setBuddy(self.horizontalHeaderCombo)

        self.verticalHeaderCombo = QComboBox()
        self.verticalHeaderCombo.addItem("ISO week numbers",
                QCalendarWidget.ISOWeekNumbers)
        self.verticalHeaderCombo.addItem("None",
                QCalendarWidget.NoVerticalHeader)

        self.verticalHeaderLabel = QLabel("&Vertical header:")
        self.verticalHeaderLabel.setBuddy(self.verticalHeaderCombo)

        self.localeCombo.currentIndexChanged.connect(self.localeChanged)
        self.firstDayCombo.currentIndexChanged.connect(self.firstDayChanged)
        self.selectionModeCombo.currentIndexChanged.connect(
                self.selectionModeChanged)
        self.gridCheckBox.toggled.connect(self.calendar.setGridVisible)
        self.navigationCheckBox.toggled.connect(
                self.calendar.setNavigationBarVisible)
        self.horizontalHeaderCombo.currentIndexChanged.connect(
                self.horizontalHeaderChanged)
        self.verticalHeaderCombo.currentIndexChanged.connect(
                self.verticalHeaderChanged)

        checkBoxLayout = QHBoxLayout()
        checkBoxLayout.addWidget(self.gridCheckBox)
        checkBoxLayout.addStretch()
        checkBoxLayout.addWidget(self.navigationCheckBox)

        outerLayout = QGridLayout()
        outerLayout.addWidget(self.localeLabel, 0, 0)
        outerLayout.addWidget(self.localeCombo, 0, 1)
        outerLayout.addWidget(self.firstDayLabel, 1, 0)
        outerLayout.addWidget(self.firstDayCombo, 1, 1)
        outerLayout.addWidget(self.selectionModeLabel, 2, 0)
        outerLayout.addWidget(self.selectionModeCombo, 2, 1)
        outerLayout.addLayout(checkBoxLayout, 3, 0, 1, 2)
        outerLayout.addWidget(self.horizontalHeaderLabel, 4, 0)
        outerLayout.addWidget(self.horizontalHeaderCombo, 4, 1)
        outerLayout.addWidget(self.verticalHeaderLabel, 5, 0)
        outerLayout.addWidget(self.verticalHeaderCombo, 5, 1)
        self.generalOptionsGroupBox.setLayout(outerLayout)

        self.firstDayChanged(self.firstDayCombo.currentIndex())
        self.selectionModeChanged(self.selectionModeCombo.currentIndex())
        self.horizontalHeaderChanged(self.horizontalHeaderCombo.currentIndex())
        self.verticalHeaderChanged(self.verticalHeaderCombo.currentIndex())
 
    def createDatesGroupBox(self):
        self.datesGroupBox = QGroupBox(self.tr("Dates"))

        self.minimumDateEdit = QDateEdit()
        self.minimumDateEdit.setDisplayFormat('MMM d yyyy')
        self.minimumDateEdit.setDateRange(self.calendar.minimumDate(),
                                          self.calendar.maximumDate())
        self.minimumDateEdit.setDate(self.calendar.minimumDate())

        self.minimumDateLabel = QLabel("&Minimum Date:")
        self.minimumDateLabel.setBuddy(self.minimumDateEdit)

        self.currentDateEdit = QDateEdit()
        self.currentDateEdit.setDisplayFormat('MMM d yyyy')
        self.currentDateEdit.setDate(self.calendar.selectedDate())
        self.currentDateEdit.setDateRange(self.calendar.minimumDate(),
                self.calendar.maximumDate())

        self.currentDateLabel = QLabel("&Current Date:")
        self.currentDateLabel.setBuddy(self.currentDateEdit)

        self.maximumDateEdit = QDateEdit()
        self.maximumDateEdit.setDisplayFormat('MMM d yyyy')
        self.maximumDateEdit.setDateRange(self.calendar.minimumDate(),
                self.calendar.maximumDate())
        self.maximumDateEdit.setDate(self.calendar.maximumDate())

        self.maximumDateLabel = QLabel("Ma&ximum Date:")
        self.maximumDateLabel.setBuddy(self.maximumDateEdit)

        self.currentDateEdit.dateChanged.connect(self.calendar.setSelectedDate)
        self.calendar.selectionChanged.connect(self.selectedDateChanged)
        self.minimumDateEdit.dateChanged.connect(self.minimumDateChanged)
        self.maximumDateEdit.dateChanged.connect(self.maximumDateChanged)
 
        dateBoxLayout = QGridLayout()
        dateBoxLayout.addWidget(self.currentDateLabel, 1, 0)
        dateBoxLayout.addWidget(self.currentDateEdit, 1, 1)
        dateBoxLayout.addWidget(self.minimumDateLabel, 0, 0)
        dateBoxLayout.addWidget(self.minimumDateEdit, 0, 1)
        dateBoxLayout.addWidget(self.maximumDateLabel, 2, 0)
        dateBoxLayout.addWidget(self.maximumDateEdit, 2, 1)
        dateBoxLayout.setRowStretch(3, 1)

        self.datesGroupBox.setLayout(dateBoxLayout)

    def createTextFormatsGroupBox(self):
        self.textFormatsGroupBox = QGroupBox("Text Formats")

        self.weekdayColorCombo = self.createColorComboBox()
        self.weekdayColorCombo.setCurrentIndex(
                self.weekdayColorCombo.findText("Black"))

        self.weekdayColorLabel = QLabel("&Weekday color:")
        self.weekdayColorLabel.setBuddy(self.weekdayColorCombo)

        self.weekendColorCombo = self.createColorComboBox()
        self.weekendColorCombo.setCurrentIndex(
                self.weekendColorCombo.findText("Red"))

        self.weekendColorLabel = QLabel("Week&end color:")
        self.weekendColorLabel.setBuddy(self.weekendColorCombo)

        self.headerTextFormatCombo = QComboBox()
        self.headerTextFormatCombo.addItem("Bold")
        self.headerTextFormatCombo.addItem("Italic")
        self.headerTextFormatCombo.addItem("Plain")

        self.headerTextFormatLabel = QLabel("&Header text:")
        self.headerTextFormatLabel.setBuddy(self.headerTextFormatCombo)

        self.firstFridayCheckBox = QCheckBox("&First Friday in blue")

        self.mayFirstCheckBox = QCheckBox("May &1 in red")

        self.weekdayColorCombo.currentIndexChanged.connect(
                self.weekdayFormatChanged)
        self.weekendColorCombo.currentIndexChanged.connect(
                self.weekendFormatChanged)
        self.headerTextFormatCombo.currentIndexChanged.connect(
                self.reformatHeaders)
        self.firstFridayCheckBox.toggled.connect(self.reformatCalendarPage)
        self.mayFirstCheckBox.toggled.connect(self.reformatCalendarPage)

        checkBoxLayout = QHBoxLayout()
        checkBoxLayout.addWidget(self.firstFridayCheckBox)
        checkBoxLayout.addStretch()
        checkBoxLayout.addWidget(self.mayFirstCheckBox)

        outerLayout = QGridLayout()
        outerLayout.addWidget(self.weekdayColorLabel, 0, 0)
        outerLayout.addWidget(self.weekdayColorCombo, 0, 1)
        outerLayout.addWidget(self.weekendColorLabel, 1, 0)
        outerLayout.addWidget(self.weekendColorCombo, 1, 1)
        outerLayout.addWidget(self.headerTextFormatLabel, 2, 0)
        outerLayout.addWidget(self.headerTextFormatCombo, 2, 1)
        outerLayout.addLayout(checkBoxLayout, 3, 0, 1, 2)
        self.textFormatsGroupBox.setLayout(outerLayout)

        self.weekdayFormatChanged()
        self.weekendFormatChanged()

        self.reformatHeaders()
        self.reformatCalendarPage()
 
    def createColorComboBox(self):
        comboBox = QComboBox()
        comboBox.addItem("Red", Qt.red)
        comboBox.addItem("Blue", Qt.blue)
        comboBox.addItem("Black", Qt.black)
        comboBox.addItem("Magenta", Qt.magenta)

        return comboBox
Esempio n. 46
0
__author__ = 'tim'

from PyQt5.QtWidgets import QApplication,QCalendarWidget
import sys

app=QApplication(sys.argv)
cal=QCalendarWidget()
cal.show()
sys.exit(app.exec_())
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# See http://doc.qt.io/qt-5/qcalendarwidget.html#details
# See also http://doc.qt.io/qt-5/qtwidgets-widgets-calendarwidget-example.html

import sys

from PyQt5.QtWidgets import QApplication, QCalendarWidget


def printValue():
    print(calendar.selectedDate())

app = QApplication(sys.argv)

calendar = QCalendarWidget()

calendar.selectionChanged.connect(printValue)

calendar.show()

# The mainloop of the application. The event handling starts from this point.
# The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.
exit_code = app.exec_()

# The sys.exit() method ensures a clean exit.
# The environment will be informed, how the application ended.
sys.exit(exit_code)
class Calendar(QWidget):
    def __init__(self, dateplot):
        self.dateplot = dateplot
        QWidget.__init__(self)
        self.layout = QHBoxLayout()

        self.cal = QCalendarWidget(self)
        self.cal.setGridVisible(True)
        self.cal.clicked[QDate].connect(self.showDate)
        self.cal.activated.connect(self.hide)

        gbCalendar = QGroupBox('Calendar')
        gbDataset = QGroupBox('Dataset')
        gbCalendar.setStyleSheet('QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}')
        gbDataset.setStyleSheet('QGroupBox { padding-top: 20 px;border: 1px solid gray; border-radius: 3px}')

        self.confAuto = QCheckBox('Configuration : Auto')
        self.checkboxRealTime = QCheckBox('Real-time')
        self.checkboxPastRuns = QCheckBox('Archived')
        self.spinboxDays = QSpinBox()
        self.spinboxDays.setRange(1, 100)
        self.spinboxDays.setValue(1)

        self.confAuto.setChecked(0)

        self.confAuto.stateChanged.connect(self.dateplot.loadConf)
        self.checkboxRealTime.stateChanged.connect(self.realtime)
        self.checkboxPastRuns.stateChanged.connect(self.archivedData)

        self.checkboxRealTime.setCheckState(2)
        layoutDataset = QGridLayout()
        layoutDataset.addWidget(self.confAuto, 0, 0, 2, 1)
        layoutDataset.addWidget(self.checkboxRealTime, 2, 0, 2, 1)
        layoutDataset.addWidget(QLabel('Duration (Days)'), 4, 1, 1, 1)
        layoutDataset.addWidget(self.checkboxPastRuns, 5, 0, 1, 1)
        layoutDataset.addWidget(self.spinboxDays, 5, 1, 1, 1)

        layoutCalendar = QVBoxLayout()
        layoutCalendar.addWidget(self.cal)

        gbCalendar.setLayout(layoutCalendar)
        gbDataset.setLayout(layoutDataset)

        self.layout.addWidget(gbCalendar)
        self.layout.addWidget(gbDataset)
        self.setLayout(self.layout)
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.setWindowModality(Qt.WindowModal)

    def showDate(self, date=None):
        date = self.cal.selectedDate() if date is None else date

        date = dt.datetime.combine(date.toPyDate(), dt.datetime.min.time())
        self.dateplot.updateDate(date)

    def closeEvent(self, event):
        self.hide()
        try:
            event.accept()
        except AttributeError:
            pass

    def realtime(self):
        state = 0 if self.checkboxRealTime.isChecked() else 2
        self.checkboxPastRuns.setCheckState(state)

    def archivedData(self):
        state = 0 if self.checkboxPastRuns.isChecked() else 2
        self.checkboxRealTime.setCheckState(state)
Esempio n. 49
0
class SelectSession(QWidget):
    def update(self):

        self.glob.socket.send_json(dict(action='listsessions'))
        res = self.glob.socket.recv_json()
        print(res,"asd")
        self.dates = set()

        self.lst.insertItems(0, [d + " " + name for d, name in res])
        for d, n in res:
            self.dates.add(d.split(' ')[0])

        format = QtGui.QTextCharFormat()
        format.setForeground(QtCore.Qt.blue)
        format.setBackground(QtCore.Qt.lightGray)
        import datetime

        for d in self.dates:
            dt = datetime.datetime.strptime(d,
                                            "%Y-%m-%d")  # datetime.datetime.strptime(str(_now), "%Y-%m-%d %H:%M:%S.%f")
            print(dt)
            self.cal.setDateTextFormat(dt.date(), format)

    def goto(self):
        i = self.lst.selectedItems()
        if (i):
            item = i[0]
            import datetime
            dt = datetime.datetime.strptime(item.text().split(" ")[0], "%Y-%m-%d")
            self.cal.setSelectedDate(dt.date())

    def doExport(self):
        i = self.lst.selectedItems()
        for x in i:
            txt = x.text()
            d, t, n = txt.split(" ")

            # mk query for n


            fname = QFileDialog.getSaveFileName(self, 'Savefile', './', "raw json(*.json);; exel tables(*.csv)")

            self.glob.socket.send_json(dict(action='getdata', name=n, limit=1000))
            res = self.glob.socket.recv_json()
            print(res)
            if ('.csv' == fname[0][-4:]):
                #print(res[0])
                f = open(fname[0], "w")
                for i, t in enumerate(res[0][0]):
                    f.write('time {0};'.format(i))
                f.write("\n")
                for r in res:
                    for r2 in r[0]:
                        f.write('{0};'.format(r2))
                    try:
                        if isinstance(r[1], list):
                            for r2 in r[1]:
                                f.write('{0};'.format(str(r2)))
                        else:
                            f.write(str(r[1]))

                    except:
                        f.write(str(r[1]))
                    f.write("\n")
            else:
                f = open(fname[0], "w")
                f.write(json.dumps(res))
                f.close()

    def __init__(self, main, parent=None):
        super(SelectSession, self).__init__(parent)
        self.glob = main

        mainLayout = QVBoxLayout()

        self.cal = QCalendarWidget()
        self.export = QPushButton('CSV export')
        self.cal.setFirstDayOfWeek(QtCore.Qt.Monday)
        self.lst = QListWidget()
        self.lst.clicked.connect(self.goto)

        mainLayout.addWidget(self.cal)
        mainLayout.addWidget(self.lst)

        mainLayout.addWidget(self.export)

        self.export.clicked.connect(self.doExport)
        mainLayout.addStretch(2)
        self.setLayout(mainLayout)