remove some methods in TourneyFilters that are identical in Filters
This commit is contained in:
parent
e0b194ddf0
commit
20ebd040c1
|
@ -63,54 +63,6 @@ class TourneyFilters(Filters.Filters):
|
|||
self.make_filter()
|
||||
#end def __init__
|
||||
|
||||
def __calendar_dialog(self, widget, entry):
|
||||
d = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
d.set_title('Pick a date')
|
||||
|
||||
vb = gtk.VBox()
|
||||
cal = gtk.Calendar()
|
||||
vb.pack_start(cal, expand=False, padding=0)
|
||||
|
||||
btn = gtk.Button('Done')
|
||||
btn.connect('clicked', self.__get_date, cal, entry, d)
|
||||
|
||||
vb.pack_start(btn, expand=False, padding=4)
|
||||
|
||||
d.add(vb)
|
||||
d.set_position(gtk.WIN_POS_MOUSE)
|
||||
d.show_all()
|
||||
#end def __calendar_dialog
|
||||
|
||||
def __clear_dates(self, w):
|
||||
self.start_date.set_text('')
|
||||
self.end_date.set_text('')
|
||||
#end def __clear_dates
|
||||
|
||||
def __get_dates(self):
|
||||
# self.day_start gives user's start of day in hours
|
||||
offset = int(self.day_start * 3600) # calc day_start in seconds
|
||||
|
||||
t1 = self.start_date.get_text()
|
||||
t2 = self.end_date.get_text()
|
||||
|
||||
if t1 == '':
|
||||
t1 = '1970-01-02'
|
||||
if t2 == '':
|
||||
t2 = '2020-12-12'
|
||||
|
||||
s1 = strptime(t1, "%Y-%m-%d") # make time_struct
|
||||
s2 = strptime(t2, "%Y-%m-%d")
|
||||
e1 = mktime(s1) + offset # s1 is localtime, but returned time since epoch is UTC, then add the
|
||||
e2 = mktime(s2) + offset # s2 is localtime, but returned time since epoch is UTC
|
||||
e2 = e2 + 24 * 3600 - 1 # date test is inclusive, so add 23h 59m 59s to e2
|
||||
|
||||
adj_t1 = strftime("%Y-%m-%d %H:%M:%S", gmtime(e1)) # make adjusted string including time
|
||||
adj_t2 = strftime("%Y-%m-%d %H:%M:%S", gmtime(e2))
|
||||
log.info("t1="+t1+" adj_t1="+adj_t1+'.')
|
||||
|
||||
return (adj_t1, adj_t2)
|
||||
#end def __get_dates
|
||||
|
||||
def __refresh(self, widget, entry):
|
||||
for w in self.mainVBox.get_children():
|
||||
w.destroy()
|
||||
|
@ -200,54 +152,6 @@ class TourneyFilters(Filters.Filters):
|
|||
cb.set_active(True)
|
||||
#end def createTourneyTypeLine
|
||||
|
||||
def fillDateFrame(self, vbox):
|
||||
# Hat tip to Mika Bostrom - calendar code comes from PokerStats
|
||||
top_hbox = gtk.HBox(False, 0)
|
||||
vbox.pack_start(top_hbox, False, False, 0)
|
||||
lbl_title = gtk.Label(self.filterText['datestitle'])
|
||||
lbl_title.set_alignment(xalign=0.0, yalign=0.5)
|
||||
top_hbox.pack_start(lbl_title, expand=True, padding=3)
|
||||
showb = gtk.Button(label="hide", stock=None, use_underline=True)
|
||||
showb.set_alignment(xalign=1.0, yalign=0.5)
|
||||
showb.connect('clicked', self.__toggle_box, 'dates')
|
||||
top_hbox.pack_start(showb, expand=False, padding=1)
|
||||
|
||||
vbox1 = gtk.VBox(False, 0)
|
||||
vbox.pack_start(vbox1, False, False, 0)
|
||||
self.boxes['dates'] = vbox1
|
||||
|
||||
hbox = gtk.HBox()
|
||||
vbox1.pack_start(hbox, False, True, 0)
|
||||
|
||||
lbl_start = gtk.Label('From:')
|
||||
|
||||
btn_start = gtk.Button()
|
||||
btn_start.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
|
||||
btn_start.connect('clicked', self.__calendar_dialog, self.start_date)
|
||||
|
||||
hbox.pack_start(lbl_start, expand=False, padding=3)
|
||||
hbox.pack_start(btn_start, expand=False, padding=3)
|
||||
hbox.pack_start(self.start_date, expand=False, padding=2)
|
||||
|
||||
#New row for end date
|
||||
hbox = gtk.HBox()
|
||||
vbox1.pack_start(hbox, False, True, 0)
|
||||
|
||||
lbl_end = gtk.Label(' To:')
|
||||
btn_end = gtk.Button()
|
||||
btn_end.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
|
||||
btn_end.connect('clicked', self.__calendar_dialog, self.end_date)
|
||||
|
||||
btn_clear = gtk.Button(label=' Clear Dates ')
|
||||
btn_clear.connect('clicked', self.__clear_dates)
|
||||
|
||||
hbox.pack_start(lbl_end, expand=False, padding=3)
|
||||
hbox.pack_start(btn_end, expand=False, padding=3)
|
||||
hbox.pack_start(self.end_date, expand=False, padding=2)
|
||||
|
||||
hbox.pack_start(btn_clear, expand=False, padding=15)
|
||||
#end def fillDateFrame
|
||||
|
||||
def fillPlayerFrame(self, vbox, display):
|
||||
top_hbox = gtk.HBox(False, 0)
|
||||
vbox.pack_start(top_hbox, False, False, 0)
|
||||
|
@ -376,14 +280,6 @@ class TourneyFilters(Filters.Filters):
|
|||
log.info("No tourney types returned from database")
|
||||
#end def fillTourneyTypesFrame
|
||||
|
||||
def getDates(self):
|
||||
return self.__get_dates()
|
||||
#end def getDates
|
||||
|
||||
def getHeroes(self):
|
||||
return self.heroes
|
||||
#end def getHeroes
|
||||
|
||||
def getNumTourneys(self):
|
||||
return self.numTourneys
|
||||
#end def getNumTourneys
|
||||
|
|
Loading…
Reference in New Issue
Block a user