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


Python Label.grid方法代码示例

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


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

示例1: initUI

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
	def initUI(self):      
		self.parent.title("AlienTiles")
		self.style = Style()
		self.style.theme_use("default")
		self.pack(fill=BOTH, expand=1)
        
		lbl = Label(self, text="Choose goal colour:")
		lbl.grid(sticky=W, padx=5, columnspan=4)

		redbtn = tk.Button(self, width=3, command = self.colour_red, bg='red')
		redbtn.grid(row=1, column=0, padx=12, pady=10)

		greenbtn = tk.Button(self, width=3, command = self.colour_green, bg='green')
		greenbtn.grid(row=1, column=1, padx=12, pady=10)

		bluebtn = tk.Button(self, width=3, command = self.colour_blue, bg='blue')
		bluebtn.grid(row=1, column=2, padx=12, pady=10)

		purplebtn = tk.Button(self, width=3, command = self.colour_purple, bg='purple')
		purplebtn.grid(row=1, column=3, padx=12, pady=10)
        
		for i in range(dimension) :
			for j in range(dimension) :
				btn.insert(i*dimension+j, tk.Button(self, width=5, bg='red'))
				btn[i*dimension+j].grid(row=i+2, column=j, padx=10, pady=1)
        
		hbtn = Button(self, text="Help", command = self.print_help)
		hbtn.grid(row=dimension+3, column=0, padx=1)

		ibtn = Button(self, text="Initial State", command = self.initial_state)
		ibtn.grid(row=dimension+3, column=1, padx=1)

		sbtn = Button(self, text="Solution", command = self.solution)
		sbtn.grid(row=dimension+3, column=2, padx=1)        
开发者ID:KonstantinaGalouni,项目名称:Artificial-Intelligence-I,代码行数:36,代码来源:alientilesgui.py

示例2: CommAdd

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
class CommAdd(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent        
        self.initUI()
        
    def initUI(self):
        # This should be different if running on Windows....
        content = pyperclip.paste()
        print content  
        self.entries_found = []

        self.parent.title("Add a new command card")
        self.style = Style()
        self.style.theme_use("default")        
        self.pack()
        
        self.new_title_label = Label(self, text="Title")
        self.new_title_label.grid(row=0, columnspan=2)
        self.new_title_entry = Entry(self, width=90)
        self.new_title_entry.grid(row=1, column=0)
        self.new_title_entry.focus()
        self.new_content_label = Label(self, text="Card")
        self.new_content_label.grid(row=2, columnspan=2)
        self.new_content_text = Text(self, width=110, height=34)
        self.new_content_text.insert(END, content)
        self.new_content_text.grid(row=3, columnspan=2)
        self.add_new_btn = Button(self, text="Add New Card", command=self.onAddNew)
        self.add_new_btn.grid(row=4)

    def onAddNew(self):

        pass
开发者ID:angelalonso,项目名称:comm,代码行数:37,代码来源:comm.py

示例3: initUI

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
    def initUI(self):
        self.parent.title("windows widget")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill= BOTH, expand=1)

        self.columnconfigure(1,weight=1)
        self.columnconfigure(3,pad=7)
        self.rowconfigure(3,weight=1)
        self.rowconfigure(5,pad=7)

        lbl = Label(self, text = "Windows")
        lbl.grid(sticky = W, pady=4, padx=5)

        area = Text(self)
        area.grid(row=1, column=0, columnspan=3, rowspan=4, padx=5, sticky = E+W+S+N)
        abtn = Button(self, text="Activate")
        abtn.grid(row=1, column=3)

        cbtn = Button(self, text="Close")
        cbtn.grid(row=2, column=3, pady=4)

        hbtn = Button(self, text="Help")
        hbtn.grid(row=5, column=0, padx=5)

        obtn = Button(self, text = "OK")
        obtn.grid(row=5, column=3)
开发者ID:shikhagarg0192,项目名称:Python,代码行数:29,代码来源:gui9.py

示例4: initUI

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
    def initUI(self):

        self.parent.title("Paste IP's Here:")
        self.style = Style()
        self.style.theme_use("aqua")
        self.pack(fill=BOTH, expand=1)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(3, pad=7)
        self.rowconfigure(3, weight=1)
        self.rowconfigure(5, pad=7)

        lbl = Label(self, text="Paste IP's Here:")
        lbl.grid(sticky=W, pady=4, padx=5)

        area = Text(self)
        area.grid(row=1, column=0, columnspan=2, rowspan=4,
            padx=5, sticky=E+W+S+N)

        abtn = Button(self, text="Open", command=self.onOpen())
        abtn.grid(row=1, column=3)

        cbtn = Button(self, text="Close")
        cbtn.grid(row=2, column=3, pady=4)

        hbtn = Button(self, text="Help")
        hbtn.grid(row=5, column=0, padx=5)

        obtn = Button(self, text="OK")
        obtn.grid(row=5, column=3)
开发者ID:Cyber-Forensic,项目名称:Telize-GeoIP-API,代码行数:32,代码来源:GeoIp-GUI.py

示例5: initUI

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
    def initUI(self):
        self.parent.title("Windows")
        self.pack(fill=BOTH, expand=True)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(3, pad=7)
        self.rowconfigure(3, weight=1)
        self.rowconfigure(5, pad=7)

        lbl = Label(self, text="Windows")
        lbl.grid(sticky=W, pady=4, padx=5)

        area = Text(self)
        area.grid(row=1, column=0, columnspan=2, rowspan=4)

        abtn = Button(self, text="Activate")
        abtn.grid(row=1, column=3)

        cbtn = Button(self, text="Close")
        cbtn.grid(row=2, column=3, pady=4)

        hbtn = Button(self, text="Help")
        hbtn.grid(row=5, column=0, padx=5)

        obtn = Button(self, text="OK")
        obtn.grid(row=5, column=3)
开发者ID:Exodus111,项目名称:Projects,代码行数:28,代码来源:windows.py

示例6: TabServices

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
class TabServices(Frame):

    def __init__(self, parent, txt=dict()):
        """Instanciating the output workbook."""
        self.parent = parent
        Frame.__init__(self)

        # variables
        self.url_srv = StringVar(self,
                                 'http://suite.opengeo.org/geoserver/wfs?request=GetCapabilities')

        # widgets
        self.lb_url_srv = Label(self,
                                text='Web service URL GetCapabilities: ')
        self.ent_url_srv = Entry(self,
                                 width=75,
                                 textvariable=self.url_srv)
        self.btn_check_srv = Button(self, text="youhou")
        # widgets placement
        self.lb_url_srv.grid(row=0, column=0,
                             sticky="NSWE", padx=2, pady=2)
        self.ent_url_srv.grid(row=0, column=1,
                              sticky="NSWE", padx=2, pady=2)
        self.btn_check_srv.grid(row=0, column=2,
                                sticky="NSWE", padx=2, pady=2)
开发者ID:Guts,项目名称:DicoGIS,代码行数:27,代码来源:tab_geoservices.py

示例7: initUI

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
    def initUI(self):
        # Set the name of the UI window
        self.parent.title("Bennington File System Client")
        # Set the style using the default theme
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        # Set the "Open File" options
        self.file_opt = options = {}
        # Allow for any file to be choosable
        options["defaultextension"] = ""
        options["filetypes"] = ""
        # Set the directory window will open up to initially
        options["initialdir"] = "C:\\"
        options["parent"] = self

        # Create a label object which holds the text labeling the listbox
        lbl = Label(self, text="Bennington File System Files List", foreground="black")
        # Place the text in the top left
        lbl.grid(column=0, row=0, pady=4, padx=5)

        # Create the listbox, which will contain a list of all the files on the system
        self.area = Listbox(self, height=20)
        # Place the lisbox in the UI frame
        self.area.grid(row=1, column=0, columnspan=1, rowspan=10, padx=5, sticky=N + W + E + S)

        # Ask the master server which files it has, then populate the listbox with the response
        self.getFiles()

        # Create a button labeled 'Upload', and bind the uploadFile() function to it
        uploadbtn = Button(self, text="Upload", command=self.uploadFile)
        # Place the button in the UI frame
        uploadbtn.grid(row=1, column=3)

        # Create a button labeled 'Download', and bind the downloadFile() function to it
        dwnbtn = Button(self, text="Download", command=self.downloadFile)
        # Place the button in the UI frame
        dwnbtn.grid(row=2, column=3)

        # Create a button labeled 'Delete', and bind the deleteFile() function to it
        delbtn = Button(self, text="Delete", command=self.deleteFile)
        # Place the button in the UI frame
        delbtn.grid(row=3, column=3)

        # Create a button labeled 'Undelete', and bind the undeleteFile() function to it
        undelbtn = Button(self, text="Undelete", command=self.undeleteFile)
        # Place the button in the UI frame
        undelbtn.grid(row=4, column=3)

        # Create a button labeled 'Refresh List', and bind the getFiles() function to it
        refbtn = Button(self, text="Refresh List", command=self.getFiles)
        # Place the button in the UI frame
        refbtn.grid(row=5, column=3)

        # Create a button labeled 'Quit', and bind the exitProgram() function to it
        quitButton = Button(self, text="Quit", command=self.exitProgram)
        # Place the button in the UI frame
        quitButton.grid(sticky=W, padx=5, pady=4)
开发者ID:BenningtonCS,项目名称:GFS,代码行数:61,代码来源:newclient.py

示例8: MainFrame

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
class MainFrame(Frame):    
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initUI()    
              
    def initUI(self):
        self.parent.title("Driver Control Panel")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        self.label = Label(self, text="Bus Tracker - Driver", font=('Helvetica', '21'))
        self.label.grid(row=0, column=0)

        self.l = Label(self, text="Bus Line", font=('Helvetica', '18'))
        self.l.grid(row=1, column=0)
        self.e = Entry(self, font=('Helvetica', '18'))
        self.e.grid(row=2, column=0)

        self.l = Label(self, text="Direction", font=('Helvetica', '18'))
        self.l.grid(row=3, column=0)

        # add vertical space
        self.l = Label(self, text="", font=('Helvetica', '14'))
        self.l.grid(row=5, column=0)

        self.e = Entry(self, font=('Helvetica', '18'))
        self.e.grid(row=4, column=0)
        self.search = Button(self, text="Start")
        self.search.grid(row=6, column=0)   
        
        
        ######### used for debug ##########
        # add vertical space
        self.l2 = Label(self, text="", font=('Helvetica', '14'))
        self.l2.grid(row=5, column=0)
        
        self.turnOnBtn = Button(self, text="Turn On")
        self.turnOnBtn["command"] = self.turnOn 
        self.turnOnBtn.grid(row=6, column=0)    
        
        self.startBtn = Button(self, text="Start")
        self.startBtn["command"] = self.start 
        self.startBtn.grid(row=7, column=0)    
        
        self.turnOffBtn = Button(self, text="Turn Off")
        self.turnOffBtn["command"] = self.turnOff 
        self.turnOffBtn.grid(row=8, column=0)   
        
    def turnOn(self):
        host.enqueue({"SM":"DRIVER_SM", "action":"turnOn", "busId":DRIVERID, "localIP":IP, "localPort":int(PORT)})
        
    def start(self):
        host.enqueue({"SM":"DRIVER_SM", "action":"start", "route":ROUTNO, "direction":"north", "location":(0,0)})
        
    def turnOff(self):
        host.enqueue({"SM":"DRIVER_SM", "action":"turnOff"})    
开发者ID:Tianwei-Li,项目名称:DS-Bus-Tracker,代码行数:60,代码来源:gui_driver.py

示例9: body

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
    def body(self, parent):
        self.parent = parent

        questionLabel = Label(self.parent, text="Give your champion pool a name:")
        questionLabel.grid(row=0)
        self.poolTitle = Entry(self.parent)
        self.poolTitle.grid(row=1)

        return self.poolTitle
开发者ID:HeerRik,项目名称:poolbuilder,代码行数:11,代码来源:poolbuilder.py

示例10: open_file_handler

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
def open_file_handler():
    global file1
    file1= askopenfilename()
    print file1
    captn = Label( top, text=file1, foreground="red")
    #captn.pack(side=TOP)
    captn.grid(row=3)
    #file2=str(file1)
    return file1
开发者ID:neenurose,项目名称:main-project,代码行数:11,代码来源:graphui.py

示例11: MainWindow

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
class MainWindow(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.setupUI()

    def setupUI(self):
        self.master.title("Markwhat")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)
        self.grid_columnconfigure(0, weight=1)
        self.grid_columnconfigure(1, weight=1)
        self.rowconfigure(1, weight=1)

        self.markwhat_label = Label(self, text="Markwhat")
        self.markwhat_label.grid(sticky=W, row=0, column=0)

        self.markwhat_textarea = WhatText(self, background='white')
        self.markwhat_textarea.grid(row=1, column=0, sticky=NSEW)
        self.markwhat_textarea.beenModified = self.on_markwhat_modfified

        self.markup_label = Label(self, text="Markup")
        self.markup_label.grid(sticky=W, row=0, column=1)

        self.markup_preview = HtmlFrame(self)
        self.markup_preview.grid(row=1, column=1, sticky=NSEW)

        self.preview_button_text = StringVar()
        self.preview_button = Button(
            self,
            textvariable=self.preview_button_text,
            command=self.on_preview_click,
        )
        self.preview_button_text.set('HTML')
        self.preview_button.grid(row=2, column=1, sticky=W)

    def on_markwhat_modfified(self, event):
        text = self.markwhat_textarea.get('1.0', END)
        markup_text = parse_markdown(text)

        if isinstance(self.markup_preview, HtmlFrame):
            self.markup_preview.set_content(markup_text)
        else:
            self.markup_preview.delete('1.0', END)
            self.markup_preview.insert('1.0', markup_text)

    def on_preview_click(self):
        if isinstance(self.markup_preview, HtmlFrame):
            self.markup_preview = WhatText(self, background="white")
            self.preview_button_text.set('HTML')
        else:
            self.markup_preview = HtmlFrame(self)
            self.preview_button_text.set('HTML Source')

        self.markup_preview.grid(row=1, column=1, sticky=NSEW)
        self.on_markwhat_modfified(None)
开发者ID:Alir3z4,项目名称:markwhat,代码行数:59,代码来源:main_window.py

示例12: init_ui

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
    def init_ui(self):
        self.parent.title("Information Theory")
        Style().configure("TButton", padding=(0, 5, 0, 5), font='Verdana 10')

        self.columnconfigure(0, pad=3)
        self.columnconfigure(1, pad=3)
        self.columnconfigure(2, pad=3)
        self.columnconfigure(3, pad=3)
        self.columnconfigure(4, pad=3)

        self.rowconfigure(0, pad=3)
        self.rowconfigure(1, pad=3)
        self.rowconfigure(2, pad=3)
        self.rowconfigure(3, pad=3)
        self.rowconfigure(4, pad=3)
        self.rowconfigure(5, pad=3)

        string_to_search_label = Label(self, text="Search a string: ")
        string_to_search_label.grid(row=0, column=0, rowspan=2)
        self.string_to_search_textfield = Entry(self)
        self.string_to_search_textfield.grid(row=0, column=1, rowspan=2, columnspan=2, sticky=W)
        self.string_to_search_textfield.bind('<Return>', self.get_string_from_textfield)
        self.compression_ratio_text = StringVar()
        self.compression_ratio_text.set('Compression Ratio: ')
        compression_ratio_label = Label(self, textvariable=self.compression_ratio_text).grid(row=0, column=2,
                                                                                             columnspan=4)

        Separator(self, orient=HORIZONTAL).grid(row=1)
        string_to_encode_label = Label(self, text="Encode a string: ")
        string_to_encode_label.grid(row=2, column=0, rowspan=2)
        self.string_to_encode_textfield = Entry(self)
        self.string_to_encode_textfield.grid(row=2, column=1, rowspan=2, columnspan=2, sticky=W)
        self.string_to_encode_textfield.bind('<Return>', self.get_string_from_textfield_to_encode)

        Separator(self, orient=HORIZONTAL).grid(row=3)
        self.area = Text(self)
        self.area.grid(row=4, column=0, columnspan=3, rowspan=1, padx=5, sticky=E + W)
        self.area.config(width=10, height=15)
        self.possible_options_text = StringVar()
        self.possible_options_text.set("Possible Options: ")
        self.possible_options_label = Label(self, textvariable=self.possible_options_text).grid(row=4, column=3,
                                                                                                sticky=N)

        huffman_coding_button = Button(self, text="Huffman",
                                       command=self.huffman_coding_callback).grid(row=5, column=0)
        arithmetic_coding_button = Button(self, text="Arithmetic Coding",
                                          command=self.arithmetic_coding_callback).grid(row=5, column=1)
        dictionary_coding_button = Button(self, text="Dictionary",
                                          command=self.dictionary_coding_callback).grid(row=5, column=2)
        elias_coding_button = Button(self, text="Elias",
                                     command=self.elias_coding_callback).grid(row=5, column=3)
        our_coding_button = Button(self, text="Elemental Coding",
                                   command=self.elemental_coding_callback).grid(row=5, column=4)
        self.pack()
        self.elemental_coding_callback()
开发者ID:JEpifanio90,项目名称:teoria_informacion,代码行数:57,代码来源:gui.py

示例13: MainFrame

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
class MainFrame(Frame):    
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initUI()
        
        # define options for opening or saving a file
        self.file_opt = options_file = {}
        options_file['defaultextension'] = '.txt'
        options_file['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
        options_file['initialdir'] = '../'
        options_file['initialfile'] = 'testFile'
        options_file['parent'] = self.parent
        options_file['title'] = 'Choose configuration file'
        
        # define options for asking local name
        self.ask_localname_opt = options_localName = {}
        options_localName['parent'] = self.parent
        options_localName['initialvalue'] = "alice"
        
        conf = tkFileDialog.askopenfilename(**self.file_opt)
        localName = tkSimpleDialog.askstring("local name", "Please enter your name:", **self.ask_localname_opt)
        
        MessagePasser.initialize(conf, localName)
        

        
    def initUI(self):
        self.parent.title("Bus Tracker")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        self.label = Label(self, text="Ready")
        self.label.grid(row=0, column=0)
        # TEST ONLY
        self.testButton = Button(self, text="Send", command= lambda: self.send("alice", "hi alice"))
        self.testButton.grid(row=1, column=0)
        self.testButton = Button(self, text="Multicast", command= lambda: self.multicast("group1", "hi group1"))
        self.testButton.grid(row=1, column=1)
        self.quitButton = Button(self, text="Quit", command=self.quit)
        self.quitButton.grid(row=1, column=2)
        
        
    def receive(self):
        self.label["text"] = MessagePasser.receive()
        #self.labelString.set(MessagePasser.receive())
    
    def send(self, dst, data):
        MessagePasser.normalSend(dst, data)
    
    def multicast(self, group, data):
        MessagePasser.multicast(group, data)
开发者ID:Tianwei-Li,项目名称:DS-Bus-Tracker,代码行数:55,代码来源:gui.py

示例14: create_window

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
 def create_window(self):
     
     t = Toplevel(self)
     t.wm_title("Elastic constants")
     l = Label(t, text="Elastic constants:")
     l.grid(row=0, column=0)
     textf = Text(t)
     try:
         textf.insert(INSERT, self.ec.get_C())
     except:
         textf.insert(INSERT, '')
     textf.grid(row=1, column=0)
开发者ID:tdengg,项目名称:pylastic,代码行数:14,代码来源:main.py

示例15: loginInit

# 需要导入模块: from ttk import Label [as 别名]
# 或者: from ttk.Label import grid [as 别名]
    def loginInit(self):
        self.parent.title("Password Keeper")
        Style().configure("Tlabel",font="Times")

        lbusr = Label(self,text="Master Username")
        lbusr.grid(row=0,column=0)
        lbps = Label(self,text="Master Password")
        lbps.grid(row=1,column=0)

        enusr = Entry(self)
        enusr.grid(row=0,column=1)
        enps = Entry(self)
        enps.grid(row=1,column=1)

        def login():
            credict = {}
            with open("cred.json","rb") as f:
                credict = json.load(f)

            for key in credict:
                if key == enusr.get() and credict[key] == enps.get():
                    switch()
                elif key != enusr.get() and credict[key] == enps.get():
                    tkMessageBox.showinfo(title=None,message="Wrong Username! Please Re-enter")
                    enusr.delete(0, Tkinter.END)
                    enps.delete(0, Tkinter.END)
                    break
                elif key == enusr.get() and credict[key] != enps.get():
                    tkMessageBox.showinfo(title=None,message="Wrong password! Please Re-enter.")
                    enusr.delete(0, Tkinter.END)
                    enps.delete(0, Tkinter.END)
                    break
                else:
                    tkMessageBox.showinfo(title=None,message="Username/Password combination is wrong! Please Re-enter")
                    enusr.delete(0, Tkinter.END)
                    enps.delete(0, Tkinter.END)
                    break

        def switch():
            self.parent.destroy()
            root = Tk()
            Primary(root,self.dict,self.enlist)
            root.mainloop()

        reg = Button(self,text="New User",command=self.register)
        reg.grid(row=2,column=0,sticky=W+E)
        lgn = Button(self,text="Login",command=login)
        lgn.grid(row=2,column=1,sticky=W+E)

        self.pack()
开发者ID:Ragzputin,项目名称:password_keeper,代码行数:52,代码来源:gui_python.py


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