本文整理汇总了Python中six.moves.tkinter.Frame.pack方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.pack方法的具体用法?Python Frame.pack怎么用?Python Frame.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.moves.tkinter.Frame
的用法示例。
在下文中一共展示了Frame.pack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_buttons
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def _create_buttons(self):
frame = Frame(self)
self._create_button(frame, self._left_button,
self._left_button_clicked)
self._create_button(frame, self._right_button,
self._right_button_clicked)
frame.pack()
示例2: _create_body
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def _create_body(self, message, value, **extra):
frame = Frame(self)
Label(frame, text=message, anchor=W, justify=LEFT, wraplength=800).pack(fill=BOTH)
selector = self._create_selector(frame, value, **extra)
if selector:
selector.pack(fill=BOTH)
selector.focus_set()
frame.pack(padx=5, pady=5, expand=1, fill=BOTH)
示例3: _init_paging
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def _init_paging(self, parent):
innerframe = Frame(parent, background=self._BACKGROUND_COLOUR)
self.prev = prev = Button(innerframe, text='Previous', command=self.previous, width='10', borderwidth=1, highlightthickness=1, state='disabled')
prev.pack(side='left', anchor='center')
self.next = next = Button(innerframe, text='Next', command=self.__next__, width='10', borderwidth=1, highlightthickness=1, state='disabled')
next.pack(side='right', anchor='center')
innerframe.pack(side='top', fill='y')
self.current_page = 0
示例4: _init_query_box
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def _init_query_box(self, parent):
innerframe = Frame(parent, background=self._BACKGROUND_COLOUR)
another = Frame(innerframe, background=self._BACKGROUND_COLOUR)
self.query_box = Entry(another, width=60)
self.query_box.pack(side='left', fill='x', pady=25, anchor='center')
self.search_button = Button(another, text='Search', command=self.search, borderwidth=1, highlightthickness=1)
self.search_button.pack(side='left', fill='x', pady=25, anchor='center')
self.query_box.bind('<KeyPress-Return>', self.search_enter_keypress_handler)
another.pack()
innerframe.pack(side='top', fill='x', anchor='n')
示例5: _init_corpus_select
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def _init_corpus_select(self, parent):
innerframe = Frame(parent, background=self._BACKGROUND_COLOUR)
self.var = StringVar(innerframe)
self.var.set(self.model.DEFAULT_CORPUS)
Label(innerframe, justify=LEFT, text=' Corpus: ', background=self._BACKGROUND_COLOUR, padx = 2, pady = 1, border = 0).pack(side='left')
other_corpora = list(self.model.CORPORA.keys()).remove(self.model.DEFAULT_CORPUS)
om = OptionMenu(innerframe, self.var, self.model.DEFAULT_CORPUS, command=self.corpus_selected, *self.model.non_default_corpora())
om['borderwidth'] = 0
om['highlightthickness'] = 1
om.pack(side='left')
innerframe.pack(side='top', fill='x', anchor='n')
示例6: _init_feedback
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def _init_feedback(self, parent):
self._feedbackframe = feedbackframe = Frame(parent)
feedbackframe.pack(fill='x', side='bottom', padx=3, pady=3)
self._lastoper_label = Label(feedbackframe, text='Last Operation:',
font=self._font)
self._lastoper_label.pack(side='left')
lastoperframe = Frame(feedbackframe, relief='sunken', border=1)
lastoperframe.pack(fill='x', side='right', expand=1, padx=5)
self._lastoper1 = Label(lastoperframe, foreground='#007070',
background='#f0f0f0', font=self._font)
self._lastoper2 = Label(lastoperframe, anchor='w', width=30,
foreground='#004040', background='#f0f0f0',
font=self._font)
self._lastoper1.pack(side='left')
self._lastoper2.pack(side='left', fill='x', expand=1)
示例7: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def __init__(self, *args, **kwargs):
pil_image = kwargs.pop('pil_image')
photo = ImageTk.PhotoImage(pil_image)
self.__photo = photo
self.__origin_image = pil_image
self.__zoomed_image = pil_image
Frame.__init__(self, *args, **kwargs)
frame = Frame(self)
frame.pack(fill='x')
save_dlg = lambda: asksaveasfilename(filetypes=[('JPEG', '.jpg'), ('PNG', '.png')], defaultextension='.jpg')
def on_save(image):
filename = save_dlg()
if filename:
image.save(filename)
Label(frame, text=eval_format('id={id(self)}')).pack(side='left')
Button(frame, text='Save Origin', command=lambda:on_save(self.__origin_image)).pack(side='left')
Button(frame, text='Save Zoomed', command=lambda:on_save(self.__zoomed_image)).pack(side='left')
scale = Scale(frame, from_=0, to=100, orient='horizontal', value=100)
scale.pack(side='left')
zoomed_label = Label(frame, text='100%')
zoomed_label.pack(side='left')
self.__label = label = Label(self, image=photo)
label.pack(expand=YES, fill=BOTH)
def on_scale(val):
val = float(val)
width, height = self.__origin_image.size
width = int(width * val / 100)
height = int(height * val / 100)
zoomed_image = self.__origin_image.resize((width, height),
Image.ANTIALIAS)
self.__zoomed_image = zoomed_image
self.__photo = ImageTk.PhotoImage(zoomed_image)
self.__label['image'] = self.__photo
zoomed_label['text'] = '{}%'.format(int(val))
scale['command'] = on_scale
示例8: set_matplotlib_style
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def set_matplotlib_style(self, style_name=''):
import matplotlib.pyplot as plt
if style_name is self.constants.ASK_DIALOG:
dialog = True
else:
dialog = False
ret = [None]
if dialog:
win = Toplevel()
Label(win, text='Select a style for newly-created figures.').pack()
combo = Combobox(win, stat='readonly')
combo['values'] = plt.style.available
combo.current(0)
combo.pack()
ret = [None]
def on_ok():
ret[0] = combo.get()
win.quit()
def on_cancel():
win.quit()
frame = Frame(win)
frame.pack()
Button(win, text='Cancel', command=on_cancel).pack(side='right')
Button(win, text='Ok', command=on_ok).pack(side='right')
win.protocol('WM_DELETE_WINDOW', win.quit)
win.focus_set()
win.grab_set()
win.mainloop()
win.destroy()
style = ret[0] if ret[0] is not None else style_name
plt.style.use(style)
示例9: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def __init__(self, package_name, base_class, display_base_class=False):
self.__package_name = package_name
self.__base_class = base_class
self.__display_base_class = display_base_class
self.__window = window = Toplevel()
window.title('Class Selector')
self.__selected_class_name = ''
self.__selected_module_name = ''
self.__tree = tree = ScrolledTree(window)
tree.pack()
# If a module print something while being loaded, the stdout of this
# script will be contaminated.
# The dumb_stream prevents the contamination.
with dumb_stream():
classes = self.load_modules()
for package in classes:
packageNode = tree.insert('', 'end', text=package)
for class_name in classes[package]:
tree.insert(packageNode, 'end', text=class_name, values=package)
button_frame = Frame(window)
button_frame.pack()
def _on_click(module_name, class_name):
self.__selected_module_name = module_name
self.__selected_class_name = class_name
window.destroy()
cancel_button = Button(button_frame, text='Cancel', command=lambda: _on_click('', ''))
cancel_button.pack(side='right')
ok_button = Button(
button_frame,
text='OK',
command=lambda: _on_click(
tree.item(tree.selection(), 'values')[0],
tree.item(tree.selection(), 'text')
)
)
ok_button.pack(side='right')
示例10: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def __init__(self, grammar, text):
self._grammar = grammar
self._text = text
# Set up the main window.
self._top = Tk()
self._top.title('Context Free Grammar Demo')
# Base font size
self._size = IntVar(self._top)
self._size.set(12) # = medium
# Set up the key bindings
self._init_bindings(self._top)
# Create the basic frames
frame1 = Frame(self._top)
frame1.pack(side='left', fill='y', expand=0)
self._init_menubar(self._top)
self._init_buttons(self._top)
self._init_grammar(frame1)
self._init_treelet(frame1)
self._init_workspace(self._top)
示例11: ask_font
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def ask_font():
win = Toplevel()
win.title('Font Dialog')
buttonFrame = Frame(win)
retval = [None]
def onClick(ret=None):
win.destroy()
retval[0] = ret
buttonFrame.pack(side=BOTTOM)
btnCancel = Button(buttonFrame, text='Cancel', command=lambda: onClick())
btnCancel.pack(side=RIGHT)
btnOk = Button(buttonFrame, text='OK', command=lambda: onClick((fontFrame.face, fontFrame.size)))
btnOk.pack(side=RIGHT)
fontFrame = FontFrame(win)
fontFrame.pack()
win.focus_set()
win.grab_set()
win.wait_window()
return retval[0]
示例12: _init_results_box
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def _init_results_box(self, parent):
innerframe = Frame(parent)
i1 = Frame(innerframe)
i2 = Frame(innerframe)
vscrollbar = Scrollbar(i1, borderwidth=1)
hscrollbar = Scrollbar(i2, borderwidth=1, orient='horiz')
self.results_box = Text(i1,
font=Font(family='courier', size='16'),
state='disabled', borderwidth=1,
yscrollcommand=vscrollbar.set,
xscrollcommand=hscrollbar.set, wrap='none', width='40', height = '20', exportselection=1)
self.results_box.pack(side='left', fill='both', expand=True)
vscrollbar.pack(side='left', fill='y', anchor='e')
vscrollbar.config(command=self.results_box.yview)
hscrollbar.pack(side='left', fill='x', expand=True, anchor='w')
hscrollbar.config(command=self.results_box.xview)
#there is no other way of avoiding the overlap of scrollbars while using pack layout manager!!!
Label(i2, text=' ', background=self._BACKGROUND_COLOUR).pack(side='left', anchor='e')
i1.pack(side='top', fill='both', expand=True, anchor='n')
i2.pack(side='bottom', fill='x', anchor='s')
innerframe.pack(side='top', fill='both', expand=True)
示例13: __init__
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def __init__(self, *args, **kwargs):
TkToolWindow.__init__(self, *args, **kwargs)
Observable.__init__(self)
self.__serialmap = None
# Temporarily
self.inst = Inst()
# End Temporarily
#window = self.tk_object
tooltab = Frame(self._tool_tabs)
self._tool_tabs.add(tooltab, text='SPI')
#tooltab.pack(expand='yes', fill='x')
# Group OPEN
open_group = Group(tooltab)
open_group.name = 'Open Device'
open_group.pack(side='left', fill='y', expand='yes')
self.__dev_combo = dev_combo = Combobox(open_group, value=[], takefocus=1, stat='readonly', width=12)
dev_combo.bind('<<ComboboxSelected>>', self._on_dev_change)
self.__current_serialno = None
dev_combo.pack(side='top')
self.__is_opened = IntVar(0)
self.__open_check = open_check = Checkbutton(open_group, text='Open',
variable=self.__is_opened,
command=self._on_open_click)
open_check.pack(expand='yes', fill='y', side='top')
# End Group Open
# Group Parameters
param_group = Group(tooltab)
param_group.name = 'Parameters'
param_group.pack(side='left')
Button(param_group, text='Configure', command=self._on_param_change).pack(side='bottom')
param_frame = Frame(param_group)
param_frame.pack()
self.__CPOL = CPOL = IntVar(0)
self.__CPHA = CPHA = IntVar(0)
Checkbutton(param_frame, text='CPOL', variable=CPOL).grid(row=0, column=0)
Checkbutton(param_frame, text='CPHA', variable=CPHA).grid(row=1, column=0)
self.__baud_combo = baud_combo = Combobox(param_frame, value=[], takefocus=1, stat='readonly', width=8)
baud_combo.grid(row=0, column=1, columnspan=2)
self.__read_timeout_str = r_timeout = StringVar()
self.__write_timeout_str = w_timeout = StringVar()
Entry(param_frame, textvariable=r_timeout, width=5).grid(row=1, column=1)
Entry(param_frame, textvariable=w_timeout, width=5).grid(row=1, column=2)
# End Group Parameters
# Write Group
write_group = Group(tooltab)
write_group.name = 'Write'
write_group.pack(side='left', fill='y', expand='yes')
self.__writebuf = writebuf = StringVar()
Entry(write_group, textvariable=writebuf).pack()
Button(write_group, text='Write', command=self._on_write_click).pack()
# End Write Group
self._make_window_manager_tab()
# To Do: a driver group for loading specified spi bus driver
converter = USBSPIConverter()
converter.add_observer(self)
self.add_observer(converter)
示例14: ConcordanceSearchView
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
class ConcordanceSearchView(object):
_BACKGROUND_COLOUR='#FFF' #white
#Colour of highlighted results
_HIGHLIGHT_WORD_COLOUR='#F00' #red
_HIGHLIGHT_WORD_TAG='HL_WRD_TAG'
_HIGHLIGHT_LABEL_COLOUR='#C0C0C0' # dark grey
_HIGHLIGHT_LABEL_TAG='HL_LBL_TAG'
#Percentage of text left of the scrollbar position
_FRACTION_LEFT_TEXT=0.30
def __init__(self):
self.queue = q.Queue()
self.model = ConcordanceSearchModel(self.queue)
self.top = Tk()
self._init_top(self.top)
self._init_menubar()
self._init_widgets(self.top)
self.load_corpus(self.model.DEFAULT_CORPUS)
self.after = self.top.after(POLL_INTERVAL, self._poll)
def _init_top(self, top):
top.geometry('950x680+50+50')
top.title('NLTK Concordance Search')
top.bind('<Control-q>', self.destroy)
top.protocol('WM_DELETE_WINDOW', self.destroy)
top.minsize(950,680)
def _init_widgets(self, parent):
self.main_frame = Frame(parent, dict(background=self._BACKGROUND_COLOUR, padx=1, pady=1, border=1))
self._init_corpus_select(self.main_frame)
self._init_query_box(self.main_frame)
self._init_results_box(self.main_frame)
self._init_paging(self.main_frame)
self._init_status(self.main_frame)
self.main_frame.pack(fill='both', expand=True)
def _init_menubar(self):
self._result_size = IntVar(self.top)
self._cntx_bf_len = IntVar(self.top)
self._cntx_af_len = IntVar(self.top)
menubar = Menu(self.top)
filemenu = Menu(menubar, tearoff=0, borderwidth=0)
filemenu.add_command(label='Exit', underline=1,
command=self.destroy, accelerator='Ctrl-q')
menubar.add_cascade(label='File', underline=0, menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
rescntmenu = Menu(editmenu, tearoff=0)
rescntmenu.add_radiobutton(label='20', variable=self._result_size,
underline=0, value=20,
command=self.set_result_size)
rescntmenu.add_radiobutton(label='50', variable=self._result_size,
underline=0, value=50,
command=self.set_result_size)
rescntmenu.add_radiobutton(label='100', variable=self._result_size,
underline=0, value=100,
command=self.set_result_size)
rescntmenu.invoke(1)
editmenu.add_cascade(label='Result Count', underline=0, menu=rescntmenu)
cntxmenu = Menu(editmenu, tearoff=0)
cntxbfmenu = Menu(cntxmenu, tearoff=0)
cntxbfmenu.add_radiobutton(label='60 characters',
variable=self._cntx_bf_len,
underline=0, value=60,
command=self.set_cntx_bf_len)
cntxbfmenu.add_radiobutton(label='80 characters',
variable=self._cntx_bf_len,
underline=0, value=80,
command=self.set_cntx_bf_len)
cntxbfmenu.add_radiobutton(label='100 characters',
variable=self._cntx_bf_len,
underline=0, value=100,
command=self.set_cntx_bf_len)
cntxbfmenu.invoke(1)
cntxmenu.add_cascade(label='Before', underline=0, menu=cntxbfmenu)
cntxafmenu = Menu(cntxmenu, tearoff=0)
cntxafmenu.add_radiobutton(label='70 characters',
variable=self._cntx_af_len,
underline=0, value=70,
command=self.set_cntx_af_len)
cntxafmenu.add_radiobutton(label='90 characters',
variable=self._cntx_af_len,
underline=0, value=90,
command=self.set_cntx_af_len)
cntxafmenu.add_radiobutton(label='110 characters',
variable=self._cntx_af_len,
underline=0, value=110,
command=self.set_cntx_af_len)
cntxafmenu.invoke(1)
cntxmenu.add_cascade(label='After', underline=0, menu=cntxafmenu)
editmenu.add_cascade(label='Context', underline=0, menu=cntxmenu)
#.........这里部分代码省略.........
示例15: init_gui
# 需要导入模块: from six.moves.tkinter import Frame [as 别名]
# 或者: from six.moves.tkinter.Frame import pack [as 别名]
def init_gui(self):
"""init helper"""
window = PanedWindow(self.root, orient="vertical")
window.pack(side=TOP, fill=BOTH, expand=True)
top_pane = Frame(window)
window.add(top_pane)
mid_pane = Frame(window)
window.add(mid_pane)
bottom_pane = Frame(window)
window.add(bottom_pane)
#setting up frames
top_frame = Frame(top_pane)
mid_frame = Frame(top_pane)
history_frame = Frame(top_pane)
radio_frame = Frame(mid_pane)
rating_frame = Frame(mid_pane)
res_frame = Frame(mid_pane)
check_frame = Frame(bottom_pane)
msg_frame = Frame(bottom_pane)
btn_frame = Frame(bottom_pane)
top_frame.pack(side=TOP, fill=X)
mid_frame.pack(side=TOP, fill=X)
history_frame.pack(side=TOP, fill=BOTH, expand=True)
radio_frame.pack(side=TOP, fill=X)
rating_frame.pack(side=TOP, fill=X)
res_frame.pack(side=TOP, fill=BOTH, expand=True)
check_frame.pack(side=TOP, fill=X)
msg_frame.pack(side=TOP, fill=BOTH, expand=True)
btn_frame.pack(side=TOP, fill=X)
# Binding F5 application-wide to run lint
self.root.bind('<F5>', self.run_lint)
#Message ListBox
rightscrollbar = Scrollbar(msg_frame)
rightscrollbar.pack(side=RIGHT, fill=Y)
bottomscrollbar = Scrollbar(msg_frame, orient=HORIZONTAL)
bottomscrollbar.pack(side=BOTTOM, fill=X)
self.lb_messages = Listbox(
msg_frame,
yscrollcommand=rightscrollbar.set,
xscrollcommand=bottomscrollbar.set,
bg="white")
self.lb_messages.bind("<Double-Button-1>", self.show_sourcefile)
self.lb_messages.pack(expand=True, fill=BOTH)
rightscrollbar.config(command=self.lb_messages.yview)
bottomscrollbar.config(command=self.lb_messages.xview)
#History ListBoxes
rightscrollbar2 = Scrollbar(history_frame)
rightscrollbar2.pack(side=RIGHT, fill=Y)
bottomscrollbar2 = Scrollbar(history_frame, orient=HORIZONTAL)
bottomscrollbar2.pack(side=BOTTOM, fill=X)
self.showhistory = Listbox(
history_frame,
yscrollcommand=rightscrollbar2.set,
xscrollcommand=bottomscrollbar2.set,
bg="white")
self.showhistory.pack(expand=True, fill=BOTH)
rightscrollbar2.config(command=self.showhistory.yview)
bottomscrollbar2.config(command=self.showhistory.xview)
self.showhistory.bind('<Double-Button-1>', self.select_recent_file)
self.set_history_window()
#status bar
self.status = Label(self.root, text="", bd=1, relief=SUNKEN, anchor=W)
self.status.pack(side=BOTTOM, fill=X)
#labelbl_ratingls
lbl_rating_label = Label(rating_frame, text='Rating:')
lbl_rating_label.pack(side=LEFT)
lbl_rating = Label(rating_frame, textvariable=self.rating)
lbl_rating.pack(side=LEFT)
Label(mid_frame, text='Recently Used:').pack(side=LEFT)
Label(top_frame, text='Module or package').pack(side=LEFT)
#file textbox
self.txt_module = Entry(top_frame, background='white')
self.txt_module.bind('<Return>', self.run_lint)
self.txt_module.pack(side=LEFT, expand=True, fill=X)
#results box
rightscrollbar = Scrollbar(res_frame)
rightscrollbar.pack(side=RIGHT, fill=Y)
bottomscrollbar = Scrollbar(res_frame, orient=HORIZONTAL)
bottomscrollbar.pack(side=BOTTOM, fill=X)
self.results = Listbox(
res_frame,
yscrollcommand=rightscrollbar.set,
xscrollcommand=bottomscrollbar.set,
bg="white", font="Courier")
self.results.pack(expand=True, fill=BOTH, side=BOTTOM)
rightscrollbar.config(command=self.results.yview)
bottomscrollbar.config(command=self.results.xview)
#buttons
Button(top_frame, text='Open', command=self.file_open).pack(side=LEFT)
#.........这里部分代码省略.........