本文整理汇总了Python中dialogs.Dialog类的典型用法代码示例。如果您正苦于以下问题:Python Dialog类的具体用法?Python Dialog怎么用?Python Dialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, title, items, **kwds):
self.title = title
self.items = items
self._items = [MenuItem(*item) for item in items]
Dialog.__init__(self, **kwds)
h = self.font.get_linesize()
self.height = h * len(self._items) + h
示例2: __init__
def __init__(self, title, responses, default=None, ok_action=None):
self.response = responses[0]
self.ok_action = ok_action
title = Label(title)
self.w_type = ChoiceButton(responses)
col = Column([title, self.w_type, Row([Button("OK", action=ok_action or self.dismiss_ok), Button("Cancel", action=ok_action or self.dismiss)], margin=0)], margin=0, spacing=2)
Dialog.__init__(self, client=col)
示例3: __edit_prefs
def __edit_prefs(self, *args):
kmap = {
'hide-read':'bool',
'update-interval':'int',
'max-articles':'int',
'use-notify':'bool',
'on-the-fly':'bool',
'enable-debug':'bool',
'auto-update':'bool',
'live-search':'bool',
'auto-hide-search':'bool',
'show-status':'bool',
}
hmap = {
'hide-read':_('Hide Read Items'),
'update-interval':_('Update interval (in minutes)'),
'max-articles':_('Maximum number of articles to keep (excluding starred)'),
'auto-update':_('Allow the engine to download new articles automatically.'),
'on-the-fly':_('Start downloading articles for new feeds on-the-fly'),
'use-notify':_('Show notification on updates'),
'enable-debug':_('Enable detailed logs'),
'live-search':_('Return search results as you type'),
'auto-hide-search':_('Hide Search form on results'),
'show-status':_('Show the bottom status bar'),
}
data = []
for k,v in kmap.iteritems():
data.append({
'type':v,
'name':k,
'header':hmap.get(k),#FIXME: can this be gotten from gsettings?
})
d = Dialog(self, _('Edit preferences'), data, self.settings)
r = d.run()
d.destroy()
示例4: __add_category
def __add_category(self, *args):
args = [
{'type':'str','name':'name', 'header':_('Name') },
]
d = Dialog(self, _('Add a category'), args)
r = d.run()
item = d.response
item['type'] = 'category'
d.destroy()
if r == Gtk.ResponseType.OK:
self.__create(item)
示例5: __add_feed
def __add_feed(self, *args):
data = [
{'type':'str','name':'url', 'header':_('Link') },
]
d = Dialog(self, _('Add a feed'), data)
r = d.run()
item = d.response
item['type'] = 'feed'
d.destroy()
if r == Gtk.ResponseType.OK:
self.__create(item)
示例6: __init__
def __init__(self, title, items, scrolling=False, scroll_items=30,
scroll_page=5, handler=None, **kwds):
self.handler = handler
self.title = _(title, doNotTranslate=kwds.get('doNotTranslate', False))
self.items = items
self._items = [MenuItem(*item, doNotTranslate=kwds.get('doNotTranslate', False)) for item in items]
self.scrolling = scrolling and len(self._items) > scroll_items
self.scroll_items = scroll_items
self.scroll_page = scroll_page
Dialog.__init__(self, **kwds)
self.root = self.get_root()
self.calc_size()
示例7: __init__
def __init__(self, title, items, scrolling=False, scroll_items=30,
scroll_page=5, **kwds):
self.title = _(title)
self.items = items
self._items = [MenuItem(*item) for item in items]
self.scrolling = scrolling and len(self._items) > scroll_items
self.scroll_items = scroll_items
self.scroll_page = scroll_page
Dialog.__init__(self, **kwds)
h = self.font.get_linesize()
if self.scrolling:
self.height = h * self.scroll_items + h
else:
self.height = h * len(self._items) + h
示例8: mouse_down
def mouse_down(self, event):
if event.button == 1:
if self.scrolling:
p = event.local
if self.scroll_up_rect().collidepoint(p):
self.scroll_up()
return
elif self.scroll_down_rect().collidepoint(p):
self.scroll_down()
return
if event.button == 4:
self.scroll_up()
if event.button == 5:
self.scroll_down()
Dialog.mouse_down(self, event)
示例9: __edit_item
def __edit_item(self, *args):
item = self.tree.current_item #FIXME: not good!!
print item
if item['type'] == 'category':
args = [{'type':'str','name':'name', 'header':_('Name'), 'value':item['name'] },]
d = Dialog(self, _('Edit this category'), args)
elif item['type'] == 'feed':
args = [{'type':'str','name':'url', 'header':_('Link'), 'value':item['url'] },]
d = Dialog(self, _('Edit this feed'), args)
r = d.run()
o = d.response
for k,v in o.iteritems():
item[k] = v
d.destroy()
if r == Gtk.ResponseType.OK:
self.__edit(item)
示例10: present
def present(self, client, pos):
client = client or self.root
self.topleft = client.local_to_global(pos)
focus = self.handler or get_focus()
font = self.font
h = font.get_linesize()
items = self._items
margin = self.margin
if self.scrolling:
height = h * self.scroll_items + h
else:
height = h * len(items) + h
w1 = w2 = 0
for item in items:
item.enabled = self.command_is_enabled(item, focus)
w1 = max(w1, font.size(item.text)[0])
w2 = max(w2, font.size(item.keyname)[0])
width = w1 + 2 * margin
self._key_margin = width
if w2 > 0:
width += w2 + margin
if self.scrolling:
width += self.scroll_button_size
self.size = (width, height)
self._hilited = None
self.rect.clamp_ip(self.root.rect)
return Dialog.present(self, centered=False)
示例11: body
def body(self, master):
if not self.Fieldvars:
logger.debug("Creating username and password tk StringVars Fieldvars. Initial username is: %s", self.Initial_username)
# Notice: you should specify the variables' master; otherwise, if you instantiate
# multiple tk.Tk() instances during e.g. testing, these will
# mess up the variable logic (apparently...)
self.Fieldvars = OrderedDict(
username = [tk.StringVar(self.parent, value=self.Initial_username), 'Username', dict()],
password = [tk.StringVar(self.parent), 'Password', dict(show="*")]
)
# Call to super:
Dialog.body(self, master)
logger.debug("login prompt created, self.Fieldvars is: %s, with values: %s",
self.Fieldvars,
"; ".join(u"{}: {}".format(k, bool(v[0].get())) for k, v in self.Fieldvars.items()))
logger.debug("self.EntryWidgets have values: %s",
"; ".join(u"{}: {}".format(k, bool(v.get())) for k, v in self.EntryWidgets.items()))
示例12: take_screenshot
def take_screenshot(self):
try:
os.mkdir(os.path.join(directories.getCacheDir(), "screenshots"))
except OSError:
pass
screenshot_name = os.path.join(directories.getCacheDir(), "screenshots", time.strftime("%Y-%m-%d (%I-%M-%S-%p)") + ".png")
pygame.image.save(pygame.display.get_surface(), screenshot_name)
self.diag = Dialog()
lbl = Label(_("Screenshot taken and saved as '%s'") % screenshot_name, doNotTranslate=True)
folderBtn = Button("Open Folder", action=self.open_screenshots_folder)
btn = Button("Ok", action=self.screenshot_notify)
buttonsRow = Row((btn, folderBtn))
col = Column((lbl, buttonsRow))
self.diag.add(col)
self.diag.shrink_wrap()
self.diag.present()
示例13: present
def present(self, client, pos):
client = client or get_root()
self.topleft = client.local_to_global(pos)
focus = get_focus()
font = self.font
h = font.get_linesize()
items = self._items
margin = self.margin
height = h * len(items) + h
w1 = w2 = 0
for item in items:
item.enabled = self.command_is_enabled(item, focus)
w1 = max(w1, font.size(item.text)[0])
w2 = max(w2, font.size(item.keyname)[0])
width = w1 + 2 * margin
self._key_margin = width
if w2 > 0:
width += w2 + margin
self.size = (width, height)
self._hilited = None
return Dialog.present(self, centered = False)
示例14: cancel
bInfoOk.setCallback(infoOk)
dialog.unfocus()
info.draw()
info.focus()
def cancel(button):
dialogs.stop()
if __name__ == '__main__':
try:
items = [{"label": "Option {}".format(i), "value": "Value {}".format(i)} for i in xrange(1,35)]
dialogs.initScreen()
dialogs.setTitle("DEMO")
dialog = Dialog("Dialog", 52, 8)
dropdown = Dropdown(1, items, 12)
bOk = Button(2, "Ok")
bCancel = Button(3, "Cancel")
dropdown.setPopupWidth(10)
bOk.setCallback(ok)
bCancel.setCallback(cancel)
dialog.addComponent(Label("Select option and press 'Ok' button:", 38), 1, 2)
dialog.addComponent(dropdown, 38, 2)
dialog.addComponent(bOk, 31, 6)
dialog.addComponent(bCancel, 39, 6)
dialog.center()
dialog.draw()
dialog.focus()
示例15: showAlert
def showAlert(button):
alert = Dialog("Alert", 40, 6, dialogs.ALERT_DIALOG_DECO)
bOk = Button(1, "Ok", dialogs.ALERT_BUTTON_DECO)
alert.addComponent(Label("Press 'Ok' button to close alert dialog.", 38), 1, 2)
alert.addComponent(bOk, 31, 4)
alert.center()
def ok(button):
alert.destroy()
dialog.focus()
bOk.setCallback(ok)
dialog.unfocus()
alert.draw()
alert.focus()