2 # -*- coding: utf-8 -*-
4 #Copyright 2008-2011 Steffen Schaumburg
5 #This program is free software: you can redistribute it and/or modify
6 #it under the terms of the GNU Affero General Public License as published by
7 #the Free Software Foundation, version 3 of the License.
9 #This program is distributed in the hope that it will be useful,
10 #but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 #GNU General Public License for more details.
14 #You should have received a copy of the GNU Affero General Public License
15 #along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #In the "official" distribution you can find the license in agpl-3.0.txt.
19 _
= L10n
.get_translation()
27 from optparse
import OptionParser
28 from time
import gmtime
, mktime
, strftime
, strptime
, localtime
33 # logging has been set up in fpdb.py or HUD_main.py, use their settings:
34 log
= logging
.getLogger("filter")
42 class Filters(threading
.Thread
):
43 def __init__(self
, db
, config
, qdict
, display
= {}, debug
=True):
44 # config and qdict are now redundant
47 self
.cursor
= db
.cursor
50 self
.display
= display
52 # text used on screen stored here so that it can be configured
53 self
.filterText
= {'limitsall':_('All'), 'limitsnone':_('None'), 'limitsshow':_('Show _Limits')
54 ,'seatsbetween':_('Between:'), 'seatsand':_('And:'), 'seatsshow':_('Show Number of _Players')
55 ,'playerstitle':_('Hero:'), 'sitestitle':(_('Sites')+':'), 'gamestitle':(_('Games')+':')
56 ,'limitstitle':_('Limits:'), 'seatstitle':_('Number of Players:')
57 ,'groupstitle':_('Grouping:'), 'posnshow':_('Show Position Stats')
58 ,'datestitle':_('Date:')
59 ,'groupsall':_('All Players')
60 ,'limitsFL':'FL', 'limitsNL':'NL', 'limitsPL':'PL', 'limitsCN':'CAP', 'ring':_('Ring'), 'tour':_('Tourney')
63 gen
= self
.conf
.get_general_params()
66 if 'day_start' in gen
:
67 self
.day_start
= float(gen
['day_start'])
70 self
.sw
= gtk
.ScrolledWindow()
71 self
.sw
.set_border_width(0)
72 self
.sw
.set_policy(gtk
.POLICY_AUTOMATIC
, gtk
.POLICY_AUTOMATIC
)
73 self
.sw
.set_size_request(235, 300)
77 self
.mainVBox
= gtk
.VBox(False, 0)
78 self
.sw
.add_with_viewport(self
.mainVBox
)
80 #print(_("DEBUG:") + _("New packing box created!"))
82 self
.found
= {'nl':False, 'fl':False, 'pl':False, 'cn':False, 'ring':False, 'tour':False}
88 def make_filter(self
):
100 for site
in self
.conf
.get_supported_sites():
101 #Get db site id for filtering later
102 self
.cursor
.execute(self
.sql
.query
['getSiteId'], (site
,))
103 result
= self
.db
.cursor
.fetchall()
105 self
.siteid
[site
] = result
[0][0]
107 print _("Either 0 or more than one site matched (%s) - EEK") % site
109 # For use in date ranges.
110 self
.start_date
= gtk
.Entry(max=12)
111 self
.start_date
.set_width_chars(12)
112 self
.end_date
= gtk
.Entry(max=12)
113 self
.end_date
.set_width_chars(12)
114 self
.start_date
.set_property('editable', False)
115 self
.end_date
.set_property('editable', False)
117 # For use in groups etc
121 # for use in graphops
122 # dspin = display in '$' or 'B'
123 self
.graphops
['dspin'] = "$"
124 self
.graphops
['showdown'] = 'OFF'
125 self
.graphops
['nonshowdown'] = 'OFF'
127 playerFrame
= gtk
.Frame()
128 playerFrame
.set_label_align(0.0, 0.0)
129 vbox
= gtk
.VBox(False, 0)
131 self
.fillPlayerFrame(vbox
, self
.display
)
132 playerFrame
.add(vbox
)
134 sitesFrame
= gtk
.Frame()
135 sitesFrame
.set_label_align(0.0, 0.0)
136 vbox
= gtk
.VBox(False, 0)
138 self
.fillSitesFrame(vbox
)
142 gamesFrame
= gtk
.Frame()
143 gamesFrame
.set_label_align(0.0, 0.0)
145 vbox
= gtk
.VBox(False, 0)
147 self
.fillGamesFrame(vbox
)
151 limitsFrame
= gtk
.Frame()
153 vbox
= gtk
.VBox(False, 0)
155 self
.cbNoLimits
= None
156 self
.cbAllLimits
= None
161 self
.rb
= {} # radio buttons for ring/tour
162 self
.type = None # ring/tour
163 self
.types
= {} # list of all ring/tour values
164 self
.num_limit_types
= 0
166 self
.fillLimitsFrame(vbox
, self
.display
)
167 limitsFrame
.add(vbox
)
170 graphopsFrame
= gtk
.Frame()
171 #graphops.set_label_align(0,0, 0.0)
173 vbox
= gtk
.VBox(False, 0)
175 self
.fillGraphOpsFrame(vbox
)
176 graphopsFrame
.add(vbox
)
180 seatsFrame
= gtk
.Frame()
182 vbox
= gtk
.VBox(False, 0)
185 self
.fillSeatsFrame(vbox
, self
.display
)
189 groupsFrame
= gtk
.Frame()
191 vbox
= gtk
.VBox(False, 0)
193 self
.fillGroupsFrame(vbox
, self
.display
)
194 groupsFrame
.add(vbox
)
197 dateFrame
= gtk
.Frame()
198 dateFrame
.set_label_align(0.0, 0.0)
200 vbox
= gtk
.VBox(False, 0)
202 self
.fillDateFrame(vbox
)
206 self
.Button1
=gtk
.Button("Unnamed 1")
207 self
.Button1
.set_sensitive(False)
209 self
.Button2
=gtk
.Button("Unnamed 2")
210 self
.Button2
.set_sensitive(False)
213 self
.mainVBox
.pack_start(playerFrame
, expand
)
214 self
.mainVBox
.pack_start(sitesFrame
, expand
)
215 self
.mainVBox
.pack_start(gamesFrame
, expand
)
216 self
.mainVBox
.pack_start(limitsFrame
, expand
)
217 self
.mainVBox
.pack_start(seatsFrame
, expand
)
218 self
.mainVBox
.pack_start(groupsFrame
, expand
)
219 self
.mainVBox
.pack_start(dateFrame
, expand
)
220 self
.mainVBox
.pack_start(graphopsFrame
, expand
)
221 self
.mainVBox
.pack_start(gtk
.VBox(False, 0))
222 self
.mainVBox
.pack_start(self
.Button1
, expand
)
223 self
.mainVBox
.pack_start(self
.Button2
, expand
)
225 self
.mainVBox
.show_all()
227 # Should do this cleaner
228 if "Heroes" not in self
.display
or self
.display
["Heroes"] == False:
230 if "Sites" not in self
.display
or self
.display
["Sites"] == False:
232 if "Games" not in self
.display
or self
.display
["Games"] == False:
234 if "Limits" not in self
.display
or self
.display
["Limits"] == False:
236 if "Seats" not in self
.display
or self
.display
["Seats"] == False:
238 if "Groups" not in self
.display
or self
.display
["Groups"] == False:
240 if "Dates" not in self
.display
or self
.display
["Dates"] == False:
242 if "GraphOps" not in self
.display
or self
.display
["GraphOps"] == False:
244 if "Button1" not in self
.display
or self
.display
["Button1"] == False:
246 if "Button2" not in self
.display
or self
.display
["Button2"] == False:
249 if 'button1' in self
.label
and self
.label
['button1']:
250 self
.Button1
.set_label( self
.label
['button1'] )
251 if 'button2' in self
.label
and self
.label
['button2']:
252 self
.Button2
.set_label( self
.label
['button2'] )
253 if 'button1' in self
.callback
and self
.callback
['button1']:
254 self
.Button1
.connect("clicked", self
.callback
['button1'], "clicked")
255 self
.Button1
.set_sensitive(True)
256 if 'button2' in self
.callback
and self
.callback
['button2']:
257 self
.Button2
.connect("clicked", self
.callback
['button2'], "clicked")
258 self
.Button2
.set_sensitive(True)
260 # make sure any locks on db are released:
264 """returns the vbox of this thread"""
268 def getNumHands(self
):
272 def getNumTourneys(self
):
273 return self
.numTourneys
274 #end def getNumTourneys
280 def getTourneyTypes(self
):
281 return self
.tourneyTypes
282 #end def getTourneyTypes
288 def getSiteIds(self
):
296 def getGraphOps(self
):
301 for l
in self
.limits
:
302 if self
.limits
[l
] == True:
310 if 'from' in self
.sbSeats
:
311 self
.seats
['from'] = self
.sbSeats
['from'].get_value_as_int()
312 if 'to' in self
.sbSeats
:
313 self
.seats
['to'] = self
.sbSeats
['to'].get_value_as_int()
321 return self
.__get
_dates
()
324 def registerButton1Name(self
, title
):
325 self
.Button1
.set_label(title
)
326 self
.label
['button1'] = title
328 def registerButton1Callback(self
, callback
):
329 self
.Button1
.connect("clicked", callback
, "clicked")
330 self
.Button1
.set_sensitive(True)
331 self
.callback
['button1'] = callback
333 def registerButton2Name(self
, title
):
334 self
.Button2
.set_label(title
)
335 self
.label
['button2'] = title
336 #end def registerButton2Name
338 def registerButton2Callback(self
, callback
):
339 self
.Button2
.connect("clicked", callback
, "clicked")
340 self
.Button2
.set_sensitive(True)
341 self
.callback
['button2'] = callback
342 #end def registerButton2Callback
344 def cardCallback(self
, widget
, data
=None):
345 log
.debug( _("%s was toggled %s") % (data
, (_("OFF"), _("ON"))[widget
.get_active()]) )
347 def createPlayerLine(self
, vbox
, site
, player
):
348 log
.debug('add:"%s"' % player
)
349 label
= gtk
.Label(site
+" id:")
350 label
.set_alignment(xalign
=0.0, yalign
=1.0)
351 vbox
.pack_start(label
, False, False, 3)
353 hbox
= gtk
.HBox(False, 0)
354 vbox
.pack_start(hbox
, False, True, 0)
357 pname
.set_text(player
)
358 pname
.set_width_chars(20)
359 hbox
.pack_start(pname
, True, True, 20)
360 pname
.connect("changed", self
.__set
_hero
_name
, site
)
362 # Added EntryCompletion but maybe comboBoxEntry is more flexible? (e.g. multiple choices)
363 completion
= gtk
.EntryCompletion()
364 pname
.set_completion(completion
)
365 liststore
= gtk
.ListStore(gobject
.TYPE_STRING
)
366 completion
.set_model(liststore
)
367 completion
.set_text_column(0)
368 names
= self
.db
.get_player_names(self
.conf
, self
.siteid
[site
]) # (config=self.conf, site_id=None, like_player_name="%")
369 for n
in names
: # list of single-element "tuples"
370 _n
= Charset
.to_gui(n
[0])
372 liststore
.append(_nt
)
374 self
.__set
_hero
_name
(pname
, site
)
375 #end def createPlayerLine
377 def __set_hero_name(self
, w
, site
):
379 # get_text() returns a str but we want internal variables to be unicode:
380 _guiname
= unicode(_name
)
381 self
.heroes
[site
] = _guiname
382 #log.debug("setting heroes[%s]: %s"%(site, self.heroes[site]))
383 #end def __set_hero_name
385 def __set_num_hands(self
, w
, val
):
387 self
.numHands
= int(w
.get_text())
390 #log.debug("setting numHands:", self.numHands)
391 #end def __set_num_hands
393 def createSiteLine(self
, hbox
, site
):
394 cb
= gtk
.CheckButton(site
)
395 cb
.connect('clicked', self
.__set
_site
_select
, site
)
397 hbox
.pack_start(cb
, False, False, 0)
398 #end def createSiteLine
400 def __set_tourney_type_select(self
, w
, tourneyType
):
401 #print w.get_active()
402 self
.tourneyTypes
[tourneyType
] = w
.get_active()
403 log
.debug("self.tourney_types[%s] set to %s" %(tourneyType
, self
.tourneyTypes
[tourneyType
]))
404 #end def __set_tourney_type_select
406 def createTourneyTypeLine(self
, hbox
, tourneyType
):
407 cb
= gtk
.CheckButton(str(tourneyType
))
408 cb
.connect('clicked', self
.__set
_tourney
_type
_select
, tourneyType
)
409 hbox
.pack_start(cb
, False, False, 0)
411 #end def createTourneyTypeLine
413 def createGameLine(self
, hbox
, game
):
414 cb
= gtk
.CheckButton(game
.replace("_", "__"))
415 cb
.connect('clicked', self
.__set
_game
_select
, game
)
416 hbox
.pack_start(cb
, False, False, 0)
419 def createLimitLine(self
, hbox
, limit
, ltext
):
420 cb
= gtk
.CheckButton(str(ltext
))
421 cb
.connect('clicked', self
.__set
_limit
_select
, limit
)
422 hbox
.pack_start(cb
, False, False, 0)
427 def __set_site_select(self
, w
, site
):
428 #print w.get_active()
429 self
.sites
[site
] = w
.get_active()
430 log
.debug(_("self.sites[%s] set to %s") %(site
, self
.sites
[site
]))
431 #end def __set_site_select
433 def __set_game_select(self
, w
, game
):
434 #print w.get_active()
435 self
.games
[game
] = w
.get_active()
436 log
.debug(_("self.games[%s] set to %s") %(game
, self
.games
[game
]))
437 #end def __set_game_select
439 def __set_limit_select(self
, w
, limit
):
440 #print "__set_limit_select: limit =", limit, w.get_active()
441 self
.limits
[limit
] = w
.get_active()
442 log
.debug(_("self.limit[%s] set to %s") %(limit
, self
.limits
[limit
]))
443 if limit
.isdigit() or (len(limit
) > 2 and (limit
[-2:] == 'nl' or limit
[-2:] == 'fl' or limit
[-2:] == 'pl' or limit
[-2:] == 'cn')):
444 # turning a leaf limit on with 'None' checked turns 'None' off
445 if self
.limits
[limit
]:
446 if self
.cbNoLimits
is not None:
447 self
.cbNoLimits
.set_active(False)
448 # turning a leaf limit off with 'All' checked turns 'All' off
450 if self
.cbAllLimits
is not None:
451 self
.cbAllLimits
.set_active(False)
452 # turning off a leaf limit turns off the corresponding fl. nl, cn or pl
453 if not self
.limits
[limit
]:
455 if self
.cbFL
is not None:
456 self
.cbFL
.set_active(False)
457 elif (len(limit
) > 2 and (limit
[-2:] == 'nl')):
458 if self
.cbNL
is not None:
459 self
.cbNL
.set_active(False)
460 elif (len(limit
) > 2 and (limit
[-2:] == 'cn')):
461 if self
.cbCN
is not None:
462 self
.cbCN
.set_active(False)
464 if self
.cbPL
is not None:
465 self
.cbPL
.set_active(False)
467 if self
.limits
[limit
]:
468 if self
.num_limit_types
== 1:
469 for cb
in self
.cbLimits
.values():
472 if self
.cbFL
is not None:
473 self
.cbFL
.set_active(True)
474 if self
.cbNL
is not None:
475 self
.cbNL
.set_active(True)
476 if self
.cbPL
is not None:
477 self
.cbPL
.set_active(True)
478 if self
.cbCN
is not None:
479 self
.cbCN
.set_active(True)
480 elif limit
== "none":
481 if self
.limits
[limit
]:
482 if self
.num_limit_types
> 1:
483 if self
.cbNL
is not None:
484 self
.cbNL
.set_active(False)
485 if self
.cbFL
is not None:
486 self
.cbFL
.set_active(False)
487 if self
.cbPL
is not None:
488 self
.cbPL
.set_active(False)
489 if self
.cbCN
is not None:
490 self
.cbCN
.set_active(False)
492 # Finally, clean-up all individual limit checkboxes
493 # needed because the overall limit checkbox may
494 # not be set, or num_limit_types == 1
496 for cb
in self
.cbLimits
.values():
499 if not self
.limits
[limit
]:
500 # only toggle all fl limits off if they are all currently on
501 # this stops turning one off from cascading into 'fl' box off
502 # and then all fl limits being turned off
504 for cb
in self
.cbLimits
.values():
505 t
= cb
.get_children()[0].get_text()
507 if not cb
.get_active():
509 found
= {'ring':False, 'tour':False}
510 for cb
in self
.cbLimits
.values():
511 #print "cb label: ", cb.children()[0].get_text()
512 t
= cb
.get_children()[0].get_text()
514 if self
.limits
[limit
] or all_fl_on
:
515 cb
.set_active(self
.limits
[limit
])
516 found
[self
.types
[t
]] = True
517 if self
.limits
[limit
]:
518 if not found
[self
.type]:
519 if self
.type == 'ring':
520 if 'tour' in self
.rb
:
521 self
.rb
['tour'].set_active(True)
522 elif self
.type == 'tour':
523 if 'ring' in self
.rb
:
524 self
.rb
['ring'].set_active(True)
526 if not self
.limits
[limit
]:
527 # only toggle all nl limits off if they are all currently on
528 # this stops turning one off from cascading into 'nl' box off
529 # and then all nl limits being turned off
531 for cb
in self
.cbLimits
.values():
532 t
= cb
.get_children()[0].get_text()
533 if "nl" in t
and len(t
) > 2:
534 if not cb
.get_active():
536 found
= {'ring':False, 'tour':False}
537 for cb
in self
.cbLimits
.values():
538 t
= cb
.get_children()[0].get_text()
539 if "nl" in t
and len(t
) > 2:
540 if self
.limits
[limit
] or all_nl_on
:
541 cb
.set_active(self
.limits
[limit
])
542 found
[self
.types
[t
]] = True
543 if self
.limits
[limit
]:
544 if not found
[self
.type]:
545 if self
.type == 'ring':
546 if 'tour' in self
.rb
:
547 self
.rb
['tour'].set_active(True)
548 elif self
.type == 'tour':
549 if 'ring' in self
.rb
:
550 self
.rb
['ring'].set_active(True)
552 if not self
.limits
[limit
]:
553 # only toggle all nl limits off if they are all currently on
554 # this stops turning one off from cascading into 'nl' box off
555 # and then all nl limits being turned off
557 for cb
in self
.cbLimits
.values():
558 t
= cb
.get_children()[0].get_text()
559 if "pl" in t
and len(t
) > 2:
560 if not cb
.get_active():
562 found
= {'ring':False, 'tour':False}
563 for cb
in self
.cbLimits
.values():
564 t
= cb
.get_children()[0].get_text()
565 if "pl" in t
and len(t
) > 2:
566 if self
.limits
[limit
] or all_nl_on
:
567 cb
.set_active(self
.limits
[limit
])
568 found
[self
.types
[t
]] = True
569 if self
.limits
[limit
]:
570 if not found
[self
.type]:
571 if self
.type == 'ring':
572 if 'tour' in self
.rb
:
573 self
.rb
['tour'].set_active(True)
574 elif self
.type == 'tour':
575 if 'ring' in self
.rb
:
576 self
.rb
['ring'].set_active(True)
578 if not self
.limits
[limit
]:
580 for cb
in self
.cbLimits
.values():
581 t
= cb
.get_children()[0].get_text()
582 if "cn" in t
and len(t
) > 2:
583 if not cb
.get_active():
585 found
= {'ring':False, 'tour':False}
586 for cb
in self
.cbLimits
.values():
587 t
= cb
.get_children()[0].get_text()
588 if "cn" in t
and len(t
) > 2:
589 if self
.limits
[limit
] or all_cn_on
:
590 cb
.set_active(self
.limits
[limit
])
591 found
[self
.types
[t
]] = True
592 if self
.limits
[limit
]:
593 if not found
[self
.type]:
594 if self
.type == 'ring':
595 if 'tour' in self
.rb
:
596 self
.rb
['tour'].set_active(True)
597 elif self
.type == 'tour':
598 if 'ring' in self
.rb
:
599 self
.rb
['ring'].set_active(True)
600 elif limit
== "ring":
601 log
.debug("set", limit
, "to", self
.limits
[limit
])
602 if self
.limits
[limit
]:
604 for cb
in self
.cbLimits
.values():
605 #print "cb label: ", cb.children()[0].get_text()
606 if self
.types
[cb
.get_children()[0].get_text()] == 'tour':
608 elif limit
== "tour":
609 log
.debug( "set", limit
, "to", self
.limits
[limit
] )
610 if self
.limits
[limit
]:
612 for cb
in self
.cbLimits
.values():
613 #print "cb label: ", cb.children()[0].get_text()
614 if self
.types
[cb
.get_children()[0].get_text()] == 'ring':
617 def __set_seat_select(self
, w
, seat
):
618 #print "__set_seat_select: seat =", seat, "active =", w.get_active()
619 self
.seats
[seat
] = w
.get_active()
620 log
.debug( _("self.seats[%s] set to %s") %(seat
, self
.seats
[seat
]) )
621 #end def __set_seat_select
623 def __set_group_select(self
, w
, group
):
624 #print "__set_seat_select: seat =", seat, "active =", w.get_active()
625 self
.groups
[group
] = w
.get_active()
626 log
.debug( _("self.groups[%s] set to %s") %(group
, self
.groups
[group
]) )
629 def __set_displayin_select(self
, w
, ops
):
630 self
.graphops
['dspin'] = ops
632 def __set_graphopscheck_select(self
, w
, data
):
633 #print "%s was toggled %s" % (data, ("OFF", "ON")[w.get_active()])
634 self
.graphops
[data
] = ("OFF", "ON")[w
.get_active()]
636 def fillPlayerFrame(self
, vbox
, display
):
637 top_hbox
= gtk
.HBox(False, 0)
638 vbox
.pack_start(top_hbox
, False, False, 0)
639 lbl_title
= gtk
.Label(self
.filterText
['playerstitle'])
640 lbl_title
.set_alignment(xalign
=0.0, yalign
=0.5)
641 top_hbox
.pack_start(lbl_title
, expand
=True, padding
=3)
643 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
644 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
645 showb
.connect('clicked', self
.__toggle
_box
, 'Heroes')
646 self
.toggles
['Heroes'] = showb
648 top_hbox
.pack_end(showb
, expand
=False, padding
=1)
650 showb
= gtk
.Button(label
=_("hide all"), stock
=None, use_underline
=True)
651 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
652 showb
.connect('clicked', self
.__toggle
_box
, 'all')
653 self
.toggles
['all'] = showb
655 top_hbox
.pack_end(showb
, expand
=False, padding
=1)
657 showb
= gtk
.Button(label
=_("Refresh"), stock
=None, use_underline
=True)
658 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
659 showb
.connect('clicked', self
.__refresh
, 'Heroes')
661 vbox1
= gtk
.VBox(False, 0)
662 vbox
.pack_start(vbox1
, False, False, 0)
663 self
.boxes
['Heroes'] = vbox1
665 for site
in self
.conf
.get_supported_sites():
666 player
= self
.conf
.supported_sites
[site
].screen_name
667 _pname
= Charset
.to_gui(player
)
668 self
.createPlayerLine(vbox1
, site
, _pname
)
670 if "GroupsAll" in display
and display
["GroupsAll"] == True:
671 hbox
= gtk
.HBox(False, 0)
672 vbox1
.pack_start(hbox
, False, False, 0)
673 cb
= gtk
.CheckButton(self
.filterText
['groupsall'])
674 cb
.connect('clicked', self
.__set
_group
_select
, 'allplayers')
675 hbox
.pack_start(cb
, False, False, 0)
676 self
.sbGroups
['allplayers'] = cb
677 self
.groups
['allplayers'] = False
679 lbl
= gtk
.Label(_('Min # Hands:'))
680 lbl
.set_alignment(xalign
=1.0, yalign
=0.5)
681 hbox
.pack_start(lbl
, expand
=True, padding
=3)
685 phands
.set_width_chars(8)
686 hbox
.pack_start(phands
, False, False, 0)
687 phands
.connect("changed", self
.__set
_num
_hands
, site
)
688 top_hbox
.pack_start(showb
, expand
=False, padding
=1)
689 #end def fillPlayerFrame
691 def fillSitesFrame(self
, vbox
):
692 top_hbox
= gtk
.HBox(False, 0)
694 vbox
.pack_start(top_hbox
, False, False, 0)
696 lbl_title
= gtk
.Label(self
.filterText
['sitestitle'])
697 lbl_title
.set_alignment(xalign
=0.0, yalign
=0.5)
698 top_hbox
.pack_start(lbl_title
, expand
=True, padding
=3)
700 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
701 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
702 showb
.connect('clicked', self
.__toggle
_box
, 'Sites')
703 self
.toggles
['Sites'] = showb
705 top_hbox
.pack_start(showb
, expand
=False, padding
=1)
707 vbox1
= gtk
.VBox(False, 0)
708 self
.boxes
['Sites'] = vbox1
709 vbox
.pack_start(vbox1
, False, False, 0)
711 for site
in self
.conf
.get_supported_sites():
712 hbox
= gtk
.HBox(False, 0)
713 vbox1
.pack_start(hbox
, False, True, 0)
714 self
.createSiteLine(hbox
, site
)
715 #Get db site id for filtering later
716 #self.cursor.execute(self.sql.query['getSiteId'], (site,))
717 #result = self.db.cursor.fetchall()
718 #if len(result) == 1:
719 # self.siteid[site] = result[0][0]
721 # print "Either 0 or more than one site matched - EEK"
722 #end def fillSitesFrame
724 def fillTourneyTypesFrame(self
, vbox
):
725 top_hbox
= gtk
.HBox(False, 0)
726 vbox
.pack_start(top_hbox
, False, False, 0)
727 lbl_title
= gtk
.Label(self
.filterText
['tourneyTypesTitle'])
728 lbl_title
.set_alignment(xalign
=0.0, yalign
=0.5)
729 top_hbox
.pack_start(lbl_title
, expand
=True, padding
=3)
730 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
731 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
732 showb
.connect('clicked', self
.__toggle
_box
, 'tourneyTypes')
733 self
.toggles
['tourneyTypes'] = showb
734 top_hbox
.pack_start(showb
, expand
=False, padding
=1)
736 vbox1
= gtk
.VBox(False, 0)
737 vbox
.pack_start(vbox1
, False, False, 0)
738 self
.boxes
['tourneyTypes'] = vbox1
740 result
= self
.db
.getTourneyTypesIds()
743 hbox
= gtk
.HBox(False, 0)
744 vbox1
.pack_start(hbox
, False, True, 0)
745 self
.createTourneyTypeLine(hbox
, line
[0])
747 print _("INFO: No tourney types returned from database")
748 log
.info(_("No tourney types returned from database"))
749 #end def fillTourneyTypesFrame
751 def fillGamesFrame(self
, vbox
):
752 top_hbox
= gtk
.HBox(False, 0)
753 vbox
.pack_start(top_hbox
, False, False, 0)
754 lbl_title
= gtk
.Label(self
.filterText
['gamestitle'])
755 lbl_title
.set_alignment(xalign
=0.0, yalign
=0.5)
756 top_hbox
.pack_start(lbl_title
, expand
=True, padding
=3)
757 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
758 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
759 showb
.connect('clicked', self
.__toggle
_box
, 'Games')
760 self
.toggles
['Games'] = showb
761 top_hbox
.pack_start(showb
, expand
=False, padding
=1)
763 vbox1
= gtk
.VBox(False, 0)
764 vbox
.pack_start(vbox1
, False, False, 0)
765 self
.boxes
['Games'] = vbox1
767 self
.cursor
.execute(self
.sql
.query
['getGames'])
768 result
= self
.db
.cursor
.fetchall()
771 hbox
= gtk
.HBox(False, 0)
772 vbox1
.pack_start(hbox
, False, True, 0)
773 self
.createGameLine(hbox
, line
[0])
775 print _("INFO: No games returned from database")
776 log
.info(_("No games returned from database"))
777 #end def fillGamesFrame
779 def fillLimitsFrame(self
, vbox
, display
):
780 top_hbox
= gtk
.HBox(False, 0)
781 vbox
.pack_start(top_hbox
, False, False, 0)
782 lbl_title
= gtk
.Label(self
.filterText
['limitstitle'])
783 lbl_title
.set_alignment(xalign
=0.0, yalign
=0.5)
784 top_hbox
.pack_start(lbl_title
, expand
=True, padding
=3)
785 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
786 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
787 showb
.connect('clicked', self
.__toggle
_box
, 'Limits')
788 self
.toggles
['Limits'] = showb
789 top_hbox
.pack_start(showb
, expand
=False, padding
=1)
791 vbox1
= gtk
.VBox(False, 15)
792 vbox
.pack_start(vbox1
, False, False, 0)
793 self
.boxes
['Limits'] = vbox1
795 self
.cursor
.execute(self
.sql
.query
['getCashLimits'])
796 # selects limitType, bigBlind
797 result
= self
.db
.cursor
.fetchall()
798 self
.found
= {'nl':False, 'fl':False, 'pl':False, 'cn':False, 'ring':False, 'tour':False}
801 hbox
= gtk
.HBox(True, 0)
802 vbox1
.pack_start(hbox
, False, False, 0)
803 vbox2
= gtk
.VBox(False, 0)
804 hbox
.pack_start(vbox2
, False, False, 0)
805 vbox3
= gtk
.VBox(False, 0)
806 hbox
.pack_start(vbox3
, False, False, 0)
807 for i
, line
in enumerate(result
):
808 if "UseType" in self
.display
:
809 if line
[0] != self
.display
["UseType"]:
811 hbox
= gtk
.HBox(False, 0)
812 if i
< len(result
)/2:
813 vbox2
.pack_start(hbox
, False, False, 0)
815 vbox3
.pack_start(hbox
, False, False, 0)
816 if True: #line[0] == 'ring':
819 self
.found
['fl'] = True
820 elif line
[1] == 'pl':
821 name
= str(line
[2])+line
[1]
822 self
.found
['pl'] = True
823 elif line
[1] == 'cn':
824 name
= str(line
[2])+line
[1]
825 self
.found
['cn'] = True
827 name
= str(line
[2])+line
[1]
828 self
.found
['nl'] = True
829 self
.cbLimits
[name
] = self
.createLimitLine(hbox
, name
, name
)
830 self
.types
[name
] = line
[0]
831 self
.found
[line
[0]] = True # type is ring/tour
832 self
.type = line
[0] # if only one type, set it now
833 if "LimitSep" in display
and display
["LimitSep"] == True and len(result
) >= 2:
834 hbox
= gtk
.HBox(True, 0)
835 vbox1
.pack_start(hbox
, False, False, 0)
836 vbox2
= gtk
.VBox(False, 0)
837 hbox
.pack_start(vbox2
, False, False, 0)
838 vbox3
= gtk
.VBox(False, 0)
839 hbox
.pack_start(vbox3
, False, False, 0)
841 hbox
= gtk
.HBox(False, 0)
842 vbox2
.pack_start(hbox
, False, False, 0)
843 self
.cbAllLimits
= self
.createLimitLine(hbox
, 'all', self
.filterText
['limitsall'])
844 hbox
= gtk
.HBox(False, 0)
845 vbox2
.pack_start(hbox
, False, False, 0)
846 self
.cbNoLimits
= self
.createLimitLine(hbox
, 'none', self
.filterText
['limitsnone'])
848 dest
= vbox3
# for ring/tour buttons
849 if "LimitType" in display
and display
["LimitType"] == True:
850 self
.num_limit_types
= 0
851 if self
.found
['fl']: self
.num_limit_types
= self
.num_limit_types
+ 1
852 if self
.found
['pl']: self
.num_limit_types
= self
.num_limit_types
+ 1
853 if self
.found
['nl']: self
.num_limit_types
= self
.num_limit_types
+ 1
854 if self
.found
['cn']: self
.num_limit_types
= self
.num_limit_types
+ 1
855 if self
.num_limit_types
> 1:
857 hbox
= gtk
.HBox(False, 0)
858 vbox3
.pack_start(hbox
, False, False, 0)
859 self
.cbFL
= self
.createLimitLine(hbox
, 'fl', self
.filterText
['limitsFL'])
861 hbox
= gtk
.HBox(False, 0)
862 vbox3
.pack_start(hbox
, False, False, 0)
863 self
.cbNL
= self
.createLimitLine(hbox
, 'nl', self
.filterText
['limitsNL'])
865 hbox
= gtk
.HBox(False, 0)
866 vbox3
.pack_start(hbox
, False, False, 0)
867 self
.cbPL
= self
.createLimitLine(hbox
, 'pl', self
.filterText
['limitsPL'])
869 hbox
= gtk
.HBox(False, 0)
870 vbox3
.pack_start(hbox
, False, False, 0)
871 self
.cbCN
= self
.createLimitLine(hbox
, 'cn', self
.filterText
['limitsCN'])
872 dest
= vbox2
# for ring/tour buttons
874 print _("INFO: No games returned from database")
875 log
.info(_("No games returned from database"))
877 if "Type" in display
and display
["Type"] == True and self
.found
['ring'] and self
.found
['tour']:
878 rb1
= gtk
.RadioButton(None, self
.filterText
['ring'])
879 rb1
.connect('clicked', self
.__set
_limit
_select
, 'ring')
880 rb2
= gtk
.RadioButton(rb1
, self
.filterText
['tour'])
881 rb2
.connect('clicked', self
.__set
_limit
_select
, 'tour')
882 top_hbox
.pack_start(rb1
, False, False, 0) # (child, expand, fill, padding)
883 top_hbox
.pack_start(rb2
, True, True, 0) # child uses expand space if fill is true
885 self
.rb
['ring'] = rb1
886 self
.rb
['tour'] = rb2
887 #print "about to set ring to true"
889 # set_active doesn't seem to call this for some reason so call manually:
890 self
.__set
_limit
_select
(rb1
, 'ring')
892 top_hbox
.pack_start(showb
, expand
=False, padding
=1)
894 def fillGraphOpsFrame(self
, vbox
):
895 top_hbox
= gtk
.HBox(False, 0)
896 vbox
.pack_start(top_hbox
, False, False, 0)
897 title
= gtk
.Label(_("Graphing Options:"))
898 title
.set_alignment(xalign
=0.0, yalign
=0.5)
899 top_hbox
.pack_start(title
, expand
=True, padding
=3)
900 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
901 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
902 showb
.connect('clicked', self
.__toggle
_box
, 'GraphOps')
903 self
.toggles
['GraphOps'] = showb
904 top_hbox
.pack_start(showb
, expand
=False, padding
=1)
906 vbox1
= gtk
.VBox(False, 0)
907 vbox
.pack_start(vbox1
, False, False, 0)
909 self
.boxes
['GraphOps'] = vbox1
911 hbox1
= gtk
.HBox(False, 0)
912 vbox1
.pack_start(hbox1
, False, False, 0)
915 label
= gtk
.Label(_("Show Graph In:"))
916 label
.set_alignment(xalign
=0.0, yalign
=0.5)
917 hbox1
.pack_start(label
, True, True, 0)
920 button
= gtk
.RadioButton(None, "$$")
921 hbox1
.pack_start(button
, True, True, 0)
922 button
.connect("toggled", self
.__set
_displayin
_select
, "$")
923 button
.set_active(True)
926 button
= gtk
.RadioButton(button
, "BB")
927 hbox1
.pack_start(button
, True, True, 0)
928 button
.connect("toggled", self
.__set
_displayin
_select
, "BB")
931 button
= gtk
.CheckButton(_("Showdown Winnings"), False)
932 vbox1
.pack_start(button
, True, True, 0)
933 # wouldn't it be awesome if there was a way to remember the state of things like
934 # this and be able to set it to what it was last time?
935 #button.set_active(True)
936 button
.connect("toggled", self
.__set
_graphopscheck
_select
, "showdown")
939 button
= gtk
.CheckButton(_("Non-Showdown Winnings"), False)
940 vbox1
.pack_start(button
, True, True, 0)
941 # ditto as 8 lines up :)
942 #button.set_active(True)
943 button
.connect("toggled", self
.__set
_graphopscheck
_select
, "nonshowdown");
946 def fillSeatsFrame(self
, vbox
, display
):
947 hbox
= gtk
.HBox(False, 0)
948 vbox
.pack_start(hbox
, False, False, 0)
949 lbl_title
= gtk
.Label(self
.filterText
['seatstitle'])
950 lbl_title
.set_alignment(xalign
=0.0, yalign
=0.5)
951 hbox
.pack_start(lbl_title
, expand
=True, padding
=3)
952 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
953 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
954 showb
.connect('clicked', self
.__toggle
_box
, 'Seats')
955 self
.toggles
['Seats'] = showb
956 hbox
.pack_start(showb
, expand
=False, padding
=1)
958 vbox1
= gtk
.VBox(False, 0)
959 vbox
.pack_start(vbox1
, False, False, 0)
960 self
.boxes
['Seats'] = vbox1
962 hbox
= gtk
.HBox(False, 0)
963 vbox1
.pack_start(hbox
, False, True, 0)
965 lbl_from
= gtk
.Label(self
.filterText
['seatsbetween'])
966 lbl_to
= gtk
.Label(self
.filterText
['seatsand'])
968 adj1
= gtk
.Adjustment(value
=2, lower
=2, upper
=10, step_incr
=1, page_incr
=1, page_size
=0)
969 sb1
= gtk
.SpinButton(adjustment
=adj1
, climb_rate
=0.0, digits
=0)
970 adj1
.connect('value-changed', self
.__seats
_changed
, 'from')
972 adj2
= gtk
.Adjustment(value
=10, lower
=2, upper
=10, step_incr
=1, page_incr
=1, page_size
=0)
973 sb2
= gtk
.SpinButton(adjustment
=adj2
, climb_rate
=0.0, digits
=0)
974 adj2
.connect('value-changed', self
.__seats
_changed
, 'to')
976 hbox
.pack_start(lbl_from
, expand
=False, padding
=3)
977 hbox
.pack_start(sb1
, False, False, 0)
978 hbox
.pack_start(lbl_to
, expand
=False, padding
=3)
979 hbox
.pack_start(sb2
, False, False, 0)
981 self
.sbSeats
['from'] = sb1
982 self
.sbSeats
['to'] = sb2
983 #end def fillSeatsFrame
985 def fillGroupsFrame(self
, vbox
, display
):
986 hbox
= gtk
.HBox(False, 0)
987 vbox
.pack_start(hbox
, False, False, 0)
988 lbl_title
= gtk
.Label(self
.filterText
['groupstitle'])
989 lbl_title
.set_alignment(xalign
=0.0, yalign
=0.5)
990 hbox
.pack_start(lbl_title
, expand
=True, padding
=3)
991 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
992 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
993 showb
.connect('clicked', self
.__toggle
_box
, 'Groups')
994 self
.toggles
['Groups'] = showb
995 hbox
.pack_start(showb
, expand
=False, padding
=1)
997 vbox1
= gtk
.VBox(False, 0)
998 vbox
.pack_start(vbox1
, False, False, 0)
999 self
.boxes
['Groups'] = vbox1
1001 hbox
= gtk
.HBox(False, 0)
1002 vbox1
.pack_start(hbox
, False, False, 0)
1003 cb
= self
.createLimitLine(hbox
, 'show', self
.filterText
['limitsshow'])
1005 hbox
= gtk
.HBox(False, 0)
1006 vbox1
.pack_start(hbox
, False, True, 0)
1007 cb
= gtk
.CheckButton(self
.filterText
['posnshow'])
1008 cb
.connect('clicked', self
.__set
_group
_select
, 'posn')
1009 hbox
.pack_start(cb
, False, False, 0)
1010 self
.sbGroups
['posn'] = cb
1011 self
.groups
['posn'] = False
1013 if "SeatSep" in display
and display
["SeatSep"] == True:
1014 hbox
= gtk
.HBox(False, 0)
1015 vbox1
.pack_start(hbox
, False, True, 0)
1016 cb
= gtk
.CheckButton(self
.filterText
['seatsshow'])
1017 cb
.connect('clicked', self
.__set
_seat
_select
, 'show')
1018 hbox
.pack_start(cb
, False, False, 0)
1019 self
.sbSeats
['show'] = cb
1020 self
.seats
['show'] = False
1022 def fillCardsFrame(self
, vbox
):
1023 hbox1
= gtk
.HBox(True,0)
1025 vbox
.pack_start(hbox1
, True, True, 0)
1027 cards
= [ "A", "K","Q","J","T","9","8","7","6","5","4","3","2" ]
1029 for j
in range(0, len(cards
)):
1030 hbox1
= gtk
.HBox(True,0)
1032 vbox
.pack_start(hbox1
, True, True, 0)
1033 for i
in range(0, len(cards
)):
1038 button
= gtk
.ToggleButton("%s%s%s" %(cards
[i
], cards
[j
], suit
))
1039 button
.connect("toggled", self
.cardCallback
, "%s%s%s" %(cards
[i
], cards
[j
], suit
))
1040 hbox1
.pack_start(button
, True, True, 0)
1043 def fillDateFrame(self
, vbox
):
1044 # Hat tip to Mika Bostrom - calendar code comes from PokerStats
1045 top_hbox
= gtk
.HBox(False, 0)
1046 vbox
.pack_start(top_hbox
, False, False, 0)
1047 lbl_title
= gtk
.Label(self
.filterText
['datestitle'])
1048 lbl_title
.set_alignment(xalign
=0.0, yalign
=0.5)
1049 top_hbox
.pack_start(lbl_title
, expand
=True, padding
=3)
1050 showb
= gtk
.Button(label
=_("hide"), stock
=None, use_underline
=True)
1051 showb
.set_alignment(xalign
=1.0, yalign
=0.5)
1052 showb
.connect('clicked', self
.__toggle
_box
, 'Dates')
1053 self
.toggles
['Dates'] = showb
1054 top_hbox
.pack_start(showb
, expand
=False, padding
=1)
1056 hbox1
= gtk
.HBox(False, 0)
1057 vbox
.pack_start(hbox1
, False, False, 0)
1058 self
.boxes
['Dates'] = hbox1
1060 table
= gtk
.Table(2,4,False)
1061 hbox1
.pack_start(table
, False, True, 0)
1063 lbl_start
= gtk
.Label(_('From:'))
1064 lbl_start
.set_alignment(xalign
=1.0, yalign
=0.5)
1065 btn_start
= gtk
.Button()
1066 btn_start
.set_image(gtk
.image_new_from_stock(gtk
.STOCK_INDEX
, gtk
.ICON_SIZE_BUTTON
))
1067 btn_start
.connect('clicked', self
.__calendar
_dialog
, self
.start_date
)
1068 clr_start
= gtk
.Button()
1069 clr_start
.set_image(gtk
.image_new_from_stock(gtk
.STOCK_CLEAR
, gtk
.ICON_SIZE_BUTTON
))
1070 clr_start
.connect('clicked', self
.__clear
_start
_date
)
1072 lbl_end
= gtk
.Label(_('To:'))
1073 lbl_end
.set_alignment(xalign
=1.0, yalign
=0.5)
1074 btn_end
= gtk
.Button()
1075 btn_end
.set_image(gtk
.image_new_from_stock(gtk
.STOCK_INDEX
, gtk
.ICON_SIZE_BUTTON
))
1076 btn_end
.connect('clicked', self
.__calendar
_dialog
, self
.end_date
)
1077 clr_end
= gtk
.Button()
1078 clr_end
.set_image(gtk
.image_new_from_stock(gtk
.STOCK_CLEAR
, gtk
.ICON_SIZE_BUTTON
))
1079 clr_end
.connect('clicked', self
.__clear
_end
_date
)
1081 table
.attach(lbl_start
, 0,1, 0,1)
1082 table
.attach(btn_start
, 1,2, 0,1)
1083 table
.attach(self
.start_date
, 2,3, 0,1)
1084 table
.attach(clr_start
, 3,4, 0,1)
1086 table
.attach(lbl_end
, 0,1, 1,2)
1087 table
.attach(btn_end
, 1,2, 1,2)
1088 table
.attach(self
.end_date
, 2,3, 1,2)
1089 table
.attach(clr_end
, 3,4, 1,2)
1091 #end def fillDateFrame
1093 def __refresh(self
, widget
, entry
):
1094 for w
in self
.mainVBox
.get_children():
1099 def __toggle_box(self
, widget
, entry
):
1100 if (entry
== "all"):
1101 if (widget
.get_label() == _("hide all")):
1102 for entry
in self
.boxes
.keys():
1103 if (self
.boxes
[entry
].props
.visible
):
1104 self
.__toggle
_box
(widget
, entry
)
1105 widget
.set_label(_("show all"))
1107 for entry
in self
.boxes
.keys():
1108 if (not self
.boxes
[entry
].props
.visible
):
1109 self
.__toggle
_box
(widget
, entry
)
1110 widget
.set_label(_("hide all"))
1111 elif self
.boxes
[entry
].props
.visible
:
1112 self
.boxes
[entry
].hide()
1113 self
.toggles
[entry
].set_label(_("show"))
1114 for entry
in self
.boxes
.keys():
1115 if (self
.display
.has_key(entry
) and
1116 self
.display
[entry
] and
1117 self
.boxes
[entry
].props
.visible
):
1120 self
.toggles
["all"].set_label(_("show all"))
1122 self
.boxes
[entry
].show()
1123 self
.toggles
[entry
].set_label(_("hide"))
1124 for entry
in self
.boxes
.keys():
1125 if (self
.display
.has_key(entry
) and
1126 self
.display
[entry
] and
1127 not self
.boxes
[entry
].props
.visible
):
1130 self
.toggles
["all"].set_label(_("hide all"))
1131 #end def __toggle_box
1133 def __calendar_dialog(self
, widget
, entry
):
1134 d
= gtk
.Window(gtk
.WINDOW_TOPLEVEL
)
1135 d
.set_title(_('Pick a date'))
1138 cal
= gtk
.Calendar()
1139 vb
.pack_start(cal
, expand
=False, padding
=0)
1141 # if the date field is already set, default to the currently selected date, else default to 'today'
1142 text
= entry
.get_text()
1144 date
= strptime(text
, "%Y-%m-%d")
1146 # if the day is configured to not start at midnight, check whether it's still yesterday,
1147 # and if so, select yesterday in the calendar instead of today
1149 if (date
.tm_hour
< self
.day_start
):
1150 date
= localtime(mktime(date
) - 24*3600)
1151 cal
.select_month(date
.tm_mon
- 1, date
.tm_year
) # months are 0 through 11
1152 cal
.select_day(date
.tm_mday
)
1154 btn
= gtk
.Button(_('Done'))
1155 btn
.connect('clicked', self
.__get
_date
, cal
, entry
, d
)
1157 vb
.pack_start(btn
, expand
=False, padding
=4)
1160 d
.set_position(gtk
.WIN_POS_MOUSE
)
1162 #end def __calendar_dialog
1164 def __clear_start_date(self
, w
):
1165 self
.start_date
.set_text('')
1166 #end def __clear_start_date
1168 def __clear_end_date(self
, w
):
1169 self
.end_date
.set_text('')
1170 #end def __clear_end_date
1172 def __get_dates(self
):
1173 # self.day_start gives user's start of day in hours
1174 offset
= int(self
.day_start
* 3600) # calc day_start in seconds
1176 t1
= self
.start_date
.get_text()
1177 t2
= self
.end_date
.get_text()
1184 s1
= strptime(t1
, "%Y-%m-%d") # make time_struct
1185 s2
= strptime(t2
, "%Y-%m-%d")
1186 e1
= mktime(s1
) + offset
# s1 is localtime, but returned time since epoch is UTC, then add the
1187 e2
= mktime(s2
) + offset
# s2 is localtime, but returned time since epoch is UTC
1188 e2
= e2
+ 24 * 3600 - 1 # date test is inclusive, so add 23h 59m 59s to e2
1190 adj_t1
= strftime("%Y-%m-%d %H:%M:%S", gmtime(e1
)) # make adjusted string including time
1191 adj_t2
= strftime("%Y-%m-%d %H:%M:%S", gmtime(e2
))
1192 log
.info("t1="+t1
+" adj_t1="+adj_t1
+'.')
1194 return (adj_t1
, adj_t2
)
1195 #end def __get_dates
1197 def __get_date(self
, widget
, calendar
, entry
, win
):
1198 # year and day are correct, month is 0..11
1199 (year
, month
, day
) = calendar
.get_date()
1201 ds
= '%04d-%02d-%02d' % (year
, month
, day
)
1205 # if the opposite date is set, and now the start date is later
1206 # than the end date, modify the one we didn't just set to be
1207 # the same as the one we did just set
1208 if (entry
== self
.start_date
):
1209 end
= self
.end_date
.get_text()
1210 if (end
and ds
> end
):
1211 self
.end_date
.set_text(ds
)
1213 start
= self
.start_date
.get_text()
1214 if (start
and ds
< start
):
1215 self
.start_date
.set_text(ds
)
1217 def __seats_changed(self
, widget
, which
):
1218 seats_from
= self
.sbSeats
['from'].get_value_as_int()
1219 seats_to
= self
.sbSeats
['to'].get_value_as_int()
1220 if (seats_from
> seats_to
):
1221 if (which
== 'from'):
1222 self
.sbSeats
['to'].set_value(seats_from
)
1224 self
.sbSeats
['from'].set_value(seats_to
)
1226 def main(argv
=None):
1227 """main can also be called in the python interpreter, by supplying the command line as the argument."""
1231 def destroy(*args
): # call back for terminating the main eventloop
1234 parser
= OptionParser()
1235 (options
, argv
) = parser
.parse_args(args
= argv
)
1237 config
= Configuration
.Config()
1240 db
= Database
.Database()
1241 db
.do_connect(config
)
1243 qdict
= SQL
.SQL(db
.get_backend_name())
1245 i
= Filters(db
, config
, qdict
)
1246 main_window
= gtk
.Window()
1247 main_window
.connect('destroy', destroy
)
1248 main_window
.add(i
.get_vbox())
1252 if __name__
== '__main__':