我正在创建一个用户可以设置设置的窗口。我在窗户上安排小工具时遇到了麻烦。这是我得到的:
我希望右栏上的设置更加向左移动。最后一个设置("报告和#34的默认目录;)应该在需要时跨越更多列,但不要将上面的行推到右边。
这是我的一段代码:
self.parser = ConfigParser.SafeConfigParser()
self.parser.read('ALSV-Settings.ini')
''' Coarse X Scan'''
coarseXFrame = LabelFrame(self, text="Coarse X", font = ('Tahoma', 11), fg = '#3A98E4')
coarseXFrame.grid(row = 0, column = 0, padx = 5, pady = 1, sticky = W)
self.minCoarseXLabel = Label(coarseXFrame, text = 'Minimum Coarse X [um]: ', font = ('Tahoma', 10)).grid(row = 1, column = 0, sticky = E)
self.minCoarseXValue = Entry(coarseXFrame, bd = 5)
self.minCoarseXValue.insert(0, self.parser.get('Coarse X Scan', 'minCoarseX'))
self.minCoarseXValue.grid(row = 1, column = 1, padx = 1, pady = 1, sticky = W)
self.maxCoarseXLabel = Label(coarseXFrame, text = 'Maximum Coarse X [um]: ', font = ('Tahoma', 10)).grid(row = 2, column = 0, sticky = E)
self.maxCoarseXValue = Entry(coarseXFrame, bd = 5)
self.maxCoarseXValue.insert(0, self.parser.get('Coarse X Scan', 'maxCoarseX'))
self.maxCoarseXValue.grid(row = 2, column = 1, padx = 1, pady = 1, sticky = W)
self.stepCoarseXLabel = Label(coarseXFrame, text = 'Step Coarse X [um]: ', font = ('Tahoma', 10)).grid(row = 3, column = 0, sticky = E)
self.stepCoarseXValue = Entry(coarseXFrame, bd = 5)
self.stepCoarseXValue.insert(0, self.parser.get('Coarse X Scan', 'stepCoarseX'))
self.stepCoarseXValue.grid(row = 3, column = 1, padx = 1, pady = 1, sticky = W)
'''Coarse Z Scan'''
coarseZFrame = LabelFrame(self, text="Coarse Z", font = ('Tahoma', 11), fg = '#3A98E4')
coarseZFrame.grid(row = 0, column = 2, padx = 5, pady = 1, sticky = W)
self.minCoarseZLabel = Label(coarseZFrame, text = 'Minimum Coarse Z [um]: ', font = ('Tahoma', 10)).grid(row = 1, column = 2, sticky = E)
self.minCoarseZValue = Entry(coarseZFrame, bd = 5)
self.minCoarseZValue.insert(0, self.parser.get('Coarse Z Scan', 'minCoarseZ'))
self.minCoarseZValue.grid(row = 1, column = 3, padx = 1, pady = 1, sticky = W)
self.maxCoarseZLabel = Label(coarseZFrame, text = 'Maximum Coarse Z [um]: ', font = ('Tahoma', 10)).grid(row = 2, column = 2, sticky = E)
self.maxCoarseZValue = Entry(coarseZFrame, bd = 5)
self.maxCoarseZValue.insert(0, self.parser.get('Coarse Z Scan', 'maxCoarseZ'))
self.maxCoarseZValue.grid(row = 2, column = 3, padx = 1, pady = 1, sticky = W)
self.stepCoarseZLabel = Label(coarseZFrame, text = 'Step Coarse Z [um]: ', font = ('Tahoma', 10)).grid(row = 3, column = 2, sticky = E)
self.stepCoarseZValue = Entry(coarseZFrame, bd = 5)
self.stepCoarseZValue.insert(0, self.parser.get('Coarse Z Scan', 'stepCoarseZ'))
self.stepCoarseZValue.grid(row = 3, column = 3, padx = 1, pady = 1, sticky = W)
'''Fine Z Scan'''
fineZFrame = LabelFrame(self, text="Fine Z", font = ('Tahoma', 11), fg = '#3A98E4')
fineZFrame.grid(row = 5, column = 0, padx = 5, pady = 1, sticky = W)
self.fineStepXLabel = Label(fineZFrame, text = 'Fine step X [um]: ', font = ('Tahoma', 10)).grid(row = 6, column = 0, sticky = E)
self.fineStepXValue = Entry(fineZFrame, bd = 5)
self.fineStepXValue.insert(0, self.parser.get('Fine Z', 'stepFineX'))
self.fineStepXValue.grid(row = 6, column = 1, padx = 1, pady = 1, sticky = W)
self.minRelZLabel = Label(fineZFrame, text = 'Minimum relative Z [um]: ', font = ('Tahoma', 10)).grid(row = 7, column = 0, sticky = E)
self.minRelZValue = Entry(fineZFrame, bd = 5)
self.minRelZValue.insert(0, self.parser.get('Fine Z', 'minRelZ'))
self.minRelZValue.grid(row = 7, column = 1, padx = 1, pady = 1, sticky = W)
self.maxRelZLabel = Label(fineZFrame, text = 'Maximum relative Z [um]: ', font = ('Tahoma', 10)).grid(row = 8, column = 0, sticky = E)
self.maxRelZValue = Entry(fineZFrame, bd = 5)
self.maxRelZValue.insert(0, self.parser.get('Fine Z', 'maxRelZ'))
self.maxRelZValue.grid(row = 8, column = 1, padx = 1, pady = 1, sticky = W)
self.stepFineZLabel = Label(fineZFrame, text = 'Step Fine Z [um]: ', font = ('Tahoma', 10)).grid(row = 9, column = 0, sticky = E)
self.stepFineZValue = Entry(fineZFrame, bd = 5)
self.stepFineZValue.insert(0, self.parser.get('Fine Z', 'stepFineZ'))
self.stepFineZValue.grid(row = 9, column = 1, padx = 1, pady = 1, sticky = W)
'''Narrowed-down coarse/fine X'''
narrowedCoarseFineXFrame = LabelFrame(self, text="Narrowed-down coarse/fine X range", font = ('Tahoma', 11), fg = '#3A98E4')
narrowedCoarseFineXFrame.grid(row = 5, column = 2, padx = 5, pady = 1, sticky = W)
self.minRelXLabel = Label(narrowedCoarseFineXFrame, text = 'Minimum relative X [um]: ', font = ('Tahoma', 10)).grid(row = 6, column = 2, sticky = E)
self.minRelXValue = Entry(narrowedCoarseFineXFrame, bd = 5)
self.minRelXValue.insert(0, self.parser.get('Narrowed Coarse X', 'minRelX'))
self.minRelXValue.grid(row = 6, column = 3, padx = 1, pady = 1, sticky = W)
self.maxRelXLabel = Label(narrowedCoarseFineXFrame, text = 'Maximum relative X [um]: ', font = ('Tahoma', 10)).grid(row = 7, column = 2, sticky = E)
self.maxRelXValue = Entry(narrowedCoarseFineXFrame, bd = 5)
self.maxRelXValue.insert(0, self.parser.get('Narrowed Coarse X', 'maxRelX'))
self.maxRelXValue .grid(row = 7, column = 3, padx = 1, pady = 1, sticky = W)
self.stepXCoarseZLabel = Label(narrowedCoarseFineXFrame, text = ' Step X coarse Z [um]: ', font = ('Tahoma', 10)).grid(row = 8, column = 2, sticky = E)
self.stepXCoarseZValue = Entry(narrowedCoarseFineXFrame, bd = 5)
self.stepXCoarseZValue.insert(0, self.parser.get('Narrowed Coarse X', 'stepXCoarseZ'))
self.stepXCoarseZValue .grid(row = 8, column = 3, padx = 1, pady = 1, sticky = W)
'''Settle Time'''
settleTimeFrame = LabelFrame(self, text="Settle time for stage position", font = ('Tahoma', 11), fg = '#3A98E4')
settleTimeFrame.grid(row = 9, column = 0, padx = 5, pady = 1, sticky = W)
self.smallStepLabel = Label(settleTimeFrame, text = 'Settle time small step [sec]: ', font = ('Tahoma', 10)).grid(row = 10, column = 0, sticky = E)
self.smallStepValue = Entry(settleTimeFrame, bd = 5)
self.smallStepValue.insert(0, self.parser.get('Settle Time', 'settleTime_smallStep'))
self.smallStepValue .grid(row = 10, column = 1, padx = 1, pady = 1, sticky = W)
self.largeStepLabel = Label(settleTimeFrame, text = 'Settle time large step [sec]: ', font = ('Tahoma', 10)).grid(row = 11, column = 0, sticky = E)
self.largeStepValue = Entry(settleTimeFrame, bd = 5)
self.largeStepValue.insert(0, self.parser.get('Settle Time', 'settleTime_largeStep'))
self.largeStepValue .grid(row = 11, column = 1, padx = 1, pady = 1, sticky = W)
'''Default X/Z positions'''
DefaultPositionsFrame = LabelFrame(self, text="Default X/Z Positions", font = ('Tahoma', 11), fg = '#3A98E4')
DefaultPositionsFrame.grid(row = 9, column = 2, padx = 5, pady = 1, sticky = W)
self.defaultXLabel = Label(DefaultPositionsFrame, text = 'Default X Position [um]: ', font = ('Tahoma', 10)).grid(row = 10, column = 2, sticky = E)
self.defaultXValue = Entry(DefaultPositionsFrame, bd = 5)
self.defaultXValue.insert(0, self.parser.get('Init Values', 'initposx'))
self.defaultXValue.grid(row = 10, column = 3, padx = 1, pady = 1, sticky = W)
self.defaultZLabel = Label(DefaultPositionsFrame, text = 'Default Z Position [um]: ', font = ('Tahoma', 10)).grid(row = 11, column = 2, sticky = E)
self.defaultZValue = Entry(DefaultPositionsFrame, bd = 5)
self.defaultZValue.insert(0, self.parser.get('Init Values', 'initposz'))
self.defaultZValue.grid(row = 11, column = 3, padx = 1, pady = 1, sticky = W)
'''Default directory for saving Report'''
DefaultPositionsFrame = LabelFrame(self, text="Default directory for Report", font = ('Tahoma', 11), fg = '#3A98E4')
DefaultPositionsFrame.grid(row = 12, column = 0, padx = 5, pady = 1, sticky = W)
self.defaultRepDirLabel = Label(DefaultPositionsFrame, text = 'Default directory for Report: ', font = ('Tahoma', 10))
self.defaultRepDirLabel.grid(row = 13, column = 0, sticky = W)
self.defaultRepDir = Entry(DefaultPositionsFrame, bd = 5, width = 65)
self.savedir = self.parser.get('Report Directory', 'reportDir')
self.defaultRepDir.insert(0, self.savedir)
self.defaultRepDir.grid(row = 13, column = 1, padx = 1, pady = 1, sticky = W)
self.commandButton = Button(DefaultPositionsFrame, text = 'Select Report Directory', command = self.chooseDir, bd = 2)
self.commandButton.grid(row = 13, column = 2, padx = 1, pady = 1, sticky = W)
UpdateButton = Button(self, text = "Apply Settings", command = self.saveValues, font = ('Tahoma', 10))
UpdateButton.grid(row = 16, column = 1, padx = 5, pady = 5)
cancelButton = Button(self, text = 'Exit', command = self.destroy, font = ('Tahoma', 10))
cancelButton.grid(row = 16, column = 2, padx = 5, pady = 5)
提前感谢您的帮助!
答案 0 :(得分:2)
当您DefaultPositionsFrame
网格添加columnspan=2
以使其拉伸2列时。这可能会占用你的其他小部件,但不应该很难重新组织它们。