当前位置: 首页>>代码示例>>Python>>正文


Python Frame.grid_columnconfigure方法代码示例

本文整理汇总了Python中Tkinter.Frame.grid_columnconfigure方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.grid_columnconfigure方法的具体用法?Python Frame.grid_columnconfigure怎么用?Python Frame.grid_columnconfigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tkinter.Frame的用法示例。


在下文中一共展示了Frame.grid_columnconfigure方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
    def __init__(self, root, *args, **kwargs):
        Frame.__init__(self, root, *args, **kwargs)

        self.app = root
        self.app.title('Campus TOur Guide v1.0')
        self.app.wm_iconbitmap('tour.ico')
        self.app.resizable(width=False, height=False)



        # the container is where we'll stack a bunch of frames
        # on top of each other, then the one we want visible
        # will be raised above the others
        container = Frame(root)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        for F in (StartPage, Instructions,Selection):
            frame = F(container, self)
            self.frames[F] = frame
            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            frame.grid(row=0, column=0, sticky="nsew")
        self.show_frame(StartPage)
开发者ID:agarwali,项目名称:CampusTourGuide,代码行数:29,代码来源:GraphApp.py

示例2: __bookmarks

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
    def __bookmarks(self, master):
        panel = Frame(master)
        panel.grid_rowconfigure(0, weight=1)

        bookmarks = Frame(panel)
        bookmarks.grid_columnconfigure(0, weight=1)
        bookmarks.grid_rowconfigure(0, weight=1)

        li = Listbox(bookmarks, width=40)
        li.grid(column=0, row=0, sticky=(N, E, S, W))
        self.bookmarks_list = li

        sb = Scrollbar(bookmarks, orient=VERTICAL, command=li.yview)
        sb.grid(column=1, row=0, sticky=(N, S))

        li.config(yscrollcommand=sb.set)
        def _lbox_selected(*args):
            selected_idx = int(li.curselection()[0])
            self.render_start.set(self.bookmarks_values[selected_idx])
            self.canvas.xview_moveto(0)
            if not self.render_auto.get():
                self.update()
        li.bind('<Double-Button-1>', _lbox_selected)
        bookmarks.grid(column=0, row=0, sticky=(N, E, S, W))

        buttons = Frame(panel)
        Button(buttons, image=self.img_start, command=self.start_event).pack(side="left")
        Button(buttons, image=self.img_prev, command=self.prev_event).pack(side="left")
        Button(buttons, image=self.img_end, command=self.end_event).pack(side="right")
        Button(buttons, image=self.img_next, command=self.next_event).pack(side="right")
        buttons.grid(column=0, row=1, sticky=(E, W))

        return panel
开发者ID:shish,项目名称:context,代码行数:35,代码来源:main.py

示例3: __init__

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
 def __init__(self, settings_file=None, *args, **kwargs):
     '''
     Generate base frame and each page, bind them in a list
     '''
     BaseController.__init__(self, settings_file=settings_file, *args, **kwargs)
     self.root = Tk()
     self.frames = []
     container = Frame(master=self.root)
     container.grid_rowconfigure(0, weight=1)
     container.grid_columnconfigure(0, weight=1)
     container.pack(side="top", fill="x", expand=False)
     self.container = container
开发者ID:armenzg,项目名称:B2G-flash-tool,代码行数:14,代码来源:tk_controller.py

示例4: __init__

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
    def __init__(self, *args, **kwargs):
        '''
        Generate base frame and each page, bind them in a list
        '''
        self.root = Tk()
        self.frames = []
        container = Frame(master=self.root)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)
        container.pack(side="top", fill="x", expand=False)

        listPage = ListPage(parent=container, controller=self)
        listPage.setupView()
        listPage.setDeviceList([
            "hamachi",
            "leo",
            "helix",
            "nexus4",
            "tarako"
            ])
        listPage.setVersionList([
            "master",
            "aurora",
            "1.2",
            "1.3",
            "1.4"
            ])
        listPage.setPackageList([
            "Gecko/gaia",
            "Gecko",
            "gaia",
            "full flash"
            ])
        listPage.setEngList([
            "Eng",
            "user",
            ])
        authPage = AuthPage(parent=container, controller=self)
        authPage.setupView(
            "Account Info",
            '',
            '')

        self.frames = [
            authPage,
            listPage,
            ]
        for idx, val in enumerate(self.frames):
            val.index = idx
            val.grid(row=0, column=0, sticky="nsew")
        self.transition()
        self.container = container
开发者ID:zapion,项目名称:working-scripts,代码行数:54,代码来源:dummy_controller.py

示例5: __init__

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
    def __init__(self, *args, **kwargs):
        '''
        Generate base frame and each page, bind them in a list
        '''
        self.flashOpts = getOsVars()

        self.root = Tk()
        self.frames = []
        container = Frame(master=self.root)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)
        container.pack(side="top", fill="x", expand=False)

        devicePage = SelectPage(parent=container, controller=self)
        devicePage.setupView("Select device", ["buri", "leo", "nexus4"])
        versionPage = SelectPage(parent=container, controller=self)
        versionPage.setupView("Select version",
                              [
                                  "master",
                                  "aurora",
                                  "1.2",
                                  "1.3",
                                  "1.4"
                                  ])
        engineerPage = SelectPage(parent=container, controller=self)
        engineerPage.setupView("Select type", ["user", "engineering"])
        packagePage = SelectPage(parent=container, controller=self)
        packagePage.setupView("Select package",
                              [
                                  "Gecko/gaia",
                                  "Gecko",
                                  "gaia",
                                  "full flash"
                                  ])
        authPage = AuthPage(parent=container, controller=self)
        authPage.setupView("Account Info",
                           OsVars.get('HTTP_USER', ''),
                           OsVars.get('HTTP_PWD', ''))

        self.frames = [
            devicePage,
            versionPage,
            engineerPage,
            packagePage,
            authPage,
            ]
        for idx, val in enumerate(self.frames):
            val.index = idx
            val.grid(row=0, column=0, sticky="nsew")
        self.transition()
        self.container = container
开发者ID:zapion,项目名称:working-scripts,代码行数:53,代码来源:testframe.py

示例6: _build_listbox

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
    def _build_listbox(self, values):
        listbox_frame = Frame()

        self._listbox = Listbox(listbox_frame, background="white", selectmode=SINGLE, activestyle="none", exportselection=False)
        self._listbox.grid(row=0, column=0,sticky = N+E+W+S)

        self._listbox.bind("<ButtonRelease-1>", self._update_entry_from_listbox)
        self._listbox.bind("<Return>", self._update_entry_from_listbox)
        self._listbox.bind("<Escape>", lambda event: self.unpost_listbox())
        
        self._listbox.bind('<Control-n>', self._next)
        self._listbox.bind('<Control-p>', self._previous)

        if self._use_vscrollbar:
            vbar = Scrollbar(listbox_frame, orient=VERTICAL, command= self._listbox.yview)
            vbar.grid(row=0, column=1, sticky=N+S)
            
            self._listbox.configure(yscrollcommand= lambda f, l: autoscroll(vbar, f, l))
            
        if self._use_hscrollbar:
            hbar = Scrollbar(listbox_frame, orient=HORIZONTAL, command= self._listbox.xview)
            hbar.grid(row=1, column=0, sticky=E+W)
            
            self._listbox.configure(xscrollcommand= lambda f, l: autoscroll(hbar, f, l))

        listbox_frame.grid_columnconfigure(0, weight= 1)
        listbox_frame.grid_rowconfigure(0, weight= 1)

        x = -self.cget("borderwidth") - self.cget("highlightthickness") 
        y = self.winfo_height()-self.cget("borderwidth") - self.cget("highlightthickness")

        if self._listbox_width:
            width = self._listbox_width
        else:
            width=self.winfo_width()

        listbox_frame.place(in_=self, x=x, y=y, width=width)
        
        height = min(self._listbox_height, len(values))
        self._listbox.configure(height=height)

        for item in values:
            self._listbox.insert(END, item)
开发者ID:Rocia,项目名称:CRES-tech,代码行数:45,代码来源:recipe-580770.py

示例7: __canvas

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
    def __canvas(self, master):
        f = Frame(master)
        f.grid_columnconfigure(0, weight=1)
        f.grid_rowconfigure(0, weight=1)

        h = Scrollbar(f, orient=HORIZONTAL)
        v = Scrollbar(f, orient=VERTICAL)
        canvas = Canvas(
            f,
            background="white",
            xscrollcommand=h.set,
            yscrollcommand=v.set,
        )
        h['command'] = canvas.xview
        v['command'] = canvas.yview

        canvas.bind("<4>", lambda e: self.scale_view(e, 1.0 * 1.1))
        canvas.bind("<5>", lambda e: self.scale_view(e, 1.0 / 1.1))

        # in windows, mouse wheel events always go to the root window o_O
        self.master.bind("<MouseWheel>", lambda e: self.scale_view(
            e, ((1.0 * 1.1) if e.delta > 0 else (1.0 / 1.1))
        ))

        # Drag based movement
        # def _sm(e):
        #    self.st = self.render_start.get()
        #    self.sx = e.x
        #    self.sy = e.y
        # def _cm(e):
        #    self.render_start.set(self.st + float(self.sx - e.x)/self.scale.get())
        #    self.render()
        # self.canvas.bind("<1>", _sm)
        # self.canvas.bind("<B1-Motion>", _cm)

        canvas.grid(column=0, row=0, sticky=(N, W, E, S))
        v.grid(column=1, row=0, sticky=(N, S))
        h.grid(column=0, row=1, sticky=(W, E))

        self.canvas = canvas

        return f
开发者ID:shish,项目名称:context,代码行数:44,代码来源:main.py

示例8: initUI

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
    def initUI(self):
      
        self.parent.title(u"OFX Converter")

        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)
        
        fileMenu = Menu(menubar)
        fileMenu.add_command(label=u"Open", command=self.openFile, accelerator=u"Ctrl-o")
        fileMenu.add_command(label=u"Exit", command=self.onExit, accelerator=u"Ctrl-e", underline=1 )
        menubar.add_cascade(label=u"File", menu=fileMenu)
        helpMenu = Menu(menubar)
        helpMenu.add_command(label=u"About", command=self.help, accelerator=u"Ctrl-i")
        menubar.add_cascade(label=u"Info", menu=helpMenu)

        notebook = ttk.Notebook( self.parent )
        tabFilesMain = Frame( notebook )

        self.tabFiles = Frame( tabFilesMain )
        self.tabFiles.pack(fill=constants.BOTH)

        button = ttk.Button( tabFilesMain, command=self.parseFile, text=u"Process" )
        button.pack(side=u"bottom", fill=constants.X, padx=5, pady=5)
        
        tabLogging = Canvas( notebook )
        tabLogging.grid_rowconfigure(0, weight=1)
        tabLogging.grid_columnconfigure(0, weight=1)

        # begin of custom csv frame

        tabCustomCsv = Frame( notebook )

        verticalScrollFrame = Frame( tabCustomCsv )
        verticalScrollFrame.grid( row=0, column=0, rowspan=3, sticky=u"WNS" )

        tabCustomCsv.grid_columnconfigure(0, weight=0)
        tabCustomCsv.grid_columnconfigure(1, weight=1)
        tabCustomCsv.grid_rowconfigure(2,weight=1)

        self.comboFrame = Frame( tabCustomCsv )
        self.comboFrame.grid( row=1, column=1, sticky=u"WE" )
 
        canvasFrame = Frame( tabCustomCsv)
        canvasFrame.grid( row=2, column=1, sticky=u"NEWS" )

        horizontalScrollFrame = Frame( tabCustomCsv )
        horizontalScrollFrame.grid( row=3, column=1, columnspan=1, sticky=u"WE" )
        
        self.canvas = Canvas( canvasFrame, highlightthickness=0 )

        scrollbar=Scrollbar( horizontalScrollFrame,orient=u"horizontal",command=self.canvas.xview)
        self.canvas.configure(xscrollcommand=scrollbar.set)

        self.canvas.pack(fill=constants.BOTH,expand=True)
        scrollbar.pack(side=u"bottom", fill=constants.X)

        scrollbar=Scrollbar( verticalScrollFrame,orient=u"vertical",command=self.canvas.yview)
        self.canvas.configure(yscrollcommand=scrollbar.set)

        scrollbar.pack(side=u"left", fill=constants.Y)
        self.canvas.pack(fill=constants.BOTH,expand=1,anchor=u"nw")

        # end of custom csv frame

        # begin of config frame

        configurationFrame = Frame( tabCustomCsv )

        Label( configurationFrame, text=u"Values to determine whether the debit field concerns a debit or credit transaction and set the currency" ).pack(anchor=constants.W)

        currencyLine = Frame( configurationFrame )
        currencyLine.pack(fill=constants.X)
        Label( currencyLine, text=u"currency", width=7, anchor=constants.W ).pack(side=constants.LEFT)
        self.currencyCombo = ttk.Combobox( currencyLine,width=30,text=u"currency" )
        self.currencyCombo.pack(side=constants.LEFT)

        config = Config()
        self.currencies = config.getCurrencies()
        self.currencyCombo[u'values'] = list(sorted(self.currencies.keys()))

        Label( configurationFrame, text=u"credit", width=7, anchor=constants.W ).pack(side=constants.LEFT)
        self.creditCombo = ttk.Combobox(configurationFrame,width=10,text=u"credit")
        self.creditCombo.pack(side=constants.LEFT)

        Label( configurationFrame, text=u"debit", width=6, anchor=constants.W ).pack(side=constants.LEFT)
        self.debitCombo = ttk.Combobox( configurationFrame,width=10,text=u"debit" )
        self.debitCombo.pack(side=constants.LEFT)

        Button( configurationFrame, text=u"save configuration", command=self.saveConfig ).pack(side=constants.RIGHT )

        configurationFrame.grid( row=4, column=0, columnspan=2, sticky=u"WES")

        # end of config frame

        self.log = Text(tabLogging, wrap=u'word')
        self.log.grid(row=0,column=0,sticky=u'news')

        hScroll = Scrollbar(tabLogging, orient=constants.HORIZONTAL, command=self.log.xview)
        hScroll.grid(row=1, column=0, sticky=u'we')
        vScroll = Scrollbar(tabLogging, orient=constants.VERTICAL, command=self.log.yview)
#.........这里部分代码省略.........
开发者ID:weirdall,项目名称:ofxconverter,代码行数:103,代码来源:main.py

示例9: OfxConverter

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
class OfxConverter(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent, background=u"white")   
         
        self.parent = parent
        self.guiMap = []
        self.debitValue = StringVar()
        self.creditValue = StringVar()
        self.row = 0
        self.frame = Frame()

        self.UNUSED = u"Unused"
        
        self.initUI()

    def writeLog(self,*msgs):
        self.log[u'state'] = u'normal'
        if self.log.index(u'end-1c')!=u'1.0':
            self.log.insert(u'end', u'\n')
        for msg in msgs:
            self.log.insert(u'end', msg)
##        self.log['state'] = 'disabled'

    def help(self):
        t = Toplevel()
        t.wm_title(u"About")
        t.transient()

        photo = ImageTk.PhotoImage(file=u"chameleon.png")
        
##        photo = PhotoImage(file="chameleon.gif")
        w = Label(t, image=photo)
        w.photo = photo
        w.pack(fill=constants.BOTH,side=constants.LEFT,expand=True)
        
        l = Label(t, text=u"OFX Converter\n\n"+
                  u"Convert files in csv format to the\nofx format " +
                  u"which is used by a lot\nof accounting programs " +
                  u"like gnucash\n\n Written in Python 3\nby Floris Groenendijk"
                  )
        l.pack(side=constants.TOP, fill=u"both", expand=False, padx=20, pady=20)

    def onComboboxChanged(self, event):
        if event.widget.get() == u'credit/debit':
            # check which checkbox in which column was changed
            for i in xrange(len(self.comboBoxes)-1):
                if self.comboBoxes[i] == event.widget:
                    break
                
            values = []

            # retrieve the values of the labels in that column
            for j in xrange(len(self.labels)):
                if self.labels[j][i][u'text'] not in values:
                    values.append(self.labels[j][i][u'text'])
            
            self.creditCombo[u'values'] = values
            self.creditCombo.current( 0 )

            if len( values ) > 1:
                self.debitCombo[u'values'] = values
                self.debitCombo.current( 1 )

    def onFrameConfigure(self, event):
        # Reset the scroll region to encompass the inner frame
        self.canvas.configure(scrollregion=self.canvas.bbox(u"all"))

    def initUI(self):
      
        self.parent.title(u"OFX Converter")

        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)
        
        fileMenu = Menu(menubar)
        fileMenu.add_command(label=u"Open", command=self.openFile, accelerator=u"Ctrl-o")
        fileMenu.add_command(label=u"Exit", command=self.onExit, accelerator=u"Ctrl-e", underline=1 )
        menubar.add_cascade(label=u"File", menu=fileMenu)
        helpMenu = Menu(menubar)
        helpMenu.add_command(label=u"About", command=self.help, accelerator=u"Ctrl-i")
        menubar.add_cascade(label=u"Info", menu=helpMenu)

        notebook = ttk.Notebook( self.parent )
        tabFilesMain = Frame( notebook )

        self.tabFiles = Frame( tabFilesMain )
        self.tabFiles.pack(fill=constants.BOTH)

        button = ttk.Button( tabFilesMain, command=self.parseFile, text=u"Process" )
        button.pack(side=u"bottom", fill=constants.X, padx=5, pady=5)
        
        tabLogging = Canvas( notebook )
        tabLogging.grid_rowconfigure(0, weight=1)
        tabLogging.grid_columnconfigure(0, weight=1)

        # begin of custom csv frame

        tabCustomCsv = Frame( notebook )

#.........这里部分代码省略.........
开发者ID:weirdall,项目名称:ofxconverter,代码行数:103,代码来源:main.py

示例10: __init__

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [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):
        """
#.........这里部分代码省略.........
开发者ID:Syntaf,项目名称:db_swapper,代码行数:103,代码来源:swapper.py

示例11: Table

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import grid_columnconfigure [as 别名]
class Table(Frame):
    def __init__(self, master, columns, column_weights=None, column_minwidths=None, height=500, minwidth=20, minheight=20, padx=5, pady=5, cell_font=None, cell_foreground="black", cell_background="white", cell_anchor=W, header_font=None, header_background="white", header_foreground="black", header_anchor=CENTER, bordercolor = "#999999", innerborder=True, outerborder=True, stripped_rows=("#EEEEEE", "white"), on_change_data=None, mousewheel_speed = 2, scroll_horizontally=False, scroll_vertically=True):
        outerborder_width = 1 if outerborder else 0

        Frame.__init__(self,master, bd= 0)

        self._cell_background = cell_background
        self._cell_foreground = cell_foreground
        self._cell_font = cell_font
        self._cell_anchor = cell_anchor
        
        self._stripped_rows = stripped_rows

        self._padx = padx
        self._pady = pady
        
        self._bordercolor = bordercolor
        self._innerborder_width = 1 if innerborder else 0

        self._data_vars = []

        self._columns = columns
        
        self._number_of_rows = 0
        self._number_of_columns = len(columns)

        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(1, weight=1)
        
        self._head = Frame(self, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd= 0)
        self._head.grid(row=0, column=0, sticky=E+W)

        header_separator = False if outerborder else True

        for j in range(len(columns)):
            column_name = columns[j]

            header_cell = Header_Cell(self._head, text=column_name, borderwidth=self._innerborder_width, font=header_font, background=header_background, foreground=header_foreground, padx=padx, pady=pady, bordercolor=bordercolor, anchor=header_anchor, separator=header_separator)
            header_cell.grid(row=0, column=j, sticky=N+E+W+S)

        add_scrollbars = scroll_horizontally or scroll_vertically
        if add_scrollbars:
            if scroll_horizontally:
                xscrollbar = Scrollbar(self, orient=HORIZONTAL)
                xscrollbar.grid(row=2, column=0, sticky=E+W)
            else:
                xscrollbar = None

            if scroll_vertically:
                yscrollbar = Scrollbar(self, orient=VERTICAL)
                yscrollbar.grid(row=1, column=1, sticky=N+S)
            else:
                yscrollbar = None

            scrolling_area = Scrolling_Area(self, width=self._head.winfo_reqwidth(), height=height, scroll_horizontally=scroll_horizontally, xscrollbar=xscrollbar, scroll_vertically=scroll_vertically, yscrollbar=yscrollbar)
            scrolling_area.grid(row=1, column=0, sticky=E+W)

            self._body = Frame(scrolling_area.innerframe, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd= 0)
            self._body.pack()
            
            def on_change_data():
                scrolling_area.update_viewport()

        else:
            self._body = Frame(self, height=height, highlightbackground=bordercolor, highlightcolor=bordercolor, highlightthickness=outerborder_width, bd= 0)
            self._body.grid(row=1, column=0, sticky=N+E+W+S)

        if column_weights is None:
            for j in range(len(columns)):
                self._body.grid_columnconfigure(j, weight=1)
        else:
            for j, weight in enumerate(column_weights):
                self._body.grid_columnconfigure(j, weight=weight)

        if column_minwidths is not None:
            for j, minwidth in enumerate(column_minwidths):
                if minwidth is None:
                    header_cell = self._head.grid_slaves(row=0, column=j)[0]
                    minwidth = header_cell.winfo_reqwidth()

                self._body.grid_columnconfigure(j, minsize=minwidth)
        else:
            for j in range(len(columns)):
                header_cell = self._head.grid_slaves(row=0, column=j)[0]
                minwidth = header_cell.winfo_reqwidth()

                self._body.grid_columnconfigure(j, minsize=minwidth)

        self._on_change_data = on_change_data

    def _append_n_rows(self, n):
        number_of_rows = self._number_of_rows
        number_of_columns = self._number_of_columns

        for i in range(number_of_rows, number_of_rows+n):
            list_of_vars = []
            for j in range(number_of_columns):
                var = StringVar()
                list_of_vars.append(var)

#.........这里部分代码省略.........
开发者ID:jacob-carrier,项目名称:code,代码行数:103,代码来源:recipe-580793.py


注:本文中的Tkinter.Frame.grid_columnconfigure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。