chord.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:Solfege 作者: RannyeriDev 项目源码 文件源码
def update_answer_buttons(self, obj=None):
        """
        Only columns with question properties that are actually used
        in the lesson file will be displayed. This way, we can make a default
        configuration:
         qprops = "name", "toptone", "inversion"
         qprop_labels = _("Name"), _("Toptone"), _("Inversion")
        and only lesson files that require other properties have to define
        these two variables.
        """
        # This part will create the table with the buttons used to answer.
        try:
            self.g_atable.destroy()
        except AttributeError:
            pass
        self.g_atable = Gtk.Table()
        self.g_atable.show()
        self.g_hbox.pack_start(self.g_atable, False, False, 0)
        self.g_hbox.reorder_child(self.g_atable, 1)
        # pprops say how many properties are we going to display.
        # We will not display a property if no questions use it.
        num_used_props = len(
            [x for x in self.m_t.m_P.m_props.keys() if self.m_t.m_P.m_props[x]])
        # tcols say how many columns we need. We need a column for each
        # column separator
        tcols = num_used_props * 2 - 1
        trows = max([len(x) for x in self.m_t.m_P.m_props.values()]) + 2
        # The column headings
        for idx, label in enumerate(self.m_t.m_P.header.qprop_labels):
            self.g_atable.attach(Gtk.Label(label=label), idx * 2, idx * 2 + 1, 0, 1,
                                 xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK,
                                 xpadding=gu.PAD_SMALL)
        # Then we create the buttons used to answer.
        for x, prop in enumerate(self.m_t.m_P.header.qprops):
            for y, proplabel in enumerate(self.m_t.m_P.m_props[prop]):
                button = Gtk.Button(unicode(proplabel))
                button.m_property_name = prop
                button.m_property_value = proplabel.cval
                button.connect('clicked', self.on_prop_button_clicked)
                button.connect('button_release_event', self.on_prop_button_right_clicked)
                self.g_atable.attach(button, x * 2, x * 2 + 1, y + 2, y + 3,
                    xpadding=gu.PAD_SMALL,
                    yoptions=Gtk.AttachOptions.SHRINK)
        # The separator below the column headings
        self.g_atable.attach(Gtk.HSeparator(), 0, tcols, 1, 2,
            xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL,
            xpadding=0, ypadding=gu.PAD_SMALL)
        # The vertical separator between columns
        for idx in range(len(self.m_t.m_P.header.qprops)-1):
            self.g_atable.attach(Gtk.VSeparator(),
            idx * 2 + 1, idx * 2 + 2, 0, trows,
            xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL,
            xpadding=0, ypadding=gu.PAD_SMALL)
        self.g_atable.show_all()
        #
        self.g_random_transpose.set_text(str(self.m_t.m_P.header.random_transpose))
        self.g_repeat.set_sensitive(False)
        self.g_repeat_arpeggio.set_sensitive(False)
        self.g_give_up.set_sensitive(False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号