Hallo Stephan
Ist es möglich Dein Kalender-Skript so irgendwo verfügbar zu machen so wie es jetzt ist?
Für mich ist es OK wenn es kein Dialog-Fenster hat und man die Eingabesngaben durch Zuweisungen im Skript selbst vornehmen muss.
Da würde mir Zeit sparen ein eigenes Skript zu entwickeln! Bzw dafür sorgen dass ich rascher vorwärts komme, s.u.
Gruss
Hannes
------------------------------------------------
Start eines Kalender-Skripts, Format A3 quer mit Monatskalendar von oben nach unten.
Statt mit einer Tabelle müsste wohl mit Textframes gearbeitet werden.

Dieses Werk bzw. dieser Inhalt ist als gemeinfrei lizenziert.
Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
# Please do not use 'from scribus import *' . If you must use a 'from import',
# Do so _after_ the 'import scribus' and only import the names you need, such
# as commonly used constants.
import scribus
except ImportError as err:
print ("This Python script is written for the Scribus scripting interface.")
print ("It can only be run from within Scribus.")
sys.exit(1)
#########################
# IMPORTS #
#########################
import sys
import locale
import calendar
import datetime
from datetime import date, timedelta
def iterate_dates(year, month):
wdayAbbrev = ["Mon", "Die", "Mit", "Don", "Fre", "Sam", "Son"]
# Get the first day of the month
start_date = datetime.date(year, month, 1)
# Calculate the last day of the month
if month == 12:
end_date = datetime(year + 1, 1, 1) # January of the next year
else:
end_date = datetime.date(year, month + 1, 1) # First day of the next month
# Iterate through the dates
row = 0
current_date = start_date
while current_date < end_date:
# print(current_date.strftime("%Y-%m-%d")) # Print the date in YYYY-MM-DD format
wday = current_date.weekday()
scribus.setCellText(row, 0, str(wdayAbbrev[wday]), "monthTable")
scribus.setCellText(row, 1, str(current_date.day), "monthTable")
row = row + 1
current_date += timedelta(days=1) # Move to the next day
def main(argv):
"""Month calendar based on a table. This is a documentation string. Write a description of what your code
does here. You should generally put documentation strings ("docstrings")
on all your Python functions."""
scribus.newDocument(scribus.PAPER_A3_MM, (10, 10, 10, 10), scribus.LANDSCAPE, 1, scribus.UNIT_MILLIMETERS, scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT, 1)
originalUnit = scribus.getUnit()
scribus.setUnit(scribus.UNIT_MILLIMETERS)
year = 2025
month = 7
rowHeight = 7
numberOfDaysInMonth = calendar.monthrange(year,month)[1]
tableWidth = 80
tableHeight = numberOfDaysInMonth * rowHeight
scribus.createText(20, 20, tableWidth , 10, "monthNameFrame")
scribus.createTable(20, 30, tableWidth , tableHeight , numberOfDaysInMonth , 3, "monthTable")
scribus.resizeTableColumn(0, 30, "monthTable")
scribus.resizeTableColumn(1, 20, "monthTable")
# Resizes "column" to "width" in the table "name". If "name" is not given the currently selected item is used.
# scribus.setCellText(row, col, value, tableName)
# scribus.setCellText(0, 1, "1", "monthTable")
# scribus.setCellFillColor(row, column, color, ["name"])
# If "name" is not given the currently selected item is used.
# scribus.setCellText(row, column, text, ["name"])
iterate_dates(year, month)
scribus.setUnit(originalUnit)
def main_wrapper(argv):
"""The main_wrapper() function disables redrawing, sets a sensible generic
status bar message, and optionally sets up the progress bar. It then runs
the main() function. Once everything finishes it cleans up after the main()
function, making sure everything is sane before the script terminates."""
try:
scribus.statusMessage("Running script...")
scribus.progressReset()
main(argv)
finally:
# Exit neatly even if the script terminated with an exception,
# so we leave the progress bar and status bar blank and make sure
# drawing is enabled.
if scribus.haveDoc():
scribus.setRedraw(True)
scribus.statusMessage("")
scribus.progressReset()
# This code detects if the script is being run as a script, or imported as a module.
# It only runs main() if being run as a script. This permits you to import your script
# and control it manually for debugging.
if __name__ == '__main__':
main_wrapper(sys.argv)
[/CC0]