2008-11-02 13 views

उत्तर

11

आपकी सर्वश्रेष्ठ शर्त tkMessageBox मॉड्यूल है, जो सभी प्रणालियों पर काम करना चाहिए (क्योंकि पाइथन आमतौर पर टिंकर के साथ आते हैं)।

यदि आप स्वयं को एक विशिष्ट ऑपरेटिंग सिस्टम तक सीमित कर सकते हैं, तो बेहतर विकल्प उपलब्ध हो सकते हैं।

2

मैंने Wx पायथन के बारे में अच्छी बातें सुनी हैं, जो मल्टी-प्लेटफॉर्म भी है।

3

सरल संदेश बॉक्स और इनपुट बॉक्स इंकगुई का उपयोग करके बनाया जा सकता है, जो टिंकर का उपयोग करके एक छोटी लाइब्रेरी है, जो पाइथन के साथ आता है।

आप EasyGui यहाँ प्राप्त कर सकते: http://easygui.sourceforge.net/

1
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 

संबंधित मुद्दे