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


Python Tk.grid_columnconfigure方法代码示例

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


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

示例1: Visualiser

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import grid_columnconfigure [as 别名]
class Visualiser(object):
    '''
    Generic Offline Visualiser. Subclasses need to be used that specify
    how to handle a data source.
    '''
    
    ### Public functions ###

    def __init__(self,
                 title="Visualisation",
                 width=400,
                 height=400,
                 recording=False,
                 recordPattern=None,
                 paused=False,
                 source=None):
        '''
        Constructor.

        Params:
        title: string - Title of the visualisation window
        width: int - Width of the visualisation window
        height: int - Height of the visualisation window
        recording: boolean - Start with recording enabled?
        recordPattern: string - Pattern for recorded images,
          e.g., cylinders%05g.png
        paused: boolean - Start with playback paused?
        source:- The data source to read.
          What is required here varies by visualiser.
        '''

        # Visualisation options
        self.vis_features = []
        self.vis_frame = 0
        self.vis_frameStep = 1
        self.vis_jumping = False
        self.vis_recording = recording
        self.vis_recordPattern = recordPattern
        self.vis_paused = paused
        self.vis_source = source

        # VTK structures
        self.vtk_cells = vtkCellArray()
        self.vtk_renderer = vtkRenderer()

        # Tk structures
        self.tk_root = Tk()
        self.tk_root.title(title)
        self.tk_root.grid_rowconfigure(0, weight=1)
        self.tk_root.grid_columnconfigure(0, weight=3)
        self.tk_root.bind('<Destroy>', self.destroyed)
        if not self.vis_paused: self.tk_root.after(100, self.animate)            

        self.tk_renderWidget = vtkTkRenderWidget(self.tk_root,
                                                 width=width,
                                                 height=height)
        self.tk_renderWidget.grid(row=0, column=0, sticky=N+S+E+W)
        self.tk_renderWidget.GetRenderWindow().AddRenderer(self.vtk_renderer)

        self.tk_featureFrame = Frame(self.tk_root)
        self.tk_featureFrame.grid(row=0, column=1, rowspan=2)
        Label(self.tk_featureFrame, text='Features:').grid(row=0, column=0)

        self.tk_controlFrame = Frame(self.tk_root)
        self.tk_controlFrame.grid(row=1, column=0)

        self.tk_quit = Button(self.tk_controlFrame, text="Quit",
                              command=self.shutdown)
        self.tk_quit.grid(row=0, column=0, columnspan=2)

        def pause():
            if self.vis_paused:
                self.tk_pause.config(text='Pause')
                self.tk_root.after(100, self.animate)
            else:
                self.tk_pause.config(text='Resume')
            self.vis_paused ^= True
        self.tk_pause = Button(self.tk_controlFrame, text="Pause", command=pause)
        self.tk_pause.grid(row=0, column=2, columnspan=2)

        if self.vis_recordPattern is not None:
            def record():
                if self.vis_recording:
                    self.tk_record.config(text='Start Recording')
                else:
                    self.tk_record.config(text='Stop Recording')
                self.vis_recording ^= True
            self.tk_record = Button(self.tk_controlFrame, text="Start Recording", command=record)
            self.tk_record.grid(row=0, column=4, columnspan=2)
            if self.vis_recording:
                self.tk_record.config(text="Stop Recording")

        def make_seek_button(label, column, frame):
            def jump():
                self.jumpTo(frame)
            b = Button(self.tk_controlFrame,
                       text=label,
                       command=jump)
            b.grid(row=1, column=column, sticky=W+E)
            return b
#.........这里部分代码省略.........
开发者ID:MattAndersonPE,项目名称:anuga_core,代码行数:103,代码来源:visualiser.py

示例2: RunnerApp

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import grid_columnconfigure [as 别名]
class RunnerApp(object):
    """ A simple GUI for running a canned set of commands on demand.
    
        The commands are loaded from a file in JSON format.  The file
        contains an array of objects containing a "button" field, a "cmd"
        field, and an optional "tooltip" field, as in the following example:
        
        [
           {
              "button" : "Backup Database",
              "cmd"    : "pgdump > db_backup.sql",
              "tooltip": "Dump the database contents to a SQL file"
           },
           {
              "button" : "Restore Database",
              "cmd"    : "psql -U admin < db_backup.sql",
              "tooltip": "Restore the database contents from an SQL file"
           }
        ]
    """
    DEFAULT_CMD_WIDTH = 80
    
    def __init__(self):
        self.args     = None
        self.cmds     = None
        self.title    = None
        self.cmdWidth = 0
        self.root     = None
    
    def parseCmdLine(self):
        parser = ArgumentParser(description=self.__doc__)
        parser.add_argument("-w", "--cmdWidth", type=int, default=0,
                            help="The displayed width of the command field (default {})".format(self.DEFAULT_CMD_WIDTH))
        parser.add_argument(dest="commandFile",
                            help="A file containing button labels and commands, in JSON format")
        self.args = parser.parse_args()
        
        if self.args.cmdWidth >= 0:
            self.cmdWidth = self.args.cmdWidth

    def readCmds(self):
        self.title = os.path.splitext(os.path.basename(self.args.commandFile))[0]
        with open(self.args.commandFile, "r") as f:
            data = json.load(f)
            if isinstance(data, (list, tuple)):
                self.cmds = data
            else:
                if "title" in data:
                    self.title = data["title"]
                if "cmds" in data:
                    self.cmds = data["cmds"]
                if "width" in data and self.cmdWidth <= 0:
                    self.cmdWidth = data["width"]

    
    def makeCmdButton(self, parent, cmd, row):
        cmdText = Entry(parent, width=self.cmdWidth)
        cmdText.grid(row=row, column=1, sticky="ew", ipady=2)
        cmdText.delete(0, END)
        cmdText.insert(0, cmd["cmd"])

        button = Button(parent, text=cmd["button"], command=lambda: self.execute(cmd["button"], cmdText))
        button.grid(row=row, column=0, sticky="ew", padx=2, pady=2)
        
        if "tooltip" in cmd:
            ToolTip(button, cmd["tooltip"])
            ToolTip(cmdText, cmd["tooltip"])
        
    def buildGUI(self):
        self.root = Tk()
        self.root.title(self.title)
        self.root.grid_columnconfigure(1, weight=1)
        row = 0
        for cmd in self.cmds:
            self.root.grid_rowconfigure(row, pad=2)
            self.makeCmdButton(self.root, cmd, row)
            row += 1
        
    def execute(self, label, cmdWidget):
        print("\nRunning {}:".format(label))
        subprocess.call(cmdWidget.get(), shell=True)
        print("=" * 80)
        
    def run(self, args=None):
        self.parseCmdLine()
        self.readCmds()
        self.buildGUI()
        
        self.root.mainloop()
开发者ID:ellerychan,项目名称:runner,代码行数:91,代码来源:runner.py

示例3: AddPOI_GUI

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import grid_columnconfigure [as 别名]

#.........这里部分代码省略.........
            self.entry4.grid(in_=self.tabPage.pages['Logs'].frame, column=2, row=1, columnspan=1, ipadx=0, ipady=0,
                             padx=5, pady=5, rowspan=1, sticky="ew")
            self.label2.grid(in_=self.tabPage.pages['Logs'].frame, column=3, row=1, columnspan=1, ipadx=0, ipady=0,
                             padx=5, pady=5, rowspan=1, sticky="")
            self.entry2.grid(in_=self.tabPage.pages['Logs'].frame, column=4, row=1, columnspan=1, ipadx=0, ipady=0,
                             padx=5, pady=5, rowspan=1, sticky="ew")
            self.label3.grid(in_=self.tabPage.pages['Logs'].frame, column=5, row=1, columnspan=1, ipadx=0, ipady=0,
                             padx=5, pady=5, rowspan=1, sticky="")
            self.entry3.grid(in_=self.tabPage.pages['Logs'].frame, column=6, row=1, columnspan=1, ipadx=0, ipady=0,
                             padx=5, pady=5, rowspan=1, sticky="ew")
            self.button1.grid(in_=self.tabPage.pages['Logs'].frame, column=8, row=1, columnspan=2, ipadx=0, ipady=0,
                              padx=5, pady=5, rowspan=1, sticky="nsew")
            self.text1.grid(in_=self.tabPage.pages['Logs'].frame, column=1, row=2, columnspan=6, rowspan=1, ipadx=5,
                            ipady=0, padx=2, pady=5, sticky="news")
            self.sbar1.grid(in_=self.tabPage.pages['Logs'].frame, column=7, row=2, columnspan=1, rowspan=1, ipadx=0,
                            ipady=0, padx=0, pady=5, sticky="nsew")
            self.text2.grid(in_=self.tabPage.pages['Logs'].frame, column=8, row=2, columnspan=1, rowspan=1, ipadx=0,
                            ipady=0, padx=0, pady=5, sticky="nsew")
            self.sbar2.grid(in_=self.tabPage.pages['Logs'].frame, column=9, row=2, columnspan=1, rowspan=1, ipadx=0,
                            ipady=0, padx=0, pady=5, sticky="nsew")
            self.entry_1.grid(in_=self.tabPage.pages['Logs'].frame, column=1, row=3, columnspan=7, rowspan=1, ipadx=5,
                              ipady=0, padx=2, pady=0, sticky="ew")
            self.button2.grid(in_=self.tabPage.pages['Logs'].frame, column=8, row=3, columnspan=2, rowspan=1, ipadx=0,
                              ipady=0, padx=5, pady=5, sticky="ew")

            self.tabPage.grid(in_=self.rootM, column=1, row=1, rowspan=3, columnspan=9, ipadx=5, ipady=0, padx=2,
                              pady=0, sticky="nsew")
            self.entry_1.focus()
            self.entry_1.bind('<Return>', (lambda event: self.send()))
            self.tabPage.pages['Logs'].frame.grid_rowconfigure(1, weight=1, minsize=21, pad=0)
            self.tabPage.pages['Logs'].frame.grid_rowconfigure(2, weight=1, minsize=509, pad=0)
            self.tabPage.pages['Logs'].frame.grid_rowconfigure(3, weight=1, minsize=21, pad=0)

            self.tabPage.pages['Logs'].frame.grid_columnconfigure(1, weight=1, minsize=40, pad=0)
            self.tabPage.pages['Logs'].frame.grid_columnconfigure(2, weight=1, minsize=220, pad=0)
            self.tabPage.pages['Logs'].frame.grid_columnconfigure(3, weight=1, minsize=76, pad=2)
            self.tabPage.pages['Logs'].frame.grid_columnconfigure(4, weight=1, minsize=84, pad=0)
            self.tabPage.pages['Logs'].frame.grid_columnconfigure(5, weight=1, minsize=40, pad=0)
            self.tabPage.pages['Logs'].frame.grid_columnconfigure(6, weight=1, minsize=180, pad=0)
            self.tabPage.pages['Logs'].frame.grid_columnconfigure(7, weight=0, minsize=0, pad=0)
            self.tabPage.pages['Logs'].frame.grid_columnconfigure(8, weight=1, minsize=131, pad=0)
            self.tabPage.pages['Logs'].frame.grid_columnconfigure(9, weight=0, minsize=0, pad=0)
            """POI Logs Tab"""
            self.labelp1 = Label(self.tabPage.pages['AddPoi'].frame, bg="#000000", fg="#ff0000", text="AddPoi Logs: ",
                                 justify=LEFT)
            self.textp1 = Text(self.tabPage.pages['AddPoi'].frame, bg="#000000", fg="#ff0000", height=0, width=0, )
            self.labelp1.grid(in_=self.tabPage.pages['AddPoi'].frame, column=1, row=1, columnspan=1, ipadx=0, ipady=0,
                              padx=5, pady=0, rowspan=1, sticky="w")

            self.textp1.grid(in_=self.tabPage.pages['AddPoi'].frame, column=1, row=2, columnspan=1, ipadx=5, ipady=0,
                             padx=2, pady=0, rowspan=2, sticky="news")
            self.tabPage.pages['AddPoi'].frame.grid_rowconfigure(1, weight=0, minsize=15, pad=0)
            self.tabPage.pages['AddPoi'].frame.grid_rowconfigure(2, weight=1, minsize=509, pad=0)
            self.tabPage.pages['AddPoi'].frame.grid_columnconfigure(1, weight=1, minsize=800, pad=0)
            """POI List Tab"""
            self.labelpl1 = Label(self.tabPage.pages['POIList.xml'].frame, bg="#000000", fg="#ff0000",
                                  text="POIList.xml source: ", justify=LEFT)
            self.textpl1 = Text(self.tabPage.pages['POIList.xml'].frame, bg="#000000", fg="#ff0000", height=0,
                                width=0, )
            self.labelpl1.grid(in_=self.tabPage.pages['POIList.xml'].frame, column=1, row=1, columnspan=1, ipadx=0,
                               ipady=0, padx=5, pady=0, rowspan=1, sticky="w")

            self.textpl1.grid(in_=self.tabPage.pages['POIList.xml'].frame, column=1, row=2, columnspan=1, ipadx=5,
                              ipady=0, padx=2, pady=0, rowspan=2, sticky="news")
            self.tabPage.pages['POIList.xml'].frame.grid_rowconfigure(1, weight=0, minsize=15, pad=0)
            self.tabPage.pages['POIList.xml'].frame.grid_rowconfigure(2, weight=1, minsize=509, pad=0)
开发者ID:Ketchu13,项目名称:7DTD-leaflet,代码行数:70,代码来源:kfp_addpoi_GUI.py

示例4: ClearFields

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import grid_columnconfigure [as 别名]
        

def ClearFields():
    
    e2.delete(0, END)
    e3.delete(0, END)
    e4.delete(0, END)

button = Button(master, text=u"Change Password !", command=OnButtonClick)
button.grid(column=0, row=5, sticky='EW')


clear_fields = Button(master, text=u"Clear Fields!", command=ClearFields)
clear_fields.grid(column=0, row=4)

master.grid_columnconfigure(0, weight=3)
master.resizable(True, False)

def oracle_connection():
    pass_string = 'passwd/[email protected]_ADDRESS_HERE/ORACLE_SID_HERE'
    
    con = cx_Oracle.connect(pass_string)
    cur = con.cursor()
    return cur



def oracle_old_connection(username, old_password):
    pass_actual_string = '%s/%[email protected]_ADDRESS_HERE/ORACLE_SID_HERE' % (username, old_password)
    con = cx_Oracle.connect(pass_actual_string)
    return con.version
开发者ID:ShahriyarR,项目名称:password_changer,代码行数:33,代码来源:change_password.py

示例5: salvar

# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import grid_columnconfigure [as 别名]
def salvar():
    fichero = tkFileDialog.asksaveasfilename()
    f = open(fichero,"w")
    f.write(contenido.get(1.0, END))
    f.close()
    
if __name__ == '__main__':
    
    ventana = Tk()
    ventana.title("Editor tonto de textos")
    
    t = Label(ventana)
    t.grid(row=0, column=2, sticky=W + E, columnspan=2)
    
    nombreFichero = StringVar()
    t["textvariable"] = nombreFichero

    botonLoad = Button(ventana, text="Load", command=cargar)
    botonLoad.grid(row=0, column=0, sticky=W)
    
    botonSave = Button(ventana, text="Save", command=salvar)
    botonSave.grid(row=0, column=1, sticky=W)
    
    contenido = ScrolledText(ventana)
    contenido.grid(row=1, columnspan=3, sticky=W + E + N + S)
    
    ventana.grid_columnconfigure(2, weight=1)
    ventana.grid_rowconfigure(1, weight=1)
    ventana.mainloop()
开发者ID:Aimee13,项目名称:chuidiang-ejemplos,代码行数:31,代码来源:editor.py


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