Last active
May 16, 2020 19:12
-
-
Save Olbergx/6aafa949e1d2d692e85e29570af4a58e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt5.QtWidgets import * | |
import os | |
import sqlite3 | |
from docxtpl import DocxTemplate | |
class Example(QWidget): | |
def __init__(self): | |
super(Example, self).__init__() | |
self.initUI() | |
def initUI(self): | |
self.btn = QPushButton("TEST WORD", self) | |
self.btn.move(20, 240) | |
cal = QCalendarWidget(self) | |
cal.setGridVisible(True) | |
cal.move(20, 20) | |
cal.clicked.connect(self.showDate) | |
self.btn.clicked.connect(self.on_click) | |
self.lbl = QLabel(self) | |
date = cal.selectedDate() | |
self.lbl.setText(date.toString()) | |
self.dat = date.toString() | |
self.lbl.move(20, 200) | |
self.setGeometry(100,100,300,300) | |
self.setWindowTitle('Calendar') | |
self.show() | |
def on_click(self, dat): | |
# dat = date.toString() | |
# self.lbl.setText(date.toString()) | |
dir = os.path.dirname(__file__) | |
filename = os.path.join(dir, 'tmp/template1.docx') | |
doc = DocxTemplate(filename) | |
context = { 'adm' : 'adm','emitent' : 'ООО Ромашка', 'address1' : self.dat, 'участник': 'ООО Участник', 'адрес_участника': 'г. Москва, ул. Полевая, д. 0', 'director': 'dir'} | |
doc.render(context) | |
doc.save('temp-final1.docx') | |
os.startfile('temp-final1.docx') | |
def showDate(self, date): | |
self.lbl.setText(date.toString()) | |
self.dat = date.toString() | |
dir = os.path.dirname(__file__) | |
filename = os.path.join(dir, 'tmp/template1.docx') | |
doc = DocxTemplate(filename) | |
context = { 'adm' : 'adm','emitent' : 'ООО Ромашка', 'address1' : date.toString(), 'участник': 'ООО Участник', 'адрес_участника': 'г. Москва, ул. Полевая, д. 0', 'director': 'dir'} | |
doc.render(context) | |
doc.save('temp-final1.docx') | |
os.startfile('temp-final1.docx') | |
def main(): | |
app = QApplication(sys.argv) | |
ex = Example() | |
sys.exit(app.exec_()) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment