Python gi.repository.Gtk 模块,VSeparator() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用gi.repository.Gtk.VSeparator()

项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def create(self):
        table = Gtk.Table()
        label = Gtk.Label()
        label.set_alignment(0.0, 0.5)
        label.set_markup(u"<b>%s</b>" % self.m_heading)
        self.pack_start(label, True, True, 0)
        for idx, (cell1, cell2) in enumerate(self.m_data):
            table.attach(label_from_key(self.m_statistics, cell1), 1, 2, idx*2+1, idx*2+2,
                         xoptions=Gtk.AttachOptions.SHRINK, xpadding=2)
            table.attach(Gtk.Label(label=cell2), 3, 4, idx*2+1, idx*2+2,
                         xoptions=Gtk.AttachOptions.SHRINK, xpadding=2)
        for idx in range(len(self.m_data) + 1):
            table.attach(Gtk.HSeparator(), 0, 5, idx*2, idx*2+1, xoptions=Gtk.AttachOptions.FILL)
        table.attach(Gtk.VSeparator(), 0, 1, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK)
        table.attach(Gtk.VSeparator(), 2, 3, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK)
        table.attach(Gtk.VSeparator(), 4, 5, 0, idx*2+2, xoptions=Gtk.AttachOptions.SHRINK)
        self.pack_start(table, False, False, 0)
        self.show_all()
项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
def setup_widgets(self):
        self.parent = Gtk.Grid()
        self.parent.set_name("osd-gesture")

        self._left_draw  = GestureDraw(self.SIZE, self._left_detector)
        # self._right_draw = GestureDraw(self.SIZE, self._right_detector)
        sep = Gtk.VSeparator()
        sep.set_name("osd-gesture-separator")

        self.parent.attach(self._left_draw,  0, 0, 1, 1)
        # self.parent.attach(sep,              1, 0, 1, 1)
        # self.parent.attach(self._right_draw, 2, 0, 1, 1)

        self.add(self.parent)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
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(label=heading)
        label.set_name("StatisticsH2")
        label.set_alignment(0.0, 0.0)
        self.pack_start(label, False, False, 0)
        hbox = gu.bHBox(self, False)
        frame = Gtk.Frame()
        hbox.pack_start(frame, False, False, 0)
        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 = label_from_key(st, key)
            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(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()
项目:bokken    作者:thestr4ng3r    | 项目源码 | 文件源码
def add_text(self, data_dict, version):
        '''data_dict ontains text to be added.
           Key will be the title
           Value will be... well, the value :)'''
        self.box = Gtk.HBox(False, 1)
        self._statusbar.pack_start(self.box, False, False, 1)
        ellipsize = Pango.EllipsizeMode.NONE
        for element in data_dict.keys():
            if element == 'Arch':
                _icon = Gtk.Image.new_from_file(self.icons[element])
            else:
                _icon = Gtk.Image.new_from_stock(self.icons[element], Gtk.IconSize.MENU)
            self.box.pack_start(_icon, False, False, 0)
            # Element label
            label = Gtk.Label()
            label.set_markup('<b>%s:</b>' % element)
            label.set_padding(1, 0)
            label.set_max_width_chars(len(element) + 1)
            label.set_single_line_mode(True)
            label.set_ellipsize(ellipsize)
            self.box.pack_start(label, True, True, 1)
            # Element content
            label = Gtk.Label(label=str(data_dict[element]))
            label.set_padding(1, 0)
            label.set_max_width_chars(len(str(data_dict[element])))
            label.set_single_line_mode(True)
            label.set_ellipsize(ellipsize)
            self.box.pack_start(label, True, True, 1)
            sep = Gtk.VSeparator()
            self.box.pack_start(sep, True, True, 1)

        if version:
            _icon = Gtk.Image.new_from_file(datafile_path('bokken-small.svg'))
            self.pack_start(_icon, False, False, 1)
            label = Gtk.Label()
            label.set_markup('<b>Bokken ' + version + '</b> (' + self.uicore.backend.capitalize() + ' ' + self.uicore.version + ')')
            label.set_padding(1, 0)
            self.pack_end(label, False, True, 0)

        self.show_all()
项目: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()
        if self.m_t.m_P.header.layout_orientation == 'horiz':
            self.g_contents.attach(self.g_atable, 1, 2, 2, 3)
        else:
            self.g_contents.attach(self.g_atable, 0, 1, 1, 2)
        # 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))
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, teacher):
        abstract.Gui.__init__(self, teacher)
        self.m_key_bindings = {'backspace_ak': self.on_backspace}
        self.g_answer_box = gu.NewLineBox()
        self.practise_box.pack_start(self.g_answer_box, False, False, 0)
        #-------
        hbox = gu.bHBox(self.practise_box)
        b = Gtk.Button(_("Play"))
        b.show()
        b.connect('clicked', self.play_users_answer)
        hbox.pack_start(b, False, True, 0)
        self.practise_box.pack_start(Gtk.HBox(False, 0), False, False,
                                     padding=gu.PAD_SMALL)
        self.g_rhythm_viewer = RhythmViewer(self)
        #FIXME the value 52 is dependant on the theme used
        self.g_rhythm_viewer.set_size_request(-1, 52)
        self.g_rhythm_viewer.create_holders()
        hbox.pack_start(self.g_rhythm_viewer, True, True, 0)

        # action area
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', self.repeat_question),
            ('give_up', self.give_up),
            ('backspace', self.on_backspace))

        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.add_select_elements_gui()
        #--------
        self.config_box.pack_start(Gtk.HBox(False, 0), False, False,
                                   padding=gu.PAD_SMALL)
        self.add_select_num_beats_gui()
        #-----
        self.config_box.pack_start(Gtk.HBox(False, 0), False, False,
                                   padding=gu.PAD_SMALL)
        #------
        hbox = gu.bHBox(self.config_box, False)
        hbox.set_spacing(gu.PAD_SMALL)
        hbox.pack_start(gu.nCheckButton(self.m_exname,
                 "not_start_with_rest",
                 _("Don't start the question with a rest")), False, False, 0)
        sep = Gtk.VSeparator()
        hbox.pack_start(sep, False, False, 0)
        hbox.pack_start(Gtk.Label(_("Beats per minute:")), False, False, 0)
        spin = gu.nSpinButton(self.m_exname, 'bpm',
                 Gtk.Adjustment(60, 20, 240, 1, 10))
        hbox.pack_start(spin, False, False, 0)
        self._add_auto_new_question_gui(self.config_box)
        self.config_box.show_all()
项目: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)
项目:indprog    作者:schlagenhauf    | 项目源码 | 文件源码
def createHud(self):
        self.tools = Gtk.ToolPalette()

        # general functions
        generalTools = Gtk.ToolItemGroup.new('General')
        self.tools.add(generalTools)

        loadItem = Gtk.ToolButton.new(None, 'Load')
        loadItem.connect("clicked", self.__loadGraph)
        generalTools.insert(loadItem, -1)

        saveItem = Gtk.ToolButton.new(None, 'Save')
        saveItem.connect("clicked", self.__saveGraph)
        generalTools.insert(saveItem, -1)

        runItem = Gtk.ToolButton.new(None, 'Run')
        runItem.connect("clicked", self.__executeGraph)
        generalTools.insert(runItem, -1)

        # node functions
        newNodeTools = Gtk.ToolItemGroup.new('New Node')
        self.tools.add(newNodeTools)

        constNodeItem = Gtk.ToolButton.new(None, 'FileRead')
        constNodeItem.connect("clicked", lambda w = None, d = None: self.__createNode('fileread', w, d))
        newNodeTools.insert(constNodeItem, -1)

        constNodeItem = Gtk.ToolButton.new(None, 'FileWrite')
        constNodeItem.connect("clicked", lambda w = None, d = None: self.__createNode('filewrite', w, d))
        newNodeTools.insert(constNodeItem, -1)

        constNodeItem = Gtk.ToolButton.new(None, 'Constant')
        constNodeItem.connect("clicked", lambda w = None, d = None: self.__createNode('const', w, d))
        newNodeTools.insert(constNodeItem, -1)

        printNodeItem = Gtk.ToolButton.new(None, 'Printer')
        printNodeItem.connect("clicked", lambda w = None, d = None: self.__createNode('print', w, d))
        newNodeTools.insert(printNodeItem, -1)

        adderNodeItem = Gtk.ToolButton.new(None, 'Adder')
        adderNodeItem.connect("clicked", lambda w = None, d = None: self.__createNode('add', w, d))
        newNodeTools.insert(adderNodeItem, -1)

        adderNodeItem = Gtk.ToolButton.new(None, 'Bash')
        adderNodeItem.connect("clicked", lambda w = None, d = None: self.__createNode('bash', w, d))
        newNodeTools.insert(adderNodeItem, -1)

        adderNodeItem = Gtk.ToolButton.new(None, 'MatLab')
        adderNodeItem.connect("clicked", lambda w = None, d = None: self.__createNode('matlab', w, d))
        newNodeTools.insert(adderNodeItem, -1)

        self.vbox.pack_start(self.tools, False, False, 0)

        vsep = Gtk.VSeparator()
        self.vbox.pack_start(vsep, False, False, 0)

        logger.debug('HUD populated')