本文整理汇总了Python中ScrolledText.grid方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledText.grid方法的具体用法?Python ScrolledText.grid怎么用?Python ScrolledText.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScrolledText
的用法示例。
在下文中一共展示了ScrolledText.grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Application
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def getnew(self,event):
# When press ENTER, write diary to local file
# and print out it in Text frame
# and also clear the Entry box
line = self.newlog.get()
f = open('diary log.txt','a+')
f.write('%s\n' % line)
f.close()
self.t.insert(END,"%s\n" %line)
self.t.see(END)
self.e.delete(0,END)
def createWidgets(self):
self.newlog = StringVar(self) # define StringVar
self.l = Label(self, text = "Input here: ") # Label Widget 提示输入
self.l.grid(row = 0, column = 0, sticky = W)
self.e = Entry(self, textvariable = self.newlog, width = 80) # Entry box 输入框
self.e.bind("<Return>", self.getnew) # bind ENTER to function getnew
self.e.grid(row = 0, column = 1, sticky = W)
self.e.focus_set() # make the mouse focus on the entry box
self.t = ScrolledText(self) # ScrolledText 打印出文档的框
self.t.grid(columnspan = 2, sticky = W)
f = open('diary log.txt','a+')
self.t.insert(END,f.read())
self.t.see(END)
self.b = Button(self, text="QUIT", fg="red", command=self.quit) # 退出的button
self.b.grid(row = 2, column = 0, sticky = W)
示例2: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class PyAbel: #(tk.Tk):
def __init__(self, parent):
self.parent = parent
self.initialize()
def initialize(self):
self.fn = None
self.old_fn = None
self.old_method = None
self.old_fi = None
self.AIM = None
self.rmx = (368, 393)
# matplotlib figure
self.f = Figure(figsize=(2, 4))
self.gs = gridspec.GridSpec(2, 2, width_ratios=[1, 2])
self.gs.update(wspace=0.2, hspace=0.5)
self.plt = []
self.plt.append(self.f.add_subplot(self.gs[0]))
self.plt.append(self.f.add_subplot(self.gs[1]))
self.plt.append(self.f.add_subplot(self.gs[2], sharex=self.plt[0],
sharey=self.plt[0]))
self.plt.append(self.f.add_subplot(self.gs[3]))
for i in [0, 2]:
self.plt[i].set_adjustable('box-forced')
# hide until have data
for i in range(4):
self.plt[i].axis("off")
# tkinter
# set default font size for buttons
self.font = tkFont.Font(size=11)
self.fontB = tkFont.Font(size=12, weight='bold')
#frames top (buttons), text, matplotlib (canvas)
self.main_container = tk.Frame(self.parent, height=10, width=100)
self.main_container.pack(side="top", fill="both", expand=True)
self.button_frame = tk.Frame(self.main_container)
#self.info_frame = tk.Frame(self.main_container)
self.matplotlib_frame = tk.Frame(self.main_container)
self.button_frame.pack(side="top", fill="x", expand=True)
#self.info_frame.pack(side="top", fill="x", expand=True)
self.matplotlib_frame.pack(side="top", fill="both", expand=True)
self._menus()
self._button_area()
self._plot_canvas()
self._text_info_box()
def _button_frame(self):
self.button_frame = tk.Frame(self.main_container)
self.button_frame.pack(side="top", fill="x", expand=True)
self._menus()
def _menus(self):
# menus with callback ----------------
# duplicates the button interface
self.menubar = tk.Menu(self.parent)
self.transform_method = tk.IntVar()
# File - menu
self.filemenu = tk.Menu(self.menubar, tearoff=0)
self.filemenu.add_command(label="Load image file",
command=self._loadimage)
self.filemenu.add_separator()
self.filemenu.add_command(label="Exit", command=self._quit)
self.menubar.add_cascade(label="File", menu=self.filemenu)
# Process - menu
self.processmenu = tk.Menu(self.menubar, tearoff=0)
self.processmenu.add_command(label="Center image", command=self._center)
self.submenu=tk.Menu(self.processmenu)
for method in Abel_methods:
self.submenu.add_radiobutton(label=method,
var=self.transform_method, val=Abel_methods.index(method),
command=self._transform)
self.processmenu.add_cascade(label="Inverse Abel transform",
menu=self.submenu, underline=0)
self.processmenu.add_command(label="Speed distribution",
command=self._speed)
self.processmenu.add_command(label="Angular distribution",
command=self._anisotropy)
self.angmenu=tk.Menu(self.processmenu)
self.menubar.add_cascade(label="Processing", menu=self.processmenu)
# view - menu
self.viewmenu = tk.Menu(self.menubar, tearoff=0)
self.viewmenu.add_command(label="Raw image", command=self._display)
self.viewmenu.add_command(label="Inverse Abel transformed image",
command=self._transform)
self.viewmenu.add_command(label="view buttons",
command=self._on_buttons)
self.menubar.add_cascade(label="View", menu=self.viewmenu)
#.........这里部分代码省略.........
示例3: getText
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
def getText():
global tekst, textPad
secret = '123456'
cipher = AES.new(pad(secret))
txt = textPad.get('1.0',Tkinter.END)
encoded = EncodeAES(cipher, txt)
textPad2.insert(Tkinter.INSERT, encoded)
pass
root = Tkinter.Tk()
root.geometry("1000x330+300+300")
textPad = ScrolledText(root, width=50, height=20, bg='grey')
textPad.grid(padx=15, pady=5, row=0, column=0)
textPad2 = ScrolledText(root, width=50, height=20, bg='grey')
textPad2.grid(padx=100, pady=5, row=0, column=4)
dugme = Tkinter.Button(root, text='Get Text', width=5, command=getText)
dugme.grid(padx=5, pady=5, row=0, column=2)
tekst = Tkinter.StringVar()
label1 = Tkinter.Label(root, textvariable=tekst)
label1.grid(row=0, column=3)
root.mainloop()
示例4: MipsxTkGui
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class MipsxTkGui(Frame):
def __init__(self, parent, control):
Frame.__init__(self, parent)
self.parent = parent
self.parent.title("Mipsx - GUI for gdb multiarch")
self.style = Style()
self.style.theme_use("default")
self.pack(fill=BOTH, expand=1)
# Para expandir cuando las ventanas cambian de tamao
for i in range(3):
self.columnconfigure(i, weight=1)
for i in range(20):
self.rowconfigure(i, weight=1)
lbl = Label(self, text="Registros")
lbl.grid(row=1,column=2, sticky=W, pady=4, padx=5)
self.registros = Text(self,height=12,width=80)
self.registros.grid(row=2, column=2, columnspan=1, rowspan=5,
sticky=E+W+S+N)
lbl = Label(self, text="Programa en Assembler y Prorama Binario Decodificado (disassemble) ")
lbl.grid(row=7, column=2, pady=1, padx=1, sticky=W+N+E+S)
self.programa = Text(self, height=6,width=80)
self.programa.grid(row=8, column=2, columnspan=1, rowspan=5,
padx=1, sticky=E+W+S+N)
lbl = Label(self, text='Memoria - Segmento de datos (debe existir la etiqueta "memoria") - Segmento de texto - Pila')
lbl.grid(row=13, column=2, pady=1, padx=1, sticky=W+N+E+S)
self.memoria = Text(self,height=15,width=80)
self.memoria.grid(row=14, column=2, columnspan=1, rowspan=5,
padx=1, sticky=E+W+S+N)
lbl4 = Label(self, text="Mensajes de Depuracion")
lbl4.grid(row=13, column=0, pady=1, padx=1, sticky=W+N+E+S)
self.mensajes = Text(self,height=8,width=60)
self.mensajes.grid(row=14, column=0, columnspan=1, rowspan=5,
padx=1, sticky=E+W+S+N)
lbl = Label(self, text="Editor del Programa")
lbl.grid(row=1,column=0, sticky=W, pady=4, padx=5)
self.editor = ScrolledText(self,height=20,width=60)
self.editor.grid(row=2, column=0, columnspan=1, rowspan=10,
padx=1, sticky=E+W+S+N)
menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label="Archivo", menu=filemenu)
filemenu.add_command(label="Nuevo", command=control.nuevo)
filemenu.add_command(label="Abrir...", command=control.abrir)
filemenu.add_command(label="Guardar...", command=control.guardar)
filemenu.add_separator()
filemenu.add_command(label="Salir", command=control.salir)
menu.add_command(label="Run", command=control.ejecutar)
menu.add_command(label="Next", command=control.prox_instruccion)
menu.add_command(label="Breakpoint", command=control.no_hacer_nada)
menu.add_command(label="Compilar y Cargar", command=control.compilarycargar)
helpmenu = Menu(menu)
menu.add_cascade(label="Ayuda", menu=helpmenu)
helpmenu.add_command(label="Acerca de...", command=control.acercade)
menu.add_command(label="Salir", command=control.salir)
def limpiar_panel(self, panel):
panel.delete('1.0',END)
def panel_agregar(self, panel, contenido):
panel.insert(END, contenido)
def panel_leer(self, panel):
return panel.get('1.0', END+'-1c')
def mostrar_en_area(self, area):
area.insert(END,contents)
# Al abrir un archivo deseamos tener un area de trabajo cero
def limpiar_paneles(self):
self.mensajes.delete('1.0',END)
self.memoria.delete('1.0',END)
self.programa.delete('1.0',END)
self.registros.delete('1.0',END)
示例5: Wiki_Window
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class WikiPedia:
def Wiki_Window(self, window):
self.window = window
self.window.geometry("1500x1500")
def Notebook(self):
self.notebook = ttk.Notebook(self.window)
self.framePyRat = ttk.Frame(self.notebook, width=2500, height=1000)
self.frameAbout = ttk.Frame(self.notebook, width=2500, height=1000)
self.notebook.add(self.framePyRat, text='PyPedia')
self.notebook.add(self.frameAbout, text='About')
self.notebook.grid(row=0)
def Design(self):
ttk.Labelframe(self.window, width=1350, height=140).grid(row=0, sticky = NW)
Label(self.window, text="Welcome To PyPedia",font=("Helvetica",20)).grid(row=0, column=0, sticky = NW, pady=50, padx = 450)
image = Image.open("wikilogo.png")
photo = ImageTk.PhotoImage(image)
label = Label(image=photo)
label.image = photo
label.grid(row=0, column=0, sticky = NW, padx=1150)
def search(self):
global infowiki
infowiki = StringVar()
ttk.Labelframe(self.window, width=1350, height=600).grid(row=0, sticky = NW, pady=150, column=0)
ttk.Labelframe(self.window, width=500, height=300).grid(row=0, sticky = NW, pady=174, column=0, padx=800)
ttk.Labelframe(self.window, width=750, height=600).grid(row=0, sticky = NW, pady=174, column=0, padx=20)
self.WikiInfo = ScrolledText(self.window, width=65,height=18, bd=7,font=("Helvetica",15))
self.WikiInfo.grid(row=0, sticky = NW, pady=280, column=0, padx=20)
self.WikiInfo.insert(END, "Please Search For Content\n")
def Content(self):
global infowiki
infowiki = StringVar()
Label(self.window, text="Search:: ",font=("Helvetica",18)).grid(row=0, column=0, sticky = NW, pady=210, padx=30)
Entry(self.window, width=30, bd=4,textvariable=infowiki, font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=210, padx=140, ipady=3)
Button(self.window,text="Go", bd=5, command = self.thread).grid(row=0, column=0, sticky = NW, pady=210, padx=500, ipady=1, ipadx=20)
self.snip = Spinbox(self.window, from_=0, to=1000, width=10)
self.snip.grid(row=0, column=0, sticky = NW, pady=215, padx=590, ipady=1, ipadx=20)
Label(self.window, text="Sentence::",font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=190, padx=595)
ttk.Labelframe(self.window, width=500, height=300).grid(row=0, sticky = NW, pady=480,padx=800, column=0)
Label(self.window, text="Information ",font=("Helvetica",18)).grid(row=0, column=0, sticky = NW, pady=500, padx=815)
Label(self.window, text="Image (0)(0)",font=("Helvetica",18)).grid(row=0, column=0, sticky = NW, pady=160, padx=970)
def Info(self):
Label(self.window, text="Title :",font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=540, padx=815)
Label(self.window, text="Url :",font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=580, padx=815)
Label(self.window, text="Total Image In Url :",font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=625, padx=815)
Label(self.window, text="Main Image :",font=("Helvetica",15)).grid(row=0, column=0, sticky = NW, pady=670, padx=815)
def GoSearch(self):
try:
text = " "
Label(self.window, text=text,font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=540, padx=870)
Label(self.window, text=text,font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=580, padx=860)
Label(self.window, text=text,font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=625, padx=985)
Label(self.window, text=text,font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=670, padx=940)
self.WikiInfo.delete(1.0, END)
self.WikiInfo.insert(END, "Title :: "+infowiki.get())
self.WikiInfo.insert(END, "\n")
self.WikiInfo.insert(END, "\n")
WikiData.wikiSearch(infowiki.get(), self.snip.get())
self.WikiInfo.insert(END, WikiData.GivingFuck())
self.Info()
Label(self.window, text=WikiData.title(),font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=540, padx=870)
Label(self.window, text=WikiData.url(),font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=580, padx=860)
Label(self.window, text=WikiData.imageAll(),font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=625, padx=985)
Label(self.window, text=WikiData.imageFront(),font=("Helvetica",12)).grid(row=0, column=0, sticky = NW, pady=670, padx=940)
WikiData.getImage()
WikiData.ResizeImage()
image = Image.open("RE_IMAGE.png")
photo = ImageTk.PhotoImage(image)
self.label = Label(image=photo, bd=8)
self.label.image = photo
self.label.grid(row=0, column=0, sticky = NW, pady=200, padx=830 )
#.........这里部分代码省略.........
示例6: TextEditor
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
#.........这里部分代码省略.........
if self.textWidget.tag_ranges("sel"):
self.textWidget.tag_add("comment",
self.textWidget.index(SEL_FIRST),
self.textWidget.index(SEL_LAST))
self.textWidget.tag_config("comment", underline = 1)
self.comments += [self.textWidget.index(SEL_FIRST) + "|" +
self.textWidget.index(SEL_LAST) + "|" + comment]
if(self.collaborativeCodingMode):
# can only send strings through socket
self.client.sendData(";".join(self.comments))
def findAndReplaceInText(self):
# finds and replaces a word
title = "Find and replace"
message = "Enter string to remove"
stringToRemove = tkSimpleDialog.askstring(title,message)
if(stringToRemove == None): return
message = "Enter string to add"
stringToReplace = tkSimpleDialog.askstring(title, message)
if(stringToReplace == None): return
self.currentText = self.currentText.replace(
stringToRemove, stringToReplace)
self.textWidget.delete(1.0, END)
self.textWidget.insert(1.0, self.currentText)
self.highlightString(stringToReplace)
def initTextWidget(self):
# initialises text widget
# used the below link to make it stop resizing on font change
# http://stackoverflow.com/questions/9833698/
# python-tkinter-how-to-stop-text-box-re-size-on-font-change
self.textWidgetContainer = Frame(self.root, borderwidth = 1,
relief = "sunken", width = 600, height = 400)
self.textWidgetContainer.grid_propagate(False)
self.textWidgetContainer.pack(side = TOP, fill = "both", expand = True)
self.textWidgetContainer.grid_rowconfigure(0, weight=1)
self.textWidgetContainer.grid_columnconfigure(0, weight=1)
self.textWidget = ScrolledText(self.textWidgetContainer,
width = 10,
font = self.font,
background =self.textWidgetBackGround)
self.textWidget.grid(row = 0, column = 0, sticky = "nsew")
self.textWidget.config(insertbackground = self.cursorColor,
foreground = self.textWidgetDefaultFontColor,
tabs = ("%dc"%self.tabWidth,"%dc"%(2*self.tabWidth)),
undo = True)
def initFont(self):
self.currentFont = "Arial"
self.fontSize = 15
self.font = tkFont.Font(family = self.currentFont,
size = self.fontSize)
def initProgrammingModeAttributes(self):
self.programmingMode = False
self.errorDetectionMode = False
self.colorScheme = None
self.defaultColorScheme = "monokai"
self.lexer = None
def initMoreGeneralAttributes(self):
self.hostingServer = False
self.hostIP = None
self.joinedServerIP = None
self.server = None
self.client = None
示例7: Entry
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
test2_label.config(bg='White', fg='Black')
test2_label.grid(row=1,column=1, padx=20,pady=20,sticky=W)
test2 = Entry(root)
test2.config(bg='White',fg='Black')
test2.grid(row=1,column=2,columnspan=2,padx=5,pady=5,sticky=W)
test_label = Label(root, text="Enter time period")
test_label.config(bg='White', fg='Black')
test_label.grid(row=2,column=1, padx=20,pady=20,sticky=W)
v=StringVar()
r1=Radiobutton(root, text="Today", variable=v, value=" today ",indicatoron = 0)
r1.config(bg='White', fg='Black')
r1.grid(row=2,column=2)
r2=Radiobutton(root, text="Lastweek", variable=v, value="lastweek",indicatoron = 0)
r2.config(bg='White', fg='Black')
r2.grid(row=3,column=2)
bn1 = Button(root, text="Analyse", command=btn)
# bn1.config(bg='White', fg='Black')
bn1.grid(row=4,column=1,padx=50,pady=20,sticky=W)
bn3 = Button(root, text="clear console", command=gen)
# bn3.config(bg='White', fg='Black')
bn3.grid(row=4,column=2,padx=50,pady=5,sticky=E)
textPad = ScrolledText(root, width=110, height=25,bg='White',fg='Black')
# textPad.config(,anchor=E,justify=LEFT)
textPad.grid(row=6,column=1,columnspan=3,padx=5,pady=10,sticky=W)
#,rowspan=4
root.mainloop()
示例8: initialisation
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
def initialisation(self):
global input_pipe
global output_pipe
if len(sys.argv) > 2 :
print 'output_pipe : ', output_pipe
global ChaineALire
global st
global fp
global colorbox
global sortieTube
global entreeTube
texte = """ Welcome in GUI for ARINC 653 emulator
"""
#on cree un fenetre principale 'fp' a� partir du 'modele' Tk
#fp = Tk()
self.title('ARINC 653 Partition')
#Declaration du texte deroulant dans 'fp'
st = ScrolledText(self,wrap="word")
st.grid(column=1,columnspan=2,rowspan=2,sticky='nw')
#Creation d'un panneau 'menu_bottom' insere dans 'fp'
# menu_bottom = Frame(self,borderwidth=2)
# menu_bottom.grid(column=1,columnspan=3,sticky='sw')
##Creation d'une etiquette inseree dans 'menu_bottom'
#etiquette = Label(menu_bottom,text = 'Commande : ')
#etiquette.grid(row=1,column=1,sticky='w')
##Creation d'un boutton dans 'menu_bottom'
#b = Button(menu_bottom,text='execute',command=self.affiche_commande)
#b.grid(row=1,column=3,sticky='e')
##Creation d'un boite d'edition dans 'nenu_top'
#entre = Entry(menu_bottom,width=20,relief='sunken')
#entre.insert(END,'Texte a afficher')
#entre.grid(row=1,column=2,sticky='ew')
#Creation d'une etiquette inseree
etiquette = Label(self,text = 'Command : ')
etiquette.grid(row=2,column=0,sticky='w')
#Creation d'un boutton
b = Button(self,text='execute',command=self.affiche_commande)
b.grid(row=2,column=2,sticky='e')
#Creation d'un boite d'edition dans 'nenu_top'
entre = Entry(self,width=20,relief='sunken')
entre.insert(END,'Text to send')
entre.grid(row=2,column=1,sticky='ew')
partitionbox = Label(self ,text = 'Active partition : ')
partitionbox.grid(column=0,row=0,sticky='n')
self.labelVariable = StringVar()
self.backcolorlabel = StringVar()
self.frontcolorlabel = StringVar()
self.backcolorlabel = "LightBlue"
self.frontcolorlabel = "Black"
label = Label(self,textvariable=self.labelVariable,
anchor="w",fg=self.frontcolorlabel,bg=self.backcolorlabel,height=28)
label.grid(column=0,row=1,sticky='EW')
#on insete le texte 'texte' dans le widget 'texte deroulant' nomme 'st'
st.insert(END,texte)
#on applique a� tout le texte la police par defaut
st.config(font = 'Arial 12')
st.config(foreground='Black')
#on configure le fond du 'texte derouant'
st.config(background='LightBlue')
#e = Entry(st,width=25)
self.grid_columnconfigure(1,weight=1)
self.rowconfigure(1,weight=1)
self.resizable(False,True)
self.update()
self.geometry(self.geometry())
try:
assert input_pipe != ''
except AssertionError:
showerror('error', "no pipe choosed")
input_pipe = tkFileDialog.askopenfilename(title='Choose the input pipe to open', defaultextension ='.fifo')
#openning the INPUT pipe
try:
assert input_pipe != ''
try :
#.........这里部分代码省略.........
示例9: App
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class App():
def __init__(self, root, conf):
self.conf = conf
self.items = conf.get_top_level_items()
self.tree = ttk.Treeview(root, selectmode="browse", columns=("name", "value", "type"), displaycolumns=("value", "type"), height=30)
ysb = ttk.Scrollbar(orient=VERTICAL, command= self.tree.yview)
xsb = ttk.Scrollbar(orient=HORIZONTAL, command= self.tree.xview)
self.tree.configure(yscroll=ysb.set, xscroll=xsb.set)
self.tree.heading('#0', text='Configuration Tree', anchor='w')
self.tree.column("#0", minwidth=0, width=800, stretch=True)
self.tree.heading("name", text="Name")
self.tree.column("name", minwidth=0, width=200, stretch=True)
self.tree.heading("value", text="Value")
self.tree.column("value", minwidth=0, width=50, stretch=True)
self.tree.heading("type", text="Type")
self.tree.column("type", minwidth=0, width=50, stretch=True)
self.add_root_items(self.items)
self.help = ScrolledText(root, width=130, height=10)
self.msg = StringVar()
self.info = Label(root, fg="green", font=("Helvetica", 16), anchor=W, justify=LEFT, textvariable=self.msg)
self.msg.set("Please set configurations, then you can save it!")
self.tree.grid(row=0, column=0)
self.help.grid(row=1, column=0)
self.info.grid(row=2, column=0)
ysb.grid(row=0, column=1, sticky='ns')
xsb.grid(row=1, column=0, sticky='ew')
root.grid()
self.root = root
# create a toplevel menu
menubar = Menu(root)
menubar.add_command(label="Save Config!", command=self.OnSaveConfig)
menubar.add_command(label="Quit Config!", command=self.OnQuitConfig)
# display the menu
root.config(menu=menubar)
self.tree.bind("<Double-1>", self.OnDoubleClick)
self.tree.bind("<<TreeviewSelect>>", self.OnSelection)
def add_subr_items(self, parent, items):
for item in items:
if item.get_visibility() != "n":
if item.is_symbol():
str = 'config {0}'.format(item.get_name())
self.tree.insert(parent, "end", text=str, values=[item.get_name(), item.get_value(), kconf.TYPENAME[item.get_type()]], open=True)
elif item.is_menu():
str = 'menu "{0}"'.format(item.get_title())
parent = self.tree.insert(parent, "end", text=str, open=True)
self.add_subr_items(parent, item.get_items())
elif item.is_choice():
str = 'choice "{0}"'.format(item.get_prompts()[0])
parent = self.tree.insert(parent, "end", text=str, open=True)
self.add_subr_items(parent, item.get_items())
elif item.is_comment():
str = 'comment "{0}"'.format(item.get_text())
self.tree.insert(parent, "end", text=str, open=True)
def add_root_items(self, items):
for item in items:
if item.get_visibility() != "n":
if item.is_symbol():
str = 'config {0}'.format(item.get_name())
self.tree.insert("", "end", text=str, values=[item.get_name(), item.get_value(), kconf.TYPENAME[item.get_type()]], open=True)
elif item.is_menu():
str = 'menu "{0}"'.format(item.get_title())
parent = self.tree.insert("", "end", text=str, open=True)
self.add_subr_items(parent, item.get_items())
elif item.is_choice():
str = 'choice "{0}"'.format(item.get_prompts()[0])
parent = self.tree.insert("", "end", text=str, open=True)
self.add_subr_items(parent, item.get_items())
elif item.is_comment():
str = 'comment "{0}"'.format(item.get_text())
self.tree.insert("", "end", text=str, open=True)
def search_for_item(self, name, item=None):
children = self.tree.get_children(item)
for child in children:
nameval = self.tree.set(child, "name")
if nameval == name:
return child
else:
res = self.search_for_item(name, child)
if res:
return res
return None
def OnDoubleClick(self, event):
#.........这里部分代码省略.........
示例10: print_message
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class UI:
def print_message(self,msg):
msg = msg + "\n"
self.scrollview["state"] = NORMAL
self.scrollview.mark_set("insert", "1.0")# 1 is line number , 0 is coloumn
self.scrollview.insert(INSERT,msg) # or END can be used
self.scrollview["state"] = DISABLED
#self.scrollview.see(END)
def __init__(self, myParent):
self.mylist = [i for i in range(1,53)]
self.display_cards(human_cards)
self.button1 = Button(root)
self.button1["text"]= "Fetch" ### (2)
self.button1.bind("<Button-1>", self.onFetchClick)
self.button1.grid(row=1,column=10)
self.scrollview = ScrolledText(root,width=10,height = 10,state = DISABLED)
self.scrollview.grid(row=200,column=5)
#self.scrollbar = Scrollbar(root)
#self.scrollbar.pack(side=RIGHT, fill=Y)
def display_top_card(self,topc):
self.image = Image.open("classic-cards/"+topc+".png")
#self.image = self.image.rotate(45)
#self.image = self.image.resize((100,200))
self.photo = ImageTk.PhotoImage(self.image)
self.label = Label(image=self.photo)
self.label.image = self.photo # keep a reference!
self.label.filename = topc
self.label.grid(row=0,column=10)
print "length of cards is " + str(len(comp_cards))
self.leftlabel = Label(root,text= "PC has " + str(len(comp_cards)) + " cards",font = "Verdana 10 bold")
self.leftlabel.grid(row=2,column=10)
def display_cards(self,newlist):
r = 0
c = -1
counter = 0
self.mywidgets=[]
for i in newlist:
if counter%10 == 0:
r = r + 1
c = 0
else:
c = c + 1
counter = counter + 1
self.image = Image.open("classic-cards/"+str(i)+".png")
#self.image = self.image.rotate(45)
#self.image = self.image.resize((100,200))
self.photo = ImageTk.PhotoImage(self.image)
self.label = Label(image=self.photo)
self.label.image = self.photo # keep a reference!
self.label.filename = i
self.label.grid(row=r,column=c)
self.label.bind("<Button-1>", self.onClick)
self.mywidgets.append(self.label)
def onFetchClick(self,event):
global human_cards
if len(carddeck) == 0:
#TODO reshuffle completed and put them
reorder_completed()
card = getcard(carddeck)
human_cards.append(card)
self.destroyAll()
self.display_cards(human_cards)
play_computer(topcard)
if len(comp_cards) == 0:
tkMessageBox.showinfo("Boooo", "You have lost :-( ")
quitfunc()
self.display_top_card(topcard)
def onClick(self,event):
global human_cards,comp_cards,carddeck,topcard
#self.mylist.remove(event.widget.filename)
if(play_human(topcard,event.widget.filename)):
self.destroyAll()
self.display_cards(human_cards)
if len(human_cards) == 0:
tkMessageBox.showinfo("Crazy", "You have won!!!")
quitfunc()
play_computer(topcard)
print str(len(comp_cards)) + " before modify"
if len(comp_cards) == 0:
tkMessageBox.showinfo("Boooo", "You have lost :-( ")
quitfunc()
self.display_top_card(topcard)
def destroyAll(self):
for i in self.mywidgets:
i.destroy()
示例11: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class GuiPart:
def __init__(self, master, queue, queue2, endCommand):
self.queue = queue
self.queue2 = queue2
self.msg = ""
self.targetpics = []
self.currentImage = -1
# Set up the GUI
console = Tkinter.Button(master, text='Done', command=endCommand)
console.grid(row=3, column=1, sticky=Tkinter.W)
#Telemetry Window
self.tele = ScrolledText(master, width=50, height=10, wrap='word')
self.tele.insert('end', 'Awaiting Telemetry...\n----------------------\n')
self.tele.grid(row=0, column=1, columnspan=1, padx=5, pady=5)
#Receiving Targets Window
self.rt = ScrolledText(master, width=50, height=10, wrap='word')
self.rt.insert('end', 'Awaiting Target Data...\n------------------------\n')
self.rt.grid(row=0, column=3, columnspan=2, padx=5, pady=5)
#Image
img = Tkinter.PhotoImage(file="logo.gif")
logo = Tkinter.Label(master, image = img)
logo.image=img
logo.grid(row=0, column=2, padx=5, pady=5)
#Obstacles Button
obs_but = Tkinter.Button(master, text='Retreive Obstacles From Server', command=self.getObstacles)
obs_but.grid(row=1, column=1, sticky=Tkinter.W)
#General Terminal Button
gt_but = Tkinter.Button(master, text='Submit Data', command=endCommand)
gt_but.grid(row=1, column=2, sticky=Tkinter.W)
#Upload Targets Button
ut_but = Tkinter.Button(master, text='Upload Target Data', command=self.uploadTarget)
ut_but.grid(row=1, column=3, columnspan=2, sticky=Tkinter.W)
#Receiving Obstacles Window
self.obs = ScrolledText(master, width=50, height=10, wrap='word')
self.obs.insert('end', 'Ready for Obstacle Data...\n--------------------------\n')
self.obs.grid(row=2, column=1, columnspan=1, padx=5, pady=5)
#General Terminal Window
self.gt = ScrolledText(master, width=50, height=10, wrap='word')
self.gt.insert('end', 'Enter in Server Query...\n------------------------\n')
self.gt.grid(row=2, column=2, columnspan=1, padx=5, pady=5)
#Upload Targets Window
#self.ut = ScrolledText(master, width=50, height=10, wrap='word')
#self.ut.insert('end', 'Enter in Target Data...\n------------------------\n')
target_label_text = ["Target Type: ","Latitude: ","Longitude: ","Orientation:", \
"Shape: ", "BG Color: ", "Letter/#: ","Letter/# Color: "]
targetlabelpane = Tkinter.PanedWindow(orient=Tkinter.VERTICAL)
for i in target_label_text:
targetlabelpane.add(Tkinter.Label(master, text=i,pady=3))
targetlabelpane.grid(row=2, column=3,sticky=Tkinter.W)
# Use combobox if user entry is also required
# Here we use optionmenu
self.available_target_type = Tkinter.StringVar() #["standard", "qrc", "off_axis", "emergent"]
self.available_target_type.set("standard")
self.available_orientation = Tkinter.StringVar() #["N","E","S","W","NE","SE","SW","NW"]
self.available_orientation.set("N")
self.available_shapes = Tkinter.StringVar() #["circle","semicircle","quarter_circle","triangle","square","rectangle","trapezoid","pentagon","hexagon","heptagon","octagon","star","cross"]
self.available_shapes.set("circle")
self.available_bg_colors = Tkinter.StringVar() #["white","black","gray","red","blue","green","yellow","purple","brown","orange"]
self.available_bg_colors.set("white")
self.available_alpha_colors = Tkinter.StringVar()
self.available_alpha_colors.set("white")
'''
drop_target_type = Tkinter.OptionMenu(master,available_target_type,"standard", "qrc", "off_axis", "emergent")
entry_lat = Tkinter.Entry(master, bd=5, width=70)
entry_lon = Tkinter.Entry(master, bd=5, width=70)
drop_orientation = Tkinter.OptionMenu(master,available_orientation,"N","E","S","W","NE","SE","SW","NW")
drop_shapes = Tkinter.OptionMenu(master,available_shapes,"circle","semicircle","quarter_circle","triangle","square","rectangle","trapezoid","pentagon","hexagon","heptagon","octagon","star","cross")
drop_bg_colors = Tkinter.OptionMenu(master,available_bg_colors,"white","black","gray","red","blue","green","yellow","purple","brown","orange")
entry_alphanum = Tkinter.Entry(master, bd=5, width=70)
drop_alpha_colors= Tkinter.OptionMenu(master,available_alpha_colors,"white","black","gray","red","blue","green","yellow","purple","brown","orange")
'''
targetpane = Tkinter.PanedWindow(orient=Tkinter.VERTICAL)
targetpane.add(Tkinter.OptionMenu(master,self.available_target_type,"standard", "qrc", "off_axis", "emergent"))
self.entry_lat = Tkinter.Entry(master, width=10)
targetpane.add(self.entry_lat)
self.entry_lon = Tkinter.Entry(master,width=10)
targetpane.add(self.entry_lon)
targetpane.add(Tkinter.OptionMenu(master,self.available_orientation,"N","E","S","W","NE","SE","SW","NW"))
targetpane.add(Tkinter.OptionMenu(master,self.available_shapes,"circle","semicircle","quarter_circle","triangle","square","rectangle","trapezoid","pentagon","hexagon","heptagon","octagon","star","cross"))
targetpane.add(Tkinter.OptionMenu(master,self.available_bg_colors,"white","black","gray","red","blue","green","yellow","purple","brown","orange"))
self.entry_alphanum = Tkinter.Entry(master, width=10)
targetpane.add(self.entry_alphanum)
targetpane.add(Tkinter.OptionMenu(master,self.available_alpha_colors,"white","black","gray","red","blue","green","yellow","purple","brown","orange"))
targetpane.grid(row=2, column=3, padx=5, pady=5)
#.........这里部分代码省略.........
示例12: construct
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
def construct():
sample_prog = '''int main (void)
{
int x;
int y;
x = (1 + 2) * (3 / 4);
y = 1 + 2 * 3 - 4 / 5;
return x + y;
}'''
def callback():
input = inputBox.get(1.0, END)
# Lexical tab
message, output, tokens = lexical(input)
lexTab = tabs['Lexical']
lexTab.configure(state=NORMAL)
lexTab.delete(1.0, END)
lexTab.insert(INSERT, message + output)
lexTab.configure(state=DISABLED)
# Syntax tab
message, output, root, syn_pass = syntax(tokens)
synTab = tabs['Syntax']
synTab.configure(state=NORMAL)
synTab.delete(1.0, END)
synTab.insert(INSERT, message + output)
synTab.configure(state=DISABLED)
# Semantics tab
if syn_pass:
message = semantic(root)
else:
message = "Couldn't perform semantic analysis"
semTab = tabs['Semantics']
semTab.configure(state=NORMAL)
semTab.delete(1.0, END)
semTab.insert(INSERT, message)
semTab.configure(state=DISABLED)
master = Tk()
master.title("C- Compiler")
# Frames
buttonFrame = Frame(master)
buttonFrame.grid(row=1, column=1)
# Labels
Label(master, text="Input").grid(row=0, column=0)
Label(master, text="Output").grid(row=0, column=1)
# Buttons
compileButton = Button(buttonFrame, text='Compile', command=callback)
compileButton.grid(row=0, column=0)
# Text Boxes
inputBox = ScrolledText(master, width=50, height=40)
inputBox.grid(row=2, column=0)
inputBox.insert(INSERT, sample_prog)
# Notebook to hold tabs
notebook = ttk.Notebook(master)
notebook.grid(row=2, column=1)
tabs = {"Lexical": [], "Syntax": [], "Semantics": []}
tab_order = ["Lexical", "Syntax", "Semantics"]
for tabname in tab_order:
tab = ScrolledText(notebook, width=50, height=40)
tab.configure(state=DISABLED)
tabs[tabname] = tab
notebook.add(tab, text=tabname)
master.mainloop()
示例13: MainGui
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class MainGui(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
Label(self, text='Title:', justify=LEFT).grid(row=0, column=0, sticky=E)
title_var = StringVar(self)
title_var.set("Bring polynomes to standard form")
title = Entry(self, textvariable=title_var, width=35)
title.grid(row=0, column=1, sticky=W)
Label(self, text='Count of tasks:', justify=LEFT).grid(row=1, column=0, sticky=E)
count_var = StringVar(self)
count_var.set("5")
count = Spinbox(self, from_=0, to=10, textvariable=count_var, width=2)
count.grid(row=1, column=1, sticky=W)
Label(self, text='Count of summands in one task:', justify=LEFT).grid(row=2, column=0, sticky=E)
sum_count_var = StringVar(self)
sum_count_var.set("5")
sum_cont = Spinbox(self, from_=0, to=10, textvariable=sum_count_var, width=2)
sum_cont.grid(row=2, column=1, sticky=W)
Label(self, text='Maximal degree:').grid(row=3, column=0, sticky=E)
deg_var = StringVar(self)
deg_var.set("5")
deg = Spinbox(self, from_=0, to=10, textvariable=deg_var, width=2)
deg.grid(row=3, column=1, sticky=W)
Label(self, text='Coefficients dispersion:').grid(row=4, column=0, sticky=E)
cof_var = StringVar(self)
cof_var.set("5")
cof = Spinbox(self, from_=0, to=10, textvariable=cof_var, width=2)
cof.grid(row=4, column=1, sticky=W)
open_files_flag = BooleanVar()
flag = Checkbutton(self, text='Open files after closing', variable=open_files_flag)
flag.grid(row=5, column=0, sticky=W)
self.gui_console = ScrolledText(self, width=50, height=20)
self.gui_console.grid(row=6, column=0, columnspan=2, sticky=W+E+N+S)
self.menubar = Menu(self)
file_menu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label='File', underline=0, menu=file_menu)
file_menu.add_command(label='Compile', underline=6, command=(lambda: self.compile(self, open_files_flag.get(),
False
)
),
accelerator="Ctrl+C")
file_menu.add_command(label='Compile and close', underline=1,
command=(lambda: self.compile(self,
open_files_flag.get(),
True
)
),
accelerator="Alt+Q")
file_menu.add_command(label='Close', underline=0, command=(lambda: self.quit()), accelerator="Ctrl+Q")
edit_menu = Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label='Edit', underline=0, menu=edit_menu)
edit_menu.add_command(label='Add', underline=0, command=(lambda: self.add(title.get(),
int(count.get()),
int(sum_cont.get()),
int(deg.get()),
int(cof.get())
)
),
accelerator="Ctrl+A")
try:
self.master.config(menu=self.menubar)
except AttributeError:
self.master.tk.call(self, "config", "-menu", self.menubar)
self.bind_all("<Control-q>", self.quit_event)
self.bind_all("<Alt-q>", self.compile_and_quit_event)
self.bind_all("<Control-a>", self.add_event)
self.bind_all("<Control-c>", self.compile_event)
def add(self, title=None, count=10, sum_count=5, deg=4, cof=20):
polygen_writer(title, count, sum_count, deg, cof)
# self.gui_console.insert(INSERT, 'Added!\n')
print 'Added print'
@staticmethod
def compile(self, open_files_flag=False, close_flag=False):
print "gen_close | current direction: " + str(os.getcwd())
ground_writer()
problems.close()
answers.close()
print 'Files closed'
status = generate_pdf(answers_filename, open_files_flag)
if status == 0:
self.gui_console.insert(INSERT, 'File ' + answers_filename + '.tex compiled successfully...\n')
else:
self.gui_console.insert(INSERT, 'Error occurred while compiling file ' + answers_filename + '.tex...\n')
status = generate_pdf(problems_filename, open_files_flag)
if status == 0:
self.gui_console.insert(INSERT, 'File ' + problems_filename + '.tex compiled successfully...\n')
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
class GuiPart:
def __init__(self, master, queue, queue2, endCommand):
self.queue = queue
self.queue2 = queue2
self.msg = ""
self.targetpics = []
self.currentImage = -1
# Set up the GUI
console = Tkinter.Button(master, text='Done', command=endCommand)
console.grid(row=3, column=1, sticky=Tkinter.W)
#Telemetry Window
self.tele = ScrolledText(master, width=50, height=10, wrap='word')
self.tele.insert('end', 'Awaiting Telemetry...\n----------------------\n')
self.tele.grid(row=0, column=1, columnspan=1, padx=5, pady=5)
#Receiving Targets Window
self.rt = ScrolledText(master, width=50, height=10, wrap='word')
self.rt.insert('end', 'Awaiting Target Data...\n------------------------\n')
self.rt.grid(row=0, column=3, columnspan=1, padx=5, pady=5)
#Image
img = Tkinter.PhotoImage(file="logo.gif")
logo = Tkinter.Label(master, image = img)
logo.image=img
logo.grid(row=0, column=2, padx=5, pady=5)
#Obstacles Button
obs_but = Tkinter.Button(master, text='Retreive Obstacles From Server', command=self.getObstacles)
obs_but.grid(row=1, column=1, sticky=Tkinter.W)
#General Terminal Button
gt_but = Tkinter.Button(master, text='Submit Data', command=endCommand)
gt_but.grid(row=1, column=2, sticky=Tkinter.W)
#Upload Targets Button
ut_but = Tkinter.Button(master, text='Upload Target Data', command=endCommand)
ut_but.grid(row=1, column=3, sticky=Tkinter.W)
#Receiving Obstacles Window
self.obs = ScrolledText(master, width=50, height=10, wrap='word')
self.obs.insert('end', 'Ready for Obstacle Data...\n--------------------------\n')
self.obs.grid(row=2, column=1, columnspan=1, padx=5, pady=5)
#General Terminal Window
self.gt = ScrolledText(master, width=50, height=10, wrap='word')
self.gt.insert('end', 'Enter in Server Query...\n------------------------\n')
self.gt.grid(row=2, column=2, columnspan=1, padx=5, pady=5)
#Upload Targets Window
self.ut = ScrolledText(master, width=50, height=10, wrap='word')
self.ut.insert('end', 'Enter in Target Data...\n------------------------\n')
self.ut.grid(row=2, column=3, columnspan=1, padx=5, pady=5)
#General Terminal Text Area
self.gt_text = Tkinter.Entry(master, bd=5, width=70)
self.gt_text.grid(row=3, column=2, columnspan=1, padx=5, pady=5)
#Target Picture Buttons
pane = Tkinter.PanedWindow()
rti_prev = Tkinter.Button(master, text='Prev Picture', command=self.prevPic)
pane.add(rti_prev)
self.rti_label = Tkinter.Label(master, text='Awaiting Target')
rti_next = Tkinter.Button(master, text='Next Picture', command=self.nextPic)
pane.add(rti_next)
pane.add(self.rti_label)
pane.grid(row=4, column=2, padx=5, pady=5)
#Target Images
rtimg = Tkinter.PhotoImage(file="target.gif")
self.rti = Tkinter.Label(master, image = rtimg)
self.rti.image=rtimg
self.rti.grid(row=5, column=2, columnspan=1, padx=5, pady=5)
# Add more GUI stuff here
def processIncoming(self):
"""
Handle all the messages currently in the queue (if any).
"""
#self.counter = 0
while self.queue.qsize():
try:
self.msg = str(self.queue.get(0)) + '\n'
# Check contents of message and do what it says
# As a test, we simply print it
self.tele.insert('end', self.msg)
self.msg2 = self.queue2.get(0) + '\n'
if(self.msg2.find('Target') == 0):
#self.targetpics[self.counter] = self.msg2
self.targetpics.append(self.msg2)
#self.counter += 1
else:
self.rt.insert('end', self.msg2)
except Queue.Empty:
pass
def getObstacles(self):
# GET obstacles request
#.........这里部分代码省略.........
示例15: help
# 需要导入模块: import ScrolledText [as 别名]
# 或者: from ScrolledText import grid [as 别名]
def help(self):
help_window = Toplevel(master=self.window)
help_window.title("Graph viewer help")
text = ScrolledText(master=help_window)
text.insert(END, help_text)
text.grid(row=0,column=0)