Пример #1
0
class WindowClass(QWidget):
    def __init__(self, parent=None):

        super(WindowClass, self).__init__(parent)
        self.btn = QPushButton(self)  #self参数则让该按钮显示当前窗体中
        self.btn.setText("选择日期")
        self.btn.move(0, 0)
        self.btn.clicked.connect(self.openCalendar)
        self.le = QLabel(self)
        self.cal = QCalendarWidget(self)
        self.cal.setMinimumDate(QDate(2017, 1, 1))  #设置日期最小范围
        self.cal.setMaximumDate(QDate(2019, 12, 30))  #设置日期最大范围
        self.cal.setGridVisible(True)  #是否显示日期之间的网格
        self.cal.move(5, 30)
        self.cal.hide()  #隐藏日期控件
        self.cal.clicked[QDate].connect(
            self.showDate)  #clicked[参数],即定义showDate是传入的参数类型设置
        date = self.cal.selectedDate()  #获取选中日期,默认当前系统时间
        self.le.setText(date.toString('yyyy-MM-dd dddd'))
        self.le.move(100, 8)
        self.setGeometry(100, 100, 400, 350)  #设置当前窗体位置和大小
        self.setWindowTitle("日历控件使用")

    def showDate(self, date):
        self.le.setText(date.toString("yyyy-MM-dd dddd"))
        self.cal.close()  #关闭日期控件

    def openCalendar(self):
        self.cal.show()  #显示日期控件
Пример #2
0
    def home(self):
        """
        Home page of the App. 
        """

        # Create and display calendar object.
        calendar = QCalendarWidget(self)
        calendar.setGridVisible(True)
        calendar.move(20, 50)
        calendar.resize(320, 200)
        calendar.setMinimumDate(QtCore.QDate(1995, 6, 16))
        calendar.setMaximumDate(QtCore.QDate.currentDate())
        calendar.clicked[QtCore.QDate].connect(self.get_apod_date)

        # Get date selected by calendar object and change date to desired
        # format. (YYMMDD)
        date = calendar.selectedDate()
        a_date = [int(str(date.year())[2:]), date.month(), date.day()]
        self.astro_date = ''.join(list(map(str, a_date)))

        # Create "See Picture" button. Connect it to get_picture function.
        see_button = QPushButton("See Picture", self)
        see_button.move(20, 280)
        see_button.clicked.connect(self.get_picture)

        # Display all objects in the window.
        self.show()
Пример #3
0
class CalendarDemo(QWidget):
    global currentYear, currentMonth

    currentYear = datetime.now().year
    currentMonth = datetime.now().month

    def __init__(self):
        super().__init__()
        self.setWindowTitle("Calendar PyQt5 & Python")
        self.setGeometry(300, 300, 450, 300)
        self.initUI()

    def initUI(self):
        self.calendar = QCalendarWidget(self)
        self.calendar.move(20, 20)
        self.calendar.setGridVisible(True)

        self.calendar.setMinimumDate(QDate(currentYear, currentMonth - 1, 1))
        self.calendar.setMaximumDate(
            QDate(currentYear, currentMonth + 1,
                  calendar.monthrange(currentYear, currentMonth)[1]))

        self.calendar.setSelectedDate(QDate(currentYear, currentMonth, 1))

        self.calendar.clicked.connect(self.printDateInfo)

    def printDateInfo(self, qDate):
        print("{0}/{1}/{2}".format(qDate.month(), qDate.day(), qDate.year()))
        print("Day Number of the year: {}".format(qDate.dayOfYear()))
        print("Day Number of the week: {}".format(qDate.dayOfWeek()))
Пример #4
0
    def __init__(self):
        super(window, self).__init__()
        self.setGeometry(50, 50, 800, 500)
        self.setWindowTitle('pyqt5 Tut')
        # self.setWindowIcon(QIcon('pic.png'))

        extractAction = QAction('&Get to the choppah', self)
        extractAction.setShortcut('Ctrl+Q')
        extractAction.setStatusTip('leave the app')
        extractAction.triggered.connect(self.close_application)

        self.statusBar()

        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('&File')
        fileMenu.addAction(extractAction)

        extractAction = QAction(QIcon('pic.png'), 'flee the scene', self)
        extractAction.triggered.connect(self.close_application)
        self.toolBar = self.addToolBar('extraction')
        self.toolBar.addAction(extractAction)

        fontChoice = QAction('Font', self)
        fontChoice.triggered.connect(self.font_choice)
        # self.toolBar = self.addToolBar('Font')
        self.toolBar.addAction(fontChoice)

        cal = QCalendarWidget(self)
        cal.move(500, 200)
        cal.resize(200, 200)

        self.home()
    def home(self):
        btn = QPushButton('quit', self)
        btn.clicked.connect(self.close_application)
        # btn.resize(btn.sizeHint()) # auto size for btn
        btn.resize(btn.minimumSizeHint())
        btn.move(0, 100)

        extractAction = QAction(QIcon('icon-smoker.jpg'), 'Flee the scene',
                                self)
        extractAction.triggered.connect(self.close_application)
        self.toolBar = self.addToolBar('Extraction')
        self.toolBar.addAction(extractAction)

        bsAction = QAction(QIcon('icon-me.jpg'), 'bullshit time', self)
        bsAction.triggered.connect(self.bullshit)
        self.toolBar.addAction(bsAction)

        fontChoice = QAction('font', self)
        fontChoice.triggered.connect(self.font_choice)
        self.toolBar.addAction(fontChoice)

        color = QColor(0, 0, 0)
        fontColor = QAction('Font bg Color', self)
        fontColor.triggered.connect(self.color_picker)
        self.toolBar.addAction(fontColor)

        cal = QCalendarWidget(self)
        cal.move(500, 200)
        cal.resize(200, 200)

        checkBox = QCheckBox('window size', self)
        checkBox.move(300, 25)
        # checkBox.toggle()
        checkBox.stateChanged.connect(self.enlargeWindow)

        self.progress = QProgressBar(self)
        self.progress.setGeometry(200, 80, 250, 20)

        self.btn = QPushButton('download', self)
        self.btn.move(200, 120)
        self.btn.clicked.connect(self.download)

        # print(self.style().objectName())
        self.styleChoice = QLabel('Windows', self)

        comboBox = QComboBox(self)
        # comboBox.addItem('motif')
        # comboBox.addItem('Windows')
        # comboBox.addItem('cde')
        # comboBox.addItem('Plastique')
        # comboBox.addItem('Cleanlooks')
        # comboBox.addItem('windowsvista')
        comboBox.addItems(QStyleFactory.keys())

        comboBox.move(25, 250)
        self.styleChoice.move(50, 150)
        comboBox.activated[str].connect(self.style_choice)

        self.show()
Пример #6
0
Файл: gui.py Проект: RMDE/DBMS
 def Calendar(self, x, y, h, w):
     cal = QCalendarWidget(self)
     cal.setMinimumDate(QDate(1988, 1, 1))
     cal.setMaximumDate(QDate(2088, 1, 1))
     cal.setGridVisible(True)
     cal.move(x, y)
     cal.resize(w, h)
     return cal
Пример #7
0
    def __init__(self):
        #Window structure set up
        super(Mainwindow, self).__init__()
        self.setWindowTitle("My GUI ")
        self.setGeometry(50, 50, 500, 500)
        self.setWindowTitle('First GUI with PyQt 5')

        #Menu Creation
        extractAction = QAction('&Quit', self)
        extractAction.setShortcut('Ctrl+Q')
        extractAction.setStatusTip('Leave the App')
        #Image set up for the menu items
        extractAction = QAction(QIcon('Quit.jpg'), 'Quit', self)
        extractAction.triggered.connect(self.closeApplication)

        #Main menu creation
        mainManu = self.menuBar()
        fileMenu = mainManu.addMenu('&File')
        fileMenu.addAction(extractAction)

        #OPen file tab
        openFile = QAction('&OpenFile', self)
        openFile.setShortcut('CTRL+O')
        openFile.setStatusTip('OpenFile')
        openFile.triggered.connect(self.openFile)
        fileMenu.addAction(openFile)

        #Save file
        saveFile = QAction('&SaveFile', self)
        saveFile.setShortcut('CTRL+S')
        saveFile.setStatusTip('Save File')
        saveFile.triggered.connect(self.fileSave)
        fileMenu.addAction(saveFile)

        self.statusBar()

        #Add Toolbar section
        self.toolBar = self.addToolBar('Extraction')
        self.toolBar.addAction(extractAction)

        #Add Text editior
        openEditor = QAction('&Editor', self)
        openEditor.setShortcut('Ctrl+E')
        openEditor.setStatusTip('Open Editor')
        openEditor.triggered.connect(self.editor)
        self.toolBar.addAction(openEditor)

        #Addition of Font list
        fontChoice = QAction('Font', self)
        fontChoice.triggered.connect(self.font_Choice)
        fontChoice.setStatusTip('Select Colors')
        self.toolBar.addAction(fontChoice)

        cal = QCalendarWidget(self)
        cal.move(500, 200)
        cal.resize(200, 200)

        self.HomeItems()
Пример #8
0
class App(QMainWindow):
    def __init__(self):
        super().__init__()

        self.title = 'PyQt5 School_admin_app'
        self.left = 10
        self.top = 100
        self.width = config1.width
        self.height = config1.height
        self.initUI()

    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.menubar()
        self.calender()
        self.root_buttons()
        self.statusBar().showMessage('School Admin Tool')
        self.show()

    def root_buttons(self):
        self.attendace_btn = QPushButton('Attendance', self)
        self.attendace_btn.clicked.connect(self.class_btn)
        self.attendace_btn.move(50, 30)
        self.performance_btn = QPushButton('Performance', self)
        self.performance_btn.clicked.connect(self.class_btn)
        self.performance_btn.move(150, 30)
        self.bonafide_btn = QPushButton('Bonafide', self)
        self.bonafide_btn.clicked.connect(self.class_btn)
        self.bonafide_btn.move(250, 30)

    def class_btn(self):
        pass

    def calender(self):
        self.cal = QCalendarWidget(self)
        self.cal.resize(200, 150)
        self.cal.setGridVisible(True)
        self.cal.move(self.width - 210, 25)

    def menubar(self):
        exitAct = QAction(QIcon('exit.png'), '&Exit', self)
        exitAct.setShortcut('Ctrl+Q')
        exitAct.setStatusTip('Exit application')
        exitAct.triggered.connect(qApp.quit)

    def addbox_text(self, ):
        print("called: ", self.clicked_class.text())
        self.textGenerated = QLineEdit(self)
        self.textGenerated.move(5, 106)
        self.textGenerated.resize(self.width - 10, 80)
        self.textGenerated.setVisible(False)

    @pyqtSlot()
    def on_click(self):
        textboxValue = self.textbox.text()
        print("text: ", textboxValue)
Пример #9
0
    def home(self):
        btn = QPushButton('Quit', self)
        btn.clicked.connect(self.close)
        btn.resize(btn.minimumSizeHint())
        btn.move(10,100)

        exitAction = QAction(QIcon('pyicon.png'), 'Exit the Application', self)
        exitAction.triggered.connect(self.close)
        
        tool = self.addToolBar('Exit')
        tool.addAction(exitAction)

        font = QAction(QIcon('pyicon.png'), 'Choose Font', self)
        font.triggered.connect(self.choosefont)
        
        tool.addAction(font)

        color = QColor(0, 0, 0)
        fontcolor = QAction('Font BG Color', self)
        fontcolor.triggered.connect(self.colorpicker)

        tool.addAction(fontcolor)
        

        
        checkBox = QCheckBox('Enlarge Window',self)
        checkBox.move(200, 25)
##        checkBox.toggle()
        checkBox.stateChanged.connect(self.enlargewindow)

        self.pbar = QProgressBar(self)
        self.pbar.setGeometry(200, 80, 250, 20)

        dbtn = QPushButton('download', self)
        dbtn.move(200, 120)
        dbtn.clicked.connect(self.download)

        self.stylelabel = QLabel('GUI Style', self)

        dropdown = QComboBox(self)
        dropdown.addItem('WindowsVista')
        dropdown.addItem('Windows')
        dropdown.addItem('Fusion')
        dropdown.addItem('WindowsXP')


        dropdown.move(50,200)
        self.stylelabel.move(55,175)
        dropdown.activated[str].connect(self.style)

        cal = QCalendarWidget(self)
        cal.move(500, 200)
        cal.resize(200,200)
        
        
        self.show()
Пример #10
0
 def initUI(self):
     self.setGeometry(300, 300, 300, 220)
     self.setWindowTitle('My App')
     self.label1 = QLabel(self)
     self.label1.setText("Hello World")
     mycal = QCalendarWidget(self)
     mycal.move(30, 30)
     self.button1 = QPushButton(self)
     self.button1.setText("Push Me")
     self.button1.move(0, 20)
def main_widget():
    win = QWidget()
    tab = QTabWidget()
    tab.setTabsClosable(True)

    cal = QCalendarWidget()
    cal.setGridVisible(True)
    cal.move(20, 20)
    cal.setVisible(False)
    excel_path = r'C:\Users\akhil\Downloads\support_roaster_format.xlsx'
    et = ExcelTable(win,
                    cal,
                    excel_path,
                    tab,
                    summary_sheet='Summary',
                    sheet_name='Prudents')
    cal.clicked.connect(et.show_date)

    def open_calendar(args):
        cal.setVisible(True)

    def file_save_as(args):
        filePath, _ = QFileDialog.getSaveFileName(
            win, "Export to Excel", "",
            "Excel Workbook (*.xlsx);;Excel 97-2003 Workbook (*.xls);;CSV UTF-8 (Comma delimited) (*.csv)"
        )
        et.export_to_excel(filePath)

    def file_open(args):
        filePath, _ = QFileDialog.getOpenFileName(
            win, "Import from Excel", "",
            "Excel Workbook (*.xlsx);;Excel 97-2003 Workbook (*.xls);;CSV UTF-8 (Comma delimited) (*.csv)"
        )
        et.import_from_excel(filePath)

    set_data_button = QPushButton("Set First Week")
    set_data_button.setFixedSize(200, 50)
    set_data_button.clicked.connect(open_calendar)

    load_existing = QPushButton("Load Existing")
    load_existing.setFixedSize(200, 50)
    load_existing.clicked.connect(file_open)

    save_data_button = QPushButton("Export to Excel")
    save_data_button.setFixedSize(200, 50)
    save_data_button.clicked.connect(file_save_as)

    layout = QGridLayout()
    layout.addWidget(set_data_button, 0, 0)
    layout.addWidget(cal, 0, 1)
    layout.addWidget(load_existing, 0, 2)
    layout.addWidget(tab, 1, 0, 1, 0)
    layout.addWidget(save_data_button, 2, 0)
    win.setLayout(layout)
    return win, cal, et
Пример #12
0
    def __init__(self):
        super(window, self).__init__()
        self.setGeometry(50, 50, 800, 500)
        self.setWindowTitle('pyqt5 Tut')
        self.setWindowIcon(QIcon('Jellyfish.jpg'))
        self._console = QTextBrowser(self)

        extractAction = QAction('Quit application', self)
        extractAction.setShortcut('Ctrl+Q')
        extractAction.setStatusTip('leave the app')
        extractAction.triggered.connect(self.close_application)

        openEditor = QAction('&Editor', self)
        openEditor.setShortcut('Ctrl+E')
        openEditor.setStatusTip('Open Editor')
        openEditor.triggered.connect(self.editor)

        openFile = QAction('&Open File', self)
        openFile.setShortcut('Ctrl+O')
        openFile.setStatusTip('Open File')
        openFile.triggered.connect(self.file_open)

        saveFile = QAction('&Save File', self)
        saveFile.setShortcut('Ctrl+S')
        saveFile.setStatusTip('Save File')
        saveFile.triggered.connect(self.file_save)

        self.statusBar()

        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('&File')
        fileMenu.addAction(extractAction)

        fileMenu.addAction(openFile)
        fileMenu.addAction(saveFile)
        # create the layout

        editorMenu = mainMenu.addMenu('&Editor')
        editorMenu.addAction(openEditor)

        extractAction = QAction(QIcon('Jellyfish.jpg'), 'flee the scene', self)
        extractAction.triggered.connect(self.close_application)
        self.toolBar = self.addToolBar('extraction')
        self.toolBar.addAction(extractAction)

        fontChoice = QAction('Font', self)
        fontChoice.triggered.connect(self.font_choice)
        # self.toolBar = self.addToolBar('Font')
        self.toolBar.addAction(fontChoice)

        cal = QCalendarWidget(self)
        cal.move(500, 200)
        cal.resize(200, 200)

        self.home()
    def home(self):
        btn = QPushButton('Quit', self)
        btn.clicked.connect(self.close_application)
        btn.resize(btn.minimumSizeHint())
        btn.move(0, 100)

        extractAction = QAction(QIcon('todachoppa.png'), 'Flee the Scene',
                                self)
        extractAction.triggered.connect(self.close_application)
        self.toolBar = self.addToolBar("Extraction")
        self.toolBar.addAction(extractAction)

        fontChoice = QAction('Font', self)
        fontChoice.triggered.connect(self.font_choice)
        #self.toolBar = self.addToolBar("Font")
        self.toolBar.addAction(fontChoice)

        color = QColor(0, 0, 0)

        fontColor = QAction('Font bg Color', self)
        fontColor.triggered.connect(self.color_picker)

        self.toolBar.addAction(fontColor)

        checkBox = QCheckBox('Enlarge Window', self)
        checkBox.move(200, 25)
        checkBox.stateChanged.connect(self.enlarge_window)

        self.progress = QProgressBar(self)
        self.progress.setGeometry(200, 80, 250, 20)

        self.btn = QPushButton("Download", self)
        self.btn.move(200, 120)
        self.btn.clicked.connect(self.download)

        print(self.style().objectName())
        self.styleChoice = QLabel("Windows Vista", self)

        comboBox = QComboBox(self)
        comboBox.addItem("motif")
        comboBox.addItem("Windows")
        comboBox.addItem("cde")
        comboBox.addItem("Plastique")
        comboBox.addItem("Cleanlooks")
        comboBox.addItem("windowsvista")

        comboBox.move(50, 250)
        self.styleChoice.move(50, 150)
        comboBox.activated[str].connect(self.style_choice)

        cal = QCalendarWidget(self)
        cal.move(500, 200)
        cal.resize(350, 350)

        self.show()
Пример #14
0
    def __init__(self):
        super(Window, self).__init__()
        self.setGeometry(50, 50, 500, 400)
        self.setWindowTitle('pyqt5 Tuts')
        self.setWindowIcon(QIcon('python-logo.png'))

        extractAction = QAction("&GET TO THE CHOPPAH!!!", self)
        extractAction.setShortcut("Ctrl+Q")
        extractAction.setStatusTip('Leave The App')
        extractAction.triggered.connect(self.close_application)

        self.statusBar()

        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('&File')
        fileMenu.addAction(extractAction)

        extractAction = QAction(QIcon('todachoppa.png'), 'Flee the Scene',
                                self)
        extractAction.triggered.connect(self.close_application)

        self.toolBar = self.addToolBar("Extraction")
        self.toolBar.addAction(extractAction)

        fontChoice = QAction('Font', self)
        fontChoice.triggered.connect(self.font_choice)
        #self.toolBar = self.addToolBar("Font")
        self.toolBar.addAction(fontChoice)

        fontColor = QAction('Font bg Color', self)
        fontColor.triggered.connect(self.color_picker)

        self.toolBar.addAction(fontColor)

        cal = QCalendarWidget(self)
        cal.move(200, 150)
        cal.resize(200, 200)

        openEditor = QAction('&Editor', self)
        openEditor.setShortcut('Ctrl+E')
        openEditor.setStatusTip('Open Editor')
        openEditor.triggered.connect(self.editor)

        editorMenu = mainMenu.addMenu('&Editor')
        editorMenu.addAction(openEditor)

        openFile = QAction("&Open File", self)
        openFile.setShortcut("Ctrl+O")
        openFile.setStatusTip('Open File')
        openFile.triggered.connect(self.file_open)

        fileMenu.addAction(openFile)

        self.home()
Пример #15
0
class Example(QWidget):
    def __init__(self):
        super(Example, self).__init__()
        self.initUI()

    def initUI(self):

        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.valueChanged.connect(self.printSlider)

        self.cb = QCheckBox('Show title', self)
        self.cb.move(0, 50)
        self.cb.stateChanged.connect(self.printCB)

        self.toggle = QPushButton("Hello", self)
        self.toggle.move(0, 100)
        self.toggle.setCheckable(True)
        self.toggle.toggled.connect(self.printToggle)

        self.cal = QCalendarWidget(self)
        self.cal.setGridVisible(True)
        self.cal.move(0, 150)
        self.cal.clicked.connect(self.printDate)

        self.setGeometry(300, 300, 600, 400)
        self.setWindowTitle('Animation')
        self.show()

    def paintEvent(self, e):

        qp = QPainter()
        qp.begin(self)
        self.draw(qp)
        qp.end()

    def draw(self, qp):

        qp.setPen(QColor(0, 0, 0))

        qp.setBrush(QColor(255, 255, 255))
        qp.drawRect(0, 0, self.width(), self.height())

    def printSlider(self):
        print self.slider.value()

    def printCB(self):
        print self.cb.checkState()

    def printToggle(self, onoff):
        print onoff

    def printDate(self, date):
        #print date
        print self.cal.selectedDate()
Пример #16
0
 def initUI(self):
     my_calendar = QCalendarWidget(self)
     my_calendar.setGridVisible(True)
     my_calendar.move(10, 20)
     my_calendar.clicked[QDate].connect(self.show_date)
     self.my_label = QLabel(self)
     date = my_calendar.selectedDate()
     self.my_label.setText(date.toString())
     self.my_label.move(10, 220)
     self.setGeometry(100, 100, 320, 240)
     self.setWindowTitle('Calendar')
     self.show()
Пример #17
0
 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, 650, 300)
     self.setWindowTitle('Calendar')
     self.show()
Пример #18
0
class Cal(QMainWindow):
    def __init__(self, parent=None):
        super(Cal, self).__init__(parent)
        self.setWindowTitle("Choose Section Date")
        self.resize(310, 210)
        self.move(750, 250)

        self.Cale = QCalendarWidget(self)
        self.Cale.setVerticalHeaderFormat(self.Cale.NoVerticalHeader)
        self.Cale.move(5, 5)
        self.Cale.resize(300, 200)

        self.Cale.clicked()
Пример #19
0
 def __init__(self, parent, title="اختر التاريخ"):
     self.parent = parent
     win = QDialog()
     layout = QHBoxLayout()
     cal = QCalendarWidget()
     cal.setLocale(QLocale("AR"))
     cal.setGridVisible(True)
     cal.move(20, 20)
     cal.clicked[QDate].connect(self.send_to_parent)
     layout.addWidget(cal)
     win.setLayout(layout)
     win.setWindowTitle(title)
     win.exec_()
Пример #20
0
    def initUI(self):
        cal = QCalendarWidget(self)  # создание виджета QCalendarWidget
        cal.setGridVisible(True)  #
        cal.move(20, 20)  # расположение календаря
        cal.clicked[QDate].connect(self.showDate)  # когда выбирается дата срабатывает сигнал clicked[QDate],
        # и мы присоединем этот сигнал к определленому пользовательскому методу showDate

        self.lbl = QLabel(self)  # создание лейбла
        date = cal.selectedDate()  # возвращаем выбранную дату путем вызова метода selectedDat (начальная дата)
        self.lbl.setText(date.toString())  # превращаем объект даты в строку и устанавливаем в лейбл (начальная дата)
        self.lbl.move(130, 260)
        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.show()
Пример #21
0
    def home(self):
        btn = QPushButton("Quit", self)
        btn.clicked.connect(self.close_application)
        btn.resize(btn.minimumSizeHint())
        btn.move(10, 70)

        extract_action = QAction(QIcon("exit.png"), 'Exit the Application',
                                 self)
        extract_action.triggered.connect(self.close_application)
        self.tool_bar = self.addToolBar("Extraction")
        self.tool_bar.addAction(extract_action)

        font_choice_action = QAction(QIcon("font.png"), 'Choice A Font', self)
        font_choice_action.triggered.connect(self.font_choice)
        self.tool_bar.addAction(font_choice_action)

        color_choice_action = QAction(QIcon("baseball.png"),
                                      'Change The Background Color a font',
                                      self)
        color_choice_action.triggered.connect(self.color_choice)
        self.tool_bar.addAction(color_choice_action)

        check_box = QCheckBox('Enlarge Window', self)
        check_box.stateChanged.connect(self.enlarge_window)
        check_box.move(10, 100)
        check_box.toggle()

        self.progress = QProgressBar(self)
        self.progress.setGeometry(200, 70, 250, 20)

        self.btn = QPushButton("Downaload", self)
        self.btn.move(200, 100)
        self.btn.clicked.connect(self.download)

        self.lbl_style_choice = QLabel("Windows Vista", self)

        combo_box = QComboBox(self)
        combo_box.addItem("Fusion")
        combo_box.addItem("Windows")
        combo_box.addItem("Windowsvista")

        combo_box.move(10, 180)
        self.lbl_style_choice.move(10, 150)
        combo_box.activated[str].connect(self.style_choice)

        cal = QCalendarWidget(self)
        cal.move(200, 200)
        cal.resize(320, 200)

        self.show()
    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()
Пример #23
0
    def __init__(self):
        super(window, self).__init__()
        self.setGeometry(50, 50, 500, 500)
        self.setWindowTitle('pyqt5 Tut')
        self.setWindowIcon(QIcon('pic.png'))

        extractAction = QAction('&Go to Home', self)
        extractAction.setShortcut('Ctrl+Q')
        extractAction.setStatusTip('leave the app')
        extractAction.triggered.connect(self.close_application)

        openEditor = QAction('&Editor', self)
        openEditor.setShortcut('Ctrl+E')
        openEditor.setStatusTip('Open Editor')
        openEditor.triggered.connect(self.editor)

        openFile = QAction('&Open File', self)
        openFile.setShortcut('Ctrl+O')
        openFile.setStatusTip('Open File')
        openFile.triggered.connect(self.file_open)

        saveFile = QAction('&Save File', self)
        saveFile.setShortcut('Ctrl+S')
        saveFile.setStatusTip('Save File')
        saveFile.triggered.connect(self.file_save)

        self.statusBar()

        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('&File')
        fileMenu.addAction(extractAction)

        fileMenu.addAction(openFile)
        fileMenu.addAction(saveFile)

        editorMenu = mainMenu.addMenu('&Editor')
        editorMenu.addAction(openEditor)

        extractAction = QAction(QIcon('pic.png'), 'flee the scene', self)
        extractAction.triggered.connect(self.close_application)
        self.toolBar = self.addToolBar('extraction')
        self.toolBar.addAction(extractAction)

        cal = QCalendarWidget(self)
        cal.move(500, 200)
        cal.resize(200, 200)

        self.home()
Пример #24
0
    def initUI(self):
        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(20, 20)
        # 如果我们从部件选择一个日期,点击[QDate]发出信号。我们将这个信号连接到用户定义的showDate()方法。
        cal.clicked[QDate].connect(self.showDate)

        self.lbl = QLabel(self)
        # 检索所选日期通过调用selectedDate()方法。然后我们将date对象转换为字符串,并将其设置为小部件的标签。
        date = cal.selectedDate()
        self.lbl.setText(date.toString())
        self.lbl.move(130, 260)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.show()
Пример #25
0
    def initUI(self):

        self.setGeometry(100, 100, 400, 300)
        self.setWindowTitle('Calendar Demo')

        cal = QCalendarWidget(self)
        cal.setGridVisible(True)  #one of the function
        cal.move(20, 20)
        cal.clicked[QDate].connect(self.showDate)

        self.label = QLabel(self)
        date = cal.selectedDate()  #another function
        self.label.setText(date.toString())
        self.label.move(20, 200)

        self.show()
    def initUI(self):
        # QCalendarWidget被创建
        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(20, 20)
        # 如果我们从部件选择一个日期, 点击[QDate]发出信号。
        # 我们将这个信号连接到用户定义的showDate()方法
        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()
Пример #27
0
    def initUI(self):
        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(20, 30)
        cal.clicked[QDate].connect(self.showDate)

        self.lbl = QLabel(self)
        date = cal.selectedDate()
        self.lbl.setText(date.toString())
        self.lbl.move(130, 260)

        # position
        self.setGeometry(300, 300, 350, 350)
        # window title
        self.setWindowTitle("CalendarWidget")
        # show window
        self.show()
Пример #28
0
    def initUI(self):

        cal = QCalendarWidget(self)
        cal.setGridVisible(True)  # 让日历网格状显示
        cal.move(20, 20)
        cal.clicked[QDate].connect(self.showDate)  # 触发事件并传递参数QDate(选中日期)

        self.lbl = QLabel(self)

        date = cal.selectedDate()  # 显示默认选中的日期
        self.lbl.setText(date.toString())

        self.lbl.move(130, 260)

        self.setGeometry(300, 300, 600, 300)
        self.setWindowTitle("cadenlar")
        self.show()
Пример #29
0
    def initWindow(self):
        # 创建了一个日历控件
        cal = QCalendarWidget(self)
        cal.setGridVisible(True)
        cal.move(20, 20)
        # 如果我们从部件选择一个日期,点击[QDate]发出信号。我们将这个信号连接到showDate()方法
        cal.clicked[QDate].connect(self.showDate)

        self.lbl = QLabel(self)
        # 检索所选日期通过调用selectedDate
        date = cal.selectedDate()
        # 转为字符串设置为小部件的标签
        self.lbl.setText(date.toString())
        self.lbl.move(130, 260)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Calendar')
        self.show()
Пример #30
0
    def initUI(self):
        # 创建了一个日历控件和一个标签控件。
        # 选择的日期会显示在标签控件中
        cal = QCalendarWidget(self)
        # 从部件选择一个日期,点击[QDate]发出信号。
        # 我们将这个信号连接到用户定义的showDate()方法。
        cal.setGridVisible(True)
        cal.move(20, 20)
        cal.clicked[QDate].connect(self.showDate)

        self.lbl = QLabel(self)
        data = cal.selectedDate()
        self.lbl.setText(data.toString())
        self.lbl.move(130, 260)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('Toggle dialog')
        self.show()
Пример #31
0
    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.resize(500, 500)
        self.center()  #设置居中

        self.setWindowTitle('Calendar')
        self.setWindowIcon(QIcon('F:/Py_learn/PyQt_learn/bone.jpg'))

        self.show()
Пример #32
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()
Пример #33
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()
Пример #34
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()