本文整理汇总了Python中tkinter.scrolledtext.ScrolledText.pack方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledText.pack方法的具体用法?Python ScrolledText.pack怎么用?Python ScrolledText.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.scrolledtext.ScrolledText
的用法示例。
在下文中一共展示了ScrolledText.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
class MyGUI:
def __init__(self, reps=3):
self.reps = reps
self.text = ScrolledText()
self.text.pack()
threadChecker(self.text)
self.text.bind('<Button-1>',
lambda event: list(map(self.onEvent, range(6))))
def onEvent(self, i):
myname = 'thread-%s' % i
startThread(action=self.threadaction, args=(i, ),
context=(myname,), onExit=self.threadexit,
onFail=self.threadfail, onProgress=self.threadprogress)
def threadaction(self, id, progress):
for i in range(self.reps):
time.sleep(1)
if progress: progress(i)
if id % 2 == 1: raise Exception
def threadexit(self, myname):
self.text.insert('end', '%s\texit\n' % myname)
self.text.see('end')
def threadfail(self, exc_info, myname):
self.text.insert('end', '%s\tfail\t%s\n' % (myname, exc_info[0]))
self.text.see('end')
def threadprogress(self, count, myname):
self.text.insert('end', '%s\tprog\t%s\n' % (myname, count))
self.text.see('end')
self.text.update()
示例2: GuiConsole
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
class GuiConsole(Frame):
def __init__(self, master=None, cnf={}, **kw):
super(GuiConsole, self).__init__(master, cnf, **kw)
self.pack(fill=BOTH, expand=YES)
self.console = ScrolledText(self, font=('Source Code Pro', 12, 'normal'))
self.console.pack(side=TOP, fill=BOTH, expand=YES, padx=5, pady=5)
self.console.focus()
self.console.mark_set(INSERT, '1.0')
def clear(self):
self.console.delete('1.0', END)
def write(self, text):
text = '{}'.format(text)
self.console.insert(INSERT, text)
self.console.mark_set(INSERT, INSERT+'+{}c'.format(len(text)))
def writeline(self, text):
self.write('{}\n'.format(text))
def writelines(self, lines):
for line in lines:
self.writeline(line)
def read(self):
pass
示例3: main
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def main():
global text_in
global sock
window = tk.Tk()
window.wm_title('Vessel XIV')
text_out = ScrolledText(window, state='disabled', takefocus=0)
#text_out.configure(state='disabled')
text_out.pack()
text_in = tk.Entry(window, takefocus=1)
text_in.bind("<Return>", lambda e: evaluate_in(e, text_in, text_out))
text_in.pack()
HOST = 'arctem.com'
#HOST = 'localhost'
PORT = 50001
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
t = threading.Thread(target=socket_thread, args=(sock, text_out))
t.start()
window.mainloop()
示例4: receivePrivateChat
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def receivePrivateChat(self, connectingUser):
global conversationBoxList
print("CHAT PRIVATA in arrivo con "+connectingUser)
newWindow = Toplevel(self.parent)
newWindow.title("Python Chat requested by "+connectingUser)
newWindow.minsize(400, 475)
newWindow.focus()
def disconnectPM():
del conversationBoxList[connectingUser]
newWindow.destroy()
newWindow.protocol('WM_DELETE_WINDOW', disconnectPM)
#label = Label(newWindow, text="PROVA PROVA")
#label.pack(side="top", fill="both", padx=10, pady=10)
frame = Frame(newWindow)
frame.pack(fill=BOTH, expand=1, side=LEFT)
box = ScrolledText(frame, wrap=WORD, relief = GROOVE, width=30, height=18, font=self.customFontMessage)
box.config(state=DISABLED)
box.pack(expand="yes", fill=BOTH, side=TOP)
textarea = Text(frame, width=30, height=5)
textarea.bind("<KeyRelease-Return>", lambda event : self.getprivatetext(event, textarea, connectingUser))
textarea.pack(expand="yes", fill=BOTH, side=TOP)
#aggiungo alla mappa globale il box di conversazione
conversationBoxList[connectingUser] = box
示例5: TextFrame
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
class TextFrame(ttk.LabelFrame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._init_ui()
def _init_ui(self):
self.textbox = ScrolledText(self, width=70, height=10)
self.textbox.bind("<1>", lambda event: self.textbox.focus_set())
self.textbox.pack(expand=True, fill='both')
示例6: _conButtonCmd
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def _conButtonCmd(self):
popwin = PopupWindow("Container Log")
popwin.grab_set()
popwin.focus()
details = self.checkresult.getContainerLogs()
stext = ScrolledText(popwin)
stext.config(font = ("courier", 15, "normal"))
stext.pack()
for d in details:
stext.insert("end",d)
stext.see("end")
示例7: _buttonCmd
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def _buttonCmd(self):
popwin = PopupWindow("Details")
popwin.grab_set()
popwin.focus()
details = self.checkresult.getDetails()
# with os.popen("kubectl describe nodes/115.154.138.241") as re:
# details = re.readlines()
stext = ScrolledText(popwin)
stext.config(font = ("courier", 15, "normal"))
stext.pack()
for d in details:
stext.insert("end",d)
stext.see("end")
示例8: Login
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def Login(entries,root):
text=[]
for entry in entries:
text.append(entry[1].get())
print(text)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(text[0], username=text[1], password=text[2])
stdin, stdout, stderr = ssh.exec_command(text[3])
u=stdout.readlines()
output = ''.join(u)
sc=ScrolledText(root)
sc.pack(side=LEFT)
sc.insert(END, output)
示例9: View
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
class View(Frame):
def __init__ (self,parent=None):
Frame.__init__(self,parent)
self.pack()
self.makeWidgets()
self.scrolltext = ScrolledText(master=self)
self.scrolltext.pack()
def makeWidgets(self):
btn = Button(text='Hello World',command=self.onClick)
btn.pack(side=TOP)
def onClick(self):
'''Delegate event handling to Controller'''
app.controller.handleClick()
示例10: contViewRaw
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def contViewRaw(self, msgnums, pyedit=True):
for msgnum in msgnums:
fulltext = self.getMessage(msgnum)
if not pyedit:
from tkinter.scrolledtext import ScrolledText
window = windows.QuietPopupWindow(appname, 'raw message viewer')
browser = ScrolledText(window)
browser.insert('0.0', fulltext)
browser.pack(expand=YES, fill=BOTH)
else:
wintitle = ' - raw message text'
browser = textEditor.TextEditorMainPopup(self, winTitle=wintitle)
browser.update()
browser.setAllText(fulltext)
browser.clearModified()
示例11: __init__
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def __init__(self, appname, helptext, iconfile=None, showsource=lambda:0):
PopupWindow.__init__(self, appname, 'Help', iconfile)
from tkinter.scrolledtext import ScrolledText # a nonmodal dialog
bar = Frame(self) # pack first=clip last
bar.pack(side=BOTTOM, fill=X)
code = Button(bar, bg='beige', text="Source", command=showsource)
quit = Button(bar, bg='beige', text="Cancel", command=self.destroy)
code.pack(pady=1, side=LEFT)
quit.pack(pady=1, side=LEFT)
text = ScrolledText(self) # add Text + scrollbar
text.config(font=self.myfont)
text.config(width=self.mywidth) # too big for showinfo
text.config(bg='steelblue', fg='white') # erase on btn or return
text.insert('0.0', helptext)
text.pack(expand=YES, fill=BOTH)
self.bind("<Return>", (lambda event: self.destroy()))
示例12: onHist
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def onHist(self):
# show recent calcs log popup
from tkinter.scrolledtext import ScrolledText # or PP4E.Gui.Tour
new = Toplevel() # make new window
ok = Button(new, text="OK", command=new.destroy)
ok.pack(pady=1, side=BOTTOM) # pack first=clip last
text = ScrolledText(new, bg='beige') # add Text + scrollbar
text.insert('0.0', self.eval.getHist()) # get Evaluator text
text.see(END) # 3.0: scroll to end
text.pack(expand=YES, fill=BOTH)
# new window goes away on ok press or enter key
new.title("PyCalc History")
new.bind("<Return>", (lambda event: new.destroy()))
ok.focus_set() # make new window modal:
new.grab_set() # get keyboard focus, grab app
new.wait_window() # don't return till new.destroy
示例13: contViewRaw
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def contViewRaw(self, msgnums, pyedit=True): # do we need full TextEditor?
for msgnum in msgnums: # could be a nested def
fulltext = self.getMessage(msgnum) # fulltext is Unicode decoded
if not pyedit:
# display in a scrolledtext
from tkinter.scrolledtext import ScrolledText
window = windows.QuietPopupWindow(appname, 'raw message viewer')
browser = ScrolledText(window)
browser.insert('0.0', fulltext)
browser.pack(expand=YES, fill=BOTH)
else:
# 3.0/4E: more useful PyEdit text editor
wintitle = ' - raw message text'
browser = textEditor.TextEditorMainPopup(self, winTitle=wintitle)
browser.update()
browser.setAllText(fulltext)
browser.clearModified()
示例14: LogViewer
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
class LogViewer(Frame):
def __init__(self, parent, filename):
Frame.__init__(self,parent)
self.filename = filename
self.file = open(filename, 'r')
self.text = ScrolledText(parent)
self.text.pack(fill=BOTH)
data = self.file.read()
self.size = len(data)
self.text.insert(END, data)
self.after(100, self.poll)
def poll(self):
if os.path.getsize(self.filename) > self.size:
data = self.file.read()
self.size = self.size + len(data)
self.text.insert(END, data)
self.after(100,self.poll)
示例15: __init__
# 需要导入模块: from tkinter.scrolledtext import ScrolledText [as 别名]
# 或者: from tkinter.scrolledtext.ScrolledText import pack [as 别名]
def __init__(self,appname,helptext,iconfile=None,
showsource=lambda:0):
PopupWindow.__init__(self,appname,'Help',iconfile)
from tkinter.scrolledtext import ScrolledText
bar=Frame(self)
bar.pack(side=BOTTOM,fill=X)
code=Button(bar,bg='beige',text='Source',command=showsource)
quit=Button(bar,bg='beige',text='Cancel',command=self.destroy)
code.pack(pady=1,side=LEFT)
quit.pack(pady=1,side=LEFT)
text=ScrolledText(self)
text.config(font=self.myfont)
text.config(width=self.mywidth)
text.config(bg='steelblue',fg='white')
text.insert('0.0',helptext)
text.pack(expand=YES,fill=BOTH)
self.bind('<Return>',(lambda event:self.destroy()))