本文整理汇总了Python中formatter.Formatter.take方法的典型用法代码示例。如果您正苦于以下问题:Python Formatter.take方法的具体用法?Python Formatter.take怎么用?Python Formatter.take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类formatter.Formatter
的用法示例。
在下文中一共展示了Formatter.take方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FormatterApp
# 需要导入模块: from formatter import Formatter [as 别名]
# 或者: from formatter.Formatter import take [as 别名]
class FormatterApp(EventBasedAnimationClass):
def __init__(self, width, height):
self.width = 480
self.height = 360
self.cx = self.width / 2
self.cy = self.height / 2
self.buttons = {}
self.textBoxes = {}
self.checkBoxes = {}
self.path = ""
self.formatter = Formatter()
self.running = False
# Initializes the animation attributes.
def initAnimation(self):
self.timerDelay = 100 # milliseconds
self.initButtons()
self.initText()
self.initCheckBoxes()
self.root.wm_title("AutoFormatter")
self.canvas.v = IntVar()
def onTimerFired(self):
if self.running and self.formatter.stage == "Complete":
self.running = False
self.formatter.stage = "Incomplete"
def quit(self):
self.root.destroy()
def browse(self):
filename = tkFileDialog.askopenfile(parent=self.root, mode="rb", title="Choose a file")
path = filename.name
filename.close()
self.path = path
def go(self):
title = self.textBoxes["Title"].get("1.0", "end-1c")
author = self.textBoxes["Author"].get("1.0", "end-1c")
publisher = self.textBoxes["Publisher"].get("1.0", "end-1c")
copyright = self.textBoxes["Copyright"].get("1.0", "end-1c")
newStory = Story(title, author, self.path, copyright, publisher)
chapterTitles = self.checkBoxes["Titles"]
self.formatter.chapterNames = bool(self.var.get())
self.formatter.take(newStory)
self.running = True
self.formatThread = thread.start_new_thread(self.formatter.run, ())
def initButtons(self):
quit = Button(self.canvas, text="Quit", command=self.quit, width=6, height=1)
self.buttons["Quit"] = quit
browse = Button(self.canvas, text="Browse", command=self.browse, width=6, height=1, anchor="e")
self.buttons["Browse"] = browse
go = Button(self.canvas, text="Go", command=self.go, width=6, height=1)
self.buttons["Go"] = go
def initCheckBoxes(self):
self.var = IntVar()
chapterTitles = Checkbutton(self.canvas, text="Use chapter titles", variable=self.var)
self.checkBoxes["Titles"] = chapterTitles
def initText(self):
height = 1
width = 35
title = Text(self.root, height=height, width=width)
self.textBoxes["Title"] = title
author = Text(self.root, height=height, width=width)
self.textBoxes["Author"] = author
publisher = Text(self.root, height=height, width=width)
self.textBoxes["Publisher"] = publisher
copyright = Text(self.root, height=height, width=width)
self.textBoxes["Copyright"] = copyright
def drawBackground(self):
width = self.width
height = self.height
background = self.canvas.create_rectangle(0, 0, width, height, fill="bisque3")
def create(self, width, height, window):
self.canvas.create_window(width, height, window=window)
def drawBar(self):
self.canvas.create_window(self.width * 1 / 2, self.height * 1 / 4, window=self.bar)
def drawButtons(self):
w = self.width
h = self.height
if self.running:
pass
else:
quit = self.buttons["Quit"]
browse = self.buttons["Browse"]
go = self.buttons["Go"]
self.create(w * 1 / 8, h * 7 / 8, go)
self.create(w * 1 / 8, h * 6 / 8, browse)
self.create(w * 2 / 8, h * 7 / 8, quit)
def drawTextBoxes(self):
w = self.width
h = self.height
#.........这里部分代码省略.........