本文整理汇总了Python中history.History.save方法的典型用法代码示例。如果您正苦于以下问题:Python History.save方法的具体用法?Python History.save怎么用?Python History.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类history.History
的用法示例。
在下文中一共展示了History.save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Timermode
# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import save [as 别名]
class Timermode():
def __init__(self):
self.timer = None
self.mode = '3x3'
self.history = History()
def nextsolve(self):
self.scramble = scramble.scramble()
print("\n" + "Scramble: " + self.scramble + "\n")
print('0.00', end='\r')
self.lasttimer = self.timer
self.timer = Timer()
time.sleep(0.5)
def run(self):
while True:
self.nextsolve()
if self.configmode() == -1:
self.history.close()
break
self.playmode()
self.history.save(self.timer, self.scramble, self.mode)
def playmode(self):
self.timer.go(self.mode)
while True:
c = getch()
if c == ' ':
self.timer.stop()
return
def configmode(self):
while True:
c = getch()
if c == ' ':
break # space = start next solve
if c == 'q': # q = exit timer mode
print("Quit Timer\n")
return -1
if c == 'p':
print(self.history.getlast(self.mode, 2)) # p = print last 2 solves
if c == 'f':
self.history.deletelast() # f = delete last solve
if c == 'd': # d = set last solve as dnf
self.history.set_dnf()
print("DNF nub\n0.00", end="\r")
if c == '2': # 2 = set last solve as plustwo
self.history.set_plustwo()
print("+2 nub\n0.00", end="\r")
if c == 'm': # m = switch modes(3x3,oh, etc.)
self.changemode()
def changemode(self):
self.mode = input("let's play ")
示例2: Entry
# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import save [as 别名]
#.........这里部分代码省略.........
if not k in spec.args:
del kwargs[k]
ret = func(**kwargs)
except Exception as e:
# Can be number of arguments, or return values or simply buggy
# modules
print(e)
traceback.print_exc()
return True
if not ret or not ret[0]:
return True
res = ret[0]
completed = ret[1]
if len(ret) > 2:
after = ret[2]
else:
after = " "
# Replace the word
if words[posidx] == None:
# At end of everything, just append
spec = None
self._entry.insert_text(completed, self._entry.get_text_length())
self._entry.set_position(-1)
else:
spec = self._complete_word_match(words[posidx])
self._entry.delete_text(spec[1], spec[2])
self._entry.insert_text(completed, spec[1])
self._entry.set_position(spec[1] + len(completed))
if len(res) == 1:
# Full completion
lastpos = self._entry.get_position()
if not isinstance(res[0], commands.module.Module) or not res[0].commands():
if (
words[posidx]
and after == " "
and (words[posidx].group(2) != None or words[posidx].group(3) != None)
):
lastpos = lastpos + 1
self._entry.insert_text(after, lastpos)
self._entry.set_position(lastpos + 1)
elif completed == wordsstr[posidx] or not res[0].method:
self._entry.insert_text(".", lastpos)
self._entry.set_position(lastpos + 1)
if self._info_window:
self._info_window.destroy()
else:
# Show popup with completed items
if self._info_window:
self._info_window.clear()
ret = []
for x in res:
if isinstance(x, commands.method.Method):
ret.append("<b>" + saxutils.escape(x.name) + "</b> (<i>" + x.oneline_doc() + "</i>)")
else:
ret.append(str(x))
self.info_show("\n".join(ret), True)
return True
def on_draw(self, widget, ct):
win = widget.get_window(Gtk.TextWindowType.BOTTOM)
if not Gtk.cairo_should_draw_window(ct, win):
return False
Gtk.cairo_transform_to_window(ct, widget, win)
color = self.get_border_color()
width = win.get_width()
ct.set_source_rgba(color.red, color.green, color.blue, color.alpha)
ct.move_to(0, 0)
ct.line_to(width, 0)
ct.stroke()
return False
def on_destroy(self, widget):
self._view.set_border_window_size(Gtk.TextWindowType.BOTTOM, 0)
self._view.disconnect(self.view_style_updated_id)
self._view.disconnect(self.view_draw_id)
if self._info_window:
self._info_window.destroy()
self._history.save()
示例3: Entry
# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import save [as 别名]
#.........这里部分代码省略.........
self._entry.show()
hbox.add(self._entry)
self._copy_style_from_view()
self._view_style_updated_id = self._view.connect('style-updated', self._on_view_style_updated)
def _on_view_destroyed (self, widget, user_data=None):
self._view.disconnect(self._view_style_updated_id)
self._view_style_updated_id = None
def _on_view_style_updated(self, widget):
self._copy_style_from_view()
@property
def _border_color(self):
style = self._view.get_buffer().get_style_scheme().get_style('right-margin')
if not style is None and style.props.foreground_set:
color = Gdk.RGBA()
color.parse(style.props.foreground)
else:
color = self._get_background_color(Gtk.StateFlags.NORMAL, 'bottom').copy()
color.red = 1 - color.red
color.green = 1 - color.green
color.blue = 1 - color.blue
color.alpha = 0.3
return color
def _get_background_color(self, state, cls=None):
context = self._view.get_style_context()
context.save()
if not cls is None:
context.add_class(cls)
ret = context.get_background_color(state)
context.restore()
return ret
def _get_foreground_color(self, state, cls=None):
context = self._view.get_style_context()
context.save()
if not cls is None:
context.add_class(cls)
ret = context.get_color(state)
context.restore()
return ret
def _get_font(self):
context = self._view.get_style_context()
return context.get_font(Gtk.StateFlags.NORMAL)
def _styled_widgets(self):
widgets = [self, self._entry, self._prompt_label]
if not self._info is None:
示例4: Location
# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import save [as 别名]
from company import Company
from history import History
for l in [ 'Delhi', 'Bangalore', 'Mumbai', 'Pune', 'Hyderabad' ]:
loc = Location(l)
loc.save()
for c in [ 'IT/Hardware', 'IT/Software', 'Sales', 'Marketing', 'Finance', 'Management', 'ITES' ]:
cat = Cat(c)
cat.save()
for c in [ 'ABC', 'XYZ' ]:
co = Company(c)
co.save()
r = Rec(fname='Ashish',lname='Mukherjee',password='foobar',email='[email protected]', cpny_id = 1)
r.save()
j = Job(job_code = 'SSE - 1000',loc_id=1,title = 'Senior Software Engineer - Java',descr = 'Seeking mid-level Java programmer',kw = 'java',rec_id = 1,cat_id = 1,cpny_id = 1)
j.save()
j = JobSeeker(fname = 'Ashish', lname = 'Mukherjee', email = '[email protected]', phone = '8800199033', title = 'Experienced Java Engineer', resume = 'AshishMukherjee.doc', loc_id = 1, cat_id = 1, kw = 'Java', vdo = '')
j.save()
h = History(job_id = 1, rec_id = 1, cand_id = 1, comments = 'Nice resume', stage = 'WIP')
h.save()
j = Job.get_object(1)
j.set_attr({ 'title': 'SSE- Java/J2EE' })
j.save()