def __init__(self, path=None): """App constructor.""" self.path = u'.' if path is not None: self.path = path self.subapp = None b = gtk.Builder() b.add_from_file(os.path.join(metarace.UI_PATH, u'mr_init.ui')) self.window = b.get_object('window') self.model = gtk.ListStore( gobject.TYPE_STRING, # fullpath gobject.TYPE_STRING, # shortpath gobject.TYPE_STRING, # descr gobject.TYPE_STRING, # type gobject.TYPE_STRING, # date gobject.TYPE_STRING, # extra info gobject.TYPE_STRING, # class road/track gobject.TYPE_STRING) # sorting? t = gtk.TreeView(self.model) #t.set_reorderable(True) t.set_rules_hint(True) #t.set_headers_clickable(True) self.model.set_sort_column_id(1, gtk.SORT_ASCENDING) #t.set_headers_visible(False) t.set_search_column(1) uiutil.mkviewcoltxt(t, 'Path', 1, width=100) uiutil.mkviewcoltxt(t, 'Description', 2, expand=True, maxwidth=300) uiutil.mkviewcoltxt(t, 'Type', 3, width=100) t.connect('row-activated', self.row_activated_cb) t.show() self.view = t b.get_object('scrollbox').add(t) b.connect_signals(self) glib.idle_add(self.loadpath)
def mkview(self, parentwin=None): """Create and return view object for the model.""" if self.__viewmodel is None: self.__viewmodel = gtk.ListStore( gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) self.__notify(None) # trigger reload if self.view is not None: return self.view self.__viewparent = parentwin v = gtk.TreeView(self.__viewmodel) #v.set_reorderable(True) v.set_enable_search(False) v.set_rules_hint(True) v.get_selection().set_mode(gtk.SELECTION_MULTIPLE) v.show() uiutil.mkviewcoltxt(v, 'No.', COL_EVNO) uiutil.mkviewcoltxt(v, 'Info', COL_INFO, expand=True) uiutil.mkviewcoltxt(v, 'Type', COL_TYPE, expand=True) self.view = v self.view.connect('button-press-event', self.__view_button_cb) self.mkpopup() return self.view
def __init__(self, configpath=None): # logger and log handler self.log = logging.getLogger() self.log.setLevel(logging.DEBUG) self.loghandler = None # set in loadconfig to meet dir # meet configuration path and options if configpath is None: configpath = u'.' # None assumes 'current dir' self.configpath = configpath self.loglevel = logging.INFO # UI log window self.io = telegraph.telegraph() self.io.set_pub_cb(self.msg_cb) self.started = False self.running = True self.fontsize = FONTSIZE fnszstr = str(self.fontsize)+'px' self.font = pango.FontDescription(FONTFACE + ' ' + fnszstr) b = gtk.Builder() b.add_from_file(os.path.join(metarace.UI_PATH, 'irtt_announce.ui')) self.window = b.get_object('window') self.lbl_header = b.get_object('lbl_header') self.lbl_header.modify_font(self.font) self.lbl_header.set_text('metarace irtt announce ' + metarace.VERSION) self.elap_lbl = b.get_object('elap_lbl') self.elap_lbl.set_text('--:--') self.elap_lbl.modify_font(self.font) b.get_object('fin_pfx_lbl').modify_font(self.font) self.fin_label = b.get_object('fin_pfx_lbl') self.fin_label.modify_font(self.font) self.fin_rank = b.get_object('fin_rank_lbl') self.fin_rank.modify_font(self.font) self.fin_rider = b.get_object('fin_rider_lbl') self.fin_rider.modify_font(self.font) self.fin_time = b.get_object('fin_time_lbl') self.fin_time.modify_font(self.font) b.get_object('int_pfx_lbl').modify_font(self.font) self.int_label = b.get_object('int_pfx_lbl') self.int_label.modify_font(self.font) self.int_rank = b.get_object('int_rank_lbl') self.int_rank.modify_font(self.font) self.int_rider = b.get_object('int_rider_lbl') self.int_rider.modify_font(self.font) self.int_time = b.get_object('int_time_lbl') self.int_time.modify_font(self.font) self.fin_box = b.get_object('fin_box') # seems to work? self.fin_box.hide() #self.map_winsz = 0 #self.map_xoft = 0 #self.map_w = 0 #self.map_area = b.get_object('map_area') #self.map_src = None #self.map_area.set_size_request(-1, 80) #self.map_area.show() # lap & bunch status values self.cur_lap = tod.tod(0) self.cur_split = tod.tod(0) self.cur_bunchid = 0 self.cur_bunchcnt = 0 self.riders = gtk.ListStore(gobject.TYPE_STRING, # rank gobject.TYPE_STRING, # no. gobject.TYPE_STRING, # namestr gobject.TYPE_STRING, # cat/com gobject.TYPE_STRING, # timestr gobject.TYPE_STRING, # downtime gobject.TYPE_PYOBJECT) # rftod self.inters = gtk.ListStore(gobject.TYPE_STRING, # rank gobject.TYPE_STRING, # no. gobject.TYPE_STRING, # namestr gobject.TYPE_STRING, # turn gobject.TYPE_STRING, # eta gobject.TYPE_STRING, # speed gobject.TYPE_PYOBJECT) # rftod t = gtk.TreeView(self.riders) self.view = t t.set_reorderable(False) t.set_rules_hint(True) t.set_headers_visible(False) self.search_lbl = b.get_object('search_lbl') self.search_lbl.modify_font(self.font) self.search_entry = b.get_object('search_entry') self.search_entry.modify_font(self.font) t.set_search_entry(b.get_object('search_entry')) t.set_search_column(1) t.modify_font(self.font) uiutil.mkviewcoltxt(t, 'Rank', 0,width=40) uiutil.mkviewcoltxt(t, 'No.', 1,calign=1.0,width=40) uiutil.mkviewcoltxt(t, 'Rider', 2,expand=True,fixed=True) uiutil.mkviewcoltxt(t, 'Cat', 3,calign=0.0) uiutil.mkviewcoltxt(t, 'Time', 4,calign=1.0,width=100) uiutil.mkviewcoltxt(t, 'Gap', 5,calign=1.0,width=90) # "down" time? #uiutil.mkviewcoltxt(t, 'Bunch', 5,width=50,bgcol=6,calign=0.5) b.get_object('text_scroll').add(t) t.show() t.grab_focus() ## let's suppress the arrivals for now ##b.get_object('arrival_xpnd').hide() t = gtk.TreeView(self.inters) self.iview = t t.set_reorderable(False) t.set_rules_hint(True) t.set_headers_visible(False) t.modify_font(self.font) uiutil.mkviewcoltxt(t, '', 0,width=40) uiutil.mkviewcoltxt(t, 'No.', 1,calign=1.0,width=40) uiutil.mkviewcoltxt(t, 'Rider', 2,expand=True,fixed=True) uiutil.mkviewcoltxt(t, 'Turn', 3,calign=0.0) uiutil.mkviewcoltxt(t, 'Time', 4,calign=1.0,width=100) uiutil.mkviewcoltxt(t, 'Avg', 5,calign=1.0,width=90) t.show() b.get_object('arrival_scroll').add(t) b.connect_signals(self)
def __init__(self, meet, event, ui=True): """Constructor. Parameters: meet -- handle to meet object event -- event object handle ui -- display user interface? """ self.meet = meet self.event = event self.evno = event[u'evid'] self.evtype = event[u'type'] self.series = event[u'seri'] self.configpath = meet.event_configfile(self.evno) self.log = logging.getLogger('sprintround') self.log.setLevel(logging.DEBUG) # config may override? self.log.debug(u'Creating new event: ' + repr(self.evno)) self.readonly = not ui self.onestart = False self.start = None self.lstart = None self.finish = None self.curelap = None self.winopen = ui # window 'open' on proper load- or consult edb self.timerwin = False self.timerstat = 'idle' self.autospec = event[u'auto'] # automatic startlist self.inomnium = False self.startchan = timy.CHAN_200 self.finchan = timy.CHAN_FINISH self.contests = [] self.comment = [] self.seedsrc = None self.distance = None self.units = 'Laps' self.timetype = 'Start/finish' self.contests = gtk.ListStore( gobject.TYPE_STRING, # COL_CONTEST = 0 gobject.TYPE_STRING, # COL_A_NO = 1 gobject.TYPE_STRING, # COL_A_STR = 2 gobject.TYPE_STRING, # COL_A_PLACE = 3 gobject.TYPE_STRING, # COL_B_NO = 4 gobject.TYPE_STRING, # COL_B_STR = 5 gobject.TYPE_STRING, # COL_B_PLACE = 6 gobject.TYPE_PYOBJECT, # COL_200M = 7 gobject.TYPE_STRING, # COL_WINNER = 8 gobject.TYPE_STRING # COL_COMMENT = 9 ) b = gtk.Builder() b.add_from_file(os.path.join(metarace.UI_PATH, 'spfin.ui')) self.frame = b.get_object('spfin_vbox') self.frame.connect('destroy', self.shutdown) # info pane self.info_expand = b.get_object('info_expand') b.get_object('spfin_info_evno').set_text(self.evno) self.showev = b.get_object('spfin_info_evno_show') self.prefix_ent = b.get_object('spfin_info_prefix') self.prefix_ent.connect('changed', self.editent_cb, u'pref') self.prefix_ent.set_text(self.event[u'pref']) self.info_ent = b.get_object('spfin_info_title') self.info_ent.connect('changed', self.editent_cb, u'info') self.info_ent.set_text(self.event[u'info']) self.time_lbl = b.get_object('spfin_info_time') self.time_lbl.modify_font(pango.FontDescription("monospace")) self.type_lbl = b.get_object('race_type') self.type_lbl.set_text(self.event[u'type'].capitalize()) # ctrl pane self.stat_but = b.get_object('spfin_ctrl_stat_but') self.ctrl_winner = b.get_object('spfin_ctrl_winner') self.ctrl_action_combo = b.get_object('spfin_ctrl_action_combo') self.ctrl_action = b.get_object('spfin_ctrl_action') self.action_model = b.get_object('spfin_action_model') self.current_contest_combo = b.get_object('current_contest_combo') self.current_contest_combo.set_model(self.contests) self.current_contest_combo.connect( 'changed', self.current_contest_combo_changed_cb) # riders pane t = gtk.TreeView(self.contests) self.view = t t.set_reorderable(False) t.set_enable_search(False) t.set_rules_hint(True) # riders columns uiutil.mkviewcoltxt(t, 'Contest', COL_CONTEST) uiutil.mkviewcoltxt(t, '', COL_A_NO, calign=1.0) uiutil.mkviewcoltxt(t, 'A Rider', COL_A_STR, expand=True) uiutil.mkviewcoltxt(t, '', COL_B_NO, calign=1.0) uiutil.mkviewcoltxt(t, 'B Rider', COL_B_STR, expand=True) uiutil.mkviewcoltod(t, '200m', cb=self.todstr) uiutil.mkviewcoltxt(t, 'Win', COL_WINNER) t.show() b.get_object('spfin_result_win').add(t) # start timer and show window if ui: # connect signal handlers b.connect_signals(self)
def mkview(self, bib=True, first=True, last=True, club=True, cat=False, series=True, refid=False, ucicode=False, note=False): """Create and return view object for the model.""" if self.view is not None: return self.view v = gtk.TreeView(self.model) v.set_reorderable(True) v.set_enable_search(False) v.set_rules_hint(True) v.connect('key-press-event', self.__view_key) v.show() self.colmap = {} colcnt = 0 if bib: uiutil.mkviewcoltxt(v, 'No.', COL_BIB, self.__editcol_cb, halign=0.5, calign=0.5, editcb=self.__editstart_cb) self.colmap[COL_BIB] = colcnt colcnt += 1 if first: uiutil.mkviewcoltxt(v, 'First Name', COL_FIRST, self.__editcol_cb, expand=True, editcb=self.__editstart_cb) self.colmap[COL_FIRST] = colcnt colcnt += 1 if last: uiutil.mkviewcoltxt(v, 'Last Name', COL_LAST, self.__editcol_cb, expand=True, editcb=self.__editstart_cb) self.colmap[COL_LAST] = colcnt colcnt += 1 if club: uiutil.mkviewcoltxt(v, 'Club', COL_CLUB, self.__editcol_cb, editcb=self.__editstart_cb) self.colmap[COL_CLUB] = colcnt colcnt += 1 if cat: uiutil.mkviewcoltxt(v, 'Cat', COL_CAT, self.__editcol_cb, editcb=self.__editstart_cb) self.colmap[COL_CAT] = colcnt colcnt += 1 if series: uiutil.mkviewcoltxt(v, 'Ser', COL_SERIES, self.__editcol_cb, editcb=self.__editstart_cb) self.colmap[COL_SERIES] = colcnt colcnt += 1 if refid: uiutil.mkviewcoltxt(v, 'Refid', COL_REFID, self.__editcol_cb, editcb=self.__editstart_cb) self.colmap[COL_REFID] = colcnt colcnt += 1 if ucicode: uiutil.mkviewcoltxt(v, 'UCI Code', COL_UCICODE, self.__editcol_cb, editcb=self.__editstart_cb) self.colmap[COL_UCICODE] = colcnt colcnt += 1 if note: uiutil.mkviewcoltxt(v, 'Note', COL_NOTE, self.__editcol_cb, editcb=self.__editstart_cb) self.colmap[COL_NOTE] = colcnt colcnt += 1 self.view = v return self.view
def __init__(self, configpath=None): # logger and log handler self.log = logging.getLogger() self.log.setLevel(logging.DEBUG) self.loghandler = None # set in loadconfig to meet dir # meet configuration path and options if configpath is None: configpath = u'.' # None assumes 'current dir' self.configpath = configpath self.loglevel = logging.INFO # UI log window self.dosave = False self.redraw_flag = False self.io = telegraph.telegraph() self.io.set_pub_cb(self.msg_cb) #self.io.debug = True # uncomment to log all IRC activity self.started = False self.running = True self.failcount = 0 self.failthresh = 45 # connect timeout ~45sec self.autoscroll = False self.scrollcnt = 0 self.timetick = TIMETICK self.fontsize = FONTSIZE fnszstr = str(self.fontsize) + 'px' b = gtk.Builder() b.add_from_file(os.path.join(metarace.UI_PATH, 'rr_announce.ui')) self.window = b.get_object('window') self.lbl_header = b.get_object('lbl_header') self.lbl_header.modify_font( pango.FontDescription(FONTFACE + ' ' + fnszstr)) self.lbl_header.set_text('metarace road announce ' + metarace.VERSION) self.lbl_resultmsg = b.get_object('lbl_resultmsg') self.lbl_resultmsg.modify_font( pango.FontDescription(FONTFACE + ' ' + fnszstr)) self.lbl_resultmsg.set_text(u'') self.search_ent = b.get_object('search_entry') self.elap_lbl = b.get_object('elap_lbl') self.elap_lbl.set_text('-h--:--') self.elap_lbl.modify_font( pango.FontDescription(FONTFACE + ' ' + fnszstr)) self.gap_lbl = b.get_object('gap_lbl') self.gap_lbl.set_text('~jjj.lkm') self.gap_lbl.modify_font( pango.FontDescription(FONTFACE + ' ' + fnszstr)) self.map_winsz = 0 self.map_xoft = 0 self.map_w = 0 self.map_area = b.get_object('map_area') self.map_src = None self.map_area.set_size_request(-1, 80) self.map_area.show() self.track_winx = 0 self.track_winy = 0 self.track_xoft = 0 self.track_w = 0 self.track_area = b.get_object('track_area') self.track_src = None self.track_area.set_size_request(300, -1) self.showtrack = False ## defer to loadconfig? self.track_area.hide() # lap & bunch status values self.cur_lap = tod.tod(0) self.cur_split = tod.tod(0) self.cur_bunchid = 0 self.cur_bunchcnt = 0 self.profile = None self.zmin = None self.zmax = None self.xmin = None self.xmax = None self.ymin = None self.ymax = None self.dmax = None self.riders = gtk.ListStore( gobject.TYPE_STRING, # rank gobject.TYPE_STRING, # no. gobject.TYPE_STRING, # namestr gobject.TYPE_STRING, # cat/com gobject.TYPE_STRING, # timestr gobject.TYPE_STRING, # bunchcnt gobject.TYPE_STRING, # colour gobject.TYPE_PYOBJECT) # rftod t = gtk.TreeView(self.riders) self.view = t t.set_reorderable(False) t.set_rules_hint(True) t.set_headers_visible(False) self.search_entry = b.get_object('search_entry') self.search_entry.modify_font(pango.FontDescription(fnszstr)) t.set_search_entry(b.get_object('search_entry')) t.set_search_column(1) t.modify_font(pango.FontDescription(FONTFACE + ' ' + fnszstr)) uiutil.mkviewcoltxt(t, 'Rank', 0, width=45) uiutil.mkviewcoltxt(t, 'No.', 1, calign=1.0, width=45) uiutil.mkviewcoltxt(t, 'Rider', 2, expand=True, fixed=True) #uiutil.mkviewcoltxt(t, 'Cat', 3,calign=0.0) uiutil.mkviewcoltxt(t, 'Time', 4, calign=1.0, width=80) uiutil.mkviewcoltxt(t, 'Bunch', 5, width=50, bgcol=6, calign=0.5) t.show() ts = b.get_object('text_scroll') ts.add(t) t.grab_focus() self.vscroll = ts.get_vadjustment() b.connect_signals(self) # animation variables self.title_str = None self.final = False self.elapstart = None self.elapfin = None self.finstr = None # used with lapstr self.timerstat = u'running' # default assume run state self.distance = None self.distancemain = None self.laplbl = None self.laptype = None self.lapstart = None self.lapfin = None self.lastmainpt = None self.lastleadpt = None self.lastchasept = None self.lastsagpt = None # start timer self.tod = tod.tod(u'now').truncate(0) self.nc = self.tod + tod.tod(u'1.22') # set interval a little off mark self.maxlaptime = tod.tod('2:00') # default maximum lap time self.log.debug(u'Starting clock intervals at: ' + self.nc.rawtime(3)) glib.timeout_add(2000, self.timeout)
def __init__(self, meet, event, ui=True): """Constructor.""" self.meet = meet self.event = event # Note: now a treerowref self.evno = event[u'evid'] self.evtype = event[u'type'] self.series = event[u'seri'] self.configpath = meet.event_configfile(self.evno) self.log = logging.getLogger('omnium') self.log.setLevel(logging.DEBUG) self.log.debug('opening event: ' + str(self.evno)) self.curevent = None self.lastevent = None self.resultvirtual = False self.eventstatusmap = {} # race run time attributes self.onestart = False self.readonly = not ui self.winopen = True self.events = '' self.nicknames = [] self.autospec = event[u'auto'] # automatic startlist self.riders = gtk.ListStore( gobject.TYPE_STRING, # 0 bib gobject.TYPE_STRING, # 1 first name gobject.TYPE_STRING, # 2 last name gobject.TYPE_STRING, # 3 club gobject.TYPE_STRING, # 4 comment gobject.TYPE_INT, # 5 total gobject.TYPE_PYOBJECT, # 6 time total gobject.TYPE_STRING, # 7 place gobject.TYPE_PYOBJECT) # event points b = gtk.Builder() b.add_from_file(os.path.join(metarace.UI_PATH, 'omnium.ui')) self.frame = b.get_object('omnium_vbox') self.frame.connect('destroy', self.shutdown) # info pane self.info_expand = b.get_object('info_expand') b.get_object('omnium_info_evno').set_text(self.evno) self.showev = b.get_object('omnium_info_evno_show') self.prefix_ent = b.get_object('omnium_info_prefix') self.prefix_ent.connect('changed', self.editent_cb, u'pref') self.prefix_ent.set_text(self.event[u'pref']) self.info_ent = b.get_object('omnium_info_title') self.info_ent.connect('changed', self.editent_cb, u'info') self.info_ent.set_text(self.event[u'info']) self.update_expander_lbl_cb() # riders pane t = gtk.TreeView(self.riders) self.view = t t.set_reorderable(True) t.set_enable_search(False) t.set_rules_hint(True) t.connect('button_press_event', self.treeview_button_press) # riders columns uiutil.mkviewcoltxt(t, 'No.', COL_BIB, calign=1.0) uiutil.mkviewcoltxt(t, 'First Name', COL_FIRST, self.editcol_db, expand=True) uiutil.mkviewcoltxt(t, 'Last Name', COL_LAST, self.editcol_db, expand=True) uiutil.mkviewcoltxt(t, 'Club', COL_CLUB, self.editcol_db) uiutil.mkviewcoltxt(t, 'Points', COL_TOTAL, calign=1.0) uiutil.mkviewcoltod(t, 'Time', cb=self.todstr) uiutil.mkviewcoltxt(t, 'Rank', COL_PLACE, halign=0.5, calign=0.5) t.show() b.get_object('omnium_result_win').add(t) self.context_menu = None if ui: # connect signal handlers b.connect_signals(self) b = gtk.Builder() b.add_from_file(os.path.join(metarace.UI_PATH, 'tod_context.ui')) self.context_menu = b.get_object('tod_context') b.connect_signals(self)