当前位置: 首页>>代码示例>>Python>>正文


Python ListStore.append方法代码示例

本文整理汇总了Python中gtk.ListStore.append方法的典型用法代码示例。如果您正苦于以下问题:Python ListStore.append方法的具体用法?Python ListStore.append怎么用?Python ListStore.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gtk.ListStore的用法示例。


在下文中一共展示了ListStore.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: warning_dialog

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class warning_dialog(Dialog):
    def __init__(self, parent, pacs, icon):

        Dialog.__init__(
            self,
            _("Warning!"),
            parent,
            DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
            (STOCK_YES, RESPONSE_YES, STOCK_NO, RESPONSE_REJECT),
        )

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_tree(pacs)
        self._setup_layout()

    def _setup_layout(self):

        self.set_default_size(-1, 250)

        label = Label(
            _(
                "This packages requires one of the packages you've selected for removal.\nDo you want to remove them all?"
            )
        )
        label.show()

        scr = ScrolledWindow()
        scr.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
        scr.add(self.tree)

        self.vbox.pack_start(label, False, False, 0)
        self.vbox.pack_start(scr, True, True, 0)
        self.vbox.show_all()
        return

    def _setup_tree(self, pacs):
        self.tree = TreeView()
        self.model = ListStore(str, str, str)

        self.tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(), stock_id=0)
        self.tree.insert_column_with_attributes(-1, "", CellRendererText(), text=1)
        self.tree.insert_column_with_attributes(-1, "", CellRendererText(), text=2)

        for pac in pacs:
            if pac.isold:
                image = "yellow"
            elif pac.installed:
                image = "green"
            else:
                image = "red"

            self.model.append([image, pac.name, pac.inst_ver])
            continue

        self.tree.set_model(self.model)
        self.tree.show_all()
        return
开发者ID:BackupTheBerlios,项目名称:gtkpacman-svn,代码行数:59,代码来源:dialogs.py

示例2: upgrade_confirm_dialog

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class upgrade_confirm_dialog(Dialog):

    def __init__(self, parent, to_upgrade, icon):

        Dialog.__init__(self, _("Confirm Upgrade"), parent,
                        DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
                        (STOCK_OK, RESPONSE_ACCEPT,
                         STOCK_CANCEL, RESPONSE_REJECT))

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_tree(to_upgrade)
        self._setup_layout()
        
    def _setup_tree(self, pacs):
        self.model = ListStore(str, str, str)

        for pac in pacs:
            self.model.append(["yellow", pac.name, pac.version])
            continue

        self.tree = TreeView()
        self.tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(),
                                                stock_id = 0)
        self.tree.insert_column_with_attributes(-1, "Package",
                                                CellRendererText(), text = 1)
        self.tree.insert_column_with_attributes(-1, "Version",
                                                CellRendererText(), text = 2)

        self.tree.set_model(self.model)
        self.tree.show()

    def _setup_layout(self):

        self.label = Label(_("Are you sure yo want to upgrade those packages?\n"))
        self.label.show()

        self.set_default_size (300, 300)

        scr = ScrolledWindow()
        scr.set_policy("automatic", "automatic")
        scr.add(self.tree)
        scr.show()
        
        self.vbox.pack_start(self.label, False, False, 0)
        self.vbox.pack_start(scr, True, True, 0)

    def run(self):
        retcode = Dialog.run(self)
        self.destroy()

        if retcode == RESPONSE_ACCEPT:
            return True
        else:
            return False
开发者ID:BackupTheBerlios,项目名称:gtkpacman-svn,代码行数:56,代码来源:dialogs.py

示例3: __populate_possible_plugins

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
    def __populate_possible_plugins(self):
        """Populates the GUI with the possible front and backend plugins."""
        
        available_plugin_liststore = ListStore(str)
        for plugin_name in get_available_frontend_plugins():
            available_plugin_liststore.append([plugin_name])
        self.plugin_add_entry_combo.set_model(available_plugin_liststore)
        self.plugin_add_entry_combo.set_text_column(0)

        available_backend_plugin_liststore = ListStore(str)
        for backend_plugin_name in get_available_backend_plugins():
            available_backend_plugin_liststore.append([backend_plugin_name])
        self.backend_plugin_entry_combo.set_model(available_backend_plugin_liststore)
        self.backend_plugin_entry_combo.set_text_column(0)
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:16,代码来源:bokeepdb.py

示例4: MemberFeeCollectionEditor

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class MemberFeeCollectionEditor(object):
    def __init__(self, trans, transid, plugin, gui_parent,
                 change_register_function):
        self.fee_trans = trans
        self.transid = transid
        self.memberfee_plugin = plugin
        self.change_register_function = change_register_function

        load_glade_file_get_widgets_and_connect_signals(
            get_memberfee_glade_file(),
            'window1', self, self)

        self.vbox1.reparent(gui_parent)
        self.window1.hide()

        self.fee_spread_liststore = ListStore(str, str)
        self.fee_spread_list.set_model(self.fee_spread_liststore)
        column_one = TreeViewColumn('Date')
        column_two = TreeViewColumn('Amount')
        self.fee_spread_list.append_column(column_one)
        self.fee_spread_list.append_column(column_two)
        for i, column in enumerate((column_one, column_two)):
            cell = CellRendererText()
            column.pack_start(cell, False)
            column.add_attribute(cell, 'text', i)
        self.populate_fee_spread_liststore()

        
    def populate_fee_spread_liststore(self):
        self.fee_spread_liststore.clear()
        for month in gen_n_months_starting_from(first_of(date.today()), 4):
            self.fee_spread_liststore.append((month, '10'))

    def detach(self):
        self.vbox1.reparent(self.window1)

    def day_changed(self, *args):
        print('day_changed')

    def amount_collected_changed(self, *args):
        print('amount_collected_changed')

    def member_changed(self, *args):
        print('member_changed')
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:46,代码来源:plugin.py

示例5: HttpHandler

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class HttpHandler(object):
    """Has callbacks that are invoked by the event system.

    It only accepts packets if:
        * They are HTTP requests
        * send or received by the IP given. If none is given, every
          IP is accepted.
    
    Subclass and overwrite handle for great good."""
    def __init__(self, ip = None):
        self.ip = ip
        self.gtk_list_store = ListStore(str, str)

    def accept(self, pkg):
        logger.debug("Accepting? %s", pkg.summary())
        if not pkg.haslayer(TCP): return False
        tcp_pkg = pkg[TCP]
        if not (tcp_pkg.dport == 80 or tcp_pkg.sport == 80): return False
        if isinstance(tcp_pkg.payload, NoPayload): return False
        if not GET.match(str(tcp_pkg.payload)): return False
        if self.ip is not None: 
            return pkg[IP].src == self.ip or pkg[IP].dst == self.ip
        else:
            return True
    def handle(self, pkg):
        self.print(pkg)

    def print(self, pkg):
        logger.debug("got a package %s to print", pkg.summary())
        time = datetime.fromtimestamp(pkg.time)
        logger.debug("initially at time={}".format(time))
        tcp_pkg = pkg[TCP]
        server_name = reverse_dns(pkg[IP].dst)
        match = GET.match(str(tcp_pkg.payload))
        try:
            entry = "http://{}{}".format(str(server_name.result(5.0)), match.group(1))
        except TimeoutError:
            entry = "http://{}{}".format(str(pkg[IP].dst), match.group(1))
        logger.info(entry)
        self.gtk_list_store.append([str(time), entry])
开发者ID:panmari,项目名称:moco-project,代码行数:42,代码来源:reader.py

示例6: create_prop_store

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
 def create_prop_store(self, extra_props=[]):
     assert(self.component is not None)
     from gtk import ListStore
     store = ListStore(object, str, object)
     # use private properties so we connect to the actual object stores and not the inherited ones
     for atom in self.component._layer_atoms:
         store.append([atom, "pn", lambda o: o.name])
     for atom in self.component._interlayer_atoms:
         store.append([atom, "pn", lambda o: o.name])
     for prop in extra_props:
         store.append(prop)
     return store
开发者ID:claudioquaglia,项目名称:PyXRD,代码行数:14,代码来源:unit_cell_prop.py

示例7: upgrade_dialog

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class upgrade_dialog(Window):

    def __init__(self, to_upgrade, icon):

        Window.__init__(self, WINDOW_TOPLEVEL)
        self.set_property("skip-taskbar-hint", True)
        self.set_property("modal", True)
        self.set_property("destroy-with-parent", True)
        self.set_position(WIN_POS_CENTER)
        self.set_default_size (300, 300)

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_tree(to_upgrade)
        self._setup_layout()

    def _setup_layout(self):
        self.vbox = VBox(False, 0)
        self.vbox.show()

        self.terminal = terminal()
        self.terminal.connect("child-exited", lambda _: self.close_button.show())
        
        self.expander = expander_new_with_mnemonic(_("_Terminal"))
        self.expander.set_expanded(False)
        self.expander.add(self.terminal)
        self.expander.show_all()
        
        self.close_button = Button(stock=STOCK_CLOSE)
        self.close_button.connect("clicked", lambda _: self.destroy())

        scr = ScrolledWindow()
        scr.set_policy ("automatic", "automatic")
        scr.add (self.tree)
        scr.show()

        vpaned = VPaned()
        vpaned.add1(scr)
        vpaned.add2(self.expander)
        vpaned.set_position (260)
        vpaned.show()

        self.vbox.pack_start(vpaned, True, True, 0)
        self.vbox.pack_start(self.close_button, False, False, 0)

        self.add(self.vbox)
        return

    def _setup_tree(self, pacs):
        self.model = ListStore(str, str, str)

        for pac in pacs:
            self.model.append(["yellow", pac.name, pac.version])
            continue

        self.tree = TreeView()
        self.tree.show()

        self.tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(),
                                                stock_id = 0)
        self.tree.insert_column_with_attributes(-1, "Package",
                                                CellRendererText(), text = 1)
        self.tree.insert_column_with_attributes(-1, "Version",
                                                CellRendererText(), text = 2)

        self.tree.set_model(self.model)
        return
    
    def run(self):
        self.show()
        self.terminal.do_upgrade()
开发者ID:BackupTheBerlios,项目名称:gtkpacman-svn,代码行数:72,代码来源:dialogs.py

示例8: do_dialog

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class do_dialog(Window):

    def __init__(self, queues, icon):

        Window.__init__(self, WINDOW_TOPLEVEL)
        self.set_property("skip-taskbar-hint", True)
        self.set_property("destroy-with-parent", True)
        self.set_modal(True)
        self.connect("delete-event", self._stop_closing)
        self.set_position(WIN_POS_CENTER)

        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_trees(queues)
        self._setup_layout()

        self.queues = queues

    def _setup_trees(self, queues):

        self._setup_install_tree(queues["add"])
        self._setup_remove_tree(queues["remove"])

    def _setup_install_tree(self, add_queue):

        self.inst_model = ListStore(str, str, str)

        for pac in add_queue:
            if pac.isold:
                image = "yellow"
            elif pac.installed:
                image = "green"
            else:
                image = "red"

            self.inst_model.append([image, pac.name, pac.version])
            continue

        self.inst_tree = TreeView()

        self.inst_tree.insert_column_with_attributes(-1, "",
                                                     CellRendererPixbuf(),
                                                     stock_id = 0)
        self.inst_tree.insert_column_with_attributes(-1, _("Package"),
                                                     CellRendererText(),
                                                     text = 1)
        self.inst_tree.insert_column_with_attributes(-1, _("Version"),
                                                     CellRendererText(),
                                                     text = 2)
        self.inst_tree.set_model(self.inst_model)

    def _setup_remove_tree(self, remove_queue):

        self.rem_model = ListStore(str, str, str)

        for pac in remove_queue:
            if pac.isold:
                image = "yellow"
            elif pac.installed:
                image = "green"
            else:
                image = "red"

            self.rem_model.append([image, pac.name, pac.inst_ver])
            continue

        self.rem_tree = TreeView()

        self.rem_tree.insert_column_with_attributes(-1, "",
                                                    CellRendererPixbuf(),
                                                    stock_id = 0)
        self.rem_tree.insert_column_with_attributes(-1, _("Package"),
                                                    CellRendererText(),
                                                    text = 1)
        self.rem_tree.insert_column_with_attributes(-1, _("Installed Version"),
                                                    CellRendererText(),
                                                    text = 2)

        self.rem_tree.set_model(self.rem_model)

    def _set_size (self, widget, event, data=None):
        if self.expander.get_expanded():
            self.size = self.get_size()
            self.expander.add(self.terminal)
            self.terminal.show()
        else:
            self.expander.remove(self.terminal)
            self.resize(self.size[0], self.size[1])
            self.show_all()

    def _setup_layout(self):

        self.hpaned = HPaned()
        self.hpaned.add1(self.inst_tree)
        self.hpaned.add2(self.rem_tree)
        self.hpaned.show_all()

        self.close_button = Button(stock=STOCK_CLOSE)
        self.close_button.connect("clicked", lambda _: self.destroy())

        self.terminal = terminal()
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:gtkpacman-svn,代码行数:103,代码来源:dialogs.py

示例9: __on_plugin_directories_button_click

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
 def __on_plugin_directories_button_click(self, button):
     """Present a dialog to the user for selecting extra plugin directories
     and process the request."""
     
     dia = Dialog('Plugin Directories',
          None, DIALOG_MODAL,
          (STOCK_OK, RESPONSE_OK,
          STOCK_CANCEL, RESPONSE_CANCEL ) )
     dia.resize(500, 300)
     dia.vbox.set_spacing(8)
     
     # Setup the tree view of plugin directories.
     model = ListStore(str) # each row contains a single string
     tv = TreeView(model)
     cell = CellRendererText()
     column = TreeViewColumn('Directory', cell, text = 0)
     tv.append_column(column)
     dia.vbox.pack_start(tv)
     
     # Populate the tree view.
     plugin_directories = \
         get_plugins_directories_from_config(self.config, self.config_path)
     for plugin_directory in plugin_directories:
         row = (plugin_directory,)
         model.append(row)
     
     modify_box = HBox(spacing = 8)
     
     # Setup the remove directory button.
     remove_button = Button('Remove')
     remove_button.set_sensitive(False) # no directory selected initially
     remove_button.connect('clicked', self.__on_remove, tv)
     modify_box.pack_end(remove_button, expand = False)
     
     tv.connect('cursor-changed', self.__on_select, remove_button)
     
     # Setup the add directory button.
     add_button = Button('Add')
     add_button.connect('clicked', self.__on_add, tv)
     modify_box.pack_end(add_button, expand = False)
     
     dia.vbox.pack_start(modify_box, expand = False)
     
     # Setup the "already included directories" label.
     included_label = Label('Plugins in the PYTHONPATH are already ' +
                            'available to BoKeep.')
     # Use a horizontal box to left-justify the label.  For some reason,
     # the label's set_justification property doesn't work for me.
     label_box = HBox()
     label_box.pack_start(included_label, expand = False)
     dia.vbox.pack_start(label_box, expand = False)
     
     dia.show_all()
     dia_result = dia.run()
     
     if dia_result == RESPONSE_OK:            
         # Remove the old plugin directories from the program's path.
         plugin_directories = \
             get_plugins_directories_from_config(self.config,
                                                 self.config_path)
         for plugin_directory in plugin_directories:
             path.remove(plugin_directory)
         
         # Get the new plugin directories from the dialog.
         plugin_directories = []
         for row in model:
             plugin_directory = row[0]
             plugin_directories.append(plugin_directory)
         
         # Update the BoKeep PYTHONPATH so that new plugins can be loaded and
         # populate the list of possible new plugins.
         for plugin_directory in plugin_directories:
             path.append(plugin_directory)
         self.__populate_possible_plugins()
         
         # Save the new plugin directories in the configuration file.
         set_plugin_directories_in_config(self.config,
             self.config_path, plugin_directories)
     
     dia.destroy()
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:82,代码来源:bokeepdb.py

示例10: InputWidget

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]

#.........这里部分代码省略.........
                        ('p', self.areas["pronunciation"])]
            },
            Cloze.id: {
            "page": 2,
            "selector": get_widget("cloze_mode_selector_w"),
            "widgets": [('text', self.areas["cloze"])]
            }
        }
        # add card_type to selectors subdict
        for card_type in self.card_types():
            self.selectors[card_type.id]["card_type"] = card_type

        # create {selector_widget:card_type.id} dict
        self.widget_card_id = dict((self.selectors[id]["selector"], id) \
            for id in self.selectors.keys())

        self.set_card_type(get_widget("front_to_back_mode_selector_w"))
        self.compose_widgets()

        # Turn off hildon autocapitalization
        try:
            for widget in self.areas.values():
                widget.set_property("hildon-input-mode", 'full')
        # stock gtk doesn't have hildon properties
        except (TypeError, AttributeError): 
            pass # so, skip silently

    def connect_signals(self, control):
        """Connect signals to widgets and save connection info."""

        for wname, signal, callback in control:
            widget = self.get_widget(wname)
            cid = widget.connect(signal, callback)
            self.connections.append((widget, cid))

    def disconnect_signals(self):
        """Disconnect previously connected signals."""

        for widget, cid in self.connections:
            widget.disconnect(cid)
        self.connections = []

    def show_snd_container(self):
        """Show or hide snd container. """
                    
        start, end = self.areas["question"].get_buffer().get_bounds()
        text = self.areas["question"].get_buffer().get_text(start, end)
        if "sound src=" in text:
            self.widgets["QuestionContainer"].hide()
            self.widgets["SoundContainer"].show()
        else:
            self.widgets["QuestionContainer"].show()
            self.widgets["SoundContainer"].hide()

    def compose_widgets (self):
        """Switch to neccessary input page. It depends on card_type."""

        self.widgets["CardTypeSwithcer"].set_current_page( \
            self.selectors[self.card_type.id]["page"])
        self.selectors[self.card_type.id]["selector"].set_active(True)
        state = self.card_type.id in (FrontToBack.id)
        self.widgets["PictureButton"].set_sensitive(state)
        self.widgets["SoundButton"].set_sensitive(state)

    def set_card_type(self, widget):
        """Set current card type."""
开发者ID:axelson,项目名称:pomni,代码行数:70,代码来源:input.py

示例11: trustor_transactions

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class trustor_transactions(object):
    def __init__(self, trust_module, trustor, trust_manager):
        self.trust_module = trust_module
        self.trustor = trustor
        self.trust_manager = trust_manager

        self.init()
        self.extended_init()
        parent_window = trust_manager.top_window
        self.top_window.set_transient_for(parent_window)
        self.top_window.set_modal(True)

    def construct_filename(self, filename):
        import trustor_management as trust_module
        return join( dirname( abspath( trust_module.__file__ ) ),
                              filename)

    def get_tran_type(self, transaction):
        if isinstance(transaction, TrustMoneyInTransaction):
            return 'In'
        elif isinstance(transaction, TrustMoneyOutTransaction):
            return 'Out'
        else:
            return 'unknown'

    def extended_init(self):
        self.widgets['name_entry'].set_text(self.trustor.name)
        self.widgets['name_entry'].connect('changed', self.on_name_entry_changed)
        
        self.widgets['dyn_balance'].set_text(str(self.trustor.get_balance()))
        
        self.transactions_view = self.widgets['transactions_view']

        self.transactions_list = ListStore( str, str, str )
        self.transactions_view.set_model(self.transactions_list)


        for i, title in enumerate(('Date', 'Type', 'Balance')):
            self.transactions_view.append_column(
                TreeViewColumn(title,CellRendererText(), text=i ) )

        for transaction in self.trustor.transactions:
            self.transactions_list.append([transaction.trans_date.strftime("%B %d, %Y, %H:%M"), self.get_tran_type(transaction), str(transaction.get_transfer_amount())])



    def init(self):

        filename = 'data/trustor_transactions.glade'
        top_window = 'window1'
        do_OldGladeWindowStyleConnect(
            self, self.construct_filename(filename), top_window)

    def generate_transaction_report(self, filename):
        report_file = open(filename, 'w')
        now = datetime.today()
        nowstring = now.strftime("%B %d, %Y, %H:%M")
        report_file.write("Trustor transaction report for " + self.trustor.name + " as at " + nowstring + "\n\n")

        for transaction in self.trustor.transactions:
            report_file.write(transaction.trans_date.strftime("%B %d, %Y, %H:%M") + ' ' + self.get_tran_type(transaction) + ' ' + str(transaction.get_transfer_amount()) + '\n')

        report_file.write('\ncurrent balance: ' + str(self.trustor.get_balance()) + '\n')
        report_file.close()
        
    def on_name_entry_changed(self, *args):
        current_name = self.trustor.name
        new_name = self.widgets['name_entry'].get_text()
        save_button = self.widgets['save_button']
        if current_name != new_name and new_name != '':
            save_button.set_sensitive(True)
        else:
            save_button.set_sensitive(False)

    def on_report_button_clicked(self, *args):
        fcd = gtk.FileChooserDialog(
            "Choose report file and location",
            None,
            gtk.FILE_CHOOSER_ACTION_SAVE,
            (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
             gtk.STOCK_SAVE, gtk.RESPONSE_OK) )
        fcd.set_modal(True)
        result = fcd.run()
        file_path = fcd.get_filename()
        fcd.destroy()
        if result == gtk.RESPONSE_OK and file_path != None:
            self.generate_transaction_report(file_path)
    
    def on_save_button_clicked(self, *args):
        #we're updating the name of someone who already exists
        current_name = self.trustor.name
        new_name = self.widgets['name_entry'].get_text()
        self.trust_module.rename_trustor(current_name, new_name)
        
        # refresh view
        self.trust_manager.refresh_trustor_list()
        self.widgets['save_button'].set_sensitive(False)
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:99,代码来源:trustor_transactions.py

示例12: create_editable_type_defined_listview_and_model

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
def create_editable_type_defined_listview_and_model(
    field_list, new_row_func, parralell_list, change_register,
    readonly=False,
    insert_pre_hook=null_function, insert_post_hook=null_function,
    change_pre_hook=null_function, change_post_hook=null_function,
    del_pre_hook=null_function, del_post_hook=null_function):
    vbox = VBox()
    tv = TreeView()
    model = ListStore( * chain((display_fieldtype_transform(fieldtype)
                                for fieldname, fieldtype in field_list),
                               (store_fieldtype_transform(fieldtype)
                                for fieldname, fieldtype in field_list)
                               ) # chain
                         ) # ListStore
    # it is important to do this fill of the liststore
    # with the existing items first prior to adding event handlers
    # (row-changed, row-inserted, row-deleted) that
    # look for changes and keep the two lists in sync
    for list_row in parralell_list:
        model.append(
            tuple(transform_list_row_into_twice_repeated_row_for_model(
                    list_row, field_list) )
            ) # append
    if not readonly:
        model.connect("row-changed",
                      row_changed_handler,
                      parralell_list, change_register, field_list,
                      change_pre_hook, change_post_hook,
                      )
        model.connect("row-inserted",
                      row_inserted_handler,
                      parralell_list, change_register,
                      insert_pre_hook, insert_post_hook )
        model.connect("row-deleted",
                      row_deleted_handler, parralell_list, change_register,
                      del_pre_hook, del_post_hook)

    for i, (fieldname, fieldtype) in enumerate(field_list):
        def setup_edited_handler_for_renderer_to_original_model(cell_renderer):
            cell_renderer.connect(
                'edited',
                cell_edited_update_original_modelhandler, model, i,
                field_list[i][FIELD_TYPE])
            return cell_renderer

        if fieldtype == date:
            cell_renderer = \
                setup_edited_handler_for_renderer_to_original_model(
                CellRendererDate() )
        elif type(fieldtype) == tuple:
            cell_renderer = CellRendererCombo()
            cell_renderer.set_property("has-entry",
                                       fieldtype[COMBO_TYPE_HAS_ENTRY_FIELD])
            combo_liststore = ListStore(
                str, store_fieldtype_transform(fieldtype) )
            for combo_string, combo_value in \
                    combobox_list_strings_and_values_iteration(fieldtype):
                combo_liststore.append( (combo_string, combo_value) )
            cell_renderer.set_property("model", combo_liststore)
            cell_renderer.set_property("text-column", 0)
            if fieldtype[COMBO_TYPE_HAS_ENTRY_FIELD]:
                setup_edited_handler_for_renderer_to_original_model(
                    cell_renderer)
            else:
                lookup_dict = dict(
                    combobox_list_strings_and_values_iteration(fieldtype) )
                cell_renderer.connect(
                'edited',
                combo_cell_edited_update_original_modelhandler, model, i,
                lookup_dict)

        elif type(fieldtype) == dict and fieldtype['type'] == file:
            cell_renderer = CellRendererFile(
                fieldtype['file_type']  if 'file_type' in fieldtype
                else FILE_CHOOSER_ACTION_OPEN 
                )
            setup_edited_handler_for_renderer_to_original_model(cell_renderer)
        else:
            cell_renderer = \
                setup_edited_handler_for_renderer_to_original_model(
                CellRendererText() )
        if not readonly:
            cell_renderer.set_property("editable", True)
            cell_renderer.set_property("editable-set", True)
        tvc = TreeViewColumn(fieldname, cell_renderer, text=i)
        tv.append_column(tvc)
    vbox.pack_start(tv)
    tv.set_model(model)
    hbox = HBox()
    buttons = [ pack_in_stock_but_and_ret(start_stock_button(code), hbox)
                for code in (STOCK_ADD, STOCK_DELETE) ]
    if readonly: 
        for button in buttons:
            button.set_property("sensitive", False)
    else:
        buttons[0].connect(
            "clicked",
            editable_listview_add_button_clicked_handler,
            model, new_row_func, field_list  )
        buttons[1].connect(
#.........这里部分代码省略.........
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:103,代码来源:gtkutil.py

示例13: trustor_management

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class trustor_management(object):
    def __init__(self, trust_module, parent_window, backend_account_fetch):
        self.backend_account_fetch = backend_account_fetch
        self.trust_module = trust_module
        self.trustors = self.trust_module.get_trustors()
        self.current_name = None

        self.init()
        if parent_window != None:
            self.top_window.set_transient_for(parent_window)
            self.top_window.set_modal(True)

        self.extended_init()
        if hasattr(self.trust_module, 'trust_liability_account_str'):
            self.widgets['trust_liability_account_label'].set_text(
                self.trust_module.trust_liability_account_str)
        if hasattr(self.trust_module, 'cash_account_str'):
            self.widgets['cash_account_label'].set_text(
                self.trust_module.cash_account_str )
        self.widgets['currency_text_entry'].set_text(
            self.trust_module.get_currency() )
        
        self.widgets['TrustManagement'].run()
        self.widgets['TrustManagement'].destroy()
        
    def construct_filename(self, filename):
        import trustor_management as trust_module
        return join( dirname( abspath( trust_module.__file__ ) ),
                              filename)
    def reset_view(self):
        if self.trustor_view.get_column(0) == None:
            #no columns to remove
            return
        while self.trustor_view.remove_column(self.trustor_view.get_column(0)) > 0:
            pass

    def refresh_trustor_list(self):
        
        self.reset_view()

        self.trustor_list = ListStore( str, str )
        self.trustor_view.set_model(self.trustor_list)


        for i, title in enumerate(('Trustor', 'Balance')):
            self.trustor_view.append_column(
                TreeViewColumn(title,CellRendererText(), text=i ) )

        for trustor in self.trustors:
            self.trustor_list.append([trustor, str(self.trustors[trustor].get_balance())])

    def extended_init(self):
        
        self.trustor_view = self.widgets['trustor_view']

        self.refresh_trustor_list()

    def init(self):
        filename = 'data/trustor_management.glade'
        top_window = 'TrustManagement'
        do_OldGladeWindowStyleConnect(
            self, self.construct_filename(filename), top_window)

    def on_add_button_clicked(self, *args):
        # Ask the user for a new trustor's name.
        md = MessageDialog(parent = self.top_window,
                           type = MESSAGE_QUESTION,
                           buttons = BUTTONS_OK_CANCEL,
                           message_format = "What's the new trustor's name?")
        vbox = md.get_child()
        name_entry = Entry()
        vbox.pack_end(name_entry)
        vbox.show_all()
        r = md.run()
        new_trustor_name = name_entry.get_text()
        md.destroy() # destroys embedded widgets too
        
        # Save the new trustor.
        if r == RESPONSE_OK and new_trustor_name != '':
            self.current_name = new_trustor_name
            self.trust_module.add_trustor_by_name(new_trustor_name)
            transaction.get().commit()
            self.refresh_trustor_list()

    def on_remove_button_clicked(self, *args):
        trustor = self.trust_module.get_trustor(self.current_name)

        if len(trustor.transactions) > 0:
            cantDeleteDia = MessageDialog(
                flags = DIALOG_MODAL,
                message_format = 'Cannot delete, trustor has associated transacactions.',
                buttons = BUTTONS_OK)
            cantDeleteDia.run()
            cantDeleteDia.hide()
        else:            
            self.trust_module.drop_trustor_by_name(self.current_name)
            transaction.get().commit()
            
            # Update the view.
            self.widgets['remove_button'].set_sensitive(False)
#.........这里部分代码省略.........
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:103,代码来源:trustor_management.py

示例14: MainWindow

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class MainWindow(object):
    """Represents the main window for the default BoKeep shell.

    This class has a lot of imperitive/procedural code with plenty of side
    effects, and the cost of them has started to show in subtle bugs.
    It would be a lost worse if the state machine BoKeepGuiState wasn't used.
    Could be a lot better if an even higher level state machine or something
    a lot more functional and a lot less imperitive were used.

    Oh well, in the meantime, here's a depth call graph with a little pseudo-
    code of the most intertangled functions from this module and major calls to
    other modules that alter the state of the interface.
    
    This is done starting from most significant entry points into this
    class's code.
    Please keep it up to date and also try to reflect the interdependencies
    in the in per function docstrings.
    
    This is pretty much the only way one can get a big picture overview of
    how much of the code here is interrelated

    __init__ (called by shell_startup prior to gtk.main() )
      build_gui
        set_sensitivities_and_status
          set_backend_error_indicator
          set_transid_label

    startup_event_handler (first thing called by gtk.main() )
      after_background_load
        if no book selected and at least one available
           guistate.do_action(BOOK_CHANGE, first book)
        else if a book selected matches one that exists
           guistate.do_action(RESET)
        else if no book selected that matches, or none even available
             guistate.do_action(BOOK_CHANGE, None)

        books_combobox_model.append
        books_combobox.set_active
        if a current book in the combo can not be determined
          set_book_from_combo
              guistate.do_action(BOOK_CHANGE, current_book_selected)
        refresh_trans_types_and_set_sensitivities_and_status
          refresh_trans_types
            trans_type_model.clear
            trans_type_model.append
            if a transaction type was found matching current
              set_transcombo_index
              reset_trans_view
                self.hide_transaction
                self.current_editor set with new editor instance  
            else no transaction type found
              hide_transaction
          END refresh_trans_types as called by..
               refresh_trans_types_and_set_sensitivities_and_status
          set_sensitivities_and_status
            set_backend_error_indicator
            set_transid_label
        END refresh_trans_types_and_set_sensitivities_and_status
             as called by after_background_load
      END after_background_load as called by startup_event_handler
    END startup_event_handler
    
    on_books_combobox_changed (called by gtk gui thread when book combo changed)
      set_book_from_combo
        guistate.do_action(BOOK_CHANGE, newly selected book)
      refresh_trans_types_and_set_sensitivities_and_status
        refresh_trans_types
          trans_type_model.clear
          trans_type_model.append
          if a transaction type was found matching current
            set_transcombo_index
            reset_trans_view
              self.hide_transaction
              self.current_editor set with new editor instance  
          else no transaction type found
            hide_transaction
        END refresh_trans_types as called by..
             refresh_trans_types_and_set_sensitivities_and_status
        set_sensitivities_and_status
          set_backend_error_indicator
          set_transid_label
      END refresh_trans_types_and_set_sensitivities_and_status as 
           called by on_books_combobox_changed
    END on_books_combobox_changed

    new_button_clicked (called by gtk gui thread when new button clicked)
      guistate.do_action(NEW)
      set_trans_type_combo_to_current_and_reset_view
        set_transcombo_index
        reset_trans_view
          self.hide_transaction
          self.current_editor set with new editor instance
      set_sensitivities_and_status
        set_backend_error_indicator
        set_transid_label

    delete_button_clicked (called by gtk gui thread when delete button
                             clicked)
      guistate.do_action(DELETE)
         if there is no transaction left
#.........这里部分代码省略.........
开发者ID:paritworkercoop,项目名称:bokeep-mirror,代码行数:103,代码来源:mainwindow.py

示例15: PeersTab

# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import append [as 别名]
class PeersTab(Tab):
    def __init__(self):
        super(PeersTab, self).__init__('Peers', 'peers_tab', 'peers_tab_label')

        self.peer_menu = self.main_builder.get_object('menu_peer_tab')
        component.get('MainWindow').connect_signals(self)

        self.listview = self.main_builder.get_object('peers_listview')
        self.listview.props.has_tooltip = True
        self.listview.connect('button-press-event', self._on_button_press_event)
        self.listview.connect('query-tooltip', self._on_query_tooltip)

        # flag, ip, client, downspd, upspd, country code, int_ip, seed/peer icon, progress
        self.liststore = ListStore(Pixbuf, str, str, int, int, str, float, Pixbuf, float)
        self.cached_flag_pixbufs = {}

        self.seed_pixbuf = icon_seeding
        self.peer_pixbuf = icon_downloading

        # key is ip address, item is row iter
        self.peers = {}

        # Country column
        column = TreeViewColumn()
        render = CellRendererPixbuf()
        column.pack_start(render, False)
        column.add_attribute(render, 'pixbuf', 0)
        column.set_sort_column_id(5)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(20)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Address column
        column = TreeViewColumn(_('Address'))
        render = CellRendererPixbuf()
        column.pack_start(render, False)
        column.add_attribute(render, 'pixbuf', 7)
        render = CellRendererText()
        column.pack_start(render, False)
        column.add_attribute(render, 'text', 1)
        column.set_sort_column_id(6)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(100)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Client column
        column = TreeViewColumn(_('Client'))
        render = CellRendererText()
        column.pack_start(render, False)
        column.add_attribute(render, 'text', 2)
        column.set_sort_column_id(2)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(100)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Progress column
        column = TreeViewColumn(_('Progress'))
        render = CellRendererProgress()
        column.pack_start(render, True)
        column.set_cell_data_func(render, cell_data_peer_progress, 8)
        column.set_sort_column_id(8)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(100)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Down Speed column
        column = TreeViewColumn(_('Down Speed'))
        render = CellRendererText()
        column.pack_start(render, False)
        column.set_cell_data_func(render, cell_data_speed_down, 3)
        column.set_sort_column_id(3)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(50)
        column.set_reorderable(True)
        self.listview.append_column(column)

        # Up Speed column
        column = TreeViewColumn(_('Up Speed'))
        render = CellRendererText()
        column.pack_start(render, False)
        column.set_cell_data_func(render, cell_data_speed_up, 4)
        column.set_sort_column_id(4)
        column.set_clickable(True)
        column.set_resizable(True)
        column.set_expand(False)
        column.set_min_width(50)
#.........这里部分代码省略.........
开发者ID:deluge-torrent,项目名称:deluge,代码行数:103,代码来源:peers_tab.py


注:本文中的gtk.ListStore.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。