本文整理汇总了Python中Tkinter.Frame.grid_propagate方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.grid_propagate方法的具体用法?Python Frame.grid_propagate怎么用?Python Frame.grid_propagate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Frame
的用法示例。
在下文中一共展示了Frame.grid_propagate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_propagate [as 别名]
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
border_width = 1
border_style = SUNKEN
background_colour = "#FFFFFF"
default_height = 600
nav_frame = Frame(
self, height=default_height, width=200, bd=border_width, relief=border_style, bg=background_colour
)
content_frame = Frame(self, height=default_height, width=804, bd=border_width, relief=border_style)
content_frame.parent = parent
nav_frame.grid(column=0, row=0)
content_frame.grid(column=1, row=0)
nav_frame.grid_propagate(0)
content_frame.pack_propagate(0)
# Create fonts for navLabels
fontMouseOver = tkFont.Font(family="Helvetica", size=14, underline=True)
fontMouseOut = tkFont.Font(family="Helvetica", size=14, underline=False)
# Creating Navigation Labels
self.lNavStudentRecords = Label(
nav_frame,
text="Student Records",
bg="white",
font=fontMouseOut,
bd=border_width,
relief=border_style,
width=20,
)
self.lNavViewLists = Label(
nav_frame,
text="View Word Lists",
bg="white",
font=fontMouseOut,
bd=border_width,
relief=border_style,
width=20,
)
self.lNavCreateLists = Label(
nav_frame,
text="Create Word Lists",
bg="white",
font=fontMouseOut,
bd=border_width,
relief=border_style,
width=20,
)
buttonBack = Button(nav_frame, text="Back", command=self.parent.new_list)
# Binding Mouse events to the Labels
# Mouse Clicks
self.lNavViewLists.bind("<Button-1>", partial(self.switch_frame, 2))
self.lNavCreateLists.bind("<Button-1>", partial(self.switch_frame, 1))
self.lNavStudentRecords.bind("<Button-1>", partial(self.switch_frame, 3))
# Mouse Movements
self.lNavViewLists.bind("<Enter>", lambda (event): self.lNavViewLists.configure(font=fontMouseOver))
self.lNavCreateLists.bind("<Enter>", lambda (event): self.lNavCreateLists.configure(font=fontMouseOver))
self.lNavViewLists.bind("<Leave>", lambda (event): self.lNavViewLists.configure(font=fontMouseOut))
self.lNavCreateLists.bind("<Leave>", lambda (event): self.lNavCreateLists.configure(font=fontMouseOut))
self.lNavStudentRecords.bind("<Enter>", lambda (event): self.lNavStudentRecords.configure(font=fontMouseOver))
self.lNavStudentRecords.bind("<Leave>", lambda (event): self.lNavStudentRecords.configure(font=fontMouseOut))
# Gridding the labels
# self.lNavStudentRecords.grid(column=0, row=0)
self.lNavViewLists.grid(column=0, row=1)
self.lNavCreateLists.grid(column=0, row=2)
buttonBack.grid(column=0, row=3)
# Creating the two views we have so far
self.viewcreate = CreateView(content_frame, default_height, 800, border_style, border_width, background_colour)
self.viewlists = ListView(content_frame, default_height, 800, border_style, border_width, background_colour)
self.viewlists.pack()
示例2: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_propagate [as 别名]
def __init__(self, parent, wdir, tooltipwidth, ehThis, ehFromHere):
"""Initiate
Arguments
parent -- parent tkinter item
wdir -- working directory
tooltipwidth -- maximum width of the tooltip
ehThis -- callback for playing one frame
ehFromHere -- callback for playing the rest of the frames from a given position
"""
IndexedFrame.__init__(self, parent)
self._wdir = wdir
self._il = None
self._parent = parent
self._lblFrame = StringVar()
self._lblImagename = StringVar()
self._lblImagenamefull = StringVar()
self._lblSoundname = StringVar()
self._lblSoundnamefull = StringVar()
self._fullSoundName = ''
content = self._content
content.columnconfigure(0, weight = 1)
content.columnconfigure(1, weight = 1)
content.rowconfigure(0, weight = 1)
content.rowconfigure(1, weight = 1)
content.rowconfigure(2, weight = 1)
#Left group box
lf = ttk.LabelFrame(content)
self._lfSlide = lf
lf.grid(row = 0, column = 0, sticky = W + N + E + S, padx = 5)
button = Button(lf, text = lang[lng.txtPlayThisFrame] + '...', command = lambda arg=self: ehThis(arg))
button.grid(row = 1, column = 0, sticky = W + E, padx = 5, pady = 5)
button = Button(lf, text = lang[lng.txtPlayFromHere] + '...', command = lambda arg=self: ehFromHere(arg))
button.grid(row = 2, column = 0, sticky = W + E, padx = 5, pady = 5)
#Image group box
lf = ttk.LabelFrame(content, text = ' ' + lang[lng.txtImage] + ' ')
lf.grid(row = 0, column = 1, padx = 5, sticky = W + N + E + S)
label = Label(lf, textvariable = self._lblImagename, justify = LEFT)
label.grid(row = 0, column = 1, padx = 5, pady = 5, sticky = W)
tt = ToolTip(label, '', textvariable = self._lblImagenamefull, wraplength = tooltipwidth)
button = Button(lf, text = lang[lng.txtSelect] + '...', command = self._ehGetImage)
button.grid(row = 0, column = 0, sticky = W, padx = 5, pady = 5)
button.ref = self
imFrame = Frame(lf)
self._imageFrame = imFrame
imFrame['width'] = _previewWidth
imFrame['height'] = _previewHeight
imFrame.grid(row = 1, column = 1, padx = 5, pady = 5)
imFrame.grid_propagate(0)
lf = ttk.Labelframe(content, text = ' ' + lang[lng.txtSound] + ' ')
lf.grid(row = 0, column = 2, padx = 5, sticky = W + N + E + S)
#Sound group box
label = Label(lf, textvariable = self._lblSoundname)
label.grid(row = 0, column = 0, padx = 5, pady = 5, sticky = W, columnspan = 10)
tt = ToolTip(label, '', textvariable = self._lblSoundnamefull, wraplength = tooltipwidth)
button = SoundButton(lf, lang[lng.txtListen], lang[lng.txtStop], self._clbPlaying)
self._btnSound = button
button.grid(row = 1, column = 0, sticky = W + E, padx = 5, pady = 5)
button = Button(lf, text = lang[lng.txtSelect] + '...', command = self._ehGetSound)
button.grid(row = 2, column = 0, sticky = W + E, padx = 5, pady = 5)
self._btnSelect = button
button = Button(lf, text = lang[lng.txtDelete], state = DISABLED, command = self._ehRemoveSound)
button.grid(row = 3, column = 0, sticky = W + E, padx = 5, pady = 5)
self._btnRemove = button
fr = Frame(lf, width = 160)
fr.grid(row = 4, column = 0, columnspan = 10)
示例3: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_propagate [as 别名]
def __init__(self, parent, height, width, border_style, border_width,
background_colour):
Frame.__init__(self, parent, height=height, width=width)
#Connect to the word/list database
self.db = SpellingDatabase()
self.parent = parent
#Create a frame containing a menu for choosing word category
categorymenu_frame = Frame(self, width=340, height=30, relief=SUNKEN, bd=1)
categorymenu_frame.pack_propagate(0)
categorymenu_label = Label(categorymenu_frame, text="Category:")
wordlist_title = Label(categorymenu_frame, text="Select Words")
#Menu options: one for each category of word
optionList = ("Child", "ESOL", "Spelling Bee", "Custom")
self.category_v = StringVar()
self.category_v.set(optionList[0])
#Command causes word browser to be populated with words from chosen category
self.category_menu = OptionMenu(categorymenu_frame, self.category_v, *optionList, command=self.update_category)
self.category_menu.config(width=10)
self.category_menu.pack(side=RIGHT)
categorymenu_label.pack(side=RIGHT)
wordlist_title.pack(side=LEFT)
#Create frame for the title of the user list panel
userlist_title_frame = Frame(self, width=340, height=30)
userlist_title_frame.pack_propagate(0)
userlist_title = Label(userlist_title_frame, text="Your New List")
userlist_title_frame.grid(column=2, row=0)
userlist_title.pack(side=LEFT)
#Create frame for middle bar containing transfer buttons
middlebar_frame = Frame(self, width = 70, height=400)
middlebar_frame.grid_propagate(0)
#Buttons transfer words from one list to the other
transfer_right_button = Button(middlebar_frame, text="->", command=self.transfer_right)
transfer_left_button = Button(middlebar_frame, text="<-", command=self.transfer_left)
#Press this button to generate a random list from the current category
random_list_button = Button(middlebar_frame, text="Create", command=self.random_list)
random_list_label = Label(middlebar_frame, text="Random\nList")
self.random_list_entry = Entry(middlebar_frame, width=3, justify=RIGHT)
self.random_list_entry.insert(0, 15)
transfer_left_button.grid(column=0, row=1, padx=15, pady=50)
transfer_right_button.grid(column=0, row=0, padx=15, pady=50)
random_list_label.grid(column=0, row=2, pady=3)
self.random_list_entry.grid(column=0, row=3, pady=3)
random_list_button.grid(column=0, row=4, pady=3)
middlebar_frame.grid(column=1, row=1)
#random_list_button.grid(column=0, row=2)
#Create frame for "Add New Word" menu
addword_frame = Frame(self, width=340, height=150, bd=2, relief=SUNKEN)
addword_frame.grid_propagate(0)
addword_label = Label(addword_frame, text = "Add a new word:")
word_label = Label(addword_frame, text="Word:")
def_label = Label(addword_frame, text="Definition:")
use_label = Label(addword_frame, text="Example of Use:")
difficulty_label = Label(addword_frame, text="Difficulty:")
#Entry boxes and an option menu allowing the user to enter attributes of the new word
self.addword_entry = Entry(addword_frame, width = 28)
self.adddefinition_entry = Entry(addword_frame, width=28)
self.adduse_entry = Entry(addword_frame, width=28)
self.difficulty_v = StringVar()
self.difficulty_v.set("1")
difficulty_list = range(1,9)
self.difficulty_menu = OptionMenu(addword_frame, self.difficulty_v, *difficulty_list)
#Pressing this button adds the new word to the database
addword_button = Button(addword_frame, text = "Add", command = self.add_word)
addword_label.grid(row=0, column=0, sticky=W)
addword_button.grid(row=0, column=1, pady=2, sticky=E)
word_label.grid(row=1, column=0, sticky=W)
def_label.grid(row=2, column=0, sticky=W)
use_label.grid(row=3, column=0, sticky=W)
difficulty_label.grid(row=4, column=0, sticky=W)
self.addword_entry.grid(row=1, column=1, pady=2, sticky=E)
self.adddefinition_entry.grid(row=2, column=1, pady=2, sticky=E)
self.adduse_entry.grid(row=3, column=1, pady=2, sticky=E)
self.difficulty_menu.grid(row=4, column=1, pady=2, sticky=E)
addword_frame.grid(column=0, row=2)
#Frame for menu allowing users to save their new lists
savelist_frame = Frame(self, width=340, height=30, bd=2, relief=SUNKEN)
savelist_frame.pack_propagate(0)
savelist_label = Label(savelist_frame, text="List Name:")
#User enters the name of the new list here
self.savelist_entry = Entry(savelist_frame, width=25)
#Pressing this button adds the new list to the database
savelist_button = Button(savelist_frame, text="Save", command = self.save_list)
savelist_label.pack(side=LEFT)
savelist_button.pack(side=RIGHT)
self.savelist_entry.pack(side=RIGHT, padx=5)
savelist_frame.grid(column=2, row=2, sticky=N, pady=5)
#Create list panel for browsing the words stored in database
self.wordbrowse_frame = ListPane(self, height=25)
categorymenu_frame.grid(column=0, row=0)
self.wordbrowse_frame.grid(column=0, row=1, sticky=N)
#Populate the list with words from database
self.update_category()
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_propagate [as 别名]
class ui:
def __init__(self, r):
self.__root = r # root of program
self.__load_icon = ImageTk.PhotoImage(file=constants.PATH + r'/ico/load.png')
self.__master_file = "" # file to merge into
self.__convert_list = [] # holds list of files to be converted
self.__sub_list = [] # holds list of files to compare against master
self.__convert_opts = None # Top level for additional convert options
self.__nth_number = None # Entry box for holding nth number for convert option
self.__lbl_file = None # Label which holds name of master file in top left corner
self.__convert_lbox = None # Listbox for holding list of files to convert
self.__sub_lbox = None # Listbox for holding list of files to compare against master file
self.__match_rule = IntVar() # the rule on how to merge files into master
self.__column_rule = IntVar() # which column to use for comparing
self.__column_rule.set(1) # initial value is the first column
self.__column_match_rule = IntVar() # which column to compare for a match
self.__column_match_rule.set(1) # initial value is the first column
# public window dimensions
self.width = self.__root.winfo_screenwidth()
self.height = self.__root.winfo_screenheight()
# upper left side of screen
self.__master_frame = Frame(self.__root, width=constants.WIDTH/3, borderwidth=1, relief=SOLID,
height=constants.HEIGHT/4)
self.__master_frame.grid_propagate(False)
self.__master_frame.grid(row=0, column=0, padx=5, pady=5)
# lower left side of screen
self.__convert_frame = Frame(self.__root, width=constants.WIDTH/3, borderwidth=1, relief=SOLID,
height=constants.HEIGHT - constants.HEIGHT/4 - 20)
self.__convert_frame.pack_propagate(False)
self.__convert_frame.grid(row=1, column=0, padx=5, pady=5)
# right side of screen
self.__sub_frame = Frame(self.__root, width=constants.WIDTH - constants.WIDTH/3 - 20, borderwidth=1, relief=SOLID,
height=constants.HEIGHT - 10)
self.__sub_frame.grid_propagate(False)
self.__sub_frame.grid(row=0, column=1, padx=5, pady=5, columnspan=2, rowspan=2)
def setup_gui(self):
"""
Top level function which is called from main(). Sets window title and dimensions, then calls three sub
routines which created and setup the rest of the GUI
"""
self.__root.title('db_swapper')
x = (self.width - constants.WIDTH) / 2
y = (self.height - constants.HEIGHT) / 2
self.__root.geometry('%dx%d+%d+%d' % (constants.WIDTH, constants.HEIGHT, x, y))
self.create_master_frame()
self.create_convert_frame()
self.create_sub_frame()
def create_master_frame(self):
"""
Initialize the GUI for the upper left
"""
load_btn = Button(self.__master_frame, image=self.__load_icon, width=20, height=20,
command=self.import_master_file)
load_btn.grid(row=1, column=1, padx=5, pady=5)
Label(self.__master_frame, text="Master List").\
grid(row=1, column=2, padx=5, pady=5)
self.__lbl_file = Label(self.__master_frame, bg="white", relief=SUNKEN, width=26)
self.__lbl_file.grid(row=2, column=1, padx=5, pady=5, columnspan=3)
# adding these weights allows the GUI to align itself within the frame
self.__master_frame.grid_rowconfigure(0, weight=1)
self.__master_frame.grid_columnconfigure(3, weight=1)
self.__master_frame.grid_rowconfigure(3, weight=1)
self.__master_frame.grid_columnconfigure(0, weight=1)
def create_convert_frame(self):
"""
Initialize the GUI for the lower left side of the program
"""
Label(self.__convert_frame, text="Files to split").\
pack(side=TOP)
self.__convert_lbox = Listbox(self.__convert_frame, width=29, height=12, selectmode=EXTENDED)
self.__convert_lbox.pack(side=TOP)
convert = Button(self.__convert_frame, text="Convert", command=self.choose_convert)
remove = Button(self.__convert_frame, text="Remove Item",
command=lambda: self.remove_item(self.__convert_lbox, self.__convert_list))
load = Button(self.__convert_frame, image=self.__load_icon, width=27, height=20,
command=lambda: self.import_and_append_file(self.__convert_lbox, self.__convert_list))
convert.pack(side=LEFT, padx=(10,5), pady=5)
remove.pack(side=LEFT, padx=(0,5))
load.pack(side=LEFT)
def create_sub_frame(self):
"""
#.........这里部分代码省略.........
示例5: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_propagate [as 别名]
class Notebook:
# initialization. receives the master widget
# reference and the notebook orientation
def __init__(self, master, width=0, height=0):
self.active_fr = None
self.count = 0
self.choice = IntVar(0)
self.dummy_x_fr = Frame(master, width=width, borderwidth=0)
self.dummy_y_fr = Frame(master, height=height, borderwidth=0)
self.dummy_x_fr.grid(row=0, column=1)
self.dummy_x_fr.grid_propagate(0)
self.dummy_y_fr.grid(row=1, rowspan=2, column=0)
self.dummy_y_fr.grid_propagate(0)
# creates notebook's frames structure
self.rb_fr = Frame(master, borderwidth=0)
self.rb_fr.grid(row=1, column=1, sticky=N + W)
self.screen_fr = Frame(master, borderwidth=2, relief=RIDGE)
self.screen_fr.grid(row=2, column=1, sticky=N + W + E)
master.rowconfigure(2, weight=1)
master.columnconfigure(1, weight=1)
# return a master frame reference for the external frames (screens)
def __call__(self):
return self.screen_fr
# add a new frame (screen) to the (bottom/left of the) notebook
def add_screen(self, fr, title):
b = Radiobutton(self.rb_fr, bd=1, text=title, indicatoron=0, \
variable=self.choice, value=self.count, \
command=lambda: self.display(fr))
b.grid(column=self.count, row=0, sticky=N + E + W)
self.rb_fr.columnconfigure(self.count, weight=1)
fr.grid(sticky=N + W + E)
self.screen_fr.columnconfigure(0, weight=1)
fr.grid_remove()
# ensures the first frame will be
# the first selected/enabled
if not self.active_fr:
fr.grid()
self.active_fr = fr
self.count += 1
# returns a reference to the newly created
# radiobutton (allowing its configuration/destruction)
return b
# hides the former active frame and shows
# another one, keeping its reference
def display(self, fr):
self.active_fr.grid_remove()
fr.grid()
self.active_fr = fr