Added missing files and removed unnessesary ones
This commit is contained in:
BIN
Python/pyqt6_4/cat1.jpg
Executable file
BIN
Python/pyqt6_4/cat1.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 347 KiB |
BIN
Python/pyqt6_4/cat2.jpg
Executable file
BIN
Python/pyqt6_4/cat2.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
21
Python/pyqt6_4/snippets/1.py
Executable file
21
Python/pyqt6_4/snippets/1.py
Executable file
@ -0,0 +1,21 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtWidgets import QApplication, QWidget
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
61
Python/pyqt6_4/snippets/10.py
Executable file
61
Python/pyqt6_4/snippets/10.py
Executable file
@ -0,0 +1,61 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication,
|
||||
QWidget,
|
||||
QHBoxLayout,
|
||||
QSpinBox,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
)
|
||||
from PyQt6.QtGui import QFont
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
self.price = 300
|
||||
self.amount = 0
|
||||
|
||||
hbox = QHBoxLayout()
|
||||
|
||||
self.line_edit = QLineEdit(str(self.price))
|
||||
self.line_edit.setFont(QFont("Times", 14))
|
||||
|
||||
self.spin_box = QSpinBox()
|
||||
self.spin_box.valueChanged.connect(self.handle_spin_box)
|
||||
self.result = QLabel(str(self.total))
|
||||
|
||||
hbox.addWidget(self.line_edit)
|
||||
hbox.addWidget(self.spin_box)
|
||||
hbox.addWidget(self.result)
|
||||
|
||||
self.setLayout(hbox)
|
||||
|
||||
def handle_spin_box(self) -> None:
|
||||
try:
|
||||
self.price = int(self.line_edit.text())
|
||||
except ValueError:
|
||||
return
|
||||
self.amount = self.spin_box.value()
|
||||
self.result.setText(str(self.total))
|
||||
|
||||
@property
|
||||
def total(self) -> int:
|
||||
return self.amount * self.price
|
||||
|
||||
def handle_line_edit(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
31
Python/pyqt6_4/snippets/2.py
Executable file
31
Python/pyqt6_4/snippets/2.py
Executable file
@ -0,0 +1,31 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtWidgets import QApplication, QWidget, QLabel
|
||||
from PyQt6.QtGui import QPixmap
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
|
||||
label = QLabel(self)
|
||||
label.setText("Текст")
|
||||
label.move(300, 300)
|
||||
|
||||
pixmap = QPixmap()
|
||||
lable_pic = QLabel(self)
|
||||
lable_pic.setPicture(pixmap)
|
||||
lable_pic.move(200, 200)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
31
Python/pyqt6_4/snippets/3.py
Executable file
31
Python/pyqt6_4/snippets/3.py
Executable file
@ -0,0 +1,31 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtWidgets import QApplication, QWidget, QPushButton
|
||||
from PyQt6.QtCore import QSize
|
||||
from PyQt6.QtGui import QFont, QIcon
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
self.create_button()
|
||||
|
||||
def create_button(self) -> None:
|
||||
btn = QPushButton("Click", self)
|
||||
btn.setGeometry(*(100,) * 4)
|
||||
btn.setFont(QFont("Times", 14, QFont.Weight.ExtraBold))
|
||||
btn.setIcon(QIcon("cat1.jpg"))
|
||||
btn.setIconSize(QSize(50, 50))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
27
Python/pyqt6_4/snippets/4.py
Executable file
27
Python/pyqt6_4/snippets/4.py
Executable file
@ -0,0 +1,27 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtGui import QFont
|
||||
from PyQt6.QtWidgets import QApplication, QLineEdit, QWidget
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
|
||||
line_edit = QLineEdit(self)
|
||||
line_edit.setFont(QFont("Times", 14))
|
||||
line_edit.setPlaceholderText("Enter your password")
|
||||
line_edit.setEchoMode(QLineEdit.EchoMode.Password)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
32
Python/pyqt6_4/snippets/5.py
Executable file
32
Python/pyqt6_4/snippets/5.py
Executable file
@ -0,0 +1,32 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
|
||||
btn1 = QPushButton("One")
|
||||
btn2 = QPushButton("Two")
|
||||
btn3 = QPushButton("Three")
|
||||
|
||||
layout = QHBoxLayout()
|
||||
layout.addWidget(btn1)
|
||||
layout.addWidget(btn2)
|
||||
layout.addWidget(btn3)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
32
Python/pyqt6_4/snippets/6.py
Executable file
32
Python/pyqt6_4/snippets/6.py
Executable file
@ -0,0 +1,32 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
|
||||
btn1 = QPushButton("One")
|
||||
btn2 = QPushButton("Two")
|
||||
btn3 = QPushButton("Three")
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(btn1)
|
||||
layout.addWidget(btn2)
|
||||
layout.addWidget(btn3)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
63
Python/pyqt6_4/snippets/7.py
Executable file
63
Python/pyqt6_4/snippets/7.py
Executable file
@ -0,0 +1,63 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtCore import QSize
|
||||
from PyQt6.QtGui import QIcon
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QRadioButton,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
|
||||
ICON_SIZE = 100
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(200, 200, 400, 300)
|
||||
self.setWindowTitle("Окно")
|
||||
self.create_radio()
|
||||
|
||||
def create_radio(self) -> None:
|
||||
hbox = QHBoxLayout()
|
||||
|
||||
rad1 = QRadioButton("Cat 1")
|
||||
rad1.setIcon(QIcon("cat1.jpg"))
|
||||
rad1.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
|
||||
rad1.toggled.connect(self.radio_selected)
|
||||
|
||||
rad2 = QRadioButton("Cat 2")
|
||||
rad2.setIcon(QIcon("cat2.jpg"))
|
||||
rad2.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
|
||||
rad2.toggled.connect(self.radio_selected)
|
||||
|
||||
hbox.addWidget(rad1)
|
||||
hbox.addWidget(rad2)
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
|
||||
self.label = QLabel("")
|
||||
|
||||
vbox.addWidget(self.label)
|
||||
vbox.addLayout(hbox)
|
||||
self.setLayout(vbox)
|
||||
|
||||
def radio_selected(self) -> None:
|
||||
radio_btn = self.sender()
|
||||
if radio_btn.isEnabled():
|
||||
self.label.setText(f"You have chosen {radio_btn.text().lower()}")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
68
Python/pyqt6_4/snippets/8.py
Executable file
68
Python/pyqt6_4/snippets/8.py
Executable file
@ -0,0 +1,68 @@
|
||||
import sys
|
||||
|
||||
from PyQt6.QtCore import QSize
|
||||
from PyQt6.QtGui import QIcon
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication,
|
||||
QCheckBox,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
ICON_SIZE = 100
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(200, 200, 400, 300)
|
||||
self.setWindowTitle("Окно")
|
||||
self.create_radio()
|
||||
|
||||
def create_radio(self) -> None:
|
||||
hbox = QHBoxLayout()
|
||||
|
||||
self.check1 = QCheckBox("Cat 1")
|
||||
self.check1.setIcon(QIcon("cat1.jpg"))
|
||||
self.check1.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
|
||||
self.check1.toggled.connect(self.radio_selected)
|
||||
|
||||
self.check2 = QCheckBox("Cat 2")
|
||||
self.check2.setIcon(QIcon("cat2.jpg"))
|
||||
self.check2.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
|
||||
self.check2.toggled.connect(self.radio_selected)
|
||||
|
||||
hbox.addWidget(self.check1)
|
||||
hbox.addWidget(self.check2)
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
|
||||
self.label = QLabel("You haven't chosen anything")
|
||||
|
||||
vbox.addWidget(self.label)
|
||||
vbox.addLayout(hbox)
|
||||
self.setLayout(vbox)
|
||||
|
||||
def radio_selected(self) -> None:
|
||||
text = "You have chosen "
|
||||
if self.check1.isChecked():
|
||||
text += self.check1.text().lower() + ", "
|
||||
if self.check2.isChecked():
|
||||
text += self.check2.text().lower()
|
||||
if not any((self.check1.isChecked(), self.check2.isChecked())):
|
||||
text = "You haven't chosen anything"
|
||||
text = text.removesuffix(", ")
|
||||
self.label.setText(text)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
70
Python/pyqt6_4/snippets/9.py
Executable file
70
Python/pyqt6_4/snippets/9.py
Executable file
@ -0,0 +1,70 @@
|
||||
import sys
|
||||
from enum import StrEnum
|
||||
|
||||
from PyQt6.QtGui import QFont
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication,
|
||||
QComboBox,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QVBoxLayout,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
|
||||
class CatType(StrEnum):
|
||||
ORANGE = "one orange brain cell"
|
||||
VOID = "void"
|
||||
DUST = "dust kitty"
|
||||
|
||||
|
||||
class Window(QWidget):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.setGeometry(*(500,) * 4)
|
||||
self.setWindowTitle("Окно")
|
||||
self.current_type = CatType.ORANGE
|
||||
self.create_combo()
|
||||
|
||||
def create_combo(self) -> None:
|
||||
hbox = QHBoxLayout()
|
||||
|
||||
label = QLabel("Select cat type:")
|
||||
label.setFont(QFont("Times", 15))
|
||||
|
||||
self.combo = QComboBox(self)
|
||||
for cat_type in CatType:
|
||||
self.combo.addItem(cat_type.capitalize())
|
||||
self.combo.currentTextChanged.connect(self.combo_changed)
|
||||
|
||||
hbox.addWidget(label)
|
||||
hbox.addWidget(self.combo)
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
self.label_result = QLabel(
|
||||
f"Current cat: {self.current_type.capitalize()}",
|
||||
)
|
||||
|
||||
self.label_result.setFont(QFont("Times", 15))
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
vbox.addWidget(self.label_result)
|
||||
vbox.addLayout(hbox)
|
||||
self.setLayout(vbox)
|
||||
|
||||
def combo_changed(self) -> None:
|
||||
self.current_type = CatType(self.combo.currentText().lower())
|
||||
self.label_result.setText(
|
||||
f"Current cat: {self.current_type.capitalize()}",
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = QApplication(sys.argv)
|
||||
window = Window()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
0
Python/pyqt6_4/task1.py
Executable file
0
Python/pyqt6_4/task1.py
Executable file
0
Python/pyqt6_4/test.py
Executable file
0
Python/pyqt6_4/test.py
Executable file
Reference in New Issue
Block a user