本文整理汇总了Python中notebook.Notebook类的典型用法代码示例。如果您正苦于以下问题:Python Notebook类的具体用法?Python Notebook怎么用?Python Notebook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Notebook类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: cargar_articulos
def cargar_articulos(self,fecha_reserva,Funcionario,descripcion, codigo, fecha_ingreso,reservado,tipo):
if ( codigo=='' or codigo == None):
raise Exception('Codigo de la dependencia vacio')
else:
try:
value=int(codigo)
except ValueError:
raise Exception('El código del articulo debe ser del tipo númerico')
else:
try:
strptime(fecha_ingreso, '%d/%m/%Y')
persistence = ControladorPersistence()
persistence.leer(codigo)
except ValueError:
raise Exception('El formato no corresponde\nfavor ingresar de la siguiente manera dd/mm/yyyy')
except:
if( tipo == 'Notebook'):
a= Notebook(fecha_reserva,Funcionario,descripcion, codigo, fecha_ingreso,reservado)
elif(tipo=='Proyector'):
a= Proyector(fecha_reserva,Funcionario,descripcion, codigo, fecha_ingreso,reservado)
elif(tipo=='Multiple Electrico'):
a= MultipleElectrico(fecha_reserva,Funcionario,descripcion, codigo, fecha_ingreso,reservado)
a.cargar_articulos()
else:
raise Exception('El código del articulo ya existe')
开发者ID:marcosd94,项目名称:reservas,代码行数:25,代码来源:controlador_articulo.py
示例2: Menu
class Menu(object):
"Display a menu and respond to choices when run"
def __init__(self):
self.notebook = Notebook()
self.choices = {
"1": self.show_notes,
"2": self.search_notes,
"3": self.add_note,
"4": self.modify_note,
"5": self.quit
}
def display_menu(self):
print "1: show notes, 2: search, 3: add, 4: modify, 5: quit"
def run(self):
"Display the menu and respond to choices"
while True:
self.display_menu()
choice = raw_input("> ")
action = self.choices.get(choice)
if action:
action()
else:
print "{0} is not a valid choice".format(choice)
def show_notes(self, notes=None):
if not notes:
notes = self.notebook.notes
for note in notes:
print "{0}, {1}:\n{2}".format(
note.id, note.tags, note.memo)
def search_notes(self):
pattern = raw_input("Search for: ")
notes = self.notebook.search(pattern)
self.show_notes(notes)
def add_note(self):
memo = raw_input("Enter a memo: ")
self.notebook.new_note(memo)
print "Your note has been added."
def modify_note(self):
note_id = int(raw_input("Enter a note id: "))
if not self.notebook._find_note(note_id):
return
memo = raw_input("Enter a memo: ")
tags = raw_input("Enter tags: ")
if memo:
self.notebook.modify_memo(note_id, memo)
if tags:
self.notebook.modify_tags(note_id, tags)
def quit(self):
print "Thanks for using your notebook today."
sys.exit()
开发者ID:jainarchita,项目名称:60-days-of-python,代码行数:57,代码来源:menu.py
示例3: __init__
def __init__(self):
self.notebook = Notebook()
self.choices = {"1": self.show_notes,
"2": self.search_notes,
"3": self.add_note,
"4": self.modify_note,
"5": self.quit
}
开发者ID:huynt1979,项目名称:python,代码行数:8,代码来源:menu.py
示例4: __init__
class Menu:
'''Display a menu and respond to choices when run.'''
def __init__(self):
self.notebook = Notebook()
self.choices = {
"1": self.show_notes,
"2": self.search_notes,
"3": self.add_note,
"4": self.modify_note,
"5": self.quit
}
def display_menu(self):
print("""
Notebook Menu
1. Show all Notes
2. Search Notes
3. Add Note
4. Modify Note
5. Quit
""")
def run(self):
'''Display the menu and respond to choices.'''
while True:
self.display_menu()
choice = input("Enter an option: ")
action = self.choices.get(choice)
if action:
action()
else:
print("{0} is not a valid choice".format(choice))
def show_notes(self, notes=None):
if not notes:
notes = self.notebook.notes
for note in notes:
print("{0}: {1}\n{2}".format(
note.id, note.tags, note.memo))
def search_notes(self):
filter = input("Search for: ")
notes = self.notebook.search(filter)
self.show_notes(notes)
def add_note(self):
memo = input("Enter a memo: ")
self.notebook.new_note(memo)
print("Your note has been added.")
def modify_note(self):
id = input("Enter a note id: ")
memo = input("Enter a memo: ")
tags = input("Enter tags: ")
if memo:
self.notebook.modify_memo(id, memo)
if tags:
self.notebook.modify_tags(id, tags)
def quit(self):
print("Thank you for using your notebook today.")
sys.exit(0)
开发者ID:nmukh,项目名称:Python-Notebook,代码行数:60,代码来源:menu.py
示例5: __init__
class Menu:
def __init__(self):
self.notebook = Notebook()
self.choices = {
"1": self.show_notes,
"2": self.search_notes,
"3": self.add_note,
"4": self.modify_note,
"5": self.quit
}
def display_menu(self):
print ("""
Notebook Menu
1. Show all Notes
2. Search Notes
3. Add Note
4. Modify Note
5. Quit """)
def run(self):
while True:
self.display_menu()
choice = input("enter an option: ")
action = self.choice.get(choice)
if action:
action()
else:
print ("{0} is not a not valid".format(choice))
def show_notes(self, notes=None):
if not notes:
notes = self.notebook.notes
for note in notes:
print ("%d: %s\n%s", % (note.id, note.tags, note.memo))
def search_notes(self):
title = input("search for: ")
notes = self.notebook.lookin(title)
self.show_notes(notes)
def add_notes(self):
memo = input("Enter a memo: ")
self.notebook.new_note(memo)
print ("you note added. ")
def modify_note(self):
id = input("enter note id: ")
memo = input("enter a memo: ")
tags = input("enter tags: ")
if memo:
self.notebook.modify_memo(id, memo)
if tags:
self.notebook.modify_tags(id, tags)
def quit(self):
print ("thanks! ")
sys.exit(0)
开发者ID:thisiswei,项目名称:learning,代码行数:60,代码来源:menu.py
示例6: __init__
def __init__(self):
self.notebook = Notebook()
self.choices = {
'1': self.show_notes,
'2': self.search_notes,
'3': self.add_notes,
'4': self.modify_notes,
'5': self.quit
}
开发者ID:ethen8181,项目名称:programming,代码行数:9,代码来源:menu.py
示例7: __init_ctrls
def __init_ctrls(self, prnt):
wx.Panel.__init__(self, id=-1, name=u'Panel', parent=prnt,
style=wx.TAB_TRAVERSAL)
self.notebook = Notebook(self, main)
self.insertToolsPanel = insertTools.Panel(self.notebook, main)
self.notebook.init_pages(self.insertToolsPanel,
_(u"Insert settings"), u'insert.ico')
self.numberingPanel = self.notebook.numbering
self.dateTimePanel = self.notebook.dateTime
开发者ID:RavenB,项目名称:metamorphose2,代码行数:9,代码来源:insert.py
示例8: __init__
def __init__(self):
self.notebook = Notebook()
# Map strings to functions
self.choices = {
"1": self.show_notes,
"2": self.search_notes,
"3": self.add_note,
"4": self.modify_note,
"5": self.quit}
开发者ID:Qi-Yang,项目名称:PythonObjectOrientedPacktNotebook,代码行数:9,代码来源:menu.py
示例9: __init__
def __init__(self):
self.notebook = Notebook()
self.choices = {
1: self.show_notes,
2: self.search_notes,
3: self.add_note,
4: self.modify_note,
5: self.quit
}
开发者ID:masalehh,项目名称:simple-notebok,代码行数:10,代码来源:menu.py
示例10: handler
def handler(self, message):
command = message.get('command')
print 'Handling bibliography command %s %s'%(command, datetime.datetime.now().strftime("%H:%M:%S.%f"))
if message.get('sub_type') in ('notebook'):
nb = Notebook(self.resource, self.render)
result = nb.handler(message)
elif command in ('parse_bibstring'):
result = Translator(None).string_reader(message.get('bibstring', ''), count=message.get('count', 10000))
elif command in ('save_bibnote'):
result = self.save_bibnote(message.get('file'), message)
elif command in ('save_bibtex'):
result = self.save_bibtex(message.get('file', '').replace('.bibnote', '.bib'), message)
elif command in ('save_html'):
result = self.save_html(message.get('file'), message)
elif command in ('save_and_load'):
try:
nb = Notebook(self.resource, self.render)
nb.save_notebook(message, message.get('file'))
result = nb.render_docmain(message.get('new_notebook'))
result['success'] = 'success'
except:
result = {'success' : 'failed to load file %s'%(message.get('file'))}
else:
result = {'success': 'undefined command: %s'%(command)}
print 'Returning from bibliography command %s %s'%(command, datetime.datetime.now().strftime("%H:%M:%S.%f"))
return result
开发者ID:v923z,项目名称:nothon,代码行数:33,代码来源:bibliography.py
示例11: __init__
def __init__(self):
self.notebook = Notebook()
self.choices = OrderedDict.fromkeys('12345')
self.choices['1'] = {'display': 'Show notes',
'handler': self.show_notes}
self.choices['2'] = {'display': 'Search notes',
'handler': self.search_notes}
self.choices['3'] = {'display': 'Add notes',
'handler': self.add_note}
self.choices['4'] = {'display': 'Modify notes',
'handler': self.modify_note}
self.choices['5'] = {'display': 'Quit',
'handler': self.quit}
开发者ID:sonhuytran,项目名称:Learning.Python,代码行数:13,代码来源:menu.py
示例12: OpPanel
class OpPanel(Operation):
"""This is the main panel for directory manipulations.
It holds the notebook holding all directory panels.
"""
def __init_sizer(self, parent):
#smallestSize = parent.rightSizer.GetSize() - parent.rightTopSizer.GetSize() - (10,10)
superSizer = wx.BoxSizer(wx.VERTICAL)
#superSizer.SetMinSize(smallestSize)
superSizer.Add(self.notebook, 0, wx.EXPAND)
self.SetSizerAndFit(superSizer)
def __init_ctrls(self, prnt):
wx.Panel.__init__(self, id=-1, name=u'Panel', parent=prnt,
style=wx.TAB_TRAVERSAL)
self.notebook = Notebook(self, main)
self.directoryToolsPanel = directoryTools.Panel(self.notebook, main)
self.notebook.init_pages(self.directoryToolsPanel,
_(u"Directory settings"), u'directory.ico')
self.numberingPanel = self.notebook.numbering
self.dateTimePanel = self.notebook.dateTime
def __init__(self, parent, main_window, params={}):
Operation.__init__(self, params)
global main
main = main_window
self.set_as_path_only()
self.__init_ctrls(parent)
self.__init_sizer(parent)
self.update_parameters(self.directoryToolsPanel.params)
def on_config_load(self):
"""Update GUI elements, settings after config load."""
self.numberingPanel.on_config_load()
self.dateTimePanel.get_from_item_checkbox(False)
def __add_path(self, newPath, path):
"""Extra operation for absolute paths."""
recurPath = ''
recur = self.directoryToolsPanel.pathRecur.GetValue()
path = path.split(os.sep)
# remove drive letter
if wx.Platform == '__WXMSW__':
path = path[1:]
# inverse the selection or not
if not self.directoryToolsPanel.inverse.GetValue():
if recur <= 0:
recur -= 1
path = path[-recur:]
else:
path = path[:-recur]
# reassemble path
for segment in path:
recurPath = os.path.join(recurPath, segment)
newPath = newPath.replace(self.params['pathStructTxt'], recurPath)
return newPath
def __add_file_name(self, newPath, name, ext):
if self.directoryToolsPanel.useFileExt.GetValue() and self.directoryToolsPanel.useFileName.GetValue():
if ext:
ext = '.' + ext
parsedName = name + ext
elif self.directoryToolsPanel.useFileName.GetValue():
parsedName = name
elif self.directoryToolsPanel.useFileExt.GetValue():
parsedName = ext
else:
parsedName = ''
newPath = newPath.replace(self.params['nameTxt'], parsedName)
return newPath
def reset_counter(self, c):
"""Reset the numbering counter for the operation."""
utils.reset_counter(self, self.directoryToolsPanel, c)
def rename_item(self, path, name, ext, original):
"""Create the new path."""
rejoin = False
operations = self.directoryToolsPanel.opButtonsPanel
newPath = self.directoryToolsPanel.directoryText.GetValue()
params = self.params
# absolute path
if os.path.isabs(newPath):
split = os.path.splitdrive(newPath)
newPath = split[1]
rejoin = True
# add path structure
if params['pathStructTxt'] in newPath:
newPath = self.__add_path(newPath, path)
# add filename
if params['nameTxt'] in newPath:
newPath = self.__add_file_name(newPath, name, ext)
#.........这里部分代码省略.........
开发者ID:javierpra,项目名称:metamorphose2,代码行数:101,代码来源:directory.py
示例13: write_example
def write_example(src_name, src_dir, rst_dir, cfg):
"""Write rst file from a given python example.
Parameters
----------
src_name : str
Name of example file.
src_dir : 'str'
Source directory for python examples.
rst_dir : 'str'
Destination directory for rst files generated from python examples.
cfg : config object
Sphinx config object created by Sphinx.
"""
last_dir = src_dir.psplit()[-1]
# to avoid leading . in file names, and wrong names in links
if last_dir == '.' or last_dir == 'examples':
last_dir = Path('')
else:
last_dir += '_'
src_path = src_dir.pjoin(src_name)
example_file = rst_dir.pjoin(src_name)
shutil.copyfile(src_path, example_file)
image_dir = rst_dir.pjoin('images')
thumb_dir = image_dir.pjoin('thumb')
notebook_dir = rst_dir.pjoin('notebook')
image_dir.makedirs()
thumb_dir.makedirs()
notebook_dir.makedirs()
base_image_name = os.path.splitext(src_name)[0]
image_path = image_dir.pjoin(base_image_name + '_{0}.png')
basename, py_ext = os.path.splitext(src_name)
rst_path = rst_dir.pjoin(basename + cfg.source_suffix)
notebook_path = notebook_dir.pjoin(basename + '.ipynb')
if _plots_are_current(src_path, image_path) and rst_path.exists and \
notebook_path.exists:
return
blocks = split_code_and_text_blocks(example_file)
if blocks[0][2].startswith('#!'):
blocks.pop(0) # don't add shebang line to rst file.
rst_link = '.. _example_%s:\n\n' % (last_dir + src_name)
figure_list, rst = process_blocks(blocks, src_path, image_path, cfg)
has_inline_plots = any(cfg.plot2rst_plot_tag in b[2] for b in blocks)
if has_inline_plots:
example_rst = ''.join([rst_link, rst])
else:
# print first block of text, display all plots, then display code.
first_text_block = [b for b in blocks if b[0] == 'text'][0]
label, (start, end), content = first_text_block
figure_list = save_all_figures(image_path)
rst_blocks = [IMAGE_TEMPLATE % f.lstrip('/') for f in figure_list]
example_rst = rst_link
example_rst += eval(content)
example_rst += ''.join(rst_blocks)
code_info = dict(src_name=src_name, code_start=end)
example_rst += LITERALINCLUDE.format(**code_info)
example_rst += CODE_LINK.format(src_name)
ipnotebook_name = src_name.replace('.py', '.ipynb')
ipnotebook_name = './notebook/' + ipnotebook_name
example_rst += NOTEBOOK_LINK.format(ipnotebook_name)
f = open(rst_path, 'w')
f.write(example_rst)
f.flush()
thumb_path = thumb_dir.pjoin(src_name[:-3] + '.png')
first_image_file = image_dir.pjoin(figure_list[0].lstrip('/'))
if first_image_file.exists:
first_image = io.imread(first_image_file)
save_thumbnail(first_image, thumb_path, cfg.plot2rst_thumb_shape)
if not thumb_path.exists:
if cfg.plot2rst_default_thumb is None:
print("WARNING: No plots found and default thumbnail not defined.")
print("Specify 'plot2rst_default_thumb' in Sphinx config file.")
else:
shutil.copy(cfg.plot2rst_default_thumb, thumb_path)
# Export example to IPython notebook
nb = Notebook()
for (cell_type, _, content) in blocks:
content = content.rstrip('\n')
if cell_type == 'code':
nb.add_cell(content, cell_type='code')
else:
content = content.replace('"""', '')
content = '\n'.join([line for line in content.split('\n') if
not line.startswith('.. image')])
#.........这里部分代码省略.........
开发者ID:A-0-,项目名称:scikit-image,代码行数:101,代码来源:plot2rst.py
示例14: make_folder
os.rmdir(os.path.join(root, name))
os.rmdir(absolute)
else:
os.remove(absolute)
try:
make_folder("subdir")
make_file("worksheet_a.rws")
make_file("subdir/worksheet_c.rws")
make_file("library_a.py")
make_file("subdir/library_b.py")
notebook = Notebook(notebook_folder)
file_list = FileList(notebook)
def expect(*expected_items):
items = []
model = file_list.get_model()
iter = model.get_iter_first()
while iter:
depth = len(model.get_path(iter)) - 1
items.append((">" * depth) + model.get_value(iter, 0).get_text())
iter = _next_row_depthfirst(model, iter)
if items != list(expected_items):
raise AssertionError("Got %s expected %s" % (items, expected_items))
expect("Worksheets",
开发者ID:lamby,项目名称:pkg-reinteract,代码行数:31,代码来源:file_list.py
示例15: Window
class Window(gtk.Window):
__gsignals__ = { 'active_tab_changed' : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (Tab,)) }
def __init__(self):
super(type(self), self).__init__()
debug(DEBUG_WINDOW)
self._active_tab = None
self._num_tabs = 0
self._removing_tabs = False
self._state = WINDOW_STATE_NORMAL
self._dispose_has_run = False
self._fullscreen_controls = None
self._fullscreen_animation_timeout_id = 0
#TODO
#self._message_bus = MessageBus()
self._window_group = gtk.WindowGroup()
self._window_group.add_window(self)
main_box = gtk.VBox(False, 0)
self.add(main_box)
main_box.show()
# Add menu bar and toolbar bar
self.create_menu_bar_and_toolbar(main_box)
# Add status bar
self.create_statusbar(main_box)
# Add the main area
debug_message(DEBUG_WINDOW, "Add main area")
self._hpaned = gtk.HPaned()
main_box.pack_start(self._hpaned, True, True, 0)
self._vpaned = gtk.VPaned()
self._hpaned.pack2(self._vpaned, True, False)
debug_message(DEBUG_WINDOW, "Create taluka notebook")
self._notebook = Notebook()
self.add_notebook(self._notebook)
# side and bottom panels
self.create_side_panel()
self.create_bottom_panel()
# panes' state must be restored after panels have been mapped,
# since the bottom pane position depends on the size of the vpaned.
self._side_panel_size = prefs_manager_get_side_panel_size()
self._bottom_panel_size = prefs_manager_get_bottom_panel_size()
self._hpaned.connect_after("map", self.hpaned_restore_position)
self._vpaned.connect_after("map", self.vpaned_restore_position)
self._hpaned.show()
self._vpaned.show()
# Drag and drop support, set targets to None because we add the
# default uri_targets below
self.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, (), gtk.gdk.ACTION_COPY)
# Add uri targets
tl = self.drag_dest_get_target_list()
if tl == None:
tl = ()
self.drag_dest_set_target_list(tl)
tl += (TARGET_URI_LIST,)
# connect instead of override, so that we can
# share the cb code with the view TODO
# self.connect("drag_data_received", drag_data_received_cb)
# we can get the clipboard only after the widget
# is realized TODO
# self.connect("realize", window_realized)
# self.connect("unrealize", window_unrealized)
# Check if the window is active for fullscreen TODO
# self.connect("notify::is-active", check_window_is_active)
debug_message(DEBUG_WINDOW, "Update plugins ui")
# plugins_engine_get_default().activate_plugins(self) TODO
# set visibility of panes.
# This needs to be done after plugins activatation TODO
# self.init_panels_visibility()
# self.update_sensitivity_according_to_open_tabs() TODO
debug_message(DEBUG_WINDOW, "END")
# self._action_group = gtk.ActionGroup("ExamplePyPluginActions")
# self._action_group.add_actions(
# [
# ("File", None, "File", None, None, None),
# ("FileNew", gtk.STOCK_NEW, None, None, None, commands._file_new),
#.........这里部分代码省略.........
开发者ID:jhasse,项目名称:taluka,代码行数:101,代码来源:window.py
示例16: __init__
def __init__(self):
super(type(self), self).__init__()
debug(DEBUG_WINDOW)
self._active_tab = None
self._num_tabs = 0
self._removing_tabs = False
self._state = WINDOW_STATE_NORMAL
self._dispose_has_run = False
self._fullscreen_controls = None
self._fullscreen_animation_timeout_id = 0
#TODO
#self._message_bus = MessageBus()
self._window_group = gtk.WindowGroup()
self._window_group.add_window(self)
main_box = gtk.VBox(False, 0)
self.add(main_box)
main_box.show()
# Add menu bar and toolbar bar
self.create_menu_bar_and_toolbar(main_box)
# Add status bar
self.create_statusbar(main_box)
# Add the main area
debug_message(DEBUG_WINDOW, "Add main area")
self._hpaned = gtk.HPaned()
main_box.pack_start(self._hpaned, True, True, 0)
self._vpaned = gtk.VPaned()
self._hpaned.pack2(self._vpaned, True, False)
debug_message(DEBUG_WINDOW, "Create taluka notebook")
self._notebook = Notebook()
self.add_notebook(self._notebook)
# side and bottom panels
self.create_side_panel()
self.create_bottom_panel()
# panes' state must be restored after panels have been mapped,
# since the bottom pane position depends on the size of the vpaned.
self._side_panel_size = prefs_manager_get_side_panel_size()
self._bottom_panel_size = prefs_manager_get_bottom_panel_size()
self._hpaned.connect_after("map", self.hpaned_restore_position)
self._vpaned.connect_after("map", self.vpaned_restore_position)
self._hpaned.show()
self._vpaned.show()
# Drag and drop support, set targets to None because we add the
# default uri_targets below
self.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, (), gtk.gdk.ACTION_COPY)
# Add uri targets
tl = self.drag_dest_get_target_list()
if tl == None:
tl = ()
self.drag_dest_set_target_list(tl)
tl += (TARGET_URI_LIST,)
# connect instead of override, so that we can
# share the cb code with the view TODO
# self.connect("drag_data_received", drag_data_received_cb)
# we can get the clipboard only after the widget
# is realized TODO
# self.connect("realize", window_realized)
# self.connect("unrealize", window_unrealized)
# Check if the window is active for fullscreen TODO
# self.connect("notify::is-active", check_window_is_active)
debug_message(DEBUG_WINDOW, "Update plugins ui")
# plugins_engine_get_default().activate_plugins(self) TODO
# set visibility of panes.
# This needs to be done after plugins activatation TODO
# self.init_panels_visibility()
# self.update_sensitivity_according_to_open_tabs() TODO
debug_message(DEBUG_WINDOW, "END")
# self._action_group = gtk.ActionGroup("ExamplePyPluginActions")
# self._action_group.add_actions(
# [
# ("File", None, "File", None, None, None),
# ("FileNew", gtk.STOCK_NEW, None, None, None, commands._file_new),
# ("FileOpen", gtk.STOCK_OPEN, None, None, None, commands._file_open),
# ("FileSave", gtk.STOCK_SAVE, None, None, None, commands._file_save),
# ("FileSaveAs", gtk.STOCK_SAVE_AS, None, "<shift><control>S",
#.........这里部分代码省略.........
开发者ID:jhasse,项目名称:taluka,代码行数:101,代码来源:window.py
示例17: OpPanel
class OpPanel(Operation):
"""This panel controls inserts."""
def __init_sizer(self, parent):
#smallestSize = parent.rightSizer.GetSize() - parent.rightTopSizer.GetSize() - (10,10)
mainSizer = wx.BoxSizer(wx.VERTICAL)
#mainSizer.SetMinSize(smallestSize)
mainSizer.Add(self.notebook, 0, wx.EXPAND)
self.SetSizerAndFit(mainSizer)
def __init_ctrls(self, prnt):
wx.Panel.__init__(self, id=-1, name=u'Panel', parent=prnt,
style=wx.TAB_TRAVERSAL)
self.notebook = Notebook(self, main)
self.insertToolsPanel = insertTools.Panel(self.notebook, main)
self.notebook.init_pages(self.insertToolsPanel,
_(u"Insert settings"), u'insert.ico')
self.numberingPanel = self.notebook.numbering
self.dateTimePanel = self.notebook.dateTime
def __init__(self, parent, main_window, params={}):
Operation.__init__(self, params)
global main
main = main_window
self.__init_ctrls(parent)
self.__init_sizer(parent)
def on_config_load(self):
"""Update GUI elements, settings after config load."""
self.insertToolsPanel.activate_options(False)
self.numberingPanel.on_config_load()
self.dateTimePanel.get_from_item_checkbox(False)
def reset_counter(self, c):
"""Reset the numbering counter for the operation."""
utils.reset_counter(self, self.insertToolsPanel, c)
def rename_item(self, path, name, ext, original):
"""Insert into name."""
newName = self.join_ext(name, ext)
if not newName:
return path, name, ext
insert = self.insertToolsPanel
operations = insert.opButtonsPanel
parsedText = operations.parse_input(insert.Text.GetValue(), original, self)
# prefix
if insert.prefix.GetValue():
newName = parsedText + name
# suffix
elif insert.suffix.GetValue():
newName = name + parsedText
# exact position
elif insert.position.GetValue():
pos = insert.positionPos.GetValue()
if pos == -1:
newName += parsedText
elif pos < -1:
newName = newName[:pos + 1] + parsedText + newName[pos + 1:]
else:
newName = newName[:pos] + parsedText + newName[pos:]
# insert before/after a character:
elif insert.after.GetValue() or insert.before.GetValue():
good2go = False
textMatch = insert.BAtextMatch.GetValue()
# text search
if not insert.regExpPanel.regExpr.GetValue():
try:
insertAt = newName.index(textMatch)
except ValueError:
pass
else:
if insert.after.GetValue():
insertAt += len(textMatch)
good2go = True
# regular expression search
else:
insertRE = insert.regExpPanel.create_regex(textMatch)
try:
insertAt = insertRE.search(newName).end()
except AttributeError:
pass
else:
if insert.before.GetValue():
insertAt -= len(textMatch)
good2go = True
if good2go:
newName = newName[:insertAt] + parsedText + newName[insertAt:]
# insert in between 2 characters:
# (copy of search.py function)
elif insert.between.GetValue():
good2go = False
if insert.regExpPanel.regExpr.GetValue():
mod1 = insert.regExpPanel.create_regex(insert.BTWtextMatch1.GetValue())
mod2 = insert.regExpPanel.create_regex(insert.BTWtextMatch2.GetValue())
try:
#.........这里部分代码省略.........
开发者ID:RavenB,项目名称:metamorphose2,代码行数:101,代码来源:insert.py
示例18: listar_articulos
def listar_articulos(self):
a=Notebook(None,None,None, None, None,None)
return a.listar_articulos()
开发者ID:marcosd94,项目名称:reservas,代码行数:3,代码来源:controlador_articulo.py
示例19: pytest_funcarg__notebook_with_two_notes
def pytest_funcarg__notebook_with_two_notes(request):
notebook = Notebook()
notebook.new_note("hello world")
notebook.new_note("hello again")
return notebook
开发者ID:TheGhostHuCodes,项目名称:py3oop,代码行数:5,代码来源:test_notebook.py
示例20: pytest_funcarg__notebook_with_one_note
def pytest_funcarg__notebook_with_one_note(request):
notebook = Notebook()
notebook.new_note("hello world")
return notebook
开发者ID:TheGhostHuCodes,项目名称:py3oop,代码行数:4,代码来源:test_notebook.py
注:本文中的notebook.Notebook类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论