本文整理汇总了Python中Tkinter.Frame.rowconfigure方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.rowconfigure方法的具体用法?Python Frame.rowconfigure怎么用?Python Frame.rowconfigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Frame
的用法示例。
在下文中一共展示了Frame.rowconfigure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_gui
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [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: Display
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [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()
示例3: createCanvas
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [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
示例4: _init_components
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [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')
示例5: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
def __init__(self, filename, parentnotebook):
"""Create a new EditTab
Argument
filename -- name and path to the file being edited
parentnotebook -- the NoteBook in which this tab will be added
"""
Frame.__init__(self)
self._filename = filename
self._parentnotebook = parentnotebook
self._inputs = []
self.path = os.path.dirname(filename)
self._dirty = False
parentnotebook.add(self, state = 'normal')
self._setLabel()
#Set up GUI
self.rowconfigure(0, weight = 1)
self.columnconfigure(0, weight = 1)
vscroll = Scrollbar(self, orient = VERTICAL)
self._vscroll = vscroll
vscroll.grid(row=0, column=1, sticky=N+S)
hscroll = Scrollbar(self, orient = HORIZONTAL)
self._hscroll = hscroll
hscroll.grid(row=1, column=0, sticky=E+W)
canvas = Canvas(self, yscrollcommand = vscroll.set, xscrollcommand = hscroll.set)
self._canvas = canvas
canvas.grid(row = 0, column = 0, padx = 5, pady = 5, sticky = NSEW)
vscroll['command'] = canvas.yview
hscroll['command'] = canvas.xview
scrollframe = Frame(canvas)
self._scrollframe = scrollframe
canvas.create_window(0, 0, window = scrollframe, anchor = N + W)
scrollframe.rowconfigure(0, weight = 1)
scrollframe.columnconfigure(0, weight = 1)
self._mainframe = Frame(scrollframe)
self._mainframe.grid(row = 0, column = 0, padx = 5, pady = 5, sticky = NSEW)
cf = Frame(scrollframe)
self._control_frame = cf
cf.grid(row = 1, column = 0, padx = 5, pady = 5, sticky = E)
b = Button(cf, text = lang[lng.txtCopyImages], command = self._ehCopyImages)
self._btnCopy = b
b.grid(row = 0, column = 0, padx = 5, pady = 5)
b = Button(cf, text = lang[lng.txtSave], command = self._ehSave, state = DISABLED)
self._btnSave = b
b.grid(row = 0, column = 1, padx = 5, pady = 5)
b = Button(cf, text = lang[lng.txtClose], command = self._ehClose)
b.grid(row = 0, column = 2, padx = 5, pady = 5)
parentnotebook.after_idle(self._setCanvas)
示例6: show
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
def show(self):
self.__root.title(CONST.APP_NAME)
mainFrame = Frame(self.__root)
# Configure main frame and make Dialog stretchable (to EAST and WEST)
top = mainFrame.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
mainFrame.rowconfigure(0, weight=1)
mainFrame.columnconfigure(0, weight=1)
mainFrame.grid(sticky='ew')
# Configure the frames to hold the controls
# - Frame with input settings
inputFrame = LabelFrame(mainFrame, text='Input Settings')
inputFrame.columnconfigure(1, weight=1)
inputFrame.grid(column=0, row=0, padx=5, pady=5, sticky='ew')
# - Frame with output settings
outputFrame = LabelFrame(mainFrame, text='Output Settings')
outputFrame.columnconfigure(1, weight=1)
outputFrame.grid(column=0, row=1, padx=5, pady=5, sticky='ew')
# - Frame with buttons at the bottom of the dialog
buttonFrame = Frame(mainFrame)
buttonFrame.grid(column=0, row=2, padx=5, pady=5, sticky='e')
# Controls for input
dataSourceFileLabel = Label(inputFrame, text='Data File:', width=15, anchor='w')
dataSourceFileLabel.grid(column=0, row=1, padx=5, pady=5, sticky='w')
dataSourceFileEntry = Entry(inputFrame, width=70, textvariable=self.__ctrl.getDataSourceFileEntryVariable())
dataSourceFileEntry.grid(column=1, row=1, padx=5, pady=5, sticky='ew')
dataSourceFileButton = Button(inputFrame, text='...', command=self.__ctrl.dataSourceFileEntryVariableHandler)
dataSourceFileButton.grid(column=2, row=1, padx=5, pady=5, sticky='e')
# Controls for output
numberOfDataLinesToMergeLabel = Label(outputFrame, text='Number of rows to merge into this document:', width=35, anchor='w')
numberOfDataLinesToMergeLabel.grid(column=0, row=2, padx=5, pady=5, sticky='w')
# numberOfDataLinesToMergeListBox = OptionMenu(outputFrame, self.__ctrl.getSelectedNumberOfLines(), tuple(self.__ctrl.getNumerOfLinesList())) # TODO: implement these two functions in the controller
numberOfDataLinesToMergeListBox = apply(OptionMenu, (outputFrame, self.__ctrl.getSelectedNumberOfLines()) + tuple(self.__ctrl.getNumerOfLinesList()))
numberOfDataLinesToMergeListBox.grid(column=1, row=2, padx=5, pady=5, sticky='w')
# Buttons
cancelButton = Button(buttonFrame, text='Cancel', width=10, command=self.__ctrl.buttonCancelHandler)
cancelButton.grid(column=1, row=0, padx=5, pady=5, sticky='e')
runButton = Button(buttonFrame, text='Run', width=10, command=self.__ctrl.buttonOkHandler)
runButton.grid(column=2, row=0, padx=5, pady=5, sticky='e')
# Show the dialog
mainFrame.grid()
self.__root.grid()
self.__root.mainloop()
示例7: createConsoles
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
def createConsoles( self, parent, nodes, width, title ):
"Create a grid of consoles in a frame."
f = Frame( parent )
# Create consoles
consoles = []
index = 0
for node in nodes:
console = Console( f, self.net, node, title=title )
consoles.append( console )
row = index / width
column = index % width
console.grid( row=row, column=column, sticky='nsew' )
index += 1
f.rowconfigure( row, weight=1 )
f.columnconfigure( column, weight=1 )
return f, consoles
示例8: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
def __init__(self, parent):
master = Frame(parent, bg = 'green')
master.grid(sticky = W + N + E + S)
master.rowconfigure(0, weight = 1)
master.columnconfigure(0, weight = 1)
canvas = Canvas(master)
self._canvas = canvas
canvas.grid(row = 0, column = 0, sticky = W + N + E + S)
hScroll = Scrollbar(master, orient = HORIZONTAL, command = canvas.xview)
hScroll.grid(row = 1, column = 0, sticky = W + E)
vScroll = Scrollbar(master, orient = VERTICAL, command = canvas.yview)
vScroll.grid(row = 0, column = 1, sticky = N + S)
canvas.configure(xscrollcommand = hScroll.set, yscrollcommand = vScroll.set)
Frame.__init__(self, canvas, bg = 'blue')
canvas.create_window(0, 0, window = self, anchor = N + W)
示例9: createWidgets
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
def createWidgets(self):
if self.widgets:
for label in self.widgets:
label.update()
else:
labels =[]
f = Frame(self.canv)
f.rowconfigure(0, weight=1)
f.columnconfigure(0, weight=1)
for slot in self.device.storage_slots:
label = StorageLabel(f,slot)
labels.append(label)
self.canv.create_window(0, 0, anchor='nw', window=f)
f.update_idletasks()
self.canv.config(scrollregion=self.canv.bbox("all"))
self.widgets = labels
示例10: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
def __init__(self, filename, parentnotebook):
EditTab.__init__(self, filename, parentnotebook)
et = eis.EditInputTheme(self._mainframe, self)
self._inputs.append(et)
et.grid(row=0, column=0, rowspan=4, padx=5, pady=5, sticky=NSEW)
et = eis.EditInputDataSource(self._mainframe, self, "Blog")
self._inputs.append(et)
et.grid(row=0, column=1, padx=5, pady=5, sticky=NSEW)
et = eis.EditInputDataSource(self._mainframe, self, "New")
self._inputs.append(et)
et.grid(row=1, column=1, padx=5, pady=5, sticky=NSEW)
et = eis.EditInputCommon3(self._mainframe, self)
self._inputs.append(et)
et.grid(row=2, column=1, padx=5, pady=5, sticky=NSEW)
et = eis.EditInputBottomArea(self._mainframe, self)
self._inputs.append(et)
et.grid(row=3, column=1, padx=5, pady=5, sticky=NSEW)
et = eis.EditInputItemView(self._mainframe, self, True)
self._inputs.append(et)
et.grid(row=0, column=2, rowspan=3, padx=5, pady=5, sticky=NSEW)
et = eis.EditInputScrollbuttons(self._mainframe, self)
self._inputs.append(et)
et.grid(row=3, column=2, padx=5, pady=5, sticky=NSEW)
right = Frame(self._mainframe)
right.grid(row=0, column=3, rowspan=4, padx=5, pady=5, sticky=NSEW)
right.rowconfigure(1, weight=1)
et = eis.EditInputDimensions(right, self)
self._inputs.append(et)
et.grid(row=0, column=0, padx=5, pady=5, sticky=NSEW)
sm = eis.SubjectManager(right, self)
self._inputs.append(sm)
sm.grid(row=1, column=0, padx=5, pady=5, sticky=NSEW)
示例11: __init__
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
class ScrolledCanvas:
def __init__(self, master, **opts):
if 'yscrollincrement' not in opts:
opts['yscrollincrement'] = 17
self.master = master
self.frame = Frame(master)
self.frame.rowconfigure(0, weight=1)
self.frame.columnconfigure(0, weight=1)
self.canvas = Canvas(self.frame, **opts)
self.canvas.grid(row=0, column=0, sticky="nsew")
self.vbar = Scrollbar(self.frame, name="vbar")
self.vbar.grid(row=0, column=1, sticky="nse")
self.hbar = Scrollbar(self.frame, name="hbar", orient="horizontal")
self.hbar.grid(row=1, column=0, sticky="ews")
self.canvas['yscrollcommand'] = self.vbar.set
self.vbar['command'] = self.canvas.yview
self.canvas['xscrollcommand'] = self.hbar.set
self.hbar['command'] = self.canvas.xview
self.canvas.bind("<Key-Prior>", self.page_up)
self.canvas.bind("<Key-Next>", self.page_down)
self.canvas.bind("<Key-Up>", self.unit_up)
self.canvas.bind("<Key-Down>", self.unit_down)
#if isinstance(master, Toplevel) or isinstance(master, Tk):
self.canvas.bind("<Alt-Key-2>", self.zoom_height)
self.canvas.focus_set()
def page_up(self, event):
self.canvas.yview_scroll(-1, "page")
return "break"
def page_down(self, event):
self.canvas.yview_scroll(1, "page")
return "break"
def unit_up(self, event):
self.canvas.yview_scroll(-1, "unit")
return "break"
def unit_down(self, event):
self.canvas.yview_scroll(1, "unit")
return "break"
def zoom_height(self, event):
ZoomHeight.zoom_height(self.master)
return "break"
示例12: show_items
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
def show_items(self, items, upper=[]):
"""
Creates a new page on the stack, automatically adds a back button when there are
pages on the stack already
:param items: list the items to display
:param upper: list previous levels' ids
:return: None
"""
num = 0
# create a new frame
wrap = Frame(self, bg="black")
# when there were previous frames, hide the top one and add a back button for the new one
if len(self.framestack):
self.hide_top()
back = FlatButton(
wrap,
text='back…',
image=self.get_icon("arrow.left"),
command=self.go_back,
)
back.set_color("#00a300") # green
back.grid(row=0, column=0, padx=1, pady=1, sticky=TkC.W + TkC.E + TkC.N + TkC.S)
num += 1
# add the new frame to the stack and display it
self.framestack.append(wrap)
self.show_top()
# calculate tile distribution
all = len(items) + num
rows = floor(sqrt(all))
cols = ceil(all / rows)
# make cells autoscale
for x in range(int(cols)):
wrap.columnconfigure(x, weight=1)
for y in range(int(rows)):
wrap.rowconfigure(y, weight=1)
# display all given buttons
for item in items:
act = upper + [item['name']]
if 'icon' in item:
image = self.get_icon(item['icon'])
else:
image = self.get_icon('scrabble.'+item['label'][0:1].lower())
btn = FlatButton(
wrap,
text=item['label'],
image=image
)
if 'items' in item:
# this is a deeper level
btn.configure(command=lambda act=act, item=item: self.show_items(item['items'], act), text=item['label']+'…')
btn.set_color("#2b5797") # dark-blue
else:
# this is an action
btn.configure(command=lambda act=act: self.go_action(act), )
if 'color' in item:
btn.set_color(item['color'])
# add buton to the grid
btn.grid(
row=int(floor(num / cols)),
column=int(num % cols),
padx=1,
pady=1,
sticky=TkC.W + TkC.E + TkC.N + TkC.S
)
num += 1
示例13: initUI
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
#.........这里部分代码省略.........
lab_res = Label(frame, textvariable=ret_indicator)
lab_res.grid(row=6,column=0, sticky=tk.W+tk.S)
var_res = tk.StringVar()
msg_res = Message(frame,textvariable=var_res, width=500)
msg_res.grid(row=7,column=0, columnspan=2,sticky=tk.W+tk.E+tk.N)
frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
def connect():
self.addr = ent_addr.get()
portStr = ent_port.get()
if self.addr == "":
self.addr = "localhost"
if portStr == "":
self.port = 50000
else:
self.port = int(portStr)
(ret, info) = ec.connect(self.addr, self.port)
if ret == 0:
ret_indicator.set("Connection Succeeded")
self.conn = info
var_res.set("")
else:
ret_indicator.set("Connection Failed")
var_res.set(info)
def sendMsg():
msg = ent_msg.get("0.0", tk.END)[0:-1]
print "msg to be sent is: " + repr(msg)
(ret, info) = ec.sendMsg(self.conn, msg.encode('utf-8'))
if ret == 0:
ret_indicator.set("Send Succeeded")
var_res.set("")
else:
ret_indicator.set("Send Failed")
var_res.set(info)
def sendNum():
msg = ent_num.get()
print "msg to be sent is: " + repr(msg)
(ret, info) = ec.sendNum(self.conn, int(msg))
if ret == 0:
ret_indicator.set("Send Succeeded")
var_res.set("")
else:
ret_indicator.set("Send Failed")
var_res.set(info)
def recvMsg():
(ret, info) = ec.recvMsg(self.conn)
if ret == 0:
ret_indicator.set("Receive Succeeded")
else:
ret_indicator.set("Receive Failed")
var_res.set(info)
def close():
(ret, info) = ec.close(self.conn)
if ret == 0:
ret_indicator.set("Close Succeeded")
var_res.set("")
else:
ret_indicator.set("Close Failed")
var_res.set(info)
frame2 = Frame(self, relief=tk.RAISED, borderwidth=1)
"""Buttoms are always in the middle."""
frame2.columnconfigure(0, pad=10, weight=1)
frame2.rowconfigure(0, weight=1000)
frame2.rowconfigure(1, weight=1)
frame2.rowconfigure(2, weight=1)
frame2.rowconfigure(3, weight=1)
frame2.rowconfigure(4, weight=1)
frame2.rowconfigure(5, weight=1)
frame2.rowconfigure(6, weight=1000)
but_conn = Button(frame2, text="Connect", command=connect)
but_conn.grid(row=1,column=0, sticky=tk.W+tk.E)
but_send_msg = Button(frame2, text="Send Message", command=sendMsg)
but_send_msg.grid(row=2,column=0, sticky=tk.W+tk.E)
but_send_num = Button(frame2, text="Send Number", command=sendNum)
but_send_num.grid(row=3,column=0, sticky=tk.W+tk.E)
but_recv = Button(frame2, text="Receive", command=recvMsg)
but_recv.grid(row=4,column=0, sticky=tk.W+tk.E)
but_close = Button(frame2, text="Close", command=close)
but_close.grid(row=5,column=0, sticky=tk.W+tk.E)
frame2.pack(side=tk.LEFT, fill=tk.BOTH,expand=1)
# expand=1 cannot be omitted
self.pack(fill=tk.BOTH, expand=1)
示例14: show
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
def show(self):
self.__root.title(CONST.APP_NAME)
mainFrame = Frame(self.__root)
# Make Dialog stretchable (to EAST and WEST)
top = mainFrame.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
mainFrame.rowconfigure(0, weight=1)
mainFrame.columnconfigure(0, weight=1)
mainFrame.grid(sticky='ew')
# Three Sections: Input-Settings, Output-Settings and Buttons
inputFrame = LabelFrame(mainFrame, text='Input Settings')
inputFrame.columnconfigure(1, weight=1)
inputFrame.grid(column=0, row=0, padx=5, pady=5, sticky='ew')
outputFrame = LabelFrame(mainFrame, text='Output Settings')
outputFrame.columnconfigure(1, weight=1)
outputFrame.grid(column=0, row=1, padx=5, pady=5, sticky='ew')
buttonFrame = Frame(mainFrame)
buttonFrame.grid(column=0, row=2, padx=5, pady=5, sticky='e')
# Input-Settings
scribusSourceFileLabel = Label(inputFrame, text='Scribus File:', width=15, anchor='w')
scribusSourceFileLabel.grid(column=0, row=0, padx=5, pady=5, sticky='w')
scribusSourceFileEntry = Entry(inputFrame, width=70, textvariable=self.__ctrl.getScribusSourceFileEntryVariable())
scribusSourceFileEntry.grid(column=1, row=0, padx=5, pady=5, sticky='ew')
scribusSourceFileButton = Button(inputFrame, text='...', command=self.__ctrl.scribusSourceFileEntryVariableHandler)
scribusSourceFileButton.grid(column=2, row=0, padx=5, pady=5, sticky='e')
dataSourceFileLabel = Label(inputFrame, text='Data File:', width=15, anchor='w')
dataSourceFileLabel.grid(column=0, row=1, padx=5, pady=5, sticky='w')
dataSourceFileEntry = Entry(inputFrame, width=70, textvariable=self.__ctrl.getDataSourceFileEntryVariable())
dataSourceFileEntry.grid(column=1, row=1, padx=5, pady=5, sticky='ew')
dataSourceFileButton = Button(inputFrame, text='...', command=self.__ctrl.dataSourceFileEntryVariableHandler)
dataSourceFileButton.grid(column=2, row=1, padx=5, pady=5, sticky='e')
# Output-Settings
outputDirectoryLabel = Label(outputFrame, text='Output Directory:', width=15, anchor='w')
outputDirectoryLabel.grid(column=0, row=0, padx=5, pady=5, sticky='w')
outputDirectoryEntry = Entry(outputFrame, width=70, textvariable=self.__ctrl.getOutputDirectoryEntryVariable())
outputDirectoryEntry.grid(column=1, row=0, padx=5, pady=5, sticky='ew')
outputDirectoryButton = Button(outputFrame, text='...', command=self.__ctrl.outputDirectoryEntryVariableHandler)
outputDirectoryButton.grid(column=2, row=0, padx=5, pady=5, sticky='e')
outputFileNameLabel = Label(outputFrame, text='Output File Name:', width=15, anchor='w')
outputFileNameLabel.grid(column=0, row=1, padx=5, pady=5, sticky='w')
outputFileNameEntry = Entry(outputFrame, width=70, textvariable=self.__ctrl.getOutputFileNameEntryVariable())
outputFileNameEntry.grid(column=1, row=1, padx=5, pady=5, sticky='ew')
outputFormatLabel = Label(outputFrame, text='Output Format:', width=15, anchor='w')
outputFormatLabel.grid(column=0, row=2, padx=5, pady=5, sticky='w')
outputFormatListBox = OptionMenu(outputFrame, self.__ctrl.getSelectedOutputFormat(), self.__ctrl.getOutputFormatList())
outputFormatListBox.grid(column=1, row=2, padx=5, pady=5, sticky='w')
keepGeneratedScribusFilesLabel = Label(outputFrame, text='Keep Scribus Files:', width=15, anchor='w')
keepGeneratedScribusFilesLabel.grid(column=0, row=3, padx=5, pady=5, sticky='w')
keepGeneratedScribusFilesCheckbox = Checkbutton(outputFrame, variable=self.__ctrl.getKeepGeneratedScribusFilesCheckboxVariable())
keepGeneratedScribusFilesCheckbox.grid(column=1, row=3, padx=5, pady=5, sticky='w')
# Buttons to Cancel or to Run the Generator with the given Settings
helpButton = Button(buttonFrame, text='Help', width=10, command=self.__ctrl.helpButtonHandler)
helpButton.grid(column=0, row=0, padx=5, pady=5, sticky='e')
cancelButton = Button(buttonFrame, text='Cancel', width=10, command=self.__ctrl.buttonCancelHandler)
cancelButton.grid(column=1, row=0, padx=5, pady=5, sticky='e')
generateButton = Button(buttonFrame, text='Generate', width=10, command=self.__ctrl.buttonOkHandler)
generateButton.grid(column=2, row=0, padx=5, pady=5, sticky='e')
# Finally show the Generator Dialog
mainFrame.grid()
self.__root.grid()
self.__root.mainloop()
示例15: TabbedPageSet
# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import rowconfigure [as 别名]
#.........这里部分代码省略.........
and first active page. If page_names is None or empty, the
TabbedPageSet will be initialized empty.
n_rows, max_tabs_per_row -- Parameters for the TabSet which will
manage the tabs. See TabSet's docs for details.
page_class -- Pages can be shown/hidden using three mechanisms:
* PageLift - All pages will be rendered one on top of the other. When
a page is selected, it will be brought to the top, thus hiding all
other pages. Using this method, the TabbedPageSet will not be resized
when pages are switched. (It may still be resized when pages are
added/removed.)
* PageRemove - When a page is selected, the currently showing page is
hidden, and the new page shown in its place. Using this method, the
TabbedPageSet may resize when pages are changed.
* PagePackForget - This mechanism uses the pack placement manager.
When a page is shown it is packed, and when it is hidden it is
unpacked (i.e. pack_forget). This mechanism may also cause the
TabbedPageSet to resize when the page is changed.
"""
Frame.__init__(self, parent, **kw)
self.page_class = page_class
self.pages = {}
self._pages_order = []
self._current_page = None
self._default_page = None
self.columnconfigure(0, weight=1)
self.rowconfigure(1, weight=1)
self.pages_frame = Frame(self)
self.pages_frame.grid(row=1, column=0, sticky=NSEW)
if self.page_class.uses_grid:
self.pages_frame.columnconfigure(0, weight=1)
self.pages_frame.rowconfigure(0, weight=1)
# the order of the following commands is important
self._tab_set = TabSet(self, self.change_page, n_rows=n_rows,
max_tabs_per_row=max_tabs_per_row,
expand_tabs=expand_tabs)
if page_names:
for name in page_names:
self.add_page(name)
self._tab_set.grid(row=0, column=0, sticky=NSEW)
self.change_page(self._default_page)
def add_page(self, page_name):
"""Add a new page with the name given in page_name."""
if not page_name:
raise InvalidNameError("Invalid TabPage name: '%s'" % page_name)
if page_name in self.pages:
raise AlreadyExistsError(
"TabPage named '%s' already exists" % page_name)
self.pages[page_name] = self.page_class(self.pages_frame)
self._pages_order.append(page_name)
self._tab_set.add_tab(page_name)
if len(self.pages) == 1: # adding first page
self._default_page = page_name