from docxtpl import DocxTemplate
doc = DocxTemplate("my_word_template.docx")
context = { 'company_name' : "World company" }
doc.render(context)
doc.save("generated_doc.docx")
import random
print("Программа подбросит монетку 100 раз и покажет, сколько раз выпадет Орел или Решка\n")
tries = 0
damage = 1
orel = 0
reshka = 0
while tries !=100:
tries += damage
result = random.randint (1, 2)
print("Осталось бросков: ", (100-tries))
if result == 1:
reshka += 1
else:
orel += 1
print("Орлов выпало: ", orel, "Решек выпало: ", reshka)
input("\nНажмите Enter, чтобы выйти.")
import subprocess
subprocess.call("d:\\file.avi", shell=True)
import os
os.startfile("d:\\file.avi")
from PyQt4 import QtCore, QtGui
import sys
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
window.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint)
window.setWindowTitle("Создание окна произвольной формы")
window.resize(300, 300)
pixmap = QtGui.QPixmap("fon.png")
pal = window.palette()
pal.setBrush(QtGui.QPalette.Normal, QtGui.QPalette.Window, QtGui.QBrush(pixmap))
pal.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, QtGui.QBrush(pixmap))
window.setPalette(pal)
window.setMask(pixmap.mask())
button = QtGui.QPushButton("Закрыть окно", window)
button.setFixedSize(150, 30)
button.move(75, 135)
QtCore.QObject.connect(button, QtCore.SIGNAL("clicked()"), QtGui.qApp, QtCore.SLOT("quit()"))
window.show()
sys.exit(app.exec())
coords = [(10,12),(8,6),(9,12),(9,9),(13,13)]
all_x = []
all_y = []
for coord in coords:
all_x.append(coord[0])
all_y.append(coord[1])
first_point = (min(all_x), min(all_y))
second_point = (max(all_x), max(all_y))
print(first_point)
print(second_point)
PyQt4 не устанавливается через pip.
import sys
from PyQt4 import QtGui,QtCore,QtWebKit,QtScript
sys.exit(app.exec_())
import sys
from PyQt4 import QtGui,QtCore,QtWebKit,QtScript
app=QtGui.QApplication(sys.argv)
web=QtWebKit.QWebView()
web.setGeometry(100,50,800,480)
web.setWindowTitle('MyBrowser')
web.load(QtCore.QUrl('http://www.belursus.info'))
web.show()
sys.exit(app.exec_())
from PIL import Image, ImageDraw
image = Image.new('RGBA', (200, 200))
draw = ImageDraw.Draw(image)
draw.ellipse((20, 25, 100, 150), fill = None, outline ='blue')
draw.ellipse((19, 24, 101, 151), fill = None, outline ='blue')
del draw
image.show("test.png", "PNG")
draw.line((0, 0) + image.size, fill=128, width=5)