本文整理汇总了Python中kiwi.ui.views.BaseView类的典型用法代码示例。如果您正苦于以下问题:Python BaseView类的具体用法?Python BaseView怎么用?Python BaseView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(
self,
model,
proxy_widgets=None,
gladefile=None,
toplevel=None,
widgets=(),
toplevel_name=None,
domain=None,
delete_handler=None,
keyactions=None,
):
"""Creates a new Delegate.
:param model: instance to be attached
:param proxy_widgets:
The keyactions parameter is sent to :class:`kiwi.controllers.BaseController`,
the rest are sent to :class:`kiwi.ui.views.BaseView`
"""
BaseView.__init__(self, toplevel, widgets, gladefile, toplevel_name, domain, delete_handler)
self.model = model
self.proxy = self.add_proxy(model, proxy_widgets)
self.proxy.proxy_updated = self.proxy_updated
BaseController.__init__(self, view=self, keyactions=keyactions)
示例2: __init__
def __init__(self):
win = gtk.Window()
win.set_title("I'm coming to London")
label = gtk.Label("Anything to declare?")
win.add(label)
win.set_default_size(200, 50)
BaseView.__init__(self, toplevel=win,
delete_handler=self.quit_if_last)
示例3: __init__
def __init__(self):
self.win = gtk.Window()
self.label = gtk.Label("foobar!")
self.win.add(self.label)
BaseView.__init__(self, toplevel=self.win)
BaseController.__init__(self, view=self)
set_foreground(self.label, "#CC99FF")
set_background(self.win, "#001100")
示例4: __init__
def __init__(self, model):
self.__model = model
#self.__model.set_view(self)
BaseView.__init__(self,
gladefile="virtlab",
delete_handler=self.quit_if_last)
# self.__col_pixbuf = gtk.TreeViewColumn("Image")
# cellrenderer_pixbuf = gtk.CellRendererPixbuf()
# cellrenderer_pixbuf.set_properties("pixbuf", )
# self.__col_pixbuf.pack_start(cellrenderer_pixbuf, False)
# self.__col_pixbuf.add_attribute(cellrenderer_pixbuf, "pixbuf", 1)
tableColumns = [
Column("image", title=" ", width=30, data_type=gtk.gdk.Pixbuf, sorted=False),
Column("name", title='VM Name', width=130, sorted=True),
Column("state", title='State', width=70),
Column("order", title='Order (Delay/min)', width=145),
Column("ordinal", visible=False),
Column("delay", visible=False),
Column("desc", title='Description', width=200)
]
self.vmlist_widget = ObjectList(tableColumns)
self.vmlist_widget.set_size_request(300, 400)
self.vmlist_widget.set_selection_mode(gtk.SELECTION_SINGLE)
self.hbox4.pack_start(self.vmlist_widget)
store = gtk.ListStore(gobject.TYPE_STRING)
self.vmlist_widget.show()
self.__dialog = None
self.__status_text = gtk.TextBuffer()
try:
self.populate_vmlist()
self.populate_order_dropdown(store, len(self.__model.get_vms()))
except VMLabException as exception:
if exception.vme_id is c.EXCEPTION_LIBVIRT_001:
error("Initialization error",
"No connection to Libvirtd.\n Exiting.")
exit(1)
self.ordercombo.set_model(store)
cell = gtk.CellRendererText()
self.ordercombo.pack_start(cell, True)
self.ordercombo.add_attribute(cell, 'text', 0)
self.virtlab.set_size_request(800, 460)
self.change_title("")
self.__statusbar_ctx = self.statusbar.get_context_id("virtlab")
self.virtlab.set_icon(gtk.gdk.pixbuf_new_from_file("pixmaps/about-logo.png"))
示例5: __init__
def __init__(self, toplevel=None, widgets=None, toplevel_name=None,
delete_handler=None, keyactions=None):
"""Creates a new Delegate.
The keyactions parameter is sent to :class:`kiwi.controllers.BaseController`,
the rest are sent to :class:`kiwi.ui.views.BaseView`
"""
BaseView.__init__(self,
toplevel=toplevel,
widgets=widgets or [],
toplevel_name=toplevel_name,
delete_handler=delete_handler)
BaseController.__init__(self, view=self, keyactions=keyactions)
示例6: __init__
def __init__(self):
win = gtk.Window()
win.set_title("Silly question")
win.set_border_width(12)
label = gtk.Label("What is your favourite color?")
box = gtk.VBox(spacing=6)
box.pack_start(label, False)
self.combo = ProxyComboEntry()
self.combo.data_type = str
self.combo.model_attribute = 'color'
self.combo.prefill(load_colors(), sort=True)
box.pack_start(self.combo, False)
win.add(box)
BaseView.__init__(self, toplevel=win,
delete_handler=self.quit_if_last)
示例7: BaseView
#!/usr/bin/env python
import gtk
from kiwi.ui.gadgets import quit_if_last
from kiwi.ui.views import BaseView
app = BaseView(gladefile="hey", delete_handler=quit_if_last)
app.show()
gtk.main()
示例8: __init__
def __init__(self):
BaseView.__init__(self, gladefile="faren.ui",
delete_handler=self.quit_if_last)
示例9: clicked
def clicked(self, widget, event):
if package.to_install:
if root:
pacman = "pacman -S %s && read" % package.to_install
command = [TERMINAL, "-e", pacman]
else:
pacman = "su --command='pacman -S %s && read'" % package.to_install
command = [TERMINAL, "-e", pacman]
out, errors = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if errors:
raise errors
else:
print("No package to install")
shell = BaseView(gladefile="gpacnet", delete_handler=quit_if_last)
local = Local()
category = Category()
package = Package()
install = Install()
shell.attach_slave("category", category)
shell.attach_slave("package", package)
category.show_all()
category.focus_topmost()
package.show_all()
示例10: News
"Reverend CyberSatan",
"http://www.pigdog.org/auto/TheCorporateFuck/link/2683.html"),
("Those Crazy Dutch Have Resurrected Elvis",
"Miss Conduct",
"http://www.pigdog.org/auto/viva_la_musica/link/2678.html")
]
class News(SlaveView):
def __init__(self):
model = gtk.ListStore(str, str)
treeview = gtk.TreeView(model)
renderer = gtk.CellRendererText()
col1 = gtk.TreeViewColumn('News', renderer, text=0)
col2 = gtk.TreeViewColumn('Author', renderer, text=1)
treeview.append_column(col1)
treeview.append_column(col2)
treeview.get_selection().set_mode(gtk.SELECTION_BROWSE)
for item in news:
model.append(item[:-1])
SlaveView.__init__(self, treeview)
news = News()
shell = BaseView(gladefile="news_shell", delete_handler=quit_if_last)
shell.attach_slave("placeholder", news)
news.show_all()
news.focus_toplevel() # explained next section, don't worry
shell.show()
gtk.main()
示例11: BaseView
#!/usr/bin/env python
import gtk
from kiwi.ui.views import BaseView, SlaveView
from kiwi.ui.objectlist import Column
from kiwi.ui.gadgets import quit_if_last
# Main window
addressbook = BaseView(gladefile="addressbook",
widgets=("add", "del"),
delete_handler=quit_if_last)
## Slave Components:
# Entry editor GUI component
entry_editor = SlaveView(toplevel=addressbook,
widgets=("name", "address", "phone"),
gladefile="entry_editor")
# Entries list GUI component
list_entries = SlaveView(toplevel=addressbook,
widgets=("table",),
gladefile="list_entries")
list_entries.table.set_columns([Column("name", title="Name"),
Column("address", title="Address"),
Column("phone", title="Phone")])
## Attach slaves to main window
addressbook.attach_slave("entry_editor", entry_editor)
addressbook.attach_slave("list", list_entries)
示例12: __init__
def __init__(self, toplevel=None, *args, **kw):
PythonViewMixin.__init__(self)
if toplevel is None:
toplevel = self.create_toplevel_widget()
BaseView.__init__(self, toplevel=toplevel, *args, **kw)
示例13: __init__
def __init__(self):
BaseView.__init__(self, delete_handler=quit_if_last)
text = self.the_label.get_text() # attached by constructor
self.the_label.set_markup('<b>%s</b>' % text)
self.the_label.set_use_markup(True)
self.set_title("Avi's declaration") # change window title
示例14: Person
#!/usr/bin/env python
import gtk
from kiwi.model import PickledModel
from kiwi.ui.views import BaseView
from kiwi.ui.gadgets import quit_if_last
# define the class that holds our application data
class Person(PickledModel):
name = ""
address = ""
phone = ""
person = Person.unpickle() # load person instance
view = BaseView(delete_handler=quit_if_last, widgets=("name", "address", "phone"), gladefile="person")
# create and run a proxy interface attached to person
view.add_proxy(person, ("name", "address", "phone"))
view.focus_topmost()
view.show_all()
# Enter main lopp, where GTK will handle events
gtk.main()
# save changes done to theinstance
person.save()
示例15: FarenControl
#!/usr/bin/env python
import gtk
from kiwi.controllers import BaseController
from kiwi.ui.views import BaseView
from kiwi.ui.gadgets import quit_if_last
class FarenControl(BaseController):
def on_quitbutton__clicked(self, *args):
self.view.hide_and_quit()
def after_temperature__insert_text(self, entry, *args):
try:
temp = float(entry.get_text())
except ValueError:
temp = 0
celsius = (temp - 32) * 5 / 9.0
farenheit = (temp * 9 / 5.0) + 32
self.view.celsius.set_text("%.2f" % celsius)
self.view.farenheit.set_text("%.2f" % farenheit)
widgets = ["quitbutton", "temperature", "celsius", "farenheit"]
view = BaseView(gladefile="faren.ui",
delete_handler=quit_if_last, widgets=widgets)
ctl = FarenControl(view)
view.show()
gtk.main()