Gibt es eine UI-Bibliothek, um ein Meldungsfeld oder Eingabefeld in Python zu erstellen?Message Box in Python
6
A
Antwort
11
Ihre beste Wette ist das tkMessageBox-Modul, das auf allen Systemen funktionieren sollte (wie Python normalerweise mit Tkinter kommt).
Wenn Sie sich auf ein bestimmtes Betriebssystem beschränken können, sind möglicherweise bessere Optionen verfügbar.
2
Ich habe gute Dinge über WX Python gehört, die auch Multi-Plattform ist.
3
Einfache Nachrichtenfelder und Eingabefelder können mit EasyGui, einer kleinen Bibliothek mit Tkinter, die Python enthält, erstellt werden.
Sie können EasyGUI hier: http://easygui.sourceforge.net/
1
von Tkinter
import *
import os
class Dialog(Toplevel):
def __init__(self, parent, title = None):
Toplevel.__init__(self, parent)
self.transient(parent)
if title:
self.title(title)
self.parent = parent
self.result = None
body = Frame(self)
self.initial_focus = self.body(body)
body.pack(padx=5, pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus = self
self.protocol("WM_DELETE_WINDOW", self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
#
# construction hooks
def body(self, master):
# create dialog body. return widget that should have
# initial focus. this method should be overridden
pass
def buttonbox(self):
# add standard button box. override if you don't want the
# standard buttons
box = Frame(self)
w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE)
w.pack(side=LEFT, padx=5, pady=5)
w = Button(box, text="Cancel", width=10, command=self.cancel)
w.pack(side=LEFT, padx=5, pady=5)
self.bind("<Return>", self.ok)
self.bind("<Escape>", self.cancel)
box.pack()
#
# standard button semantics
def ok(self, event=None):
if not self.validate():
self.initial_focus.focus_set() # put focus back
return
self.withdraw()
self.update_idletasks()
self.apply()
self.cancel()
def cancel(self, event=None):
# put focus back to the parent window
self.parent.focus_set()
self.destroy()
#
# command hooks
def validate(self):
return 1 # override
def apply(self):
pass # override
Verwandte Themen
- 1. C# Message Box Display
- 2. C# Winforms Message Box Eigenschaften
- 3. Ext JS Message Box Position
- 4. Zeige nur eine Message Box
- 5. Google Maps API Message Box
- 6. Silverlight-Anwendung zeigt nicht Message Box
- 7. Befüllen facebook feed dialog message box
- 8. Message Box wenn Zelle Bereich ist heute
- 9. Löschen Sie Javascript Message Box von VBA
- 10. Wie setze ich Fortschrittsbalken auf Message Box
- 11. Google mail und moz-box-shadow in html message
- 12. Message Box wird nicht in einfachen Vergleich Textfeldstrings Programm
- 13. Message-Box mit "Ja", "Nein" Auswahlen in C#?
- 14. C# Wie erhalte ich eine Pop-Message-Box?
- 15. Respond to Website Message Box von mit VBA automatisieren Internetexplorer
- 16. C# Web Browser Message Box - Kopieren Sie den Alarmtext
- 17. Virtual Box Python verschiedene Python-Version
- 18. Black Box Testen von Webseiten in Python
- 19. Qt-Message-Box in der linken Ecke in der Debian-Linux
- 20. Message Queue in PHP
- 21. Message-driven Beans mit activemq-message Verbrauch
- 22. elisp message-box: kann ich Zeilenumbrüche in den Text einfügen, und wenn ja, wie?
- 23. Drop-Down-Werte Senden '0' anstelle von Wert zu Message-Box in VB.net
- 24. Wie zeige ich Message Box nach ein paar Klicks in C#
- 25. Message Board/Gästebuch in asp.net
- 26. OOP - Message Passing in C#
- 27. send mouseclick message in .net
- 28. Ausnahmefälle In Wso2 Message Broker
- 29. Kann nicht entfernt werden Legende Box [Python]
- 30. Python Bokeh Balkendiagramm - Ändern der Legende Box