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

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

项目: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()
项目:hachoir3    作者:vstinner    | 项目源码 | 文件源码
def __init__(self):
        self.main_window = Gtk.Window()
        self.main_window.set_border_width(5)
        self.main_window.connect("destroy", self._destroy)

        self.main_vbox = Gtk.VBox()

        self.select_hbox = Gtk.HBox()
        self.select_button = Gtk.Button("Select")
        self.select_button.connect("clicked", self._select_clicked)
        self.select_hbox.pack_start(self.select_button, False, True, 0)
        self.file_combo = Gtk.ComboBoxText()
        self.file_combo.connect("changed", self._file_combo_changed)
        self.select_hbox.pack_start(self.file_combo, True, True, 0)
        self.main_vbox.pack_start(self.select_hbox, False, True, 0)

        self.metadata_table = Gtk.Table(1, 1)
        self.metadata_table.attach(
            Gtk.Label("Select a file to view metadata information..."), 0, 1, 0, 1)
        self.main_vbox.pack_start(self.metadata_table, True, True, 0)

        self.main_window.add(self.main_vbox)
        self.main_window.show_all()
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, label_text=""):
        Gtk.Viewport.__init__(self)
        self.spinner = Gtk.Spinner()
        self.spinner.set_size_request(48, 48)

        # use a table for the spinner (otherwise the spinner is massive!)
        spinner_table = Gtk.Table(3, 3, False)
        self.spinner_label = Gtk.Label()
        self.spinner_label.set_markup('<big>%s</big>' % label_text)
        spinner_vbox = Gtk.VBox()
        spinner_vbox.pack_start(self.spinner, True, True, 0)
        spinner_vbox.pack_start(self.spinner_label, True, True, 10)
        spinner_table.attach(spinner_vbox, 1, 2, 1, 2,
            Gtk.AttachOptions.EXPAND, Gtk.AttachOptions.EXPAND)

        #~ self.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(1.0, 1.0, 1.0))
        self.add(spinner_table)
        self.set_shadow_type(Gtk.ShadowType.NONE)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, label_text=""):
        Gtk.Viewport.__init__(self)
        self.spinner = Gtk.Spinner()
        self.spinner.set_size_request(48, 48)

        # use a table for the spinner (otherwise the spinner is massive!)
        spinner_table = Gtk.Table(3, 3, False)
        self.spinner_label = Gtk.Label()
        self.spinner_label.set_markup('<big>%s</big>' % label_text)
        spinner_vbox = Gtk.VBox()
        spinner_vbox.pack_start(self.spinner, True, True, 0)
        spinner_vbox.pack_start(self.spinner_label, True, True, 10)
        spinner_table.attach(spinner_vbox, 1, 2, 1, 2,
            Gtk.AttachOptions.EXPAND, Gtk.AttachOptions.EXPAND)

        #~ self.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(1.0, 1.0, 1.0))
        self.add(spinner_table)
        self.set_shadow_type(Gtk.ShadowType.NONE)
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Dialog.__init__(self, 'File Downloader',None,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_size_request(400, 100)
        self.set_title('? ubi site file downloader')
        self.connect('destroy', self.close_application)
        #
        vbox0 = Gtk.VBox(spacing = 10)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)
        #
        table1 = Gtk.Table(3,2,False)
        vbox0.add(table1)
        label10 = Gtk.Label('Extension:')
        label10.set_alignment(0, 0.5)
        table1.attach(label10,0,1,0,1)
        #
        self.entry10 = Gtk.Entry()
        table1.attach(self.entry10,1,2,0,1)     
        #
        label11 = Gtk.Label('Url:')
        label11.set_alignment(0, 0.5)
        table1.attach(label11,0,1,1,2)
        #
        self.entry11 = Gtk.Entry()
        table1.attach(self.entry11,1,2,1,2)
        #
        #self.button = Gtk.Button('Select folder')
        #self.button.connect('clicked',self.on_button_clicked)
        #table1.attach(self.button,0,2,2,3)
        #
        self.show_all()
项目:ubi-virtual-assistant    作者:Alzemand    | 项目源码 | 文件源码
def __init__(self):
        Gtk.Dialog.__init__(self, 'File Downloader',None,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_size_request(400, 100)
        self.set_title('? ubi site file downloader')
        self.connect('destroy', self.close_application)
        #
        vbox0 = Gtk.VBox(spacing = 10)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)
        #
        table1 = Gtk.Table(3,2,False)
        vbox0.add(table1)
        label10 = Gtk.Label('Extension:')
        label10.set_alignment(0, 0.5)
        table1.attach(label10,0,1,0,1)
        #
        self.entry10 = Gtk.Entry()
        table1.attach(self.entry10,1,2,0,1)     
        #
        label11 = Gtk.Label('Url:')
        label11.set_alignment(0, 0.5)
        table1.attach(label11,0,1,1,2)
        #
        self.entry11 = Gtk.Entry()
        table1.attach(self.entry11,1,2,1,2)
        #
        #self.button = Gtk.Button('Select folder')
        #self.button.connect('clicked',self.on_button_clicked)
        #table1.attach(self.button,0,2,2,3)
        #
        self.show_all()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, teacher):
        abstract.LessonbasedGui.__init__(self, teacher)
        ################
        # practise_box #
        ################
        self.g_contents = Gtk.Table()
        hbox = gu.bHBox(self.practise_box, True, False)
        hbox.pack_start(Gtk.HBox(), True, True, 0)
        hbox.pack_start(self.g_contents, True, True, 0)
        hbox.pack_start(Gtk.HBox(), True, True, 0)
        self.g_contents.set_col_spacings(gu.PAD)
        self.g_contents.set_row_spacings(gu.PAD)

        self.g_music_displayer = mpd.MusicDisplayer()
        self.g_music_displayer.set_size_request(100, -1)
        self.g_contents.attach(self.g_music_displayer, 1, 2, 1, 2)
        self.g_flashbar = gu.FlashBar()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)

        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)),
            ('repeat_arpeggio', lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio)),
            ('give_up', self.give_up))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.PAD_SMALL)
        self.add_random_transpose_gui()
        # -----------------------------------------
        self.g_select_questions_category_box, category_box= gu.hig_category_vbox(
            _("Chord types to ask"))
        self.config_box.pack_start(self.g_select_questions_category_box, True, True, 0)
        self.g_select_questions = QuestionNameCheckButtonTable(self.m_t)
        self.g_select_questions.initialize(4, 0)
        category_box.pack_start(self.g_select_questions, False, False, 0)
        self.g_select_questions.show()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, exname, name):
        Gtk.Table.__init__(self)
        cfg.ConfigUtils.__init__(self, exname)
        self.m_varname = name
        self.g_buttons = fill_table(Gtk.CheckButton, self)
        for key, button in self.g_buttons.items():
            button.connect('toggled', self.on_toggled)
        for key in self.get_list('tones'):
            self.g_buttons[key].set_active(True)
项目: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()
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, exname):
        Gtk.Table.__init__(self)
        cfg.ConfigUtils.__init__(self, exname)
        self._ignore_watch = 0
        self.add_watch('ask_for_names', self.ask_for_names_changed)
项目:backlight-indicator    作者:atareao    | 项目源码 | 文件源码
def __init__(self, value):
        #
        Gtk.Dialog.__init__(self,
                            'Backlight Indicator | ' + _('Set backlight'),
                            None,
                            Gtk.DialogFlags.MODAL |
                            Gtk.DialogFlags.DESTROY_WITH_PARENT,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                                Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.connect('close', self.close_ok)
        self.set_icon_from_file(comun.ICON)
        #
        vbox0 = Gtk.VBox(spacing=5)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)
        frame0 = Gtk.Frame()
        vbox0.pack_start(frame0, False, True, 1)
        table0 = Gtk.Table(2, 2, False)
        frame0.add(table0)
        label23 = Gtk.Label(_('Backlight') + ':')
        label23.set_alignment(0, 0.5)
        table0.attach(label23, 0, 1, 0, 1,
                      xpadding=5, ypadding=5)
        configuration = Configuration()
        minimum_backlight = configuration.get('minimum-backlight')
        maximum_backlight = configuration.get('maximum-backlight')
        ba = BacklightManager()
        backlight = ba.get_backlight()
        adjustment3 = Gtk.Adjustment(backlight,
                                     minimum_backlight,
                                     maximum_backlight, 5, 10, 1)
        self.backlight = Gtk.Scale()
        self.backlight.set_digits(0)
        self.backlight.set_size_request(200, 10)
        self.backlight.set_adjustment(adjustment3)
        table0.attach(self.backlight, 1, 2, 0, 1,
                      xpadding=5, ypadding=5)
        self.backlight.set_value(value)
        self.show_all()
项目:pycam    作者:SebKuzminsky    | 项目源码 | 文件源码
def __init__(self):
        self._widgets = []
        self._table = gtk.Table(rows=1, columns=2)
        self._table.set_col_spacings(3)
        self._table.set_row_spacings(3)
        self.update_widgets()
        self._update_widgets_visibility()
项目:google-tasks-indicator    作者:atareao    | 项目源码 | 文件源码
def __init__(self, tasklist = None):
        Gtk.Dialog.__init__(self)
        if tasklist == None:
            self.set_title(comun.APPNAME + ' | '+_('Add new tasklist'))
        else:
            self.set_title(comun.APPNAME + ' | '+_('Edit tasklist'))
        self.set_modal(True)
        self.add_buttons(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT,Gtk.STOCK_CANCEL,Gtk.ResponseType.CANCEL)    
        self.set_size_request(200, 80)
        self.set_resizable(False)
        self.set_icon_from_file(comun.ICON)
        #
        vbox0 = Gtk.VBox(spacing = 5)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)
        #
        table1 = Gtk.Table(n_rows = 1, n_columns = 2, homogeneous = False)
        table1.set_border_width(5)
        table1.set_col_spacings(5)
        table1.set_row_spacings(5)
        vbox0.add(table1)
        #
        label11 = Gtk.Label.new(_('Title')+':')
        label11.set_alignment(0,.5)
        table1.attach(label11,0,1,0,1, xoptions = Gtk.AttachOptions.FILL, yoptions = Gtk.AttachOptions.FILL)
        #
        self.entry1 = Gtk.Entry()
        self.entry1.set_width_chars(60)
        table1.attach(self.entry1,1,2,0,1, xoptions = Gtk.AttachOptions.EXPAND, yoptions = Gtk.AttachOptions.SHRINK)
        #
        if tasklist is not None:
            if 'title' in tasklist.keys():
                self.entry1.set_text(tasklist['title'])
        self.show_all()
项目:gracer    作者:isamert    | 项目源码 | 文件源码
def do_create_configure_widget(self):
        table = Gtk.Table(3, 2, Gtk.true())
        table.set_row_spacings(5)
        table.set_col_spacings(5)

        lbl_racerpath = Gtk.Label("Racer path: ")
        lbl_rustsrc   = Gtk.Label("Rust source path: ")

        self.txt_racerpath = Gtk.TextView()
        self.txt_rustsrc   = Gtk.TextView()

        rust_src_path = self.racer.get_rust_src_path()
        racer_path = self.racer.get_racer_path()

        self.txt_racerpath.get_buffer().set_text(racer_path)
        self.txt_rustsrc.get_buffer().set_text(rust_src_path)

        btn_save = Gtk.Button("Save")
        btn_save.connect("clicked", self.on_btn_save_clicked)

        table.attach(lbl_racerpath, 0, 1, 0, 1)
        table.attach(lbl_rustsrc, 0, 1, 1, 2)
        table.attach(self.txt_racerpath, 1, 2, 0, 1)
        table.attach(self.txt_rustsrc, 1, 2, 1, 2)
        table.attach(btn_save, 0, 2, 2, 3)

        return table
项目:hachoir3    作者:vstinner    | 项目源码 | 文件源码
def _file_combo_changed(self, widget):
        self.main_vbox.remove(self.metadata_table)

        filename = self.file_combo.get_active_text()
        parser = createParser(filename)
        metadata = extractMetadata(parser)

        self.metadata_table = Gtk.Table(1, 2)
        self.main_vbox.pack_start(self.metadata_table, True, True, 0)

        if metadata is None:
            self.metadata_table.attach(
                Gtk.Label("Unknown file format"), 0, 1, 0, 1)
        else:
            total = 1
            for data in sorted(metadata):
                if not data.values:
                    continue
                title = data.description
                for item in data.values:
                    self.metadata_table.resize(total, 2)
                    value = item.text
                    self.metadata_table.attach(
                        Gtk.Label(title + ":"), 0, 1, total - 1, total)
                    self.metadata_table.attach(
                        Gtk.Label(value), 1, 2, total - 1, total)
                    total += 1
        self.metadata_table.show_all()
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def __init__(self, table_type, source, reference, save_callback_function, save_function,  stats_callback_function, tab_grid, output_directory):
        self.save_callback_function = save_callback_function
        self.stats_callback_function = stats_callback_function
        self.save_function = save_function
        self.table_type = table_type
        self.source = source
        self.reference = reference
        self.tab_grid = tab_grid
        self.output_directory = output_directory

        self.saved_reference_filepath = ""
        self.last_segment_changed = -1
        self._table_initializing()
        self.make_table_interface()
        self.update_table()

        self.modified_references =  []
        self.last_cell_focused = None
        self.last_cell_focused_index = -1

        # Post Editing: Table
        search_frame = Gtk.Frame()
        self.table_scroll_window = Gtk.ScrolledWindow()
        self.table_scroll_window.set_hexpand(True)
        self.table_scroll_window.set_vexpand(True)
        self.table_scroll_window.add(self.table)
        search_frame.add(self.table_scroll_window)
        self.tab_grid.attach(search_frame, 0, 1, 2, 1)

        # Post Editing: Term Search
        table_frame = Gtk.Frame()
        self.search_results_scroll_window = Gtk.ScrolledWindow()
        self.search_results_scroll_window.show()
        term_search_frame = Gtk.Frame(label="Term Search")
        term_search_entry = Gtk.Entry()
        term_search_frame.add(term_search_entry)
        self.tab_grid.add(term_search_frame)
        term_search_entry.connect("changed", self.search_and_mark_wrapper)
        self.search_results_scroll_window.add(self.search_buttons_table)
        table_frame.add(self.search_results_scroll_window)
        self.tab_grid.attach_next_to(table_frame, term_search_frame, Gtk.PositionType.BOTTOM, 2, 1)
项目:MTTT    作者:roxana-lafuente    | 项目源码 | 文件源码
def _table_initializing(self):
        (self.source_text_lines,
        self.unedited_reference_text_lines,
        self.reference_text_lines,
        self.table_index,
        self.source_text_views,
        self.reference_text_views,
        self.bilingual_reference_text_views,
        self.rows_ammount,
        self.get_menu_grid,
        self.initialized) = range(10)
        #source_text_lines,unedited_reference_text_lines, reference_text_lines, table_index, source_text_views, reference_text_views, bilingual_reference_text_views, rows_ammount, get_menu_grid, initialized
        self.tables_content = [[],[],[],0,{},{},{}, 0, None, False]
        self.tables_content[self.rows_ammount] = 5
        self.search_buttons_array = []

        if self.table_type == "translation_table":
            self.translation_reference_text_TextViews_modified_flag = {}
            self.tables_content[self.get_menu_grid] = Gtk.Grid()
            self.tab_grid.add(self.tables_content[self.get_menu_grid])
        elif self.table_type == "diff_table":
            self.tables_content[self.get_menu_grid] = Gtk.Grid()
            self.tab_grid.add(self.tables_content[self.get_menu_grid])
        table = Gtk.Table(1,1, True)
        self.table = table
        self.search_buttons_table = Gtk.Table(1,1, True)

        self.monolingual = True
        self.btn_post_editing_mode = Gtk.Button("Monolingual")
        self.btn_post_editing_mode.connect("clicked", self.toggle_post_editing_mode)
        self.tables_content[self.get_menu_grid].attach(self.btn_post_editing_mode, 2, 2, 30, 3)
        self.btn_post_editing_mode.set_no_show_all(True)
        if not self.source: self.btn_post_editing_mode.hide()
        else: self.btn_post_editing_mode.show()


        self.table.set_col_spacings(5)
        self.table.set_row_spacings(5)
        self.table.set_homogeneous(False)

        return self.table
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, pane):
        SearchAidLogic.__init__(self, pane)
        # gtk box basics
        Gtk.Table.__init__(self)
        self.resize(2, 2)
        self.set_border_width(2 * StockEms.XLARGE)

        # no results (sad face) image
        image = Gtk.Image.new_from_icon_name(self.HEADER_ICON_NAME,
                                             Gtk.IconSize.DIALOG)
        self.attach(image,
                    0, 1,  # left_attach, right_attach
                    0, 1,  # top_attach, bottom_attach
                    Gtk.AttachOptions.SHRINK,
                    Gtk.AttachOptions.SHRINK,
                    StockEms.LARGE, 0)

        # title
        self.title = Gtk.Label()
        self.title.set_use_markup(True)
        self.title.set_alignment(0.0, 0.5)
        self.attach(self.title,
                    1, 2,  # left_attach, right_attach
                    0, 1,  # top_attach, bottom_attach
                    Gtk.AttachOptions.FILL,
                    Gtk.AttachOptions.FILL,
                    StockEms.MEDIUM, 0)

        # suggestion label
        self.suggestion = Suggestions()
        self.suggestion.set_alignment(0.0, 0.5)
        self.attach(self.suggestion,
                    1, 2,  # left_attach, right_attach
                    1, 2,  # top_attach, bottom_attach
                    Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND,
                    Gtk.AttachOptions.FILL,
                    StockEms.MEDIUM, StockEms.MEDIUM)

        self.suggestion.connect("activate-link", self.on_link_activate)
项目:x-mario-center    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, pane):
        SearchAidLogic.__init__(self, pane)
        # gtk box basics
        Gtk.Table.__init__(self)
        self.resize(2, 2)
        self.set_border_width(2 * StockEms.XLARGE)

        # no results (sad face) image
        image = Gtk.Image.new_from_icon_name(self.HEADER_ICON_NAME,
                                             Gtk.IconSize.DIALOG)
        self.attach(image,
                    0, 1,  # left_attach, right_attach
                    0, 1,  # top_attach, bottom_attach
                    Gtk.AttachOptions.SHRINK,
                    Gtk.AttachOptions.SHRINK,
                    StockEms.LARGE, 0)

        # title
        self.title = Gtk.Label()
        self.title.set_use_markup(True)
        self.title.set_alignment(0.0, 0.5)
        self.attach(self.title,
                    1, 2,  # left_attach, right_attach
                    0, 1,  # top_attach, bottom_attach
                    Gtk.AttachOptions.FILL,
                    Gtk.AttachOptions.FILL,
                    StockEms.MEDIUM, 0)

        # suggestion label
        self.suggestion = Suggestions()
        self.suggestion.set_alignment(0.0, 0.5)
        self.attach(self.suggestion,
                    1, 2,  # left_attach, right_attach
                    1, 2,  # top_attach, bottom_attach
                    Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND,
                    Gtk.AttachOptions.FILL,
                    StockEms.MEDIUM, StockEms.MEDIUM)

        self.suggestion.connect("activate-link", self.on_link_activate)
项目:my-weather-indicator    作者:atareao    | 项目源码 | 文件源码
def __init__(self, location, ws, weather):
        Gtk.Dialog.__init__(self, 'my-weather-indicator | ' + _('Forecast'),
                            None, Gtk.DialogFlags.MODAL |
                            Gtk.DialogFlags.DESTROY_WITH_PARENT)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_size_request(200, 200)
        self.connect('destroy', self.close_application)
        self.set_icon_from_file(comun.ICON)
        vbox0 = Gtk.VBox(spacing=5)
        vbox0.set_border_width(5)
        self.get_content_area().add(vbox0)
        label11 = Gtk.Label(label='<b>' + location + '</b>')
        label11.set_markup('<b>' + location + '</b>')
        vbox0.pack_start(label11, True, True, 0)
        frame = Gtk.Frame()
        vbox0.add(frame)
        hbox1 = Gtk.HBox(spacing=5)
        hbox1.set_border_width(5)
        frame.add(hbox1)
        self.ws = ws
        forecast = weather['forecasts']
        self.table = Gtk.Table(rows=9, columns=5, homogeneous=False)
        self.table.set_col_spacings(10)
        self.create_labels()
        if self.ws == 'yahoo':
            total = 2
        if self.ws == 'wunderground':
            total = 4
        else:
            total = 5
        for i in range(0, total):
            self.create_forecast_dor_day(forecast, i)
        hbox1.add(self.table)
        #
        if self.ws == 'yahoo':
            filename = comun.YAHOOLOGO
            web = comun.YAHOOWEB
        elif self.ws == 'worldweatheronline':
            filename = comun.WOLRDWEATHERONLINE
            web = comun.WOLRDWEATHERONLINEWEB
        elif self.ws == 'openweathermap':
            filename = comun.OPENWEATHERMAPLOGO
            web = comun.OPENWEATHERMAPWEB
        elif self.ws == 'wunderground':
            filename = comun.UNDERGROUNDLOGO
            web = comun.UNDERGROUNDWEB
        image = load_image(filename, size=64)
        image.set_alignment(0.5, 0.5)
        button = Gtk.Button()
        button.set_image(image)
        button.connect('clicked', (lambda x: webbrowser.open(web)))
        hbox1.pack_start(button, True, True, 0)
        #
        self.show_all()
        while Gtk.events_pending():
            Gtk.main_iteration()
        self.run()
        self.destroy()
项目:jcchess    作者:johncheetham    | 项目源码 | 文件源码
def rename_engine(self, widget, data=None):

        ts = self.treeview.get_selection()

        # get liststore object/iter
        lso, l_iter = ts.get_selected()
        tm = self.treeview.get_model()

        if l_iter is None:
            gv.gui.info_box(_("no engine selected"))
            return

        name = tm.get_value(l_iter, 0)
        path = tm.get_value(l_iter, 1)

        dialog = Gtk.MessageDialog(
            None,
            Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.QUESTION,
            Gtk.ButtonsType.OK_CANCEL,
            None)

        markup = "<b>" + _("Rename Engine") + "</b>"
        dialog.set_markup(markup)

        # create the text input fields
        entry = Gtk.Entry()
        entry.set_text(name)
        entry.set_max_length(30)
        entry.set_width_chars(30)

        tbl = Gtk.Table(1, 2, True)
        tbl.attach(Gtk.Label(label=_("Engine Name: ")), 0, 1, 0, 1)
        tbl.attach(entry, 1, 2, 0, 1)

        dialog.vbox.add(tbl)

        dialog.show_all()

        # If user hasn't clicked on OK then exit now
        if dialog.run() != Gtk.ResponseType.OK:
            dialog.destroy()
            return

        # user clicked OK so update with the values entered
        newname = entry.get_text()
        lso.set_value(l_iter, 0, newname)
        dialog.destroy()
项目: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)
        t = Gtk.Table()
        self.g_buttons = fill_table(Gtk.Button, t)
        for key, button in self.g_buttons.items():
            button.connect('clicked', self.on_left_click, key)
        self.practise_box.pack_start(t, False, False, 0)
        self.g_flashbar = gu.FlashBar()
        self.g_flashbar.show()
        self.practise_box.pack_start(self.g_flashbar, False, False, 0)
        self.std_buttons_add(
            ('new', self.new_question),
            ('repeat', lambda _o, self=self: self.m_t.play_question()),
            ('give_up', self.give_up))
        self.practise_box.show_all()
        ##############
        # config_box #
        ##############
        self.config_box.set_spacing(gu.hig.SPACE_MEDIUM)
        self.g_random = gu.nCheckButton(self.m_exname, 'random_tonic', _("Random transpose"))
        self.config_box.pack_start(self.g_random, False, False, 0)
        self._add_auto_new_question_gui(self.config_box)
        #
        self.g_tones_category, box = gu.hig_category_vbox(_("Tones"))
        self.config_box.pack_start(self.g_tones_category, False, False, 0)
        self.g_tone_selector = nConfigButtons(self.m_exname, 'tones')
        self.g_tone_selector.show_all()
        box.pack_start(self.g_tone_selector, False, False, 0)
        # Cadences
        self.g_cadences_category, self.g_cadences = gu.hig_category_vbox(_("Cadences"))
        self.g_cadences.show()
        self.config_box.pack_start(self.g_cadences_category, False, False, 0)
        #
        def _ff(var):
            if self.m_t.m_custom_mode:
                # If we are running in custom mode, then the user can
                # select himself what intervals to practise. And then
                # we have to reset the exercise.
                #self.on_end_practise()
                #self.on_start_practise()
                self.cancel_question()
        self.add_watch('tones', _ff)
        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
                                   _("Tone in cadence"))
项目: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)
项目:Solfege    作者:RannyeriDev    | 项目源码 | 文件源码
def __init__(self, statistics):
        Gtk.Frame.__init__(self)
        table = Gtk.Table()
        self.add(table)
        self.boxdict = {}
        self.m_totals = {}
        #       0     1  2    3 4     5 6       7     8
        # 0  -------------------------------------------
        # 1  |        |   Session     |     Today     |
        # 2  |        | Percent Count | Percent Count |
        # 3  +------ ----------------------------------
        # 4  | Total  |  85%  | 13    |
        # 5  +-------------------------
        # 6  | label1 |  100% | 4     |
        #    | label2 |   50% | 5     |
        # 7  +-----------------------------------------
        for k, l, x in (('session', _("Session"), 2), ('today', _("Today"), 5),
                     ('last7', _("Last 7 days"), 8), ('total', _("Total"), 11)):
            table.attach(Gtk.Label(label=l), x, x+2, 0, 1,
                         xpadding=gu.PAD_SMALL, ypadding=gu.PAD_SMALL)
            b = Gtk.VBox(False, 0)
            table.attach(b, x, x+1, 6, 7)
            self.boxdict[k+'percent'] = b
            b = Gtk.VBox(False, 0)
            table.attach(b, x+1, x+2, 6, 7)
            self.boxdict[k+'count'] = b
            l = Gtk.Label()
            table.attach(l, x, x+1, 4, 5)
            self.m_totals[k+'percent'] = l
            l = Gtk.Label()
            table.attach(l, x+1, x+2, 4, 5)
            self.m_totals[k+'count'] = l
        for x in (2, 5, 8, 11):
            table.attach(Gtk.Label(label=_("Percent")), x, x+1, 1, 2,
                         xpadding=gu.PAD_SMALL, ypadding=gu.PAD_SMALL)
            table.attach(Gtk.Label(label=_("Count")), x+1, x+2, 1, 2,
                         xpadding=gu.PAD_SMALL, ypadding=gu.PAD_SMALL)
        l = Gtk.Label(label=_("Total"))
        l.set_alignment(0.0, 0.5)
        table.attach(l, 0, 1, 4, 5, xpadding=gu.PAD_SMALL, ypadding=gu.PAD_SMALL)
        table.attach(Gtk.HSeparator(), 0, 13, 3, 4)
        table.attach(Gtk.HSeparator(), 0, 13, 5, 6)
        table.attach(Gtk.VSeparator(), 1, 2, 0, 7)
        table.attach(Gtk.VSeparator(), 4, 5, 0, 7)
        table.attach(Gtk.VSeparator(), 7, 8, 0, 7)
        table.attach(Gtk.VSeparator(), 10, 11, 0, 7)
        self.boxdict['keys'] = key_box = Gtk.VBox(False, 0)
        table.attach(key_box, 0, 1, 6, 7)
        for key, box in self.boxdict.items():
            box.set_border_width(gu.PAD_SMALL)
        self.update(statistics)
        self.show_all()