Seite 1 von 1

ComboBox (ohne Pmw)

Verfasst: Sonntag 5. Juli 2009, 16:51
von krisi12345
HI!
Hab mal ComboBox in Tkinter gegooglelt.
Hab aber nur welche mit Pmw gefunden.
Weis einer wie man ComboBoxen mit Tkinter erzeugt?

Re: ComboBox (ohne Pmw)

Verfasst: Sonntag 5. Juli 2009, 18:25
von numerix
krisi12345 hat geschrieben:HI!
Hab mal ComboBox in Tkinter gegooglelt.
Hab aber nur welche mit Pmw gefunden.
Weis einer wie man ComboBoxen mit Tkinter erzeugt?
Evtl. genügt das: http://effbot.org/tkinterbook/optionmenu.htm

Verfasst: Sonntag 5. Juli 2009, 18:37
von krisi12345
O.K.
Danke :D

Verfasst: Sonntag 5. Juli 2009, 18:52
von krisi12345
HI!²
Weis vieleicht noch jemand wie man ein Kommando bei einer auswahl von einem Item senden kann?

Verfasst: Dienstag 7. Juli 2009, 13:22
von numerix
Wenn du eine "echte" Combobox willst, die auch so heißt, dann nimmt Python 3.1. Da gibt es die neuen ttk-Widgets und dabei ist auch eine Combobox.

Verfasst: Dienstag 7. Juli 2009, 13:42
von EyDu
krisi12345 hat geschrieben:HI!²
Weis vieleicht noch jemand wie man ein Kommando bei einer auswahl von einem Item senden kann?
http://effbot.org/tkinterbook/variable.htm

Verfasst: Dienstag 7. Juli 2009, 13:50
von krisi12345
Ich hab noch nie mit py3 gearbeitet und von der Python 3 GUI hab Ich noch keine Ahnung denn so weit Ich weis ist da Tkinter nicht mehr enthalten.
Hast du vieleicht ein Beispiel?

Verfasst: Dienstag 7. Juli 2009, 14:28
von numerix
krisi12345 hat geschrieben:von der Python 3 GUI hab Ich noch keine Ahnung denn so weit Ich weis ist da Tkinter nicht mehr enthalten
Wenn das so wäre, hätte ich sicher nicht auf Python 3.1 verwiesen.

Verfasst: Dienstag 7. Juli 2009, 14:32
von krisi12345
Schon gut hab Mich JETZT schon zurecht gefunden. Danke!

Verfasst: Freitag 21. August 2009, 04:32
von Ene Uran
Na ja, hier ist ein Beispiel the ttk Kombo Kiste:

Code: Alles auswählen

# ttk_combobox2.py
# exploring the Tkinter expansion module ttk combobox
# tested with Python 3.1 and Tkinter 8.5   by  vegaseat

import tkinter as tk
import tkinter.ttk as ttk

def action(event):
    """
    a combo box item has been selected, do some action
    """
    label['bg'] = combo.get()


root = tk.Tk()

# create a label
label = tk.Label(text='select a color', bg='white')

# create the combo box
combo = ttk.Combobox()
combo.bind('<<ComboboxSelected>>', action)

colors = ['red', 'green', 'magenta', 'yellow']
# load the combo box with the colors list
combo['values'] = colors

# set the initial color
combo.set('yellow')
label['bg'] = combo.get()

# pack the widgets vertically in this order
label.pack(fill='both', expand='yes')
combo.pack()

root.mainloop()