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


Python Label.grid方法代码示例

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


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

示例1: statusScreen

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
class statusScreen(independentScreen):

	working = False

	def __init__(self, owner):
		if super().__init__() == False:
			return

		self.owner = owner
		self.root.title('정보')
		self.label = Label(self.root, text='서버 상태 읽는 중...\n\n(계속 나타나지 않으면 서버에 HCl이 설치되어 있나 확인하세요)', justify='center')
		self.label.grid(row=0, column=0)
		Button(self.root, text='나가기', command=self.quit).grid(row=1, column=0, sticky='nwe')
		self.thread = Thread(target=self.updateThread)
		statusScreen.working = True
		self.thread.start()
		self.root.mainloop()

	def updateThread(self):
		while True:
			if not self._available():
				self.quit()
				break

			try:
				self.label['text'] = ('메인 스레드 메모리 사용량: %s\n최대 메모리: %s\n최대 가상 메모리: %s\n힙 메모리: %s\n서버 구동 시간: %s\n업로드 속도: %s\n다운로드 속도: %s\n플레이어 수/최대 플레이어 수: %s' % tuple(self.owner.messages['stat'].split(';')))
			except:
				sleep(1)

			sleep(1)

		sys.exit(0)
开发者ID:cr0sh,项目名称:NaOH,代码行数:34,代码来源:status.py

示例2: ProgramWidget

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

    def __init__(self, parent, client):
        super(ProgramWidget, self).__init__(parent)
        self.client = client
        self.client.onProgramChange = self.programChanged

        self.programLabel = Label(self, text = 'Program:')
        self.programLabel.grid(row = 0, column = 0)
        self.programEntry = Entry(self, text = 'Program name',
                                  state = 'readonly')
        self.programEntry.grid(row = 0, column = 1)
        self.buttonPanel = Frame(self)
        self.buttonPanel.grid(row = 1, column = 0, columnspan = 2, sticky = W)
        self.newButton = Button(self.buttonPanel, text='New',
                                command = self.newProgram)
        self.newButton.pack(side = LEFT)

    def programChanged(self):
        self.__setProgramText(str(self.client.state))

    def __setProgramText(self, text):
        self.programEntry.configure(state = NORMAL)
        self.programEntry.delete(0)
        self.programEntry.insert(0, text)
        self.programEntry.configure(state = 'readonly')

    def newProgram(self):
        self.client.makeNewProgram()
开发者ID:mindhog,项目名称:mawb,代码行数:31,代码来源:tkui.py

示例3: append_chords

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
    def append_chords(self, chords=[]):
        '''pass a [list] of Chords to the Accordion object'''

        self.update_idletasks()
        row = 0
        width = max([c.winfo_reqwidth() for c in chords])
        
        for c in chords:
            i = PhotoImage() # blank image to force Label to use pixel size
            label = Label(self, text=c.title,
                          image=i,
                          compound='center',
                          width=width,
                          anchor='w',
                          font=('Franklin Gothic Book', 11),
                          bg=self.style['title_bg'],
                          fg=self.style['title_fg'],
                          cursor=self.style['cursor'],
                          bd=1, relief='flat')
            
            label.grid(row=row, column=0, sticky='nsew')
            c.grid(row=row+1, column=0, sticky='nsew')
            c.grid_remove()
            row += 2
            
            label.bind('<Button-1>', lambda e,
                       c=c: self._click_handler(c))
            label.bind('<Enter>', lambda e,
                       label=label, i=i: label.configure(bg=self.style['highlight'],fg=self.style['highlight_fg']))
            label.bind('<Leave>', lambda e,
                       label=label, i=i: label.configure(bg=self.style['title_bg'],fg=self.style['title_fg']))
开发者ID:jozz68x,项目名称:Simulador-Cisco,代码行数:33,代码来源:acordeon.py

示例4: Remove_Machine_Modal

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
class Remove_Machine_Modal(Modal):
	def __init__(self, parent=None, title="Remove Machine"):
		Modal.__init__(self, parent, title, geometry="500x85" if system() == "Windows" else "395x70")

	def initialize(self):
		self.label = Label(self, font=("TkTextFont", 13), width=36)
		self.label.grid(row=0, column=0, padx=10, columnspan=2)

		cancel_button = Button(self, text="Cancel", width=20, command=self.cancel)
		self.bind("<Escape>", self.cancel)
		cancel_button.grid(row=1, column=0, pady=10, padx=5, sticky="W")

		ok_button = Button(self, text="OK", width=20, command=self.ok)
		self.bind("<Return>", self.ok)
		ok_button.grid(row=1, column=1, pady=10, sticky="E")

	def ok(self, event=None):
		self.remove = True
		self.destroy()

	def cancel(self, event=None):
		self.remove = False
		self.destroy()

	def show(self, machine_name):
		self.label.config(text="Remove " + machine_name + "?")
		Modal.show(self)
		return self.remove
开发者ID:nalexander50,项目名称:MCRC-JSON-Creator,代码行数:30,代码来源:Remove_Machine_Modal.py

示例5: initUI

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
    def initUI(self):
        self.parent.title("Mario's Picross Puzzle Editor")
        self.puzzles = None

        # Build the menu
        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)
        fileMenu = Menu(menubar)
        self.fileMenu = fileMenu
        fileMenu.add_command(label="Open Mario's Picross ROM...",
                              command=self.onOpen)
        fileMenu.add_command(label="Save ROM as...",
                             command=self.onSave,
                             state=DISABLED)
        fileMenu.add_separator()
        fileMenu.add_command(label="Exit", command=self.onExit)
        menubar.add_cascade(label="File", menu=fileMenu)

        # Navigation
        Label(self.parent).grid(row=0, column=0)
        Label(self.parent).grid(row=0, column=4)
        self.parent.grid_columnconfigure(0, weight=1)
        self.parent.grid_columnconfigure(4, weight=1)

        prevButton = Button(self.parent,
                            text="<--",
                            command=self.onPrev,
                            state=DISABLED
        )
        self.prevButton = prevButton
        prevButton.grid(row=0, column=1)

        puzzle_number = 1
        self.puzzle_number = puzzle_number
        puzzleNumber = Label(self.parent, text="Puzzle #{}".format(puzzle_number))
        self.puzzleNumber = puzzleNumber
        puzzleNumber.grid(row=0, column=2)

        nextButton = Button(self.parent,
                            text="-->",
                            command=self.onNext,
                            state=DISABLED
        )
        self.nextButton = nextButton
        nextButton.grid(row=0, column=3)

        # Canvas
        canvas = Canvas(self.parent)
        self.canvas = canvas
        for i in range(15):
            for j in range(15):
                fillcolor = "gray80"
                self.canvas.create_rectangle(10+20*j,     10+20*i,
                                             10+20*(j+1), 10+20*(i+1),
                                             fill=fillcolor,
                                             tags="{},{}".format(i, j)
                )
        self.canvas.bind("<ButtonPress-1>", self.onClick)
        canvas.grid(row=1, columnspan=5, sticky=W+E+N+S)
        self.parent.grid_rowconfigure(1, weight=1)
开发者ID:sopoforic,项目名称:cgrr-mariospicross,代码行数:62,代码来源:marios_picross_puzzle_editor_gui.py

示例6: _initfilepanel

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
 def _initfilepanel(self):
     frame = Frame(self)
     frame.grid(row=0, column=0, sticky=E + W + S + N)
     
     label = Label(frame, text="File List: ")
     label.grid(sticky=N + W)
     
     self.filelist = Listbox(frame, width=40)
     self.filelist.grid(row=1, column=0, rowspan=2, columnspan=3)
     
     vsl = Scrollbar(frame, orient=VERTICAL)
     vsl.grid(row=1, column=3, rowspan=2, sticky=N + S + W)
     
     hsl = Scrollbar(frame, orient=HORIZONTAL)
     hsl.grid(row=3, column=0, columnspan=3, sticky=W + E + N)
     
     self.filelist.config(yscrollcommand=vsl.set, xscrollcommand=hsl.set)
     self.filelist.bind('<<ListboxSelect>>', self._onfilelistselection)
     
     hsl.config(command=self.filelist.xview)
     vsl.config(command=self.filelist.yview)
     
     upbtn = Button(frame, text="Up", width=7, command=self._upfile)
     upbtn.grid(row=1, column=4, padx=5, pady=5)
     
     downbtn = Button(frame, text="Down", width=7, command=self._downfile)
     downbtn.grid(row=2, column=4, padx=5, pady=5)
     
     newbtn = Button(frame, text="New", width=7, command=self._addfile)
     newbtn.grid(row=4, column=1, pady=5, sticky=E + S)
     
     delbtn = Button(frame, text="Delete", width=7, command=self._deletefile)
     delbtn.grid(row=4, column=2, padx=5, pady=5, sticky=W + S)
开发者ID:shawncx,项目名称:LogParser,代码行数:35,代码来源:logui.py

示例7: InfoFrame

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
class InfoFrame(Frame):
    def __init__(self,master=None, thread=None):
        Frame.__init__(self, master)
        self.controlThread=thread
        
        self.stringVar=StringVar()
        
        self.grid()
        self.createWidgets()
        
    def createWidgets(self):
        self.inputText=Label(self)
        if self.inputText != None:
            self.inputText['textvariable']=self.stringVar
            self.inputText["width"] = 50
            self.inputText.grid(row=0, column=0, columnspan=6)
        else:
            pass
        
        
        self.cancelBtn = Button(self, command=self.clickCancelBtn)   # need to implement
        if self.cancelBtn !=None:
            self.cancelBtn["text"] = "Cancel"
            self.cancelBtn.grid(row=0, column=6)
        else:
            pass
        
    def clickCancelBtn(self):
        print("close the InfoDialog")
        self.controlThread.setStop()
            
    def updateInfo(self, str):
        self.stringVar.set(str)
开发者ID:fscnick,项目名称:RapidgatorDownloader,代码行数:35,代码来源:DialogThread.py

示例8: CircleBuilderPopup

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
class CircleBuilderPopup(BuilderPopup):
    """
    Class that launches a popup and collects user data to pass data back to the main window
    to build a circle.
    """
    def __init__(self, master):
        """
        Establish the GUI of this popup
        """
        BuilderPopup.__init__(self, master)
        self.data = (0, 0)
        self.radius = Label(self.top, text="Radius")
        self.radius_entry = Entry(self.top, width=self.width, bd=self.bd)
        self.center = Label(self.top, text="Center")
        self.center_entry = Entry(self.top, width=self.width, bd=self.bd)
        self.build_circle_submit = Button(self.top, text="Build!", command=self.cleanup)
        self.top.bind("<Return>", self.cleanup)
        self.radius.grid(row=0, column=0)
        self.radius_entry.grid(row=0, column=1)
        self.center.grid(row=1, column=0)
        self.center_entry.grid(row=1, column=1)
        self.build_circle_submit.grid(row=2, column=0, columnspan=2)
        self.top_left = 0
        self.bottom_right = 0
        self.radius_entry.focus()

    def cleanup(self, entry=None):
        """
        Collect the data from the user and package it into object variables, then close.
        """
        center = complex(0, 0)
        if self.center_entry.get():
            center = complex(allow_constants(self.center_entry.get()))
        self.data = (float(allow_constants(self.radius_entry.get())), center)
        self.top.destroy()
开发者ID:SamuelDoud,项目名称:complex-homotopy,代码行数:37,代码来源:BuilderWindows.py

示例9: __init__

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
    def __init__(self, client):
        # Basic setup
        super(Preferences, self).__init__()
        self.client = client

        # Setup the variables used
        self.echo_input = BooleanVar()
        self.echo_input.set(self.client.config['UI'].getboolean('echo_input'))
        self.echo_input.trace("w", self.echo_handler)
        self.logging = BooleanVar()
        self.logging.set(self.client.config['logging'].getboolean('log_session'))
        self.logging.trace('w', self.logging_handler)
        self.log_dir = self.client.config['logging']['log_directory']

        # Build the actual window and widgets
        prefs = Toplevel(self)
        prefs.wm_title("Preferences")
        echo_input_label = Label(prefs, text="Echo Input:")
        logging_label = Label(prefs, text='Log to file:')
        echo_checkbox = Checkbutton(prefs, variable=self.echo_input)
        logging_checkbox = Checkbutton(prefs, variable=self.logging)
        logging_button_text = 'Choose file...' if self.log_dir == "" else self.log_dir
        logging_button = Button(prefs, text=logging_button_text, command=self.logging_pick_location)

        # Pack 'em in.
        echo_input_label.grid(row=0, column=0)
        echo_checkbox.grid(row=0, column=1)
        logging_label.grid(row=1, column=0)
        logging_checkbox.grid(row=1, column=1)
        logging_button.grid(row=1, column=2)
开发者ID:Errorprone85,项目名称:TEC-Client,代码行数:32,代码来源:preferences.py

示例10: _initjoincondpanel

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
 def _initjoincondpanel(self):
     frame = Frame(self)
     frame.grid(row=0, column=2, sticky=E + W + S + N, padx=5)
     
     label = Label(frame, text="Join Condition: ")
     label.grid(sticky=N + W)
     
     self.joincondlist = Listbox(frame)
     self.joincondlist.grid(row=1, rowspan=1, columnspan=3, sticky=E + W + S + N)
     
     vsl = Scrollbar(frame, orient=VERTICAL)
     vsl.grid(row=1, column=3, rowspan=1, sticky=N + S + W)
     
     hsl = Scrollbar(frame, orient=HORIZONTAL)
     hsl.grid(row=2, column=0, columnspan=3, sticky=W + E + N)
     
     self.joincondlist.config(yscrollcommand=vsl.set, xscrollcommand=hsl.set)
     
     hsl.config(command=self.joincondlist.xview)
     vsl.config(command=self.joincondlist.yview)
     
     newbtn = Button(frame, text="New", width=7, command=self._addjoincondition)
     newbtn.grid(row=3, column=0, padx=5, pady=5, sticky=E)
     
     delbtn = Button(frame, text="Delete", width=7, command=self._deletejoincondition)
     delbtn.grid(row=3, column=1, sticky=E)
     
     modbtn = Button(frame, text="Update", width=7, command=self._modifyjoincondition)
     modbtn.grid(row=3, column=2, padx=5, pady=5, sticky=W)
开发者ID:shawncx,项目名称:LogParser,代码行数:31,代码来源:logui.py

示例11: make_widgets

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
    def make_widgets(self):
        self.lines = ['Red Line', 'Blue Line', 'Brown Line', 'Purple Line',
                 'Orange Line', 'Green Line', 'Pink Line', 'Yellow Line']

        headimg = PhotoImage(file='header.gif')
        header = Label(self, image=headimg)
        header.image = headimg
        header.grid(row=0, columnspan=2)
        
        r = 1
        c = 0
        for b in self.lines:
            rel = 'ridge'
            cmd = lambda x=b: self.click(x)
            splt = b.split()
            if splt[0] not in 'OrangeGreenPinkYellow':
                Button(self,text=b, width = 19, height=2, relief=rel,
                       bg = splt[0], fg = "#FFF", font = ("Helvetica", 16),
                       command=cmd).grid(row=r,column=c)
            else:
                Button(self,text=b, width = 19, relief=rel,
                       bg = splt[0], fg = "#000", height=2, font = ("Helvetica", 16),
                       command=cmd).grid(row=r,column=c) 
            c += 1
            if c > 1:
                c = 0
                r += 1
开发者ID:dahlke,项目名称:PyTrain,代码行数:29,代码来源:lines.py

示例12: create_shape_buttons

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
 def create_shape_buttons(self, root):
     """
     This function get a root and creates all the shapes
     buttons (because they have picture they need to
     compile and resize the icons...
     :param root: Tk frame
     :return: returns Frame object (it won`t pack it)
     """
     shapes_frame = Frame(root)
     shape_text = Label(shapes_frame, text="Shape: ")
     shape_text.grid(row=0, column=0)
     self.line_image = self.create_shape_img(SHAPES_DICT[LINE])
     line_btn = Button(shapes_frame,
                       image=self.line_image,
                       command=lambda: self.create_shape(LINE))
     line_btn.grid(row=0, column=1)
     self.square_image = self.create_shape_img(SHAPES_DICT[SQUARE])
     square_btn = Button(shapes_frame,
                         image=self.square_image,
                         command=lambda: self.create_shape(SQUARE))
     square_btn.grid(row=0, column=2)
     self.triangle_image = self.create_shape_img(SHAPES_DICT[TRIANGLE])
     triangle_btn = Button(shapes_frame,
                           image=self.triangle_image,
                           command=lambda: self.create_shape(TRIANGLE))
     triangle_btn.grid(row=0, column=3)
     self.elipse_image = self.create_shape_img(SHAPES_DICT[ELIPSE])
     elipse_btn = Button(shapes_frame,
                         image=self.elipse_image,
                         command=lambda: self.create_shape(ELIPSE))
     elipse_btn.grid(row=0, column=4)
     self.debug_event("shapes toolbar was generated")
     return shapes_frame
开发者ID:Omertorren,项目名称:ex12,代码行数:35,代码来源:client.py

示例13: home_page

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
    def home_page(self, master):
        frame = Frame(master)
        frame.grid(row=0, column=0)

        image = PhotoImage(file="img/guido.gif")
        bg = Label(frame, image=image)
        bg.image = image
        bg.grid(row=0, column=0, rowspan=4, columnspan=2)

        index = 0
        while index < 3:
            frame.grid_columnconfigure(index, minsize=200)
            frame.grid_rowconfigure(index, minsize=80)
            index += 1

        summary_button = HomeButton(frame, self.to_summary, 'img/summary.png')
        summary_button.grid(row=0, column=0, sticky='w')

        edit_button = HomeButton(frame, self.to_edit, 'img/edit.png')
        edit_button.grid(row=0, column=1, sticky='e')

        momentary_button = HomeButton(frame, self.to_momentary, 'img/momentary.png')
        momentary_button.grid(row=1, column=0, sticky='w')

        preferences_button = HomeButton(frame, self.to_pref, 'img/preferences.png')
        preferences_button.grid(row=1, column=1, sticky='e')

        music = HomeButton(frame, self.to_summary, 'img/music.png')
        music.grid(row=2, column=0, sticky='w')

        info = HomeButton(frame, self.to_summary, 'img/info.png')
        info.grid(row=2, column=1, sticky='e')

        return frame
开发者ID:xistingsherman,项目名称:SPTOR,代码行数:36,代码来源:Gui.py

示例14: show_about

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
 def show_about(self):
     about = About(self.master, "About {}".format(self.version[:-5]), self.logo)
     Label(about.frame, text=self.version, style="atitle.TLabel").grid(sticky="w")
     Label(about.frame, text="Developer:  Joel W. Dafoe").grid(pady="6", sticky="w")
     link = Link(about.frame, text="http://cyberdatx.com", foreground="blue", cursor="hand2")
     link.grid(sticky="w")
     link.bind("<Button-1>", lambda e: webbrowser.open("http://cyberdatx.com"))
     Label(about.frame, text=self.description, wraplength=292).grid(columnspan=2, pady=6, sticky=W)
开发者ID:jwdafoe,项目名称:ContactPro,代码行数:10,代码来源:gui.py

示例15: callback_origin

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid [as 别名]
def callback_origin():
    # Push button event handler.
    data_input_1 = enter_data_1.get()           # Grab text in the entry box
    
    # Create a label and write the value from the entry box to it.
    # i.e., validate by displaying the newly acquired string as a label
    label_2_far_right = Label(root, text=data_input_1)
    label_2_far_right.grid(row=1, column=3)
开发者ID:dahickey,项目名称:Meeting-5,代码行数:10,代码来源:entry_box.py


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