本文整理汇总了Python中ScrolledText.pack方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledText.pack方法的具体用法?Python ScrolledText.pack怎么用?Python ScrolledText.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScrolledText
的用法示例。
在下文中一共展示了ScrolledText.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GredAboutBox
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class GredAboutBox(GatoDialogs.AboutBox):
def body(self, master):
self.resizable(0,0)
self.catIconImage = PhotoImage(data=GatoIcons.gred)
self.catIcon = Label(master, image=self.catIconImage)
self.catIcon.pack(side=TOP)
label = Label(master, text=GatoDialogs.crnotice1)
label.pack(side=TOP)
label = Label(master, font="Helvetica 10",
text=GatoDialogs.crnotice2, justify=CENTER)
label.pack(side=TOP)
color = self.config("bg")[4]
self.infoText = ScrolledText(master, relief=FLAT,
padx=3, pady=3,
background=color,
#foreground="black",
wrap='word',
width=60, height=12,
font="Times 10")
self.infoText.pack(expand=0, fill=X, side=BOTTOM)
self.infoText.delete('0.0', END)
self.infoText.insert('0.0', GatoGlobals.gLGPLText)
self.infoText.configure(state=DISABLED)
self.title("Gred - About")
示例2: create_widgets
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
def create_widgets(self, parent, controller):
self.info = tk.Label(self, text="Enter a stock ticker")
self.info.pack()
self.e = ttk.Entry(self) # entry form for stock symbol
self.e.pack()
self.info2 = tk.Label(self, text="Enter timespan (6m, 1y, 3y)")
self.info2.pack()
self.span = tk.Entry(self)
self.span.pack(side=tk.TOP)
self.span.focus_set()
self.b = ttk.Button(self, text='Submit', command=lambda: self.get_input())
# self.b.grid(row=3, column=1, sticky=tk.N)
self.b.pack(side=tk.TOP)
self.info3 = tk.Label(self, text="Results")
self.info3.pack(side=tk.LEFT)
global text
text = ScrolledText(self, font=("Consolas",10), padx=10, pady=10)
text.insert(tk.INSERT, "\n")
text.pack(side=tk.BOTTOM, expand=True)
self.b1 = tk.Button(self, text='Event Plot', command=lambda: self.chart_events())
self.b1.pack(side=tk.RIGHT)
示例3: compilePythonCode
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
def compilePythonCode(self):
if(self.currentFile):
self.saveFile()
original_stdout = sys.stdout
try:
a = compiler.compile(self.currentText, self.currentFile,
mode = "exec")
# (http://stackoverflow.com/questions/4904079/
# execute-a-block-of-python-code-with-exec-capturing-all-its-output)
# captures stdout in temp stringIO buffer to get output
# and then reverts changes
buffer = StringIO()
sys.stdout = buffer
eval(a)
sys.stdout = original_stdout
val = buffer.getvalue()
rt = Tk()
outputText = ScrolledText(rt, width = 50)
outputText.insert(END, val)
outputText.pack()
rt.mainloop()
except:
print "Error!"
self.displayMessageBox("Error","There is an error in the code.")
sys.stdout = original_stdout
else:
self.saveAs()
示例4: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
def __init__(self, master):
def saisie():
myref = pyP2B()
resultBox.insert('end', myref.getPubmedReference(valeur.get()))
valeur = StringVar()
frame = Frame(master)
frame.pack()
queryFrame = Frame(frame)
queryFrame.pack(fill=X)
label = Label(queryFrame, text="PMID: ")
label.pack(side=LEFT)
entry = Entry(queryFrame, textvariable=valeur, text=' ')
entry.pack(side=LEFT)
okButton = Button(queryFrame, text="OK", command=saisie)
okButton.pack(side=LEFT)
resultFrame = Frame(frame)
resultFrame.pack(fill=X)
resultBox = ScrolledText(resultFrame)
resultBox.pack(side=LEFT)
示例5: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class editor:
def __init__(self,rt):
if rt == None:
self.t = Tk(rt)
else:
self.t = Toplevel(rt)
self.t.title("Taposh's Editor %d" %len(t1))
self.bar = Menu(rt)
self.filem = Menu(self.bar)
self.filem.add_command(label ="Open..", command =openfile)
self.filem.add_command(label ="New..", command =newwin)
self.filem.add_command(label ="Save..", command =savefile)
self.filem.add_command(label ="Save as..", command =savefile)
self.filem.add_separator()
self.filem.add_command(label ="Exit..", command = die)
self.helpm = Menu(bar)
self.helpm.add_command(label ="Index..", command =callee)
self.helpm.add_separator()
self.helpm.add_command(label ="About..", command =about)
self.bar.add_cascade(label="File",menu=filem)
self.bar.add_cascade(label="Help",menu=helpm)
self.t.config(menu=bar)
self.f = Frame(self.t,width=512)
self.f.pack(expand=1,fill=BOTH)
self.st = ScrolledText(self.f,background="white")
self.st.pack(side=LEFT, fill=BOTH, expand=1)
示例6: App
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class App(Thread):
server = socket()
server.bind(('localhost', input("Port: ")))
server.listen(5)
client,addr = server.accept()
def __init__(self, master):
Thread.__init__(self)
frame = Frame(master)
frame.pack()
self.gettext = ScrolledText(frame, height=10,width=100, state=NORMAL)
self.gettext.pack()
sframe = Frame(frame)
sframe.pack(anchor='w')
self.pro = Label(sframe, text="Server>>");
self.sendtext = Entry(sframe,width=80)
self.sendtext.focus_set()
self.sendtext.bind(sequence="<Return>", func=self.Send)
self.pro.pack(side=LEFT)
self.sendtext.pack(side=LEFT)
self.gettext.insert(END,'Welcome to Chat\n')
self.gettext.configure(state=DISABLED)
def Send(self, args):
self.gettext.configure(state=NORMAL)
text = self.sendtext.get()
if text=="": text=" "
self.gettext.insert(END,'Me >> %s \n'%text)
self.sendtext.delete(0,END)
self.client.send(text)
self.sendtext.focus_set()
self.gettext.configure(state=DISABLED)
self.gettext.see(END)
def run(self):
Receive(self.client, self.gettext)
示例7: App
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class App(Thread):
client = socket()
def __init__(self, master):
Thread.__init__(self)
frame = Frame(master)
frame.pack()
gframe = Frame(frame)
gframe.pack(anchor='w')
self.lblserver = Label(gframe, text="IP Server :")
self.txtserver = Entry(gframe,width=40)
self.lblserver.pack(side=LEFT)
self.txtserver.pack(side=LEFT)
self.lblport = Label(gframe, text="Port :")
self.txtport = Entry(gframe,width=40)
self.lblport.pack(side=LEFT)
self.txtport.pack(side=LEFT)
self.koneksi = Button(gframe, text='Connect', command=self.Connect).pack(side=LEFT)
self.gettext = ScrolledText(frame, height=10,width=100)
self.gettext.pack()
self.gettext.configure(state=DISABLED)
sframe = Frame(frame)
sframe.pack(anchor='w')
self.pro = Label(sframe, text="Client>>")
self.sendtext = Entry(sframe,width=80)
self.sendtext.focus_set()
self.sendtext.bind(sequence="<Return>", func=self.Send)
self.pro.pack(side=LEFT)
self.sendtext.pack(side=LEFT)
def Connect(self):
try:
self.client.connect((str(self.txtserver.get()), int(self.txtport.get())))
self.gettext.configure(state=NORMAL)
self.gettext.insert(END,'Start to Chat\n')
self.gettext.configure(state=DISABLED)
self.start()
except:
tkMessageBox.showinfo("Error", "Unconnected")
def Send(self, args):
self.gettext.configure(state=NORMAL)
text = self.sendtext.get()
if text=="": text=" "
self.gettext.insert(END,'Me >> %s\n'%text)
self.sendtext.delete(0,END)
self.client.send(text)
self.sendtext.focus_set()
self.gettext.configure(state=DISABLED)
self.gettext.see(END)
def run(self):
Receive(self.client, self.gettext)
def __del__(self):
self.client.close()
示例8: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class editor:
def __init__(self, rt):
if rt == None:
self.t = Tk()
else:
self.t = Toplevel(rt)
self.t.title("Tkeditor %d" % len(t1))
self.bar = Menu(rt)
self.filem = Menu(self.bar)
self.filem.add_command(label="打开", command=self.openfile)
self.filem.add_command(label="新建", command=neweditor)
self.filem.add_command(label="保存", command=self.savefile)
self.filem.add_command(label="关闭", command=self.close)
self.filem.add_separator()
self.filem.add_command(label="退出", command=die)
self.helpm = Menu(self.bar)
self.helpm.add_command(label="关于", command=about)
self.bar.add_cascade(label="文件", menu=self.filem)
self.bar.add_cascade(label="帮助", menu=self.helpm)
self.t.config(menu=self.bar)
self.f = Frame(self.t, width=512)
self.f.pack(expand=1, fill=BOTH)
self.st = ScrolledText(self.f, background="white")
self.st.pack(side=LEFT, fill=BOTH, expand=1)
self.open = Button(self)
self.open["text"] = "open"
self.open["fg"] = "Blue"
self.open["command"] = self.openfile
self.open.pack({"side": "left"})
self.open.pack({"anchor": "nw"})
def close(self):
self.t.destroy()
print "close"
def openfile(self):
p1 = END
oname = askopenfilename(filetypes=[("Python file", "*.*")])
if oname:
for line in fileinput.input(oname):
self.st.insert(p1, line)
self.t.title(oname)
def savefile(self):
sname = asksaveasfilename()
if sname:
ofp = open(sname, "w")
ofp.write(self.st.get(1.0, END))
ofp.flush()
ofp.close()
self.t.title(sname)
示例9: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class editor:
def __init__(self,rt):
self.top=Tk()
self.top.title('记事本')
self.top.geometry('300x400')
self.bar=Menu(self.top)
self.filem=Menu(self.bar)
self.filem.add_command(label="打开",command=self.openfile)
self.filem.add_command(label="新建",command=self.neweditor)
self.filem.add_command(label="保存",command=self.savefile)
self.filem.add_command(label="关闭",command=self.close)
self.helpm=Menu(self.bar)
self.helpm.add_command(label="Help",command=self.about)
self.bar.add_cascade(label="文件",menu=self.filem)
self.bar.add_cascade(label="帮助",menu=self.helpm)
self.top.config(menu=self.bar)
self.f=Frame(self.top,width=512)
self.f.pack(expand=1,fill=BOTH)
self.st=ScrolledText(self.f,background="white")
self.st.pack(side=LEFT,fill=BOTH,expand=1)
def close(self):
self.top.destroy()
def openfile(self):
p1=END
oname=askopenfilename()#filetypes=[("Python file","*.*")])
if oname:
for line in fileinput.input(oname):
self.st.insert(p1,line)
self.top.title(oname)
def savefile(self):
sname=asksaveasfilename()
if sname:
ofp=open(sname,"w")
ofp.write(self.st.get(1.0,END).encode('utf-8'))
ofp.flush()
ofp.close()
self.top.title(sname)
def neweditor(self):
global root
self.top.append(editor(root))
def about(self):
tkMessageBox.showwarning("Tkeditor",'What?\n记事本也要帮助?')
示例10: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
def __init__(self,filenames={}):
self.a = Tk()
self.a.wm_title("Makefile Module Summary Logs")
self.n = notebook(self.a, LEFT)
self.frames = {}
for filename in filenames:
f = Frame(self.n())
st = ScrolledText(f, width=100, height=50)
logfile = open(filenames[filename], 'r')
st.insert(END, logfile.read())
st.pack()
self.frames[f] = st
x = self.n.add_screen(f, filename)
示例11: Add_Group
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class Add_Group(Frame):
def __init__(self, parent, app):
Frame.__init__(self, parent)
self.parent = parent
self.app = app
#Frame to hold Keyword Group new Entry and new keywords text box
addKGFrame = Frame(parent, bg="#E8E8E8", relief=RAISED)
addKGFrame.pack(fill=BOTH, expand=True, side=LEFT, padx=10, pady=10)
#Label for Entry Box
addGroupLabel = Label(addKGFrame, text="Enter New Group Name",bg="#E8E8E8")
addGroupLabel.pack(side=TOP)
#Entry Box for new Keyword Group
self.addGroup = Entry(addKGFrame, width=30, relief=SUNKEN)
self.addGroup.pack(side=TOP, fill=X, expand=True, pady=5)
#Label for New Keywords for Group Text Box
addKGLabel = Label(addKGFrame, text="Enter New Keywords (Optional)",bg="#E8E8E8")
addKGLabel.pack(side=TOP, fill=X, expand=True, pady=5)
#Canvas for Text Box to Enter New Keywords for New Group
addKGCanvas = Canvas(addKGFrame, bg="#E8E8E8", relief=SUNKEN)
addKGCanvas.pack(side=TOP, fill=BOTH, expand=True, pady=5)
#Keywords for new group scrollable text box
self.addKGText = ScrolledText(addKGCanvas, wrap=WORD, width=25,
height=15, relief=SUNKEN, highlightthickness=0, bd=1, padx=1, pady=1)
self.addKGText.pack(fill=BOTH, side=TOP, expand=True)
#Button to add new Keyword Group and Keywords
addKGButton = Button(addKGFrame, text="Add Group",
width=30, highlightbackground='#E8E8E8', command=self.group_add)
addKGButton.pack(side=TOP, fill=BOTH, expand=True)
#Function to add the keyword group
def group_add(self):
newGroup = self.addGroup.get()
if newGroup != "":
self.app.key_group.keyword_groups[newGroup] = []
text = self.addKGText.get('1.0', 'end-1c').splitlines()
for line in text:
self.app.key_group.keyword_groups[newGroup].append(line)
self.app.Groups.groupList.delete(0, END)
for x in self.app.key_group.keyword_groups:
self.app.Groups.groupList.insert(END, '%s' % x)
self.addKGText.delete('1.0', END)
self.addGroup.delete(0, END)
示例12: LogWindow
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class LogWindow(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master.title("Network Simulator Log")
self.text = ScrolledText(self)
self.text.pack(fill=BOTH, expand=1)
self.pack(fill=BOTH, expand=1)
self.text.config(
background="black",
foreground="white",
font=Font(
family="Courier", weight="bold"),
# state=DISABLED,
wrap=NONE, )
self.text.tag_config("DEBUG", foreground="green")
self.text.tag_config("ERROR", foreground="red")
self.text.tag_config("CRITICAL", foreground="red")
self.text.tag_config("EXCEPTION", foreground="red")
self.text.tag_config("WARNING", foreground="yellow")
self.text.tag_config("INFO", foreground="white")
self.text.bind("<Key>", lambda e: 'break')
self.text.bind("<Return>", self._clear)
self.queue = Queue()
self._update()
def _clear(self, event):
self.text.delete(1.0, END)
return 'break'
def _update(self):
try:
while True:
text, level = self.queue.get(block=False)
at_bottom = self.text.yview()[1] == 1.0
# self.text.config(state=NORMAL)
if len(self.text.get(1.0, END).strip()) != 0:
text = "\n" + text
self.text.insert(END, text, str(level))
# self.text.config(state=DISABLED)
if at_bottom:
self.text.yview_moveto(1.0)
except Empty:
pass
self.after(50, self._update)
def append(self, entry, level="INFO"):
self.queue.put((entry, level))
示例13: main
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
def main():
root = Tkinter.Tk(className=" TextPad")
textPad = ScrolledText(root, width=100, height=50)
# create a menu & define functions for each menu item
def open_command():
file = tkFileDialog.askopenfile(parent=root,mode='rb',title='Select a file')
if file != None:
contents = file.read()
textPad.insert('1.0',contents)
file.close()
def saving():
save_command(textPad)
def save_command(self):
file = tkFileDialog.asksaveasfile(mode='w')
if file != None:
# slice off the last character from get, as an extra return is added
data = self.get('1.0', END+'-1c')
file.write(data)
file.close()
def exit_command():
if tkMessageBox.askokcancel("Quit", "Do you really want to quit?"):
root.destroy()
def about_command():
label=tkMessageBox.showinfo("About", "Just Another TextPad Judical CLAIR")
menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=main)
filemenu.add_command(label="Open...", command=open_command)
filemenu.add_command(label="Save", command=saving)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=exit_command)
helpmenu = Menu(menu)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About...", command=about_command)
textPad.pack()
root.mainloop()
示例14: App
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class App(object):
def __init__(self,master):
topframe = Frame(master)
topframe.pack()
self.views = Frame(topframe)
self.views.pack()
self.controls = Frame(topframe)
self.controls.pack()
self.button = Button(self.controls, text='Quit', fg='red',
command=topframe.quit)
self.button.pack(side=RIGHT)
self.hi_there = Button(self.controls, text='Hello',
command=self.say_hi)
self.hi_there.pack(side=RIGHT)
self.textwindow = ScrolledText(self.views, width=90)
self.textwindow.pack(side=TOP)
self.chatline = Entry(self.controls)
self.chatline.pack(side=BOTTOM)
def say_hi(self):
print 'Hi there, everyone!'
示例15: Application
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import pack [as 别名]
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self): # 创建组件(包括文本框、输入框、)
# 创建文本框
self.text = ScrolledText(self)
target = open('test.txt', 'a+') # 打开test.txt,并进入读取与追加状态
target.seek(0)
self.text.insert(END, target.read()) # 打印文档记录
self.text.pack(side= BOTTOM)
# 创建输入框并可以输入
self.content = StringVar(self)
self.enter = Entry(self,textvariable=self.content)
self.enter.bind("<Return>", self.write) # bind第二参数可以调用函数
self.enter.pack(side=TOP,fill = X)
def write(self,target): # 输入内容后,按<Return>消失,同时内容一能保存到txt文档,二能在文本框显示
content = self.content.get()
target = open('test.txt', 'a+') # 打开test.txt,并进入读取与追加状态
date = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime()) # 计算时间(年月日时分秒)
target.write(date) # 写入时间
target.write("\n") # 给写入空一行
target.write(content) # 写入输入的日记内容
target.write("\n\n") # 重新开一行,保持每行只有一条日记内容
target.close()
self.text.insert(END,date)
self.text.insert(END,"\n")
self.text.insert(END,content) # 在文本框显示
self.text.insert(END,"\n\n")
self.text.see(END) # 指定位置
self.enter.delete(0,END) # 清除输入框内容,需由bind的Return激活