本文整理汇总了Python中Tkinter.Frame.grid方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.grid方法的具体用法?Python Frame.grid怎么用?Python Frame.grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Frame
的用法示例。
在下文中一共展示了Frame.grid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_gui
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def _load_gui(self):
root = Tk()
root.title("Scraper")
main_frame = Frame(root)
main_frame.grid(column=0, row=0, sticky=(N, W, E, S))
main_frame.columnconfigure(0, weight=1)
main_frame.rowconfigure(0, weight=1)
main_frame.pack()
self.scale_red_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_red_min)
self.scale_red_min.grid(column=1, row=1)
self.scale_red_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_red_max)
self.scale_red_max.grid(column=2, row=1)
self.scale_red_max.set(255)
self.scale_green_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_green_min)
self.scale_green_min.grid(column=1, row=2)
self.scale_green_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_green_max)
self.scale_green_max.grid(column=2, row=2)
self.scale_green_max.set(255)
self.scale_blue_min = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_blue_min)
self.scale_blue_min.grid(column=1, row=3)
self.scale_blue_max = Scale(main_frame, from_=0, to=255, orient=HORIZONTAL, command=self._update_blue_max)
self.scale_blue_max.grid(column=2, row=3)
self.scale_blue_max.set(255)
return root
示例2: _init_components
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def _init_components(self):
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
upper_pane = Frame(self)
upper_pane.columnconfigure(0, weight=1)
upper_pane.rowconfigure(0, weight=1)
self.apex_list = ApexList(upper_pane, self._apex)
self.apex_list.grid(row=0, column=0, sticky='nesw')
self._scrollbar_x = Scrollbar(upper_pane, command=self.apex_list.xview,
orient='horizontal')
self._scrollbar_x.grid(row=1, column=0, sticky='ews')
self.apex_list['xscrollcommand'] = self._scrollbar_x.set
self._scrollbar_y = Scrollbar(upper_pane, command=self.apex_list.yview)
self._scrollbar_y.grid(row=0, column=1, sticky='nse')
self.apex_list['yscrollcommand'] = self._scrollbar_y.set
buttons_pane = Frame(self)
self._expand_button = Button(buttons_pane, text="Expand all",
command=self.apex_list.expand_all)
self._expand_button.pack(side='left', expand=True, fill='x')
self._reset_button = Button(buttons_pane, text="Reset",
command=self.apex_list.reset)
self._reset_button.pack()
upper_pane.grid(sticky='nesw')
buttons_pane.grid(row=1, sticky='nesw')
示例3: initUI
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def initUI(self):
self.parent.title("File dialog")
menubar = Menu(self.parent)
self.parent.config(menu=menubar)
fileMenu = Menu(menubar)
fileMenu.add_command(label="Open", command=self.onOpen)
menubar.add_cascade(label="File", menu=fileMenu)
self.style = Style()
self.style.theme_use("default")
global frame1
frame1 = Frame()
frame1.grid(row=0, column=0, sticky='w')
l1 = Label(frame1, text='CSV file name', relief=RIDGE, width=20)
l1.grid(row=4, column=0)
l2 = Label(frame1, text='SCR file name', relief=RIDGE, width=20)
l2.grid(row=5, column=0)
inform = Button(frame1, text="Choose CSV file", command=self.onCSVfile)
inform.grid(row=1, column=0)
self.file_opt = options = {}
options['defaultextension'] = '.csv'
options['filetypes'] = [('CSV files', '.csv'), ('all files', '.*')]
示例4: prior
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def prior(self):
priorheader = headersmall(self.frame, text="Hyperprior Settings:")
f = Frame(self.frame)
f.config(padx=20, bg=Styles.colours["grey"])
Message(f, text="Horseshoe Prior sn:", width=200, bg=Styles.colours["grey"], font=Styles.fonts["entry"]).grid(
row=0, column=0, columnspan=2, sticky=W)
epriorsnscale = smallentry(f, self.params["priorsnscale"], 15)
mpriorsnscale = Message(f, text="scale:", width=32, bg=Styles.colours["grey"])
mpriorsnscale.grid(row=1, column=0, columnspan=1, sticky=E)
epriorsnscale.grid(row=1, column=1, columnspan=1, sticky=W)
smallentryframetext(f, 1, 2, self.params["priorsnmin"], 15, "min:")
Message(f, text="Log Normal Prior sf:", width=200, bg=Styles.colours["grey"], font=Styles.fonts["entry"]).grid(
row=2, column=0, columnspan=2, sticky=W)
f3 = Frame(f)
smallentryframetext(f3, 0, 0, self.params["priorsfmu"], 10, "mu:")
smallentryframetext(f3, 0, 2, self.params["priorsfsigma"], 10, "sigma:")
smallentryframetext(f3, 0, 4, self.params["priorsfmin"], 10, "min:")
f3.grid(row=3, column=0, columnspan=4)
Message(f, text="Uniform Prior ell:", width=200, bg=Styles.colours["grey"], font=Styles.fonts["entry"]).grid(
row=4, column=0, columnspan=2, sticky=W)
smallentryframetext(f, 5, 0, self.params["priorella"], 15, "a:")
smallentryframetext(f, 5, 2, self.params["priorellb"], 15, "b:")
Message(f, text="Gaussian Prior mu:", width=200, bg=Styles.colours["grey"], font=Styles.fonts["entry"]).grid(
row=6, column=0, columnspan=2, sticky=W)
smallentryframetext(f, 7, 0, self.params["priormumu"], 15, "mu:")
smallentryframetext(f, 7, 2, self.params["priormuvar"], 15, "var:")
priorheader.grid(row=6, column=4, sticky=W, columnspan=1)
Message(self.frame, text="You can set following parameters based on the variables defined in the GP section.",
width=400, font=Styles.fonts["entry"], bg=Styles.colours["grey"]).grid(row=7, column=4, columnspan=2)
f.grid(row=8, column=4, sticky=E + W, columnspan=2, rowspan=10)
示例5: Display
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
class Display(object):
'''
classdocs
'''
TITLE = 'House Monitor'
TIME_COLUMN = 0
NAME_COLUMN = 1
VALUE_COLUMN = 2
mainframe = None
proxy = None
current_row = 0
current_values = {}
def __init__(self, current_values):
'''
Constructor
'''
self.current_values = current_values
super(Display, self).__init__()
self.root = Tk()
self.root.title(self.TITLE)
# self.mainframe = Frame(self.root, padding="3 3 12 12")
self.mainframe = Frame(self.root)
self.mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
self.mainframe.columnconfigure(0, weight=1)
self.mainframe.rowconfigure(0, weight=1)
print(current_values)
# self.display_header()
def display_header(self):
Tk.Label(self.mainframe, text='Time', width=15, background='lightblue').grid(column=self.TIME_COLUMN, row=self.current_row, sticky=W)
Tk.Label(self.mainframe, text='Name', width=45, background='lightblue').grid(column=self.NAME_COLUMN, row=self.current_row, sticky=W)
Tk.Label(self.mainframe, text='Value', width=15, background='lightblue').grid(column=self.VALUE_COLUMN, row=self.current_row, sticky=W)
self.current_row = self.current_row + 1
def update(self):
self.current_row = 1
for device in self.current_values.keys():
for port in self.current_values[device].keys():
arrival_time = self.current_values[device][port]['arrival_time']
Tk.Label(self.mainframe, text=arrival_time).grid(column=self.TIME_COLUMN, row=self.current_row, sticky=W)
name = self.current_values[device][port]['name']
Tk.Label(self.mainframe, text=name).grid(column=self.NAME_COLUMN, row=self.current_row, sticky=W)
value = self.current_values[device][port]['current_value']
units = self.current_values[device][port]['units']
value = '{}{}'.format(value, units)
Tk.Label(self.mainframe, text=value).grid(column=self.VALUE_COLUMN, row=self.current_row, sticky=W)
self.current_row = self.current_row + 1
def run(self):
self.root.mainloop()
示例6: add_instrument
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def add_instrument(self, instrument):
if not isinstance(instrument, ScaleSynth):
return
index = len(self.instruments)
self.instruments.append(instrument)
scale_plot = ScalePlot(self)
scale_plot.draw_scale(instrument.scale)
scale_plot.grid(column=1, row=self.row, sticky='nesw')
self.scale_plots.append(scale_plot)
instrument.add_observer(scale_plot)
control_frame = Frame(self)
self.control_frames.append(control_frame)
activate_button = Radiobutton(control_frame,
# text=str(instrument.name),
textvar=instrument.id_variable,
variable=self.radio_btn_var,
value=index,
command=self.activate_instrument,
width=15,
)
activate_button.pack()
self.radio_btn_var.set(index)
self.activate_instrument()
control_frame.grid(column=0, row=self.row, sticky='nesw')
self.row += 1
示例7: makeKeys
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def makeKeys(self):
keyContainer = Frame(self)
for number in range (0, DICE):
button = Button(keyContainer, text = str(number+1), command = self.makePress(number))
button.grid(row = 1, column=number)
keyContainer.grid(row = 1, column = 0)
示例8: concolefooter
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def concolefooter(self):
footerframe = Frame(self.master)
footerframe.config(padx=5, pady=5, bg=Styles.colours["darkGrey"])
title = Message(footerframe, text="Console:",
justify=CENTER, bg=Styles.colours["darkGrey"],
foreground=Styles.colours["yellow"],
width=100, font=Styles.fonts["entry"])
consoletext = Text(footerframe, height=5, width=80, bg=Styles.colours["darkGrey"],
foreground=Styles.colours["grey"], state=NORMAL, relief=FLAT, font=Styles.fonts["console"])
consoletext.insert(END, "Welcome to Project Bi")
consoletext.config(state=DISABLED)
self.console.setconsolefield(consoletext)
scroll = Scrollbar(footerframe, command=consoletext.yview, relief=FLAT)
consoletext.configure(yscrollcommand=scroll.set)
self.boptimize = yellowbutton(footerframe, "Optimize", 20, lambda e: self.observerstage())
deactivatebutton(self.boptimize)
self.boptimize.pack(side=RIGHT, fill=BOTH, padx=5, pady=5)
self.boptimize.configure(font=Styles.fonts["h1Button"])
title.pack(side=LEFT, fill=BOTH)
scroll.pack(side=LEFT, fill=BOTH)
consoletext.pack(side=LEFT, fill=BOTH)
footerframe.grid(row=2, column=0, sticky=W + E + N + S, columnspan=2)
return footerframe
示例9: __bookmarks
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def __bookmarks(self, master):
panel = Frame(master)
panel.grid_rowconfigure(0, weight=1)
bookmarks = Frame(panel)
bookmarks.grid_columnconfigure(0, weight=1)
bookmarks.grid_rowconfigure(0, weight=1)
li = Listbox(bookmarks, width=40)
li.grid(column=0, row=0, sticky=(N, E, S, W))
self.bookmarks_list = li
sb = Scrollbar(bookmarks, orient=VERTICAL, command=li.yview)
sb.grid(column=1, row=0, sticky=(N, S))
li.config(yscrollcommand=sb.set)
def _lbox_selected(*args):
selected_idx = int(li.curselection()[0])
self.render_start.set(self.bookmarks_values[selected_idx])
self.canvas.xview_moveto(0)
if not self.render_auto.get():
self.update()
li.bind('<Double-Button-1>', _lbox_selected)
bookmarks.grid(column=0, row=0, sticky=(N, E, S, W))
buttons = Frame(panel)
Button(buttons, image=self.img_start, command=self.start_event).pack(side="left")
Button(buttons, image=self.img_prev, command=self.prev_event).pack(side="left")
Button(buttons, image=self.img_end, command=self.end_event).pack(side="right")
Button(buttons, image=self.img_next, command=self.next_event).pack(side="right")
buttons.grid(column=0, row=1, sticky=(E, W))
return panel
示例10: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def __init__(self, master):
rows = 10
columns = 7
self.d = door(rows, columns)
master.title("The Fridge")
self.frame = Frame(master)
controls = Frame(self.frame)
self.start = Button(controls,
text = "Restart",
width = 6,
command = self.restart
)
self.start.grid(row = 0, column = 4, columnspan = 2, sticky = E)
self.rowtext = Entry(controls, width = 4)
self.rowtext.grid(row = 0, column = 0, columnspan = 2, sticky = W)
self.coltext = Entry(controls, width = 4)
self.coltext.grid(row = 0, column = 2, columnspan = 2, sticky = E)
controls.grid(row = 0, column = 0, columnspan = 7)
self.bttns = []
for i in xrange(rows):
for j in xrange(columns):
cb = Button(self.frame,
bg = "green" if self.d.plate[i][j].state else "red",
text = " ",
command = self.click(self.bttns, self.d, i, j) # coolhack
)
cb.grid(row = i+1, column = j)
self.bttns.append(cb)
self.frame.grid(column = 0, row = 0)
示例11: __setup_menus
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def __setup_menus(self):
self.menu = Menu(self.root, relief=FLAT)
file_menu = Menu(self.menu, tearoff=0)
file_menu.add_command(label="Add holiday",
command=self.holiday_manager.add_holiday_gui)
file_menu.add_command(label="Reset holidays", command=self.holiday_manager.reset_holidays_gui)
file_menu.add_command(label="Goto month", command=self.goto_date_gui)
self.menu.add_cascade(label="File", menu=file_menu)
# Contains about option, giving application information
help_menu = Menu(self.menu, tearoff=0)
help_menu.add_command(label="About", command=self.about_info_gui)
self.menu.add_cascade(label="Help", menu=help_menu)
# Display on screen
self.root.config(menu=self.menu)
# Toolbar
toolbar = Frame(self.root)
# Add holiday button calls add_new_holiday with args to refresh window
add_holiday = Button(toolbar, text="Add Holiday",
command=self.holiday_manager.add_holiday_gui)
add_holiday.grid(row=0, column=0)
tooltip.createToolTip(add_holiday, "Adds a new holiday to the calendar")
# Reset button clears holidays, resets to current date
reset_holidays = Button(toolbar, text="Reset Holidays", command=self.holiday_manager.reset_holidays_gui)
reset_holidays.grid(row=0, column=1)
tooltip.createToolTip(reset_holidays, "Resets all of the user set holidays")
toolbar.grid(row=0, sticky="W")
示例12: Application
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.createWidgets()
self.turtle = Turtle()
def createWidgets(self):
self.EntryFrame = Frame(self,bd=5)
self.EntryFrame.grid(row=0, column=1)
i = 0
Label(self.EntryFrame, text='Type some Python code\n').grid(row=i, column=0, columnspan=2)
i += 1
Label(self.EntryFrame, text='The Code').grid(row=i, column=0, sticky=E)
self.text = Text(self.EntryFrame, width=50, height=10)
self.text.grid(row=i, column=1)
self.EntryFrame.after(1000, self.runCode)
def runCode(self):
t = self.turtle
script = self.text.get("1.0", "end-1c")
try:
t.tracer(100000)
t.reset()
exec script in globals(), locals()
t.tracer(1)
except:
pass
self.EntryFrame.after(1000, self.runCode)
示例13: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def __init__(self, master):
self.master = master
self.master.wm_title('PEP8 checker')
self.master.resizable(False, True)
self.frame = Frame(master)
self.frame.pack(fill=BOTH, expand=1)
home_dir = expanduser("~")
self.directory = StringVar(value=home_dir)
directory_frame = Frame(self.frame)
directory_frame.grid()
self.frame.grid_rowconfigure(2, weight=1)
self.entry_directory = Entry(directory_frame, textvariable=self.directory)
self.entry_directory.pack(anchor=W, side=LEFT)
self.select_directory = Button(directory_frame, text="Select directory to scan", command=self.select_directory)
self.select_directory.pack(anchor=E, side=RIGHT)
self.run_button = Button(self.frame, text='Run PEP8!', command=self.run_pep)
self.run_button.grid(sticky=W + E)
self.errors_list = Listbox(self.frame)
self.errors_list.grid(sticky=W + E)
self.status_label = Label(self.frame)
示例14: createCanvas
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def createCanvas( self ):
"Create and return our scrolling canvas frame."
f = Frame( self )
canvas = Canvas( f, width=self.cwidth, height=self.cheight,
bg=self.bg )
# Scroll bars
xbar = Scrollbar( f, orient='horizontal', command=canvas.xview )
ybar = Scrollbar( f, orient='vertical', command=canvas.yview )
canvas.configure( xscrollcommand=xbar.set, yscrollcommand=ybar.set )
# Resize box
resize = Label( f, bg='white' )
# Layout
canvas.grid( row=0, column=1, sticky='nsew')
ybar.grid( row=0, column=2, sticky='ns')
xbar.grid( row=1, column=1, sticky='ew' )
resize.grid( row=1, column=2, sticky='nsew' )
# Resize behavior
f.rowconfigure( 0, weight=1 )
f.columnconfigure( 1, weight=1 )
f.grid( row=0, column=0, sticky='nsew' )
f.bind( '<Configure>', lambda event: self.updateScrollRegion() )
# Mouse bindings
canvas.bind( '<ButtonPress-1>', self.clickCanvas )
canvas.bind( '<B1-Motion>', self.dragCanvas )
canvas.bind( '<ButtonRelease-1>', self.releaseCanvas )
return f, canvas
示例15: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid [as 别名]
def __init__(self, brdNum, frmRow, parentFrm):
self.brdNum = brdNum
self.brdPos = frmRow
self.statLbl = StringVar()
self.prevLedState = 0x00 #1 is on, 0 is off
self.bitFrms = []
self.canvas = []
if (TkLedBrd._ledOffImage == 0):
TkLedBrd._ledOffImage = PhotoImage(file="graphics/ledOff.gif")
if (TkLedBrd._ledOnWhtImage == 0):
TkLedBrd._ledOnWhtImage = PhotoImage(file="graphics/ledOnWht.gif")
if (TkLedBrd._ledOnGrnImage == 0):
TkLedBrd._ledOnGrnImage = PhotoImage(file="graphics/ledOnGrn.gif")
#Create main frame
self.ledCardFrm = Frame(parentFrm, borderwidth = 5, relief=RAISED)
self.ledCardFrm.grid(column = 0, row = frmRow)
#Create card info frame
ledCardInfoFrm = Frame(self.ledCardFrm)
ledCardInfoFrm.grid(column = 8, row = 0)
#Add card info
tmpLbl = Label(ledCardInfoFrm, text="LED Card %d" % (brdNum + 1))
tmpLbl.grid(column = 0, row = 0)
tmpLbl = Label(ledCardInfoFrm, text="Status")
tmpLbl.grid(column = 0, row = 1)
tmpLbl = Label(ledCardInfoFrm, textvariable=self.statLbl, relief=SUNKEN)
self.statLbl.set("0x%02x" % self.prevLedState)
tmpLbl.grid(column = 0, row = 2)
for i in xrange(rs232Intf.NUM_LED_PER_BRD):
TkLedBrd.createBitFrame(self, i)