# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # label1 = QLabel('Label1', self)
# # label1.move(20, 20)
# # label2 = QLabel('Label2', self)
# # label2.move(20, 60)
# #
# # btn1 = QPushButton('Button1', self)
# # btn1.move(80, 13)
# # btn2 = QPushButton('Button2', self)
# # btn2.move(80, 53)
# #
# # self.setWindowTitle('Absolute Positioning')
# # self.setGeometry(300, 300, 400, 200)
# # self.show()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QVBoxLayout
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # okButton = QPushButton('OK')
# # cancelButton = QPushButton('Cancel')
# #
# # hbox = QHBoxLayout()
# # hbox.addStretch(1)
# # hbox.addWidget(okButton)
# # hbox.addWidget(cancelButton)
# # hbox.addStretch(1)
# #
# # vbox = QVBoxLayout()
# # vbox.addStretch(3)
# # vbox.addLayout(hbox)
# # vbox.addStretch(1)
# #
# # self.setLayout(vbox)
# #
# # self.setWindowTitle('Box Layout')
# # self.setGeometry(300, 300, 300, 200)
# # self.show()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import (QApplication, QWidget, QGridLayout, QLabel, QLineEdit, QTextEdit)
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # grid = QGridLayout()
# # self.setLayout(grid)
# #
# # grid.addWidget(QLabel('Title:'), 0, 0)
# # grid.addWidget(QLabel('Author:'), 1, 0)
# # grid.addWidget(QLabel('Review:'), 2, 0)
# #
# # grid.addWidget(QLineEdit(), 0, 1)
# # grid.addWidget(QLineEdit(), 1, 1)
# # grid.addWidget(QTextEdit(), 2, 1)
# #
# # self.setWindowTitle('QGridLayout')
# # self.setGeometry(300, 300, 300, 200)
# # self.show()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # btn1 = QPushButton('&Button1', self)
# # btn1.setCheckable(True)
# # btn1.toggle()
# #
# # btn2 = QPushButton(self)
# # btn2.setText('Button&2')
# #
# # btn3 = QPushButton('Button3', self)
# # btn3.setEnabled(False)
# #
# # vbox = QVBoxLayout()
# # vbox.addWidget(btn1)
# # vbox.addWidget(btn2)
# # vbox.addWidget(btn3)
# #
# # self.setLayout(vbox)
# # self.setWindowTitle('QPushButton')
# # self.setGeometry(300, 300, 300, 200)
# # self.show()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
# # from PyQt5.QtCore import Qt
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # label1 = QLabel('First Label', self)
# # label1.setAlignment(Qt.AlignCenter)
# #
# # label2 = QLabel('Second Label', self)
# # label2.setAlignment(Qt.AlignVCenter)
# #
# # font1 = label1.font()
# # font1.setPointSize(20)
# #
# # font2 = label2.font()
# # font2.setFamily('Times New Roman')
# # font2.setBold(True)
# #
# # label1.setFont(font1)
# # label2.setFont(font2)
# #
# # layout = QVBoxLayout()
# # layout.addWidget(label1)
# # layout.addWidget(label2)
# #
# # self.setLayout(layout)
# #
# # self.setWindowTitle('QLabel')
# # self.setGeometry(300, 300, 300, 200)
# # self.show()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QCheckBox
# # from PyQt5.QtCore import Qt
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # cb = QCheckBox('Show title', self)
# # cb.move(20, 20)
# # cb.toggle()
# # cb.stateChanged.connect(self.changeTitle)
# #
# # self.setWindowTitle('QCheckBox')
# # self.setGeometry(300, 300, 300, 200)
# # self.show()
# #
# # def changeTitle(self, state):
# # if state == Qt.Checked:
# # self.setWindowTitle('QCheckBox')
# # else:
# # self.setWindowTitle(' ')
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QRadioButton
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # rbtn1 = QRadioButton('First Button', self)
# # rbtn1.move(50, 50)
# # rbtn1.setChecked(True)
# #
# # rbtn2 = QRadioButton(self)
# # rbtn2.move(50, 70)
# # rbtn2.setText('Second Button')
# #
# # self.setGeometry(300, 300, 300, 200)
# # self.setWindowTitle('QRadioButton')
# # self.show()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QComboBox
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # self.lbl = QLabel('Option1', self)
# # self.lbl.move(50, 150)
# #
# # cb = QComboBox(self)
# # cb.addItem('Option1')
# # cb.addItem('Option2')
# # cb.addItem('Option3')
# # cb.addItem('Option4')
# # cb.move(50, 50)
# #
# # cb.activated[str].connect(self.onActivated)
# #
# # self.setWindowTitle('QComboBox')
# # self.setGeometry(300, 300, 300, 200)
# # self.show()
# #
# # def onActivated(self, text):
# # self.lbl.setText(text)
# # self.lbl.adjustSize()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # self.lbl = QLabel(self)
# # self.lbl.move(60, 40)
# #
# # qle = QLineEdit(self)
# # qle.move(60, 100)
# # qle.textChanged[str].connect(self.onChanged)
# #
# # self.setWindowTitle('QLineEdit')
# # self.setGeometry(300, 300, 300, 200)
# # self.show()
# #
# # def onChanged(self, text):
# # self.lbl.setText(text)
# # self.lbl.adjustSize()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QProgressBar
# # from PyQt5.QtCore import QBasicTimer
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # self.pbar = QProgressBar(self)
# # self.pbar.setGeometry(30, 40, 200, 25)
# #
# # self.btn = QPushButton('Start', self)
# # self.btn.move(40, 80)
# # self.btn.clicked.connect(self.doAction)
# #
# # self.timer = QBasicTimer()
# # self.step = 0
# #
# # self.setWindowTitle('QProgressBar')
# # self.setGeometry(300, 300, 300, 200)
# # self.show()
# #
# # def timerEvent(self, e):
# # if self.step >= 100:
# # self.timer.stop()
# # self.btn.setText('Finished')
# # return
# #
# # self.step = self.step + 1
# # self.pbar.setValue(self.step)
# #
# # def doAction(self):
# # if self.timer.isActive():
# # self.timer.stop()
# # self.btn.setText('Start')
# # else:
# # self.timer.start(100, self)
# # self.btn.setText('Stop')
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QSlider, QDial, QPushButton
# # from PyQt5.QtCore import Qt
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # self.slider = QSlider(Qt.Horizontal, self)
# # self.slider.move(30, 30)
# # self.slider.setRange(0, 50)
# # self.slider.setSingleStep(2)
# #
# # self.dial = QDial(self)
# # self.dial.move(30, 50)
# # self.dial.setRange(0, 50)
# #
# # btn = QPushButton('Default', self)
# # btn.move(35, 160)
# #
# # self.slider.valueChanged.connect(self.dial.setValue)
# # self.dial.valueChanged.connect(self.slider.setValue)
# # btn.clicked.connect(self.button_clicked)
# #
# # self.setWindowTitle('QSlider and QDial')
# # self.setGeometry(300, 300, 400, 200)
# # self.show()
# #
# # def button_clicked(self):
# # self.slider.setValue(0)
# # self.dial.setValue(0)
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# # import sys
# # from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QFrame, QSplitter
# # from PyQt5.QtCore import Qt
# #
# #
# # class MyApp(QWidget):
# #
# # def __init__(self):
# # super().__init__()
# # self.initUI()
# #
# # def initUI(self):
# # hbox = QHBoxLayout()
# #
# # top = QFrame()
# # top.setFrameShape(QFrame.Box)
# #
# # midleft = QFrame()
# # midleft.setFrameShape(QFrame.StyledPanel)
# #
# # midright = QFrame()
# # midright.setFrameShape(QFrame.Panel)
# #
# # bottom = QFrame()
# # bottom.setFrameShape(QFrame.WinPanel)
# # bottom.setFrameShadow(QFrame.Sunken)
# #
# # splitter1 = QSplitter(Qt.Horizontal)
# # splitter1.addWidget(midleft)
# # splitter1.addWidget(midright)
# #
# # splitter2 = QSplitter(Qt.Vertical)
# # splitter2.addWidget(top)
# # splitter2.addWidget(splitter1)
# # splitter2.addWidget(bottom)
# #
# # hbox.addWidget(splitter2)
# # self.setLayout(hbox)
# #
# # self.setGeometry(300, 300, 300, 200)
# # self.setWindowTitle('QSplitter')
# # self.show()
# #
# #
# # if __name__ == '__main__':
# # app = QApplication(sys.argv)
# # ex = MyApp()
# # sys.exit(app.exec_())
#
# import sys
# from PyQt5.QtWidgets import (QApplication, QWidget, QGroupBox, QRadioButton
# , QCheckBox, QPushButton, QMenu, QGridLayout, QVBoxLayout)
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# grid = QGridLayout()
# grid.addWidget(self.createFirstExclusiveGroup(), 0, 0)
# grid.addWidget(self.createSecondExclusiveGroup(), 1, 0)
# grid.addWidget(self.createNonExclusiveGroup(), 0, 1)
# grid.addWidget(self.createPushButtonGroup(), 1, 1)
#
# self.setLayout(grid)
#
# self.setWindowTitle('Box Layout')
# self.setGeometry(300, 300, 480, 320)
# self.show()
#
# def createFirstExclusiveGroup(self):
# groupbox = QGroupBox('Exclusive Radio Buttons')
#
# radio1 = QRadioButton('Radio1')
# radio2 = QRadioButton('Radio2')
# radio3 = QRadioButton('Radio3')
# radio1.setChecked(True)
#
# vbox = QVBoxLayout()
# vbox.addWidget(radio1)
# vbox.addWidget(radio2)
# vbox.addWidget(radio3)
# groupbox.setLayout(vbox)
#
# return groupbox
#
# def createSecondExclusiveGroup(self):
# groupbox = QGroupBox('Exclusive Radio Buttons')
# groupbox.setCheckable(True)
# groupbox.setChecked(False)
#
# radio1 = QRadioButton('Radio1')
# radio2 = QRadioButton('Radio2')
# radio3 = QRadioButton('Radio3')
# radio1.setChecked(True)
# checkbox = QCheckBox('Independent Checkbox')
# checkbox.setChecked(True)
#
# vbox = QVBoxLayout()
# vbox.addWidget(radio1)
# vbox.addWidget(radio2)
# vbox.addWidget(radio3)
# vbox.addWidget(checkbox)
# vbox.addStretch(1)
# groupbox.setLayout(vbox)
#
# return groupbox
#
# def createNonExclusiveGroup(self):
# groupbox = QGroupBox('Non-Exclusive Checkboxes')
# groupbox.setFlat(True)
#
# checkbox1 = QCheckBox('Checkbox1')
# checkbox2 = QCheckBox('Checkbox2')
# checkbox2.setChecked(True)
# tristatebox = QCheckBox('Tri-state Button')
# tristatebox.setTristate(True)
#
# vbox = QVBoxLayout()
# vbox.addWidget(checkbox1)
# vbox.addWidget(checkbox2)
# vbox.addWidget(tristatebox)
# vbox.addStretch(1)
# groupbox.setLayout(vbox)
#
# return groupbox
#
# def createPushButtonGroup(self):
# groupbox = QGroupBox('Push Buttons')
# groupbox.setCheckable(True)
# groupbox.setChecked(True)
#
# pushbutton = QPushButton('Normal Button')
# togglebutton = QPushButton('Toggle Button')
# togglebutton.setCheckable(True)
# togglebutton.setChecked(True)
# flatbutton = QPushButton('Flat Button')
# flatbutton.setFlat(True)
# popupbutton = QPushButton('Popup Button')
# menu = QMenu(self)
# menu.addAction('First Item')
# menu.addAction('Second Item')
# menu.addAction('Third Item')
# menu.addAction('Fourth Item')
# popupbutton.setMenu(menu)
#
# vbox = QVBoxLayout()
# vbox.addWidget(pushbutton)
# vbox.addWidget(togglebutton)
# vbox.addWidget(flatbutton)
# vbox.addWidget(popupbutton)
# vbox.addStretch(1)
# groupbox.setLayout(vbox)
#
# return groupbox
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# class Person :
# def __init__(self):
# self.age = 10
# self.name = "abcd"
#
# def speak(self):
# print("age",self.age," name ",self.name)
#
# class Student(Person) :
# def __init__(self):
# super().__init__()
# self.school = "def"
# def stu_speak(self):
# super().speak()
# print("im student")
#
# b = Student()
# b.stu_speak()
# class Circle:
# def __init__(self,radius,name):
# self.radius = radius
# self.name = name
#
# def setRadius(self,r):
# self.radius = r
#
# def speak(self):
# print("radius is",self.radius," name is ",self.name)
#
# a = Circle(50,"pizza")
# a.speak()
#
# a.setRadius(500)
# a.speak()
# a = Circle()
# b = Circle()
#
# a.radius = 10
# a.name = "pizza"
#
# a.speak()
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QTabWidget, QVBoxLayout
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# tab1 = QWidget()
# tab2 = QWidget()
#
# tabs = QTabWidget()
# tabs.addTab(tab1, 'Tab1')
# tabs.addTab(tab2, 'Tab2')
#
# vbox = QVBoxLayout()
# vbox.addWidget(tabs)
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QTabWidget')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
# from PyQt5.QtGui import QPixmap
# from PyQt5.QtCore import Qt
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# pixmap = QPixmap('landscape.jpg')
#
# lbl_img = QLabel()
# lbl_img.setPixmap(pixmap)
# lbl_size = QLabel('Width: '+str(pixmap.width())+', Height: '+str(pixmap.height()))
# lbl_size.setAlignment(Qt.AlignCenter)
#
# vbox = QVBoxLayout()
# vbox.addWidget(lbl_img)
# vbox.addWidget(lbl_size)
# self.setLayout(vbox)
#
# self.setWindowTitle('QPixmap')
# self.move(300, 300)
# self.show()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout, QCalendarWidget
# from PyQt5.QtCore import QDate
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# cal = QCalendarWidget(self)
# cal.setGridVisible(True)
# cal.clicked[QDate].connect(self.showDate)
#
# self.lbl = QLabel(self)
# date = cal.selectedDate()
# self.lbl.setText(date.toString())
#
# vbox = QVBoxLayout()
# vbox.addWidget(cal)
# vbox.addWidget(self.lbl)
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QCalendarWidget')
# self.setGeometry(300, 300, 400, 300)
# self.show()
#
# def showDate(self, date):
# self.lbl.setText(date.toString())
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QSpinBox, QVBoxLayout
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.lbl1 = QLabel('QSpinBox')
# self.spinbox = QSpinBox()
# self.spinbox.setMinimum(-10)
# self.spinbox.setMaximum(30)
# # self.spinbox.setRange(-10, 30)
# self.spinbox.setSingleStep(2)
# self.lbl2 = QLabel('0')
#
# self.spinbox.valueChanged.connect(self.value_changed)
#
# vbox = QVBoxLayout()
# vbox.addWidget(self.lbl1)
# vbox.addWidget(self.spinbox)
# vbox.addWidget(self.lbl2)
# vbox.addStretch()
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QSpinBox')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def value_changed(self):
# self.lbl2.setText(str(self.spinbox.value()))
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QDoubleSpinBox, QVBoxLayout
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.lbl1 = QLabel('QDoubleSpinBox')
# self.dspinbox = QDoubleSpinBox()
# self.dspinbox.setRange(0, 100)
# self.dspinbox.setSingleStep(0.5)
# self.dspinbox.setPrefix('$ ')
# self.dspinbox.setDecimals(1)
# self.lbl2 = QLabel('$ 0.0')
#
# self.dspinbox.valueChanged.connect(self.value_changed)
#
# vbox = QVBoxLayout()
# vbox.addWidget(self.lbl1)
# vbox.addWidget(self.dspinbox)
# vbox.addWidget(self.lbl2)
# vbox.addStretch()
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QDoubleSpinBox')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def value_changed(self):
# self.lbl2.setText('$ ' + str(self.dspinbox.value()))
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QDateEdit, QVBoxLayout
# from PyQt5.QtCore import QDate
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# lbl = QLabel('QDateEdit')
#
# dateedit = QDateEdit(self)
# dateedit.setDate(QDate.currentDate())
# dateedit.setMinimumDate(QDate(1900, 1, 1))
# dateedit.setMaximumDate(QDate(2100, 12, 31))
# # dateedit.setDateRange(QDate(1900, 1, 1), QDate(2100, 12, 31))
#
# vbox = QVBoxLayout()
# vbox.addWidget(lbl)
# vbox.addWidget(dateedit)
# vbox.addStretch()
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QDateEdit')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QTimeEdit, QVBoxLayout
# from PyQt5.QtCore import QTime
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# lbl = QLabel('QTimeEdit')
#
# timeedit = QTimeEdit(self)
# timeedit.setTime(QTime.currentTime())
# timeedit.setTimeRange(QTime(3, 00, 00), QTime(23, 30, 00))
# timeedit.setDisplayFormat('hh:mm:ss')
#
# vbox = QVBoxLayout()
# vbox.addWidget(lbl)
# vbox.addWidget(timeedit)
# vbox.addStretch()
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QTimeEdit')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QDateTimeEdit, QVBoxLayout
# from PyQt5.QtCore import QDateTime
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# lbl = QLabel('QTimeEdit')
#
# datetimeedit = QDateTimeEdit(self)
# datetimeedit.setDateTime(QDateTime.currentDateTime())
# datetimeedit.setDateTimeRange(QDateTime(1900, 1, 1, 00, 00, 00), QDateTime(2100, 1, 1, 00, 00, 00))
# datetimeedit.setDisplayFormat('yyyy.MM.dd hh:mm:ss')
#
# vbox = QVBoxLayout()
# vbox.addWidget(lbl)
# vbox.addWidget(datetimeedit)
# vbox.addStretch()
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QDateTimeEdit')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import (QApplication, QWidget
# , QLineEdit, QTextBrowser, QPushButton, QVBoxLayout)
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.le = QLineEdit()
# self.le.returnPressed.connect(self.append_text)
#
# self.tb = QTextBrowser()
# self.tb.setAcceptRichText(True)
# self.tb.setOpenExternalLinks(True)
#
# self.clear_btn = QPushButton('Clear')
# self.clear_btn.pressed.connect(self.clear_text)
#
# vbox = QVBoxLayout()
# vbox.addWidget(self.le, 0)
# vbox.addWidget(self.tb, 1)
# vbox.addWidget(self.clear_btn, 2)
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QTextBrowser')
# self.setGeometry(300, 300, 300, 300)
# self.show()
#
# def append_text(self):
# text = self.le.text()
# self.tb.append(text)
# self.le.clear()
#
# def clear_text(self):
# self.tb.clear()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QTextEdit, QVBoxLayout
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.lbl1 = QLabel('Enter your sentence:')
# self.te = QTextEdit()
# self.te.setAcceptRichText(False)
# self.lbl2 = QLabel('The number of words is 0')
#
# self.te.textChanged.connect(self.text_changed)
#
# vbox = QVBoxLayout()
# vbox.addWidget(self.lbl1)
# vbox.addWidget(self.te)
# vbox.addWidget(self.lbl2)
# vbox.addStretch()
#
# self.setLayout(vbox)
#
# self.setWindowTitle('QTextEdit')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def text_changed(self):
# text = self.te.toPlainText()
# self.lbl2.setText('The number of words is ' + str(len(text.split())))
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import *
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
#
# self.tableWidget = QTableWidget()
# self.tableWidget.setRowCount(20)
# self.tableWidget.setColumnCount(4)
#
# self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
# # self.tableWidget.setEditTriggers(QAbstractItemView.DoubleClicked)
# # self.tableWidget.setEditTriggers(QAbstractItemView.AllEditTriggers)
#
# self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
# # self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
#
# for i in range(20):
# for j in range(4):
# self.tableWidget.setItem(i, j, QTableWidgetItem(str(i+j)))
#
# layout = QVBoxLayout()
# layout.addWidget(self.tableWidget)
# self.setLayout(layout)
#
# self.setWindowTitle('QTableWidget')
# self.setGeometry(300, 100, 600, 400)
# self.show()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import (QApplication, QWidget, QPushButton, QLineEdit, QInputDialog)
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.btn = QPushButton('Dialog', self)
# self.btn.move(30, 30)
# self.btn.clicked.connect(self.showDialog)
#
# self.le = QLineEdit(self)
# self.le.move(120, 35)
#
# self.setWindowTitle('Input dialog')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def showDialog(self):
# text, ok = QInputDialog.getText(self, 'Input Dialog', 'Enter your name:')
#
# if ok:
# self.le.setText(str(text))
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QFrame, QColorDialog
from PyQt5.QtGui import QColor
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# col = QColor(0, 0, 0)
#
# self.btn = QPushButton('Dialog', self)
# self.btn.move(30, 30)
# self.btn.clicked.connect(self.showDialog)
#
# self.frm = QFrame(self)
# self.frm.setStyleSheet('QWidget { background-color: %s }' % col.name())
# self.frm.setGeometry(130, 35, 100, 100)
#
# self.setWindowTitle('Color Dialog')
# self.setGeometry(300, 300, 250, 180)
# self.show()
#
# def showDialog(self):
# col = QColorDialog.getColor()
#
# if col.isValid():
# self.frm.setStyleSheet('QWidget { background-color: %s }' % col.name())
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout
# , QPushButton, QSizePolicy, QLabel, QFontDialog)
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# btn = QPushButton('Dialog', self)
# btn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
# btn.move(20, 20)
# btn.clicked.connect(self.showDialog)
#
# vbox = QVBoxLayout()
# vbox.addWidget(btn)
#
# self.lbl = QLabel('The quick brown fox jumps over the lazy dog', self)
# self.lbl.move(130, 20)
#
# vbox.addWidget(self.lbl)
# self.setLayout(vbox)
#
# self.setWindowTitle('Font Dialog')
# self.setGeometry(300, 300, 250, 180)
# self.show()
#
# def showDialog(self):
# font, ok = QFontDialog.getFont()
#
# if ok:
# self.lbl.setFont(font)
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QMainWindow, QTextEdit, QAction, QFileDialog
# from PyQt5.QtGui import QIcon
#
#
# class MyApp(QMainWindow):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.textEdit = QTextEdit()
# self.setCentralWidget(self.textEdit)
# self.statusBar()
#
# openFile = QAction(QIcon('open.png'), 'Open', self)
# openFile.setShortcut('Ctrl+O')
# openFile.setStatusTip('Open New File')
# openFile.triggered.connect(self.showDialog)
#
# menubar = self.menuBar()
# menubar.setNativeMenuBar(False)
# fileMenu = menubar.addMenu('&File')
# fileMenu.addAction(openFile)
#
# self.setWindowTitle('File Dialog')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def showDialog(self):
# fname = QFileDialog.getOpenFileName(self, 'Open file', './')
#
# if fname[0]:
# f = open(fname[0], 'r')
#
# with f:
# data = f.read()
# self.textEdit.setText(data)
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.setWindowTitle('QMessageBox')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def closeEvent(self, event):
# reply = QMessageBox.question(self, 'Message', 'Are you sure to quit?',
# QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
#
# if reply == QMessageBox.Yes:
# event.accept()
# else:
# event.ignore()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QApplication, QWidget, QLCDNumber, QDial, QVBoxLayout
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# lcd = QLCDNumber(self)
# dial = QDial(self)
#
# vbox = QVBoxLayout()
# vbox.addWidget(lcd)
# vbox.addWidget(dial)
# self.setLayout(vbox)
#
# dial.valueChanged.connect(lcd.display)
#
# self.setWindowTitle('Signal and Slot')
# self.setGeometry(300, 300, 200, 200)
# self.show()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import (QApplication, QWidget
# , QLCDNumber, QDial, QPushButton, QVBoxLayout, QHBoxLayout)
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# lcd = QLCDNumber(self)
# dial = QDial(self)
# btn1 = QPushButton('Big', self)
# btn2 = QPushButton('Small', self)
#
# hbox = QHBoxLayout()
# hbox.addWidget(btn1)
# hbox.addWidget(btn2)
#
# vbox = QVBoxLayout()
# vbox.addWidget(lcd)
# vbox.addWidget(dial)
# vbox.addLayout(hbox)
# self.setLayout(vbox)
#
# dial.valueChanged.connect(lcd.display)
# btn1.clicked.connect(self.resizeBig)
# btn2.clicked.connect(self.resizeSmall)
#
# self.setWindowTitle('Signal and Slot')
# self.setGeometry(200, 200, 200, 250)
# self.show()
#
# def resizeBig(self):
# self.resize(400, 500)
#
# def resizeSmall(self):
# self.resize(200, 250)
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtCore import Qt
# from PyQt5.QtWidgets import QApplication, QWidget
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.setWindowTitle('Reimplementing event handler')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def keyPressEvent(self, e):
# if e.key() == Qt.Key_Escape:
# self.close()
# elif e.key() == Qt.Key_F:
# self.showFullScreen()
# elif e.key() == Qt.Key_N:
# self.showNormal()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# x = 0
# y = 0
#
# self.text = 'x: {0}, y: {1}'.format(x, y)
# self.label = QLabel(self.text, self)
# self.label.move(20, 20)
#
# self.setMouseTracking(True)
#
# self.setWindowTitle('Reimplementing event handler')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def mouseMoveEvent(self, e):
# x = e.x()
# y = e.y()
#
# text = 'x: {0}, y: {1}'.format(x, y)
# self.label.setText(text)
# self.label.adjustSize()
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtCore import pyqtSignal, QObject
# from PyQt5.QtWidgets import QApplication, QMainWindow
#
#
# class Communicate(QObject):
#
# closeApp = pyqtSignal()
#
#
# class MyApp(QMainWindow):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.c = Communicate()
# self.c.closeApp.connect(self.close)
#
# self.setWindowTitle('Emitting Signal')
# self.setGeometry(300, 300, 300, 200)
# self.show()
#
# def mousePressEvent(self, e):
# self.c.closeApp.emit()
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QWidget, QApplication
# from PyQt5.QtGui import QPainter, QPen
# from PyQt5.QtCore import Qt
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.setGeometry(300, 300, 400, 300)
# self.setWindowTitle('Points')
# self.show()
#
# def paintEvent(self, e):
# qp = QPainter()
# qp.begin(self)
# self.draw_point(qp)
# qp.end()
#
# def draw_point(self, qp):
# qp.setPen(QPen(Qt.blue, 8))
# qp.drawPoint(self.width()/2, self.height()/2)
#
# def draw_point(self, qp):
# qp.setPen(QPen(Qt.blue, 8))
# qp.drawPoint(self.width() / 2, self.height() / 2)
# qp.setPen(QPen(Qt.green, 12))
# qp.drawPoint(self.width() / 4, 3 * self.height() / 4)
# qp.setPen(QPen(Qt.red, 16))
# qp.drawPoint(3 * self.width() / 4, self.height() / 4)
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QWidget, QApplication
# from PyQt5.QtGui import QPainter, QPen
# from PyQt5.QtCore import Qt
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.setGeometry(300, 300, 400, 300)
# self.setWindowTitle('drawLine')
# self.show()
#
# def paintEvent(self, e):
# qp = QPainter()
# qp.begin(self)
# self.draw_line(qp)
# qp.end()
#
# def draw_line(self, qp):
# qp.setPen(QPen(Qt.gray, 15))
# qp.drawLine(30, 230, 200, 50)
# qp.setPen(QPen(Qt.black, 30))
# qp.drawLine(140, 60, 320, 280)
# qp.setPen(QPen(Qt.white, 16))
# qp.drawLine(330, 250, 40, 190)
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import QWidget, QApplication
# from PyQt5.QtGui import QPainter, QPen, QColor, QBrush
# from PyQt5.QtCore import Qt
#
#
# class MyApp(QWidget):
#
# def __init__(self):
# super().__init__()
# self.initUI()
#
# def initUI(self):
# self.setGeometry(300, 300, 400, 300)
# self.setWindowTitle('drawRect')
# self.show()
#
# def paintEvent(self, e):
# qp = QPainter()
# qp.begin(self)
# self.draw_rect(qp)
# qp.end()
#
# def draw_rect(self, qp):
# qp.setBrush(QColor(50, 20, 25))
# qp.setPen(QPen(QColor(10, 10, 10), 3))
# qp.drawRect(20, 20, 100, 100)
#
# qp.setBrush(QColor(40, 150, 20))
# qp.setPen(QPen(Qt.blue, 2))
# qp.drawRect(180, 120, 50, 120)
#
# qp.setBrush(Qt.yellow)
# qp.setPen(QPen(Qt.red, 5))
# qp.drawRect(280, 30, 80, 40)
#
#
# if __name__ == '__main__':
# app = QApplication(sys.argv)
# ex = MyApp()
# sys.exit(app.exec_())
import sys
from PyQt5.QtWidgets import QWidget, QApplication
from PyQt5.QtGui import QPainter, QPen, QColor, QBrush
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
class MyApp(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.btn = QPushButton('START', self)
self.btn.setGeometry(10, 10, 360, 50)
self.btn.setStyleSheet("background-color : pink")
self.btn1 = QPushButton('STOP', self)
self.btn1.setGeometry(10, 80, 360, 50)
self.btn1.setStyleSheet("background-color : orange")
self.btn2 = QPushButton('SAVE', self)
self.btn2.setGeometry(10, 150, 360, 50)
self.btn2.setStyleSheet("background-color : yellow")
self.btn3 = QPushButton('PRINT', self)
self.btn3.setGeometry(10, 220, 360, 50)
self.btn3.setStyleSheet("background-color : green")
self.setGeometry(300, 300, 400, 300)
self.setWindowTitle('drawRect')
self.show()
def paintEvent(self, e):
qp = QPainter()
qp.begin(self)
self.draw_rect(qp)
qp.end()
def draw_rect(self, qp):
qp.setBrush(QColor(250, 100, 160))
qp.setPen(QPen(QColor(20, 20, 20), 2))
qp.drawRect(10, 10, 360, 50)
qp.setBrush(QColor(250, 150, 20))
qp.setPen(QPen(Qt.blue, 2))
qp.drawRect(10, 80, 360, 50)
qp.setBrush(Qt.yellow)
qp.setPen(QPen(Qt.red, 2))
qp.drawRect(10, 150, 360, 50)
qp.setBrush(QColor(100, 200, 150))
qp.setPen(QPen(Qt.black, 2))
qp.drawRect(10, 220, 360, 50)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyApp()
sys.exit(app.exec_())top of page

실제 작동 상태를 확인하려면 라이브 사이트로 이동하세요.
20250809
20250809
댓글 0개
좋아요
댓글(0)
더 이상 게시물에 대한 댓글 기능이 지원되지 않습니다. 자세한 사항은 사이트 소유자에게 문의하세요.
bottom of page


