nun kann auch ich als Mitleser hier mal ein Problem posten.

Folgender Code stellt die Elemente im Fenster zentriert dar. Wie bekomme ich es hin, das die Elemente im Fenster oben links beginnen?
Ich habe die grid Geometriemanager Doku schon vorwärts und rückwärts gelesen aber nichts gefunden.
Code: Alles auswählen
from Tkinter import *
import tkMessageBox
class GUIFramework(Frame):
"""This is the GUI"""
def __init__(self,master=None):
"""Initialize yourself"""
"""Initialise the base class"""
Frame.__init__(self,master)
"""Set the Window Title"""
self.master.title("mini QR-GUI")
"""Set the window size"""
self.master.geometry("600x300")
"""Display the main window"
with a little bit of padding"""
self.grid(padx=2, pady=2, sticky=NW)
self.CreateWidgets()
def CreateWidgets(self):
"""Create all the widgets that we need"""
"""Create the menu"""
# create a toplevel menu
self.menubar = Menu(self)
# create a pulldown menu, and add it to the menu bar
self.filemenu = Menu(self.menubar, tearoff=0)
self.filemenu.add_command(label="Beenden", command=self.quit)
self.menubar.add_cascade(label="Datei", menu=self.filemenu)
# display the menu
self.master.config(menu=self.menubar)
"""Create the Text"""
self.lbText = Label(self, text="Enter Text:")
self.lbText.grid(row=0, column=0, sticky=NW)
"""Create the Entry, set it to be a bit wider"""
self.enText = Entry(self, relief=FLAT, width=50)
self.enText.grid(row=0, column=1, sticky=W+E)
"""Create the Button, set the text and the
command that will be called when the button is clicked"""
self.btnDisplay = Button(self, text="Display!", command=self.Display)
self.btnDisplay.grid(row=0, column=2, sticky=NW)
"""Create a label for showing the input after
btnDisplay clicked"""
self.lblDisplayVar = StringVar()
self.lblDisplay = Label(self, textvariable=self.lblDisplayVar,
justify=LEFT, borderwidth=1)
self.lblDisplay.grid(row=1, column=0, columnspan=3, sticky=NW)
self.grid(padx=5,pady=5, sticky=NW)
def Display(self):
"""Called when btnDisplay is clicked, displays the contents of self.enText"""
self.lblDisplayVar.set('QR code for: %s\n%d Zeichen' %
(self.enText.get(), len(self.enText.get())))
tkMessageBox.showinfo("Text", "You typed: %s" % self.enText.get())
if __name__ == "__main__":
guiFrame = GUIFramework()
guiFrame.mainloop()
Danke an Alle für irgendwelche Tipps!
Andreas