Tkinter--gui layout

Source: Internet
Author: User
Tags pack

  http://blog.csdn.net/xxb2008

#-*-coding:utf-8-*-"" "tkconstants.py--Constant class Tkinter Layout pack parameter Description fill--X horizontal Fill (default, components from top to bottom), y vertical padding (each component from left to right), both filled Expand-1 when the size of the parent frame changes, automatically expands the size, 0 is false side--the left right top bottom dock on which side of the parent component anchor--alignment grid parameter description row--line number Rowspa N--merge row column--column number ColumnSpan--merge column sticky--component close to a corner of the cell (auto scale)--expand property of the same pack root.columnconfigure (0, W eight=1) root.rowconfigure (0, Weight=1) frame.grid (row=0, column=0, sticky= "Nsew") below is a program that blends pack padding (automatic scaling) and Grid padding (auto scale) and multi-component integration Layout http://blog.csdn.net/xxb2008 "" "" "" "" Import Tkinter class MainFrame (tkinter.frame): Def __init__
        (Self, Master=none): tkinter.frame.__init__ (self, Master) Self.grid (row=0, column=0, sticky= "Nsew") Self.createframe () def createframe (self): Self.frametop = Tkinter.frame (self) self.frameTop.pack (fi Ll= "x") self.labelfilepaths = Tkinter.label (self.frametop, text= "file path:", width=10) SELF.LABELFILEPATHS.PA CK (fill= "y", Expand=0, Side=tkinter.lefT) self.textfilepaths = Tkinter.text (Self.frametop, height=10) Self.textFilePaths.pack (fill= "both", Expan D=1, side=tkinter.left) Self.framecenter = Tkinter.frame (self) self.frameCenter.pack (fill= "x") s Elf.framebottom = Tkinter.frame (self) self.frameBottom.pack (fill= "x") #self. Labelfilepaths = tkinter.la Bel (Self, text= "file path:", width=10) #self. Labelfilepaths.grid (row=0, Column=0, sticky= "W") #self. Textfilepa ths = Tkinter.text (Self.frame, height=10) #self. Textfilepaths.pack (fill= "both") #self. Textfilepaths.grid (r Ow=1, column=0, sticky= "Nsew") def main (): root = tkinter.tk () root.columnconfigure (0, Weight=1) root.rowcon Figure (0, Weight=1) root.geometry (' 640x360 ') #设置了主窗口的初始大小960x540 app = MainFrame (root) App.mainloop () If _ _name__ = = "__main__": Main ()


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.