from tkinter import ttk
from tkinter import *
from tkinter import Tk, Frame, Menu
import tkinter as tk
import sys
######Function
# def test():
# sub.mainloop()
# ---------------------------------------
def test():
sub.deiconify() # показать окно
# ---------------------------------------
def qu1():
a = ent_1.get()
x = (float(a))
y = str(x)
if float(x) == 1:
sublabel2["text"] = ("Ваш вес идеален")
elif float(x) == 2:
sublabel2["text"] = ("Вам нужно набрать" + y + " кг")
elif float(x) == 3:
sublabel2["text"] = ("Вам нужно сбросить" + y + " кг")
def quit():
sys.exit()
###################
def theoryfile1():
text_box.delete(1.0, END)
for word in numbers:
text_box.insert(END,word)
def theoryfile2():
text_box.delete(1.0, END)
for word in numbers2:
text_box.insert(END,word)
def theoryfile3():
text_box.delete(1.0, END)
for word in numbers3:
text_box.insert(END,word)
def practicfile1():
text_box.delete(1.0, END)
for word in numbers4:
text_box.insert(END,word)
def practicfile2():
text_box.delete(1.0, END)
for word in numbers5:
text_box.insert(END,word)
def practicfile3():
text_box.delete(1.0, END)
for word in numbers6:
text_box.insert(END,word)
def practic():
label.config(text="Практическая часть",font=("Arial Black", 14))
label2.config(text="ПР 1 Составление линейных алгоритмов",font=("Arial", 12))
label3.config(text="ПР 2 Составление разветвляющихся алгоритмов",font=("Arial", 12))
label4.config(text="ПР 3 Составление цикла со схемой ПОКА",font=("Arial", 12))
btn2.config(text=" + ",width=4,command=pluspractic)
btn3.config(command=practicfile1)
btn4.config(command=practicfile2)
btn5.config(command=practicfile3)
def theory():
label.config(text="Теоретическая часть",font=("Arial Black", 14))
label2.config(text="1.1. Основные алгоритмические конструкции",font=("Arial", 12))
label3.config(text="1.1.1. Понятие алгоритма и его свойства",font=("Arial", 12))
label4.config(text="1.1.2. Основные алгоритмические конструкции",font=("Arial", 12))
btn2.config(command=plusteory)
btn3.config(command=theoryfile1)
btn4.config(command=theoryfile2)
btn5.config(command=theoryfile3)
def minus():
label2.config(text="")
label3.config(text="")
label4.config(text="")
btn2.config(text=" + ",width=4,state=NORMAL)
btn3.config(state=DISABLED)
btn4.config(state=DISABLED)
btn5.config(state=DISABLED)
def plusteory():
label2.config(text="1.1. Основные алгоритмические конструкции",font=("Arial", 12))
label3.config(text="1.1.1. Понятие алгоритма и его свойства",font=("Arial", 12))
label4.config(text="1.1.2. Основные алгоритмические конструкции",font=("Arial", 12))
btn3.config(state=NORMAL)
btn4.config(state=NORMAL)
btn5.config(state=NORMAL)
def pluspractic():
label2.config(text="ПР 1 Составление линейных алгоритмов",font=("Arial", 12))
label3.config(text="ПР 2 Составление разветвляющихся алгоритмов",font=("Arial", 12))
label4.config(text="ПР 3 Составление цикла со схемой ПОКА",font=("Arial", 12))
btn3.config(state=NORMAL)
btn4.config(state=NORMAL)
btn5.config(state=NORMAL)
######Window
root = Tk()
root.title("Электронный учебник")
root.geometry("800x400")
with open("111.htm", "r") as file:
contents = file.readlines()
numbers=list(contents)
with open("112.htm", "r") as file:
contents = file.readlines()
numbers2=list(contents)
with open("113.htm", "r") as file:
contents = file.readlines()
numbers3=list(contents)
with open("1.htm ", "r") as file:
contents = file.readlines()
numbers4=list(contents)
with open("2.htm ", "r") as file:
contents = file.readlines()
numbers5=list(contents)
with open("3.htm ", "r") as file:
contents = file.readlines()
numbers6=list(contents)
main_menu = Menu()
main_menu.add_command(label="Теория",command=theory)
main_menu.add_command(label="Практика",command=practic)
main_menu.add_command(label="Начать тест",command=test)
main_menu.add_command(label="Выход",command=quit)
label=Label(text="Теоретическая часть",font=("Arial Black", 14))
label.place(x=1,y=1)
label2=Label(text="1.1. Основные алгоритмические конструкции",font=("Arial", 12))
label2.place(x=1,y=40)
label3=Label(text="1.1.1. Понятие алгоритма и его свойства",font=("Arial", 12))
label3.place(x=1,y=80)
label4=Label(text="1.1.2. Основные алгоритмические конструкции",font=("Arial", 12))
label4.place(x=1,y=120)
btn=Button(text=" - ",width=4,command=minus)
btn.place(x=300,y=1)
btn2=Button(text=" + ",width=4,command=plusteory,state=DISABLED)
btn2.place(x=250,y=1)
btn3=Button(text="+",command=theoryfile1)
btn3.place(x=370,y=40)
btn4=Button(text="+",command=theoryfile2)
btn4.place(x=370,y=80)
btn5=Button(text="+",command=theoryfile3)
btn5.place(x=370,y=120)
text_box = tk.Text(height=22,width=45)
text_box.place(x=400,y=1)
root.config(menu=main_menu)
sub = tk.Toplevel(root)
sub.transient(root)
sub.title('Ебаный тест')
sub.geometry("300x400")
sublabel = Label(sub, text="Cколько будет 1+1", font=("Arial", 10))
sublabel.place(x=1, y=1)
sublabel2 = Label(sub, text="", font=("Arial", 10))
sublabel2.place(x=1, y=60)
ent_1 = Entry(sub, width=10)
ent_1.place(x=1, y=20)
subbtn = Button(sub, text=" Назад ", width=4, command=quit)
subbtn.place(x=250, y=200)
subbtn2 = Button(sub, text=" ОК ", width=4, command=qu1)
subbtn2.place(x=150, y=200)
subbtn3 = Button(sub, text=" Далее ", width=4, command=quit)
subbtn3.place(x=1, y=200)
# ---------------------------------------
sub.withdraw() # скрыть окно
# заменить закрытие окна на скрытие окна:
def hide_sub():
sub.withdraw()
sub.protocol("WM_DELETE_WINDOW", hide_sub) # переназначаем кнопку закрытия окна на скрытие окна
# ---------------------------------------
root.mainloop()
notify-send --icon=mail-unread "Message Header" "<a href='https://developer.mozilla.org'><span color='green' font='Times, 12'><b>Link Name</b></span></a> \n <b><i>Message 1</i></b> <span font='11'>\nMessage 2</span> "
<b>
должен быть закрывающий <\b>
notify-send «Шапка» "<b>жирный</b> <i>италик</i> <a href='https://developer.mozilla.org/ru/'>ссылка</a>"
import PySimpleGUI as sg
import random
import string
sg.theme('Dark Green')
data = [['rocsptjach', 161, 570, 844, 745, 454],
['jwsqgvyatn', 380, 524, 697, 124, 911],
['egeflqdyvd', 813, 138, 834, 292, 625],
['vkrguwdoaw', 642, 607, 209, 688, 699],
['rygewgrzst', 670, 570, 499, 557, 518],
['stsfbznqtn', 419, 540, 638, 78, 325],
['szycvyypig', 786, 581, 489, 279, 264],
['rixofzlgil', 483, 243, 970, 664, 313],
['yzqrqhtwvt', 213, 887, 55, 119, 211],
['rurwvjivsy', 75, 110, 795, 484, 977],
['dimuvsdwan', 630, 840, 842, 822, 297],
['xnmcmlyyjh', 284, 936, 368, 183, 411],
['xogepbuatb', 309, 408, 181, 281, 219],
['zpiuwvnfcz', 770, 750, 652, 111, 440]]
headings = ['column 1', 'column 10', 'column 2', 'column 3', 'column 4', 'column 5']
# ------ Window Layout ------
layout = [[sg.Table(values=data, headings=headings, max_col_width=35,
# background_color='light blue',
auto_size_columns=True,
display_row_numbers=True,
justification='right',
num_rows=20,
alternating_row_color='lightyellow',
key='-TABLE-',
row_height=35,
tooltip='This is a table')],
[sg.Button('Read')],
[sg.Text('Read = read which rows are selected')]]
# ------ Create Window ------
window = sg.Window('The Table Element', layout )
# ------ Event Loop ------
while True:
event, values = window.read()
print(event, values)
if event == sg.WIN_CLOSED:
break
window.close()
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QGridLayout, QSlider, QWidget
from PyQt5.QtSvg import QSvgWidget
# потом <g transform="rotate({} 149 239)"> вместо {} подставляем поворот svg_str.format('угол')
svg_str = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="300" height="300" viewBox="0 0 300 300" id="smile" version="1.1">
<g transform="rotate({} 149 239)">
<path
id="path3709"
style="fill:#ffaaaa"
d="m 139.42058,223.21182 c 0.87131,-14.42535 -4.24928,-28.50419 -2.9033,-42.95942 0.48305,-19.46355 -1.22008,-39.07505 1.373,-58.42743 1.6052,
-8.94222 4.9895,-17.45415 6.16399,-26.504939 1.01772,-7.086915 3.62587,-13.774342 5.77506,-20.51875 -0.66844,-6.151843 7.18967,-17.418207 12.67961,
-11.676647 0.95503,7.682153 2.02107,15.331586 1.83789,23.120357 -0.33324,15.262759 4.70165,29.992469 4.90459,45.223769 1.63015,7.39779 4.63818,
14.62777 3.86823,22.358 0.53553,10.04962 1.0294,20.61631 -3.7416,29.84285 -4.14927,9.74091 -10.65255,18.64536 -12.38767,29.28844 2.6986,7.78269 16.15108,
2.57929 17.73005,12.21779 4.03312,10.37811 -0.18518,23.79596 -10.23781,29.07756 -7.18928,5.23203 -18.32381,7.8453 -25.2464,0.73107 -7.03162,
-6.32331 -14.32459,-14.01261 -14.14214,-24.16516 -1.81894,-9.77467 8.70717,-14.9605 16.7892,-16.15672 3.57541,-1.44912 11.05229,0.60824 4.21681,
3.35074 -3.55116,4.38962 -14.95304,3.44507 -16.39528,3.56979 3.20643,-0.98242 9.77158,-6.97143 5.3999,-0.45377 -1.78849,9.88387 3.2561,
19.49489 10.74511,25.66411 4.71707,6.23276 13.94834,7.51007 20.02775,4.68256 -3.55814,1.65986 -11.33056,7.06102 -4.50259,1.28568 5.4695,
-7.14418 7.51638,-18.29409 1.6675,-25.78616 -6.14571,-3.96281 -20.63622,-3.00294 -14.81272,-14.47468 4.44453,-14.02342 15.463,-25.87651 15.69919,
-41.19539 -0.0512,-10.63367 0.3575,-21.63757 -3.59197,-31.73103 -1.7771,-9.93749 -1.54095,-20.12739 -3.75043,-30.01069 -1.90453,-11.483749 -1.62159,
-23.186685 -2.8041,-34.711619 -3.81963,-5.549256 2.88463,-14.540184 7.44473,-11.98753 -1.26415,10.384778 -6.79308,19.654848 -7.94853,30.11085 -1.24183,
11.198529 -6.6712,21.552179 -6.71927,32.945869 -0.93022,16.32705 0.13083,32.69954 -0.40451,49.04457 -0.31902,11.27313 1.05757,22.49297 2.69956,
33.56835 3.45207,8.6394 -2.57318,11.85467 -9.43385,14.67758 z"
/>
</g>
</svg>
"""
app = QApplication(sys.argv)
layout = QGridLayout() # планировка
widget = QWidget()
widget.setLayout(layout)
svgWidget = QSvgWidget() # SVG виджет
svg_bytes = bytearray(svg_str.format('0'), encoding='utf-8') # подставить угол и перевести в байтовую строку
svgWidget.renderer().load(svg_bytes) # загрузить SVG в виджет
svgWidget.setGeometry(100,100,300,300)
layout.addWidget(svgWidget)
slider = QSlider(Qt.Horizontal) # слайдер
slider.setRange(-50, 50)
def updateSVG(value):
""" Обновляет SVG при движении слайдера"""
svg_bytes = bytearray(svg_str.format(str(value)), encoding='utf-8') # обновить угол и перевести в байтовую строку
svgWidget.renderer().load(svg_bytes) # загрузить SVG в виджет
slider.valueChanged.connect(updateSVG)
layout.addWidget(slider)
widget.show()
sys.exit(app.exec_())
import sys
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QApplication, QMainWindow
class Window(QMainWindow):
resized = QtCore.pyqtSignal() # 1
def __init__(self):
super(Window, self).__init__()
self.resized.connect(self.someFunction) # 2
def resizeEvent(self, event):
self.resized.emit()
return super(Window, self).resizeEvent(event)
def someFunction(self):
print("someFunction")
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
window.setGeometry(300, 100, 600, 600)
window.show()
sys.exit(app.exec_())
import sys
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import *
class WebPage( QWebEnginePage):
def userAgentForUrl(self, url):
return super(WebPage, self).userAgentForUrl(url) + ' Chrome'
class Window( QWebEngineView):
def __init__(self):
super(Window, self).__init__()
self.setPage(WebPage(self))
self.load(QtCore.QUrl('https://www.google.com/recaptcha/api2/demo'))
if __name__ == '__main__':
app = QApplication(sys.argv)
window = Window()
window.setGeometry(300, 100, 600, 600)
window.show()
sys.exit(app.exec_())