コード例 #1
0
 def __init__(self, heading, st_data, st):
     """
     st_data is the statistics data we want displayled
     st is the statistics object the statistics are collected from.
     """
     gtk.VBox.__init__(self)
     label = gtk.Label(heading)
     label.set_name("StatisticsH2")
     label.set_alignment(0.0, 0.0)
     self.pack_start(label, False)
     hbox = gu.bHBox(self, False)
     frame = gtk.Frame()
     hbox.pack_start(frame, False)
     t = gtk.Table()
     frame.add(t)
     keys = st.get_keys(True)
     for x in range(len(keys)):
         t.attach(gtk.VSeparator(), x*2+1, x*2+2, 0, len(keys)*2)
     for x in range(len(keys)-1):
         t.attach(gtk.HSeparator(), 0, len(keys)*2+1, x*2+1, x*2+2)
     for y, key in enumerate(keys):
         l = lessonfilegui.new_labelobject(st.key_to_pretty_name(key))
         l.set_alignment(0.0, 0.5)
         t.attach(l, 0, 1, y*2, y*2+1, xpadding=gu.PAD)
         for x, skey in enumerate(keys):
             try:
                 s = st_data[key][skey]
             except KeyError:
                 s = '-'
             l = gtk.Label(s)
             if x == y:
                 l.set_name('BoldText')
             t.attach(l, x*2+2, x*2+3, y*2, y*2+1, xpadding=gu.PAD)
     self.show_all()
コード例 #2
0
ファイル: gu.py プロジェクト: 314pi/PortableEducation
 def display(self, txt, **kwargs):
     self.empty()
     r = re.compile("(\{\w+\})")  # Unicode??
     self.set_size_request(-1, -1)
     for child in r.split(txt):
         m = r.match(child)
         if m:
             varname = child[1:][:-1]
             from solfege import lessonfilegui
             if isinstance(kwargs[varname], basestring):
                 w = gtk.Label(kwargs[varname])
                 w.set_name("FlashBarLabel")
             else:
                 w = lessonfilegui.new_labelobject(kwargs[varname])
         elif child:  # don't create label for empty string
             w = gtk.Label(child)
             w.set_name("FlashBarLabel")
         self.__content.pack_start(w, False)
         w.show()
     sx, sy = self.size_request()
     self.m_sx = max(sx, self.m_sx)
     self.m_sy = max(sy, self.m_sy)
     self.set_size_request(self.m_sx, self.m_sy)
     if self.__timeout:
         gobject.source_remove(self.__timeout)
         self.__timeout = None
コード例 #3
0
ファイル: gu.py プロジェクト: PauloJava2016/Solfege
 def display(self, txt, **kwargs):
     self.empty()
     r = re.compile("(\{\w+\})") # Unicode??
     self.set_size_request(-1, -1)
     for child in r.split(txt):
         m = r.match(child)
         if m:
             varname = child[1:][:-1]
             from solfege import lessonfilegui
             if isinstance(kwargs[varname], basestring):
                 w = Gtk.Label(label=kwargs[varname])
                 w.set_name("FlashBarLabel")
             else:
                 w = lessonfilegui.new_labelobject(kwargs[varname])
         elif child: # don't create label for empty string
             w = Gtk.Label(label=child)
             w.set_name("FlashBarLabel")
         self.__content.pack_start(w, False, False, 0)
         w.show()
     self.m_sx = max(self.size_request().width, self.m_sx)
     self.m_sy = max(self.size_request().height, self.m_sy)
     self.set_size_request(self.m_sx, self.m_sy)
     if self.__timeout:
         GObject.source_remove(self.__timeout)
         self.__timeout = None
コード例 #4
0
ファイル: specialwidgets.py プロジェクト: gitGNU/gnu_solfege
 def add(self, question, callback):
     """add a button and set up callback function.
     there should not be created more than one button with the same
     (c locale) name.
     return the button created.
     """
     if 'newline' in question and question.newline:
         self.newline()
     b = Gtk.Button()
     if question.name.cval in self.m_button_dict:
         print(
             "Warning: The lessonfile contain several questions with the same name:",
             question.name.cval,
             file=sys.stderr)
         print("         This is a bug in the lesson file.",
               file=sys.stderr)
     self.m_button_dict[question.name.cval] = b
     self.m_name_list.append(question.name.cval)
     b.m_cname = question.name.cval
     b.set_sensitive(question.active)
     b.add(lessonfilegui.new_labelobject(question.name))
     b.show_all()
     self.attach(b, self.m_x, self.m_x + 1, self.m_y, self.m_y + 1)
     b.connect('clicked', callback)
     b.connect('button_release_event', callback)
     self.conditional_newline()
     return b
コード例 #5
0
ファイル: specialwidgets.py プロジェクト: gitGNU/gnu_solfege
 def add(self, question):
     """add a button and set up callback function.
     there should not be created more than one button with the same
     (c locale) name.
     return the button created.
     """
     if 'newline' in question and question.newline:
         self.newline()
     b = Gtk.CheckButton()
     if question.name.cval in self.m_button_dict:
         print(
             "Warning: The lessonfile contain several questions with the same name:",
             question.name.cval,
             file=sys.stderr)
         print("         Things will not work as normal after this.",
               file=sys.stderr)
     self.m_button_dict[question.name.cval] = b
     self.m_name_list.append(question.name.cval)
     b.set_active(question.active)
     b.connect('toggled', self.on_checkbutton_toggled)
     b.m_cname = question.name.cval
     b.add(lessonfilegui.new_labelobject(question.name))
     b.show_all()
     self.attach(b, self.m_x, self.m_x + 1, self.m_y, self.m_y + 1)
     self.conditional_newline()
     return b
コード例 #6
0
def label_from_key(statistics, key):
    try:
        v = eval(key)
    except Exception:
        v = key
    else:
        if isinstance(v, (int, float, long)):
            v = key
    if not v:
        l = gtk.Label(key)
    elif hasattr(statistics, 'm_key_is_list'):
        l = lessonfilegui.LabelObjectBox(statistics.m_t.m_P, v)
    else:
        l = lessonfilegui.new_labelobject(statistics.key_to_pretty_name(v))
    l.set_alignment(0.0, 0.5)
    return l
コード例 #7
0
def label_from_key(statistics, key):
    try:
        v = eval(key)
    except Exception:
        v = key
    else:
        if isinstance(v, (int, float)):
            v = key
    if not v:
        l = Gtk.Label(label=key)
    elif hasattr(statistics, 'm_key_is_list'):
        l = lessonfilegui.LabelObjectBox(statistics.m_t.m_P, v)
    else:
        l = lessonfilegui.new_labelobject(statistics.key_to_pretty_name(v))
    l.set_alignment(0.0, 0.5)
    return l
コード例 #8
0
 def add(self, question):
     """add a button and set up callback function.
     there should not be created more than one button with the same
     (c locale) name.
     return the button created.
     """
     if 'newline' in question and question.newline:
         self.newline()
     b = gtk.CheckButton()
     if question.name.cval in self.m_button_dict:
         print >> sys.stderr, "Warning: The lessonfile contain several questions with the same name:", question.name.cval
         print >> sys.stderr, "         Things will not work as normal after this."
     self.m_button_dict[question.name.cval] = b
     self.m_name_list.append(question.name.cval)
     b.set_active(question.active)
     b.connect('toggled', self.on_checkbutton_toggled)
     b.set_data('cname', question.name.cval)
     b.add(lessonfilegui.new_labelobject(question.name))
     b.show_all()
     self.attach(b, self.m_x, self.m_x+1, self.m_y, self.m_y+1)
     self.conditional_newline()
     return b
コード例 #9
0
    def update(self, statistics):
        for box in self.boxdict.values():
            for o in box.get_children():
                o.destroy()
        for k in statistics.get_keys(True):
            l = lessonfilegui.new_labelobject(statistics.key_to_pretty_name(k))
            l.set_alignment(0.0, 0.5)
            self.boxdict['keys'].pack_start(l)
            for sk, seconds in (('session', 0),
                       ('today', 60*60*24),
                       ('last7', 60*60*24*7),
                       ('total', -1)):

                percentage = statistics.get_percentage_correct_for_key(seconds, k)
                if percentage == 0.0:
                    self.boxdict[sk+'percent'].pack_start(gtk.Label("-"))
                else:
                    self.boxdict[sk+'percent'].pack_start(
                        gtk.Label("%.0f" % percentage))
                self.boxdict[sk+'count'].pack_start(
                    gtk.Label(str(statistics.get_num_guess_for_key(seconds, k))))
        self.show_all()
コード例 #10
0
 def add(self, question, callback):
     """add a button and set up callback function.
     there should not be created more than one button with the same
     (c locale) name.
     return the button created.
     """
     if 'newline' in question and question.newline:
         self.newline()
     b = gtk.Button()
     if question.name.cval in self.m_button_dict:
         print >> sys.stderr, "Warning: The lessonfile contain several questions with the same name:", question.name.cval
         print >> sys.stderr, "         This is a bug in the lesson file."
     self.m_button_dict[question.name.cval] = b
     self.m_name_list.append(question.name.cval)
     b.set_data('cname', question.name.cval)
     b.set_sensitive(question.active)
     b.add(lessonfilegui.new_labelobject(question.name))
     b.show_all()
     self.attach(b, self.m_x, self.m_x+1, self.m_y, self.m_y+1)
     b.connect('clicked', callback)
     b.connect('button_release_event', callback)
     self.conditional_newline()
     return b
コード例 #11
0
ファイル: elembuilder.py プロジェクト: gitGNU/gnu_solfege
 def __init__(self, label):
     Gtk.Button.__init__(self)
     l = lessonfilegui.new_labelobject(label)
     self.add(l)
     self.m_marked_wrong = False