2. Wie kann ich die widgets in einem Fenster wie Button und Entry genau positionieren, also dass die nicht einlach untereinander liegen und dazwischen kein platz ist.
danke

Code: Alles auswählen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Tkinter as tk
#~~ Lade den Dateiname dieses Skriptes
script_name = sys.argv[0]
#~~ Konstanten für die Abmessungen des Hauptfensters
MAIN_WIN_XPOS = 10
MAIN_WIN_YPOS = 10
MAIN_WIN_WIDTH = 320
MAIN_WIN_HEIGHT = 320
#--- Erstelle ein Tk-Hauptfenster ----
app_win = tk.Tk()
app_win.geometry("%dx%d+%d+%d" % (MAIN_WIN_WIDTH, MAIN_WIN_HEIGHT,
MAIN_WIN_XPOS, MAIN_WIN_YPOS))
app_win.maxsize(MAIN_WIN_WIDTH, MAIN_WIN_HEIGHT)
app_win['bg'] = 'khaki'
app_win.title(script_name)
app_win.mainloop()
Kannst du uns eine von dir gewünschte Anordnung von Widgets (in einem Fenster) präsentieren?questlove hat geschrieben:2. Wie kann ich die widgets in einem Fenster wie Button und Entry genau positionieren, also dass die nicht einlach untereinander liegen und dazwischen kein platz ist.
Code: Alles auswählen
def new_project():
#Erstellung des "Neues Projekt" Fensters
new_project_dialog = tk.Toplevel()
new_project_dialog.title("Neues Projekt")
width = 200
height = 300
xpos = 850
ypos = 450
new_project_dialog.geometry('%dx%d+%d+%d' % (width, height, xpos, ypos))
#Funktion des "Fertig" Buttons
def Ende():
projektname = titel.get()
new_project_dialog.destroy()
Projektfenster(projektname)
# Widgets des "Neues Projekt" Fensters
project_name_frame = tk.Frame(new_project_dialog)
project_name_frame.pack(side='top', fill='x')
name=tk.Label(project_name_frame, text="Projektname:")
name.pack()
titel=tk.Entry(project_name_frame, bg='white', bd=1, highlightthickness=0)
titel.pack()
button_frame = tk.Frame(new_project_dialog)
button_frame.pack(side='bottom', fill='x')
finish_button = tk.Button(button_frame, text="Fertig", command=Ende)
finish_button.pack(side='left')
Code: Alles auswählen
self.clef= [(38,184), (40,190), (47,184), ( 37, 150), (44, 140), (45,155),
(32,169), (40,180), (49,175), (46,163), ( 37,168), (40,173)]
self.create_line(self.clef, smooth=True, width=1)