This file is indexed.

/usr/share/doc/python-gtk2-tutorial/html/sec-Calendar.html is in python-gtk2-tutorial 2.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>9.12. Calendar</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PyGTK 2.0 Tutorial"><link rel="up" href="ch-MiscellaneousWidgets.html" title="Chapter 9. Miscellaneous Widgets"><link rel="previous" href="sec-ComboWidget.html" title="9.11. Combo Widget"><link rel="next" href="sec-ColorSelection.html" title="9.13. Color Selection"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">9.12. Calendar</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-ComboWidget.html">Prev</a> </td><th width="60%" align="center">Chapter 9. Miscellaneous Widgets</th><td width="20%" align="right"> <a accesskey="n" href="sec-ColorSelection.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-Calendar"></a>9.12. Calendar</h2></div></div><div></div></div><p>The <tt class="classname">Calendar</tt> widget is an effective way
to display and retrieve monthly date related information. It is a very
simple widget to create and work with.</p><p>Creating a <tt class="classname">gtk.Calendar</tt> widget is as
simple as:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  calendar = gtk.Calendar()
</pre></td></tr></table><p>The calendar will display the current month and year by
default.</p><p>There might be times where you need to change a lot of
information within this widget and the following methods allow you to make
multiple changes to a <tt class="classname">Calendar</tt> widget without the
user seeing multiple on-screen updates.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  calendar.freeze()

  calendar.thaw()
</pre></td></tr></table><p>They work just like the freeze/thaw methods of every other
widget.</p><p>The <tt class="classname">Calendar</tt> widget has a few options
that allow you to change the way the widget both looks and operates by using
the method:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  calendar.display_options(<b class="parameter"><tt>flags</tt></b>)
</pre></td></tr></table><p>The <i class="parameter"><tt>flags</tt></i> argument can be formed by
combining either of the following five options using the logical bitwise OR
(|) operation:</p><div class="informaltable"><table width="100%" border="1"><colgroup><col><col></colgroup><tbody><tr><td>CALENDAR_SHOW_HEADING</td><td>this option specifies that the month and year should be
shown when drawing the calendar.</td></tr><tr><td>CALENDAR_SHOW_DAY_NAMES</td><td>this option specifies that the three letter descriptions
should be displayed for each day (e.g. Mon,Tue, etc.).</td></tr><tr><td>CALENDAR_NO_MONTH_CHANGE</td><td>this option states that the user should not and can not
change the currently displayed month. This can be good if you only need to
display a particular month such as if you are displaying 12 calendar widgets
for every month in a particular year.</td></tr><tr><td>CALENDAR_SHOW_WEEK_NUMBERS</td><td>this option specifies that the number for each week should
be displayed down the left side of the calendar. (e.g. Jan 1 = Week 1,Dec 31
= Week 52).</td></tr><tr><td>CALENDAR_WEEK_START_MONDAY</td><td>this option states that the calender week will start on
Monday instead of Sunday which is the default. This only affects the order
in which days are displayed from left to right. Note that in PyGTK 2.4 and
above this option is deprecated.</td></tr></tbody></table></div><p>The following methods are used to set the the currently
displayed date:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  result = calendar.select_month(<b class="parameter"><tt>month</tt></b>, <b class="parameter"><tt>year</tt></b>)

  calendar.select_day(<b class="parameter"><tt>day</tt></b>)
</pre></td></tr></table><p>The return value from the
<tt class="methodname">select_month</tt>() method is a boolean value indicating
whether the selection was successful.</p><p>With the <tt class="methodname">select_day</tt>() method the
specified day number is selected within the current month, if that is
possible. A day value of 0 will deselect any current selection.</p><p>In addition to having a day selected, any number of days in the
month may be "marked". A marked day is highlighted within the calendar
display. The following methods are provided to manipulate marked
days:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  result = calendar.mark_day(<b class="parameter"><tt>day</tt></b>)

  result = calendar.unmark_day(<b class="parameter"><tt>day</tt></b>)

  calendar.clear_marks()
</pre></td></tr></table><p><tt class="methodname">mark_day</tt>() and
<tt class="methodname">unmark_day</tt>() return a boolean indicating whether
the method was successful. Note that marks are persistent across month and
year changes.</p><p>The final <tt class="classname">Calendar</tt> widget method is used
to retrieve the currently selected date, month and/or year.</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  year, month, day = calendar.get_date()
</pre></td></tr></table><p>The <tt class="classname">Calendar</tt> widget can generate a number
of signals indicating date selection and change. The names of these signals
are self explanatory, and are:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
  month_changed

  day_selected

  day_selected_double_click

  prev_month

  next_month

  prev_year

  next_year
</pre></td></tr></table><p>That just leaves us with the need to put all of this together
into the <a href="examples/calendar.py" target="_top"><span><b class="command">calendar.py</b></span></a> example
program.  <a href="sec-Calendar.html#calendarfig" title="Figure 9.12. Calendar Example">Figure 9.12, &#8220;Calendar Example&#8221;</a> illustrates the program
operation:</p><div class="figure"><a name="calendarfig"></a><p class="title"><b>Figure 9.12. Calendar Example</b></p><div class="mediaobject" align="center"><img src="figures/calendar.png" align="middle" alt="Calendar Example"></div></div><p>The <a href="examples/calendar.py" target="_top"><span><b class="command">calendar.py</b></span></a> source
code is:</p><table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="programlisting">
    1	#!/usr/bin/env python
    2	
    3	# example calendar.py
    4	#
    5	# Copyright (C) 1998 Cesar Miquel, Shawn T. Amundson, Mattias Gronlund
    6	# Copyright (C) 2000 Tony Gale
    7	# Copyright (C) 2001-2004 John Finlay
    8	#
    9	# This program is free software; you can redistribute it and/or modify
   10	# it under the terms of the GNU General Public License as published by
   11	# the Free Software Foundation; either version 2 of the License, or
   12	# (at your option) any later version.
   13	#
   14	# This program is distributed in the hope that it will be useful,
   15	# but WITHOUT ANY WARRANTY; without even the implied warranty of
   16	# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17	# GNU General Public License for more details.
   18	#
   19	# You should have received a copy of the GNU General Public License
   20	# along with this program; if not, write to the Free Software
   21	# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   22	
   23	import pygtk
   24	pygtk.require('2.0')
   25	import gtk, pango
   26	import time
   27	
   28	class CalendarExample:
   29	    DEF_PAD = 10
   30	    DEF_PAD_SMALL = 5
   31	    TM_YEAR_BASE = 1900
   32	
   33	    calendar_show_header = 0
   34	    calendar_show_days = 1
   35	    calendar_month_change = 2 
   36	    calendar_show_week = 3
   37	
   38	    def calendar_date_to_string(self):
   39	        year, month, day = self.window.get_date()
   40	        mytime = time.mktime((year, month+1, day, 0, 0, 0, 0, 0, -1))
   41	        return time.strftime("%x", time.localtime(mytime))
   42	
   43	    def calendar_set_signal_strings(self, sig_str):
   44	        prev_sig = self.prev_sig.get()
   45	        self.prev2_sig.set_text(prev_sig)
   46	
   47	        prev_sig = self.last_sig.get()
   48	        self.prev_sig.set_text(prev_sig)
   49	        self.last_sig.set_text(sig_str)
   50	
   51	    def calendar_month_changed(self, widget):
   52	        buffer = "month_changed: %s" % self.calendar_date_to_string()
   53	        self.calendar_set_signal_strings(buffer)
   54	
   55	    def calendar_day_selected(self, widget):
   56	        buffer = "day_selected: %s" % self.calendar_date_to_string()
   57	        self.calendar_set_signal_strings(buffer)
   58	
   59	    def calendar_day_selected_double_click(self, widget):
   60	        buffer = "day_selected_double_click: %s"
   61	        buffer = buffer % self.calendar_date_to_string()
   62	        self.calendar_set_signal_strings(buffer)
   63	
   64	        year, month, day = self.window.get_date()
   65	
   66	        if self.marked_date[day-1] == 0:
   67	            self.window.mark_day(day)
   68	            self.marked_date[day-1] = 1
   69	        else:
   70	            self.window.unmark_day(day)
   71	            self.marked_date[day-1] = 0
   72	
   73	    def calendar_prev_month(self, widget):
   74	        buffer = "prev_month: %s" % self.calendar_date_to_string()
   75	        self.calendar_set_signal_strings(buffer)
   76	
   77	    def calendar_next_month(self, widget):
   78	        buffer = "next_month: %s" % self.calendar_date_to_string()
   79	        self.calendar_set_signal_strings(buffer)
   80	
   81	    def calendar_prev_year(self, widget):
   82	        buffer = "prev_year: %s" % self.calendar_date_to_string()
   83	        self.calendar_set_signal_strings(buffer)
   84	
   85	    def calendar_next_year(self, widget):
   86	        buffer = "next_year: %s" % self.calendar_date_to_string()
   87	        self.calendar_set_signal_strings(buffer)
   88	
   89	    def calendar_set_flags(self):
   90	        options = 0
   91	        for i in range(5):
   92	            if self.settings[i]:
   93	                options = options + (1&lt;&lt;i)
   94	        if self.window:
   95	            self.window.display_options(options)
   96	
   97	    def calendar_toggle_flag(self, toggle):
   98	        j = 0
   99	        for i in range(5):
  100	            if self.flag_checkboxes[i] == toggle:
  101	                j = i
  102	
  103	        self.settings[j] = not self.settings[j]
  104	        self.calendar_set_flags()
  105	
  106	    def calendar_font_selection_ok(self, button):
  107	        self.font = self.font_dialog.get_font_name()
  108	        if self.window:
  109	            font_desc = pango.FontDescription(self.font)
  110	            if font_desc: 
  111	                self.window.modify_font(font_desc)
  112	
  113	    def calendar_select_font(self, button):
  114	        if not self.font_dialog:
  115	            window = gtk.FontSelectionDialog("Font Selection Dialog")
  116	            self.font_dialog = window
  117	    
  118	            window.set_position(gtk.WIN_POS_MOUSE)
  119	    
  120	            window.connect("destroy", self.font_dialog_destroyed)
  121	    
  122	            window.ok_button.connect("clicked",
  123	                                     self.calendar_font_selection_ok)
  124	            window.cancel_button.connect_object("clicked",
  125	                                                lambda wid: wid.destroy(),
  126	                                                self.font_dialog)
  127	        window = self.font_dialog
  128	        if not (window.flags() &amp; gtk.VISIBLE):
  129	            window.show()
  130	        else:
  131	            window.destroy()
  132	            self.font_dialog = None
  133	
  134	    def font_dialog_destroyed(self, data=None):
  135	        self.font_dialog = None
  136	
  137	    def __init__(self):
  138	        flags = [
  139	            "Show Heading",
  140	            "Show Day Names",
  141	            "No Month Change",
  142	            "Show Week Numbers",
  143	            ]
  144	        self.window = None
  145	        self.font = None
  146	        self.font_dialog = None
  147	        self.flag_checkboxes = 5*[None]
  148	        self.settings = 5*[0]
  149	        self.marked_date = 31*[0]
  150	
  151	        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  152	        window.set_title("Calendar Example")
  153	        window.set_border_width(5)
  154	        window.connect("destroy", lambda x: gtk.main_quit())
  155	
  156	        window.set_resizable(False)
  157	
  158	        vbox = gtk.VBox(False, self.DEF_PAD)
  159	        window.add(vbox)
  160	
  161	        # The top part of the window, Calendar, flags and fontsel.
  162	        hbox = gtk.HBox(False, self.DEF_PAD)
  163	        vbox.pack_start(hbox, True, True, self.DEF_PAD)
  164	        hbbox = gtk.HButtonBox()
  165	        hbox.pack_start(hbbox, False, False, self.DEF_PAD)
  166	        hbbox.set_layout(gtk.BUTTONBOX_SPREAD)
  167	        hbbox.set_spacing(5)
  168	
  169	        # Calendar widget
  170	        frame = gtk.Frame("Calendar")
  171	        hbbox.pack_start(frame, False, True, self.DEF_PAD)
  172	        calendar = gtk.Calendar()
  173	        self.window = calendar
  174	        self.calendar_set_flags()
  175	        calendar.mark_day(19)
  176	        self.marked_date[19-1] = 1
  177	        frame.add(calendar)
  178	        calendar.connect("month_changed", self.calendar_month_changed)
  179	        calendar.connect("day_selected", self.calendar_day_selected)
  180	        calendar.connect("day_selected_double_click",
  181	                         self.calendar_day_selected_double_click)
  182	        calendar.connect("prev_month", self.calendar_prev_month)
  183	        calendar.connect("next_month", self.calendar_next_month)
  184	        calendar.connect("prev_year", self.calendar_prev_year)
  185	        calendar.connect("next_year", self.calendar_next_year)
  186	
  187	        separator = gtk.VSeparator()
  188	        hbox.pack_start(separator, False, True, 0)
  189	
  190	        vbox2 = gtk.VBox(False, self.DEF_PAD)
  191	        hbox.pack_start(vbox2, False, False, self.DEF_PAD)
  192	  
  193	        # Build the Right frame with the flags in 
  194	        frame = gtk.Frame("Flags")
  195	        vbox2.pack_start(frame, True, True, self.DEF_PAD)
  196	        vbox3 = gtk.VBox(True, self.DEF_PAD_SMALL)
  197	        frame.add(vbox3)
  198	
  199	        for i in range(len(flags)):
  200	            toggle = gtk.CheckButton(flags[i])
  201	            toggle.connect("toggled", self.calendar_toggle_flag)
  202	            vbox3.pack_start(toggle, True, True, 0)
  203	            self.flag_checkboxes[i] = toggle
  204	
  205	        # Build the right font-button 
  206	        button = gtk.Button("Font...")
  207	        button.connect("clicked", self.calendar_select_font)
  208	        vbox2.pack_start(button, False, False, 0)
  209	
  210	        #  Build the Signal-event part.
  211	        frame = gtk.Frame("Signal events")
  212	        vbox.pack_start(frame, True, True, self.DEF_PAD)
  213	
  214	        vbox2 = gtk.VBox(True, self.DEF_PAD_SMALL)
  215	        frame.add(vbox2)
  216	  
  217	        hbox = gtk.HBox (False, 3)
  218	        vbox2.pack_start(hbox, False, True, 0)
  219	        label = gtk.Label("Signal:")
  220	        hbox.pack_start(label, False, True, 0)
  221	        self.last_sig = gtk.Label("")
  222	        hbox.pack_start(self.last_sig, False, True, 0)
  223	
  224	        hbox = gtk.HBox (False, 3)
  225	        vbox2.pack_start(hbox, False, True, 0)
  226	        label = gtk.Label("Previous signal:")
  227	        hbox.pack_start(label, False, True, 0)
  228	        self.prev_sig = gtk.Label("")
  229	        hbox.pack_start(self.prev_sig, False, True, 0)
  230	
  231	        hbox = gtk.HBox (False, 3)
  232	        vbox2.pack_start(hbox, False, True, 0)
  233	        label = gtk.Label("Second previous signal:")
  234	        hbox.pack_start(label, False, True, 0)
  235	        self.prev2_sig = gtk.Label("")
  236	        hbox.pack_start(self.prev2_sig, False, True, 0)
  237	
  238	        bbox = gtk.HButtonBox ()
  239	        vbox.pack_start(bbox, False, False, 0)
  240	        bbox.set_layout(gtk.BUTTONBOX_END)
  241	
  242	        button = gtk.Button("Close")
  243	        button.connect("clicked", lambda w: gtk.main_quit())
  244	        bbox.add(button)
  245	        button.set_flags(gtk.CAN_DEFAULT)
  246	        button.grab_default()
  247	
  248	        window.show_all()
  249	
  250	def main():
  251	    gtk.main()
  252	    return 0
  253	
  254	if __name__ == "__main__":
  255	    CalendarExample()
  256	    main()
</pre></td></tr></table></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-ComboWidget.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch-MiscellaneousWidgets.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sec-ColorSelection.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">9.11. Combo Widget </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 9.13. Color Selection</td></tr></table></div></body></html>