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


Python View.connect方法代码示例

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


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

示例1: Reader

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import connect [as 别名]
class Reader (Gtk.Window, GObject.GObject):
    """

    """
    __gsignals__ = {
        "loaded" : (
            GObject.SignalFlags.RUN_FIRST,
            None,
            ()),
        "next-article" : (
            GObject.SignalFlags.RUN_FIRST,
            None,
            ()),
        "previous-article" : (
            GObject.SignalFlags.RUN_FIRST,
            None,
            ()),
        "next-feed" : (
            GObject.SignalFlags.RUN_FIRST,
            None,
            ()),
        "previous-feed" : (
            GObject.SignalFlags.RUN_FIRST,
            None,
            ()),
        "no-engine" : (
            GObject.SignalFlags.RUN_FIRST,
            None,
            ()),
        }

    def __repr__(self):
        return "Reader"
    def __init__(self):
        Gtk.Window.__init__(self)
        GObject.GObject.__init__(self)
        GObject.type_register(Reader)
        self.log = Logger("reader.log", "BRss-Reader")
        self.settings = Gio.Settings.new(BASE_KEY)
        self.settings.connect("changed::show-status", self.__toggle_status)

        # ui elements
        self.tree = Tree(self.log)
        self.ilist = ArticleList(self.log)
        self.ilist.set_property("height-request", 250)
        self.view = View(self.log)
        self.status = Status()
        # layout
        self.__layout_ui()
        #signals
        self.__connect_signals()
        self.__get_engine()
        # ready to go
        self.emit('loaded')

    def __check_engine(self):
        bus = dbus.SessionBus()
        try:
            engine = bus.get_object(ENGINE_DBUS_KEY, ENGINE_DBUS_PATH)
        except:
            return False
        return engine

    def __get_engine(self):
        self.engine = self.__check_engine()
        if not self.engine:
            self.log.critical("{0}: Couldn't get a DBus connection; quitting.".format(self))
            self.alert.error(_("Could not connect to Engine"),
                _("BRss will now quit.\nPlease make sure that the engine is running and restart the application"))
            self.quit()
        self.create              = self.engine.get_dbus_method('create', ENGINE_DBUS_KEY)
        self.edit                = self.engine.get_dbus_method('edit', ENGINE_DBUS_KEY)
        self.update              = self.engine.get_dbus_method('update', ENGINE_DBUS_KEY)
        self.delete              = self.engine.get_dbus_method('delete', ENGINE_DBUS_KEY)
        self.get_menu_items      = self.engine.get_dbus_method('get_menu_items', ENGINE_DBUS_KEY)
        self.get_articles_for    = self.engine.get_dbus_method('get_articles_for', ENGINE_DBUS_KEY)
        self.search_for          = self.engine.get_dbus_method('search_for', ENGINE_DBUS_KEY)
        self.get_article         = self.engine.get_dbus_method('get_article', ENGINE_DBUS_KEY)
        self.toggle_starred      = self.engine.get_dbus_method('toggle_starred', ENGINE_DBUS_KEY)
        self.toggle_read         = self.engine.get_dbus_method('toggle_read', ENGINE_DBUS_KEY)
        self.stop_update         = self.engine.get_dbus_method('stop_update', ENGINE_DBUS_KEY)
        self.count_special       = self.engine.get_dbus_method('count_special', ENGINE_DBUS_KEY)
        self.get_configs         = self.engine.get_dbus_method('get_configs', ENGINE_DBUS_KEY)
        self.set_configs         = self.engine.get_dbus_method('set_configs', ENGINE_DBUS_KEY)
        self.import_opml         = self.engine.get_dbus_method('import_opml', ENGINE_DBUS_KEY)
        self.export_opml         = self.engine.get_dbus_method('export_opml', ENGINE_DBUS_KEY)
        self.rag.set_visible(False)
        self.ag.set_visible(True)
        self.__connect_engine_signals()
        self.log.debug(_("{0}: Connected to feed engine {1}".format(self, self.engine)))
    def __create_menu(self):
        ui_string = """<ui>
                   <menubar name='Menubar'>
                    <menu action='FeedMenu'>
                     <menuitem action='New feed'/>
                     <menuitem action='New category'/>
                     <menuitem action='Delete'/>
                     <separator/>
                     <menuitem action='Import feeds'/>
                     <menuitem action='Export feeds'/>
#.........这里部分代码省略.........
开发者ID:bidossessi,项目名称:brss,代码行数:103,代码来源:reader.py

示例2: CollabEdit

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import connect [as 别名]
class CollabEdit(Gtk.VBox):

    __gsignals__ = {
        "insert-char": (GObject.SIGNAL_RUN_FIRST, None, [int, int]),
        "cursor-position-changed": (GObject.SIGNAL_RUN_FIRST, None, [int])
    }

    def __init__(self, activity):
        Gtk.VBox.__init__(self)

        self.collab = CollabWrapper(activity)
        self.collab.connect('message', self.__message_cb)
        self.collab.connect('joined', self.__joined_cb)

        self.view = View()
        self.view.connect("insert-char", self.__insert_char_cb)
        self.view.connect("cursor-position-changed", self.__cursor_position_changed_cb)
        self.view.connect("tag-applied", self.__tag_applied_cb)
        self.view.connect("tag-removed", self.__tag_removed_cb)
        self.pack_start(self.view, True, True, 0)

    def __message_cb(self, collab, buddy, msg):
        action = msg.get("action")
        if action is None:
            return

        elif action == "insert":
            self.view.insert_at_position(msg.get("key"), msg.get("position"))

        elif action == "curosr_moved":
            self.view.draw_other_cursor(msg.get("id"), msg.get("position"))

        elif action == "insert_tag":
            self.view.insert_tag(msg.get("tag"), msg.get("start"), msg.get("end"))

        elif action == "remove_tag":
            self.view.remove_tag(msg.get("tag"), msg.get("start"), msg.get("end"))

    def __joined_cb(self, sender):
        if self.collab._leader:
            return

        self.collab.post(dict(action='init_request',
                              res_id=10))  # How get an unique id?

    def __insert_char_cb(self, view, key, position):
        if key in utils.LETTERS_KEYS:
            self.collab.post(dict(action="insert",
                                  key=Gdk.keyval_name(key),
                                  position=position))

    def __cursor_position_changed_cb(self, view, position):
        self.collab.post(dict(action="cursor_moved",
                              id=10,  # How get an unique id?
                              position=position))

        self.emit("cursor-position-changed", position)

    def __tag_applied_cb(self, buffer, tag, start, end):
        self.collab.post(dict(action="insert_tag",
                              tag=tag,
                              start=start,
                              end=end))

    def __tag_removed_cb(self, buffer, tag, start, end):
        self.collab.post(dict(action="remove_tag",
                              tag=tag,
                              start=start,
                              end=end))

    def toggle_bold(self):
        self.view.toggle_bold()

    def toggle_italic(self):
        self.view.toggle_italic()

    def toggle_underline(self):
        self.view.toggle_underline()

    def check_tag_at_offset(self, tag, position):
        return self.view.check_tag_at_offset(tag, position)
开发者ID:sugarlabs,项目名称:collabedit,代码行数:83,代码来源:collabedit.py

示例3: MainWindow

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import connect [as 别名]
class MainWindow(gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)
        
        self.set_title("Phone Repairer Loans")
        
        self.connect("delete_event", self.delete_event)
        self.connect("destroy", self.destroy)
        
        self.uimanager = UIManager()

        accelgroup = self.uimanager.get_accel_group()
        self.add_accel_group(accelgroup)
        
        self.uimanager.get_action('/MenuBar/File/Quit').connect("activate", self.destroy)
        self.uimanager.get_action('/MenuBar/File/Print').connect("activate", self.printing)
        self.uimanager.get_action('/MenuBar/File/Export').connect("activate", self.export)
        self.uimanager.get_action('/MenuBar/Loans/Add').connect("activate", self.addloan)
        self.uimanager.get_action('/MenuBar/Loans/Edit').connect("activate", self.editloan)
        self.uimanager.get_action('/MenuBar/Loans/Del').connect("activate", self.delloan)
        self.uimanager.get_action('/MenuBar/Help/About').connect("activate", self.aboutdialog)
        self.uimanager.get_action('/MenuBar/Loans/Edit').set_sensitive(False)
        self.uimanager.get_action('/MenuBar/Loans/Del').set_sensitive(False)
            
        vbox = gtk.VBox()
        
        menubar = self.uimanager.get_widget('/MenuBar')
        toolbar = self.uimanager.get_widget('/ToolBar')
        
        vbox.pack_start(menubar, False)
        vbox.pack_start(toolbar, False)
        
        scroll = gtk.ScrolledWindow()
        self.view = View()
        self.model = Model()
        self.view.set_model(self.model)
        self.view.connect("row-activated", self.on_row_actived)
        self.view.connect("cursor-changed", self.on_cursor_changed)
        
        scroll.add(self.view)
        vbox.add(scroll)
        
        self.statusbar = gtk.Statusbar()
        self.contextid = self.statusbar.get_context_id("Phone Repairer")
        self.statusbar.push(self.contextid, "Ready")
        
        vbox.pack_start(self.statusbar, False)
        vbox.show()
        
        self.add(vbox)
        self.resize(800, 600)
        self.show_all()
     
    def draw_page2 (self, operation, context, page_number):
        cr = context.get_cairo_context()
        #print self.view.get_column(0).get_cell_renderers()[0].get_property('family')
        #print self.view.get_column(0).get_cell_renderers()[0].get_property('family-set')
        #print self.view.get_column(0).get_cell_renderers()[0].get_property('font')
        #print self.view.get_column(0).get_cell_renderers()[0].get_property('font-desc')
        print context.get_width(),context.get_height()
        x, y, width, height = self.view.get_visible_rect()
        print width, height
        print context.get_dpi_x(),context.get_dpi_y()
        
        
        
        cr.move_to(0, 0)
        
        cols = self.view.get_columns()
        font = pango.FontDescription("Sans 10")# cols[0].get_cell_renderers()[0].get_property('font-desc')
        w = 0
        h = 0
        
        sum = 0
        for col in cols:
            sum += col.get_width()
        print sum
        
        r = context.get_width()/sum
        
        for i,col in enumerate(cols):
            txt = col.get_title()
            
            for row in self.model:
                txt += "\n" + str(row[i+1])
                
            layout = context.create_pango_layout()
            layout.set_markup(txt)
            layout.set_font_description(font)
            #layout.set_spacing(0.5)
            
            w, h = layout.get_pixel_size()
            
            cr.layout_path(layout)
            cr.rel_move_to(w+5, 0)

        cr.fill()
        
        tabs = pango.TabArray(4, True)
        tabs.set_tab(1, pango.TAB_LEFT, 60)
#.........这里部分代码省略.........
开发者ID:wrongware,项目名称:PhoneRepairer,代码行数:103,代码来源:main.py


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