+1

My custom Plugin not working

Huu Nhan Tran 9 year бұрын жаңартылды 9 year бұрын 1
Hi,
I wrote a test plugin based on Ajenti dev doc, but it look like not working correctly. I have an add button, but when I click on it, nothing happen (it should pop an entry)

#main.py
from ajenti.api import *
from ajenti.ui.binder import Binder
import logging


from ajenti.plugins.main.api import SectionPlugin

class JungleCreature(object):
def __init__(self, name):
self.name = name





@plugin
class Jungle (SectionPlugin):

def init(self):
self.title = _('Jungle')
self.icon = 'globe'
self.category = _('System')
#self.jc = JungleCreature("Bot name", "config")
self.append(self.ui.inflate('jungle:main'))


self.find('jc').new_item = lambda c: JungleCreature('animal name')
self.binder = Binder(None, self.find('3Dapp'))
self.refresh()

def refresh(self):
self.binder.update()
self.binder.setup(self).populate()

def on_page_load(self):
self.refresh()

#init.py
from ajenti.api import *
from ajenti.plugins import *


info = PluginInfo(
title='Jungle',
icon=None,
dependencies=[
PluginDependency('main'),
PluginDependency('services'),
],
)


def init():
import main

#main.xml layout
<body>
<pad id="3Dapp" binder:context="3D App">
<label text="3D App" stype="bold"/>
<formline>
<button icon="plus" style="mini" bind="__add" />
<bind:collection bind="jc" id="jc">
<dt bind="__items" width="300">
<dtr header="True">
<dth text="Name" />
</dtr>
</dt>

<bind:template>
<dtr>
<dtd><textbox bind="name" /></dtd>
</dtr>
</bind:template>
</bind:collection>
</formline>
</pad>

<button id="save" text="{Save}" icon="ok" />
</body>
Can someone look into these and help me why I click Add button, nothing happen