forked from sanyaade-machine-learning/Transana
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionSummaryReport.py
More file actions
95 lines (83 loc) · 4.67 KB
/
CollectionSummaryReport.py
File metadata and controls
95 lines (83 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Copyright (C) 2004 - 2007 The Board of Regents of the University of Wisconsin System
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
"""This module implements the Collection Summary Report. """
__author__ = 'David K. Woods <dwoods@wcer.wisc.edu>'
import wx
import DBInterface
import Dialogs
import TransanaGlobal
import TranscriptPrintoutClass
class CollectionSummaryReport(wx.Object):
""" Collection Summary Report """
def __init__(self, dbTree, sel):
# Set the Cursor to the Hourglass while the report is assembled
TransanaGlobal.menuWindow.SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
try:
# Build the title and subtitle
title = _('Collection Summary Report')
if dbTree.GetPyData(sel).nodetype == 'SearchCollectionNode':
reportType = _('Search Result Collection')
else:
reportType = _('Collection')
prompt = '%s: %s'
if 'unicode' in wx.PlatformInfo:
# Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
reportType = unicode(reportType, 'utf8')
prompt = unicode(prompt, 'utf8')
subtitle = prompt % (reportType, dbTree.GetItemText(sel))
# Prepare the Transcript for printing
(graphic, pageData) = TranscriptPrintoutClass.PrepareData(TransanaGlobal.printData, collectionTree=dbTree, collectionNode=sel, title=title, subtitle=subtitle)
# If there's data inthe report...
if pageData != []:
# Send the results of the PrepareData() call to the MyPrintout object, once for the print preview
# version and once for the printer version.
printout = TranscriptPrintoutClass.MyPrintout(title, graphic, pageData, subtitle=subtitle)
printout2 = TranscriptPrintoutClass.MyPrintout(title, graphic, pageData, subtitle=subtitle)
# Create the Print Preview Object
printPreview = wx.PrintPreview(printout, printout2, TransanaGlobal.printData)
# Check for errors during Print preview construction
if not printPreview.Ok():
dlg = Dialogs.ErrorDialog(None, _("Print Preview Problem"))
dlg.ShowModal()
dlg.Destroy()
else:
# Create the Frame for the Print Preview
# The parent Frame is the global Menu Window
theWidth = max(wx.ClientDisplayRect()[2] - 180, 760)
theHeight = max(wx.ClientDisplayRect()[3] - 200, 560)
printFrame = wx.PreviewFrame(printPreview, TransanaGlobal.menuWindow, _("Print Preview"), size=(theWidth, theHeight))
printFrame.Centre()
# Initialize the Frame for the Print Preview
printFrame.Initialize()
# Restore Cursor to Arrow
TransanaGlobal.menuWindow.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
# Display the Print Preview Frame
printFrame.Show(True)
else:
# Restore Cursor to Arrow
TransanaGlobal.menuWindow.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
# If there are no clips to report, display an error message.
if 'unicode' in wx.PlatformInfo:
# Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
prompt = unicode(_('Collection "%s" has no Clips for the Collection Summary Report.'), 'utf8')
else:
prompt = _('Collection "%s" has no Clips for the Collection Summary Report.')
dlg = wx.MessageDialog(None, prompt % dbTree.GetItemText(sel), style = wx.OK | wx.ICON_EXCLAMATION)
dlg.ShowModal()
dlg.Destroy()
finally:
# Restore Cursor to Arrow
TransanaGlobal.menuWindow.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))